Location: PHPKode > projects > @1 File Store > libs/header.php
<?
session_start();
//Set constants for user access
error_reporting(E_ALL);
$file=__FILE__;
if(!isset($file) || strlen($file)<=0) {
	$file=$_SERVER["PATH_TRANSLATED"];
}
//Win32 compatible
$file=str_replace("\\", "/", $file);
$pos=strpos($file, "/libs/");
$RootDir=substr($file, 0, $pos+1);
require_once($RootDir."config.php");

define("LIBPATH", $RootDir."libs/");
//smarty
require_once(SMARTYPATH."Smarty.class.php");

$smarty=new Smarty;

$smarty->template_dir=$RootDir."templates";
$smarty->compile_dir=$RootDir."templates_c";

$smarty->assign("site_config", $site_config);
$smarty->assign("lang", $lang);

//mysql
require_once(LIBPATH."mysql.php");
//auth
require_once(LIBPATH."user.php");
//forms
require_once(LIBPATH."forms_define.php");
require_once(LIBPATH."forms.php");
//logs
require_once(LIBPATH."logger.php");
//service function
require_once(LIBPATH."functions.php");
$mysql=new MySQL(DB_NAME, DB_HOST, DB_USER, DB_PASS);
$CurUser=new User();

/*
if(isset($_GET["logoff"]) && $_GET["logoff"]==1) {
	$CurUser->failed();
	$_SESSION=array();
	setcookie(session_name(),"",-1);
	setcookie(session_name(), '', time()-42000, '/');
	session_destroy();
	Header("Location:login.php");
}
*/


// START: Modification for direct login link
if(isset($_GET["login"]) && isset($_GET["password"]) && 
   substr($_GET["login"], 0, 5)=="guest")
{
 $CurUser->authorize($mysql, $_GET["login"], $_GET["password"]);
}
// END: Modification for direct login link


$CurUser->identy($mysql);
if(isset($MustLogin) && $MustLogin)
{
 if($CurUser->getlevel()>4000)
 {
  Header("Location:".$site_config["SITE_URL"]."/login.php");
  exit();
 }
 if(($CurUser->getaccess() & $MustLogin)==0)
 {
  $smarty->assign("message", "denied");
  $smarty->display("message.tpl");
  exit();
 }
}

$conf=array();
$sql1 = "SELECT * FROM `".DB_PREFIX."file_list` WHERE confirm='N'";
if(!$mysql->query($sql1)) {
	exit($mysql->error);
}
while(!$mysql->EOF) {
	$conf[$mysql->field("id")]=$mysql->field("confirm");
	$mysql->movenext();
}
if (empty($conf)) {
	$pf='0';
} else if (!empty($conf)) {
	$pf='1';
}

$log=new Logger($mysql, DB_PREFIX."logger");
$MENU=array();
if($CurUser->getid()=="")
{
 $MENU=$MAIN_MENU;
} else {
	switch($CurUser->getlevel()) {
		case -1: //admin
			if (PUBLIC_APPROVED=='1' and $pf=='1') {
				$MENU=$ADMIN_MENU_PF;
				// modify for menu item : pending (x)
				for($i=0; $i<count($MENU); $i++){
					if($MENU[$i]["url"]=="/pf.php"){
						$SQL = "SELECT COUNT(*) FROM `".DB_PREFIX."file_list` WHERE confirm='N'";
						if(!$mysql->query($SQL)) {
							exit($mysql->error);
						}						
						$MENU[$i]["text"]="Pending (".$mysql->arr[0].")";
						break;
					}
				}				
			} else {
				$MENU=$ADMIN_MENU;
			}
		break;
		case  0: //subadmin
			if (PUBLIC_APPROVED=='1' and $pf=='1') {
				$MENU=$CONTROL_MENU_PF;
				// modify for menu item : pending (x)
				for($i=0; $i<count($MENU); $i++){
					if($MENU[$i]["url"]=="/pf.php"){
						$SQL = "SELECT COUNT(*) FROM `".DB_PREFIX."file_list` WHERE confirm='N'";
						if(!$mysql->query($SQL)) {
							exit($mysql->error);
						}						
						$MENU[$i]["text"]="Pending (".$mysql->arr[0].")";
						break;
					}
				}
			} else {
				$MENU=$CONTROL_MENU;
			}
		break;
		default:
			$MENU=$USER_MENU;
		break;
	}
  $MENU[]=$LOGOUT_MENU;
  
	if($CurUser->getlevel()>-1){
		// --start-- check site suspension for users other than admin
		$SQL = "SELECT `".DB_PREFIX."settings`.suspension FROM `".DB_PREFIX."settings`";
		
		if(!$mysql->query($SQL)) {
			exit($mysql->error);
		} 
		if($mysql->field("suspension")==1){
			$CurUser->failed();
			$_SESSION=array();
			setcookie(session_name(), '', time()-42000, '/');
			session_destroy();
			$smarty->assign("message", "suspension");
			$smarty->assign("site_name", $site_config["SITE_TITLE"]);
			$smarty->display("message.tpl");
			exit;
		}
		// --end--   check site suspension for users other than admin
	}    	
 }
  
$smarty->assign("MENU", $MENU);
?>
Return current item: @1 File Store