Location: PHPKode > projects > PHPEcho CMS > index.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Tigran Abrahamyan
*   |     License:       GPL
*   |     Last updated:  06.03.07
*   |     For version:   2.0 
*   |     Desc:          Core call, Template system, Language system, index
*   |        
*   +--------------------------------------------
*/

// -------------------
// Set base load variable for modules & blocks
// ------------------- 

$BASE_LOAD = TRUE;

// -------------------
// Session start
// -------------------

session_start();

// -------------------
// Get core
// -------------------

require ( "./kernel/init.php" );
$core = new core();

// -------------------
// Template system load.
// -------------------

$smarty = new Smarty;

$smarty->debugging = $debug_on;
$smarty->force_compile = $debug_on; // This forces templates to compile every time. Useful for development or debugging.
                 
// -------------------
// Get site settings from database.
// -------------------

$settings = query ( "SELECT * FROM ".PREFIX."settings", 4 );

// -------------------
// If user is logged on, get settings.
// -------------------

if( session_is_registered ('login') )
{
    $username = $_SESSION['username'];
    $password = $_SESSION['password'];
    $user_data = query("SELECT * FROM ".PREFIX."users WHERE username='$username' and password='$password'", 4);
    
    if ($user_data['password'] != $password)
    {
	    session_unset();
	    $language = $settings['default_lang'];
    	$theme = $settings['default_theme'];
    }
    else
    {
        // -------------------
        // Get lang
        // -------------------

        $language = $user_data['language'];

        // -------------------
        // Get theme
        // -------------------
    
        $theme = $user_data['theme'];
    }
}
else
{
    // -------------------
    // Load default lang & theme settings
    // -------------------
    
    $language = $settings['default_lang'];
    $theme = $settings['default_theme'];
}

// -------------------
// Lang or theme error
// -------------------

if (!$language OR !$theme)
{
    die ( "Database error.<br/>Language or/and Theme error.<br/>Please contact with administrator." );
}

// -------------------
// Get global lang file.
// -------------------

require ( $root_path . "lang/" . $language . "/global.php" );

// -------------------
// Right-to-left
// -------------------

if ($lang['rtl']=='yes')
    $rtl = "dir=rtl";
else
    $rtl = "";

// -------------------
// Banners
// -------------------

$banners = "";
$thebanners = query("select * from `".PREFIX."banners` order by `position` asc", 1);
while ($banner = mysql_fetch_array($thebanners))
{
	$thepath = "./banners/".$banner['name'];
	if (is_file($thepath) && is_readable($thepath))
		$banners .= "<tr><td><center><img src='".$thepath."'></center></td></tr>";
}

// -------------------
// Send variables to template system, and call display.
// -------------------

$smarty->template_dir = "./templates/" . $theme; 
$smarty->assign_by_ref( "core" , $core ); 
$smarty->assign ("banners", $banners);
$smarty->assign ( "rtl", $rtl );
$smarty->assign ( "settings" , $settings );
$smarty->assign ( "theme" , $theme );
$smarty->assign ( "cmsVersion" , CMSVERSION );
$smarty->assign ( "lang" , $lang );
if ( session_is_registered ( "login" ) )
{
    $smarty->assign ( "session" , $_SESSION );
    $smarty->assign ( "username" , $_SESSION['username'] );
}

$smarty->display ('index.tpl');
?>
Return current item: PHPEcho CMS