Location: PHPKode > projects > Basic Announce > Basic Announce Version 4.0/system/home.php
<?php
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  ApPHP AdminPanel Pro                                                       #
##  Developed by:  ApPHP <hide@address.com>                                      #
##  License:       GNU LGPL v.3                                                #
##  Site:          http://www.apphp.com/php-adminpanel/                        #
##  Copyright:     ApPHP AdminPanel (c) 2006-2011. All rights reserved.        #
##                                                                             #
################################################################################

    // Initialize the session.
    session_start();
    
    require_once("../inc/classes/session.class.php");	
    require_once("../inc/checkAdminPagePermissions.php");

    require_once("../inc/config.inc.php");
    require_once("../inc/settings.inc.php");
	require_once("../inc/functions.inc.php");
	require_once("../inc/languages/".$SETTINGS['site_language'].".php");

    if(!page_access_allowed($_SERVER['SCRIPT_NAME'])) redirect_to("access_denied.php");

	$act = isset($_GET['act']) ? $_GET['act'] : "";
    $menu_group_index = 0;
    $menu_group_count = 0;
	$action_required = false;
	$arr_actions_msg = array();
	$br = set_browser_definitions();
	if($br['browser'] == "MSIE"){
		$panel_width = "32%";
	}else{
		$panel_width = "35%";
	}

	if(strtolower(_SITE_MODE) != "demo"){
		if($act == "update_rank"){
			set_site_settings(array(
				"rank_alexa"  => number_format(get_alexa_rank($SETTINGS['site_address']), "0", ".", ","),
				"rank_google" => get_google_rank($SETTINGS['site_address']),
				"rank_last_updated" => date("Y-m-d H:i:s")
			));
		}else if($act == "hide_home_panel"){
			$db->Exec("UPDATE ".TABLE_SETTINGS." SET home_panel_status = 0");
			header("location: home.php");
			exit;
		}else if($act == "hide_alert_panel"){
			$db->Exec("UPDATE ".TABLE_SETTINGS." SET alert_panel_status = 0");
			header("location: home.php");
			exit;
		}	
	}

    if($_SESSION['adm_status'] == "admin"){
		$res = $db->Query("SELECT ".TABLE_MENU.".*
		    FROM ".TABLE_MENU."
				INNER JOIN ".TABLE_MENU_ACCESS_RIGHTS." ON ".TABLE_MENU.".id = ".TABLE_MENU_ACCESS_RIGHTS.".menu_id
				INNER JOIN ".TABLE_ADMINS." ON ".TABLE_MENU_ACCESS_RIGHTS.".admin_id = ".TABLE_ADMINS.".id    
		    WHERE
				".TABLE_MENU.".is_menu_group = 1 AND
				".TABLE_MENU.".is_hidden = 0 AND
				".TABLE_MENU.".is_dashboard_icon = 1 AND 
				".TABLE_MENU_ACCESS_RIGHTS.".is_accessible = 1 AND
				".TABLE_ADMINS.".status = 'admin' AND
				".TABLE_ADMINS.".id = ".(int)$_SESSION['adm_user_id']." 
		    ORDER BY ".TABLE_MENU.".order_index ASC");	
    }else{
	    $res = $db->Query("SELECT * FROM ".TABLE_MENU."
                    WHERE is_menu_group = 1 AND is_hidden = 0 AND is_dashboard_icon = 1
                    ORDER BY order_index ASC");
    }
    $menu_group_count = $db->RowCount();
	
	// prepare Action Required data
	if(file_exists("../install.php") || file_exists("../install")){
		$arr_actions_msg[] = lang('alert_remove_instal_files');
		$action_required = true;
	}
	if(!is_writable("../pages") || !is_writable("../tmp/export") || !is_writable("../tmp/backup")){
		$actions_msg = "For correct work of the system, you have to grant write access rights to following directories:";
		$actions_msg .= "<ul>";
		if(!is_writable("../pages")) $actions_msg .= "<li>pages/</li>";
		if(!is_writable("../tmp/export")) $actions_msg .= "<li>tmp/export/</li>";
		if(!is_writable("../tmp/backup")) $actions_msg .= "<li>tmp/backup/</li>";
		$actions_msg .= "</ul>";
		$arr_actions_msg[] = $actions_msg;
		$action_required = true;
	}
	if(isset($SETTINGS['site_address']) && ($SETTINGS['site_address'] == "" || preg_match("/mydomain.com/i", $SETTINGS['site_address']))){
		$arr_actions_msg[] = lang('alert_change_site_address');
		$action_required = true;
	}
	if(isset($SETTINGS['admin_email']) && ($SETTINGS['admin_email'] == "" || preg_match("/mydomain.com/i", $SETTINGS['admin_email']))){
		$arr_actions_msg[] = lang('alert_change_admin_email');
		$action_required = true;	
	}
	if(isset($_SESSION['adm_email']) && ($_SESSION['adm_email'] == "" || preg_match("/mydomain.com/i", $_SESSION['adm_email']))){
		$arr_actions_msg[] = lang('alert_change_own_email');
		$action_required = true;	
	}

	// prepare categories state 
	$CategoriesState = array();
	for($i = 0; $i < $menu_group_count; $i++){
		$CategoriesState[$i] = (isset($_COOKIE['HomeCategorySection_'.$i.'_State']) && ($_COOKIE['HomeCategorySection_'.$i.'_State'] != "")) ? $_COOKIE['HomeCategorySection_'.$i.'_State'] : "maximized";
	}
	

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
    <title><?php echo $SETTINGS['site_name']; ?> :: <?php echo lang('admin_panel'); ?> :: <?php echo lang('home'); ?></title>
    <meta http-equiv=Content-Type content="text/html; charset=utf-8">
    <!-- CSS style files -->
    <link href="../styles/<?php echo $SETTINGS['css_style'];?>/style.css" type="text/css" rel="stylesheet">
    <link href="../styles/<?php echo $SETTINGS['css_style'];?>/menu.css" type="text/css" rel="stylesheet">

    <!-- JavaScript files -->
    <script type="text/javascript" src="../js/functions.js"></script>
    <script type="text/javascript" src="../modules/jquery/jquery.js"></script>
	<script type='text/javascript'>
		//------------------------------------------------------------------------------
		function toggleCategoryPane(el){
			if(jQuery("#categoryPane"+el).is(":hidden")){
				jQuery("#categoryPane"+el).show("fast");
			}else{
				jQuery("#categoryPane"+el).hide();
			}			
			for(var i = 0; i < <?php echo $menu_group_count; ?>; i++){
				if(jQuery("#categoryPane"+i).is(":hidden")){
					setCookie("HomeCategorySection_"+i+"_State","minimized",14);
				}else{
					setCookie("HomeCategorySection_"+i+"_State","maximized",14);
				}
			}
		}

		//------------------------------------------------------------------------------
		function m_over(el){
			if(el) el.style.borderColor="#ababab";
		}
		function m_out(el){
			if(el) el.style.borderColor="#dedede";
		}
	</script>
</head>
<body style="background:#ffffff; padding:0px 2px; margin:0px;" dir="<?php echo $SETTINGS['language_dir'];?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
    <td valign="top" align="left">    
    <?php	
		// panels status
		if($SETTINGS['home_panel_status'] || $SETTINGS['alert_panel_status']){
			$max_icons_in_row = 6;
			$icon_block_width = "16%";					
		}else{
			$max_icons_in_row = 10;
			$icon_block_width = "10%";					
		}

        ob_start();
		if($SETTINGS['dashboard_icons'] == "1"){
            // draw is heap
			if($_SESSION['adm_status'] == "admin"){
				$sql =  "SELECT ".TABLE_MENU.".*
						FROM ".TABLE_MENU."
							INNER JOIN ".TABLE_MENU_ACCESS_RIGHTS." ON ".TABLE_MENU.".id = ".TABLE_MENU_ACCESS_RIGHTS.".menu_id
							INNER JOIN ".TABLE_ADMINS." ON ".TABLE_MENU_ACCESS_RIGHTS.".admin_id = ".TABLE_ADMINS.".id    
						WHERE
							".TABLE_MENU.".is_menu_group = 0 AND
							".TABLE_MENU.".is_hidden = 0 AND                        
							".TABLE_MENU.".is_dashboard_icon = 1 AND
							".TABLE_MENU_ACCESS_RIGHTS.".is_accessible = 1 AND
							".TABLE_ADMINS.".status = 'admin' AND
							".TABLE_ADMINS.".id = ".(int)$_SESSION['adm_user_id']."                        
						ORDER BY ".TABLE_MENU.".parent_id ASC, ".TABLE_MENU.".order_index ASC";
				$res2 = $db->Query($sql);				
			}else{
				$sql = "SELECT ".TABLE_MENU.".*
						FROM ".TABLE_MENU."
						WHERE is_menu_group = 0 AND is_hidden = 0 AND is_dashboard_icon = 1
						ORDER BY ".TABLE_MENU.".parent_id ASC, ".TABLE_MENU.".order_index ASC";
				$res2 =$db->Query($sql);
			}

			echo "<table border='0' cellpadding='0' cellspacing='2'><tr>";
			$ind = "0";
			$category_name = "";
			$parent_id = "";
			while($r___ = $res2->fetch()){
				// detect category name
				if($parent_id != $r___['parent_id']){
					$sql = "SELECT name FROM ".TABLE_MENU." WHERE id = ".(int)$r___['parent_id'];
					$res3 = $db->Query($sql);
					if($r____ = $res3->fetch()) $category_name = $r____['name']." &raquo; ";
				}				
				
				if($r___['file_type_id'] == "0"){       // system pages
					$page_href = $r___['page_name'];
				}else if($r___['file_type_id'] == "1"){ // static_page
					$page_href = "static_pages.php?page=".$r___['id'];				
				}else if($r___['file_type_id'] == "4"){ // link
					$page_href = $r___['page_name'];				
				}else{
					$page_href = "../pages/".$r___['page_name'];
				}
				if(($ind != 0) && ($ind % $max_icons_in_row == 0)) echo "</tr><tr>";
				echo "<td width='".$icon_block_width."' height='85px' onclick='javascript:document.location.href=\"".$page_href."\"' onmouseover='m_over(this)' onmouseout='m_out(this)' class='icon-cell' align='center' valign='middle' title='".$category_name.$r___['name']."'>";
				if($r___['icon'] != ""){ echo "<a href='".$page_href."'><img src='../images/icons/".$r___['icon']."' title='".$category_name.$r___['name']."' width='48px' height='48px' alt='' /></a><br />"; }
				echo "<a href='".$page_href."' style='font-size:12px;'>".$r___['name']."</a>";
				echo "</td>";
				$ind++;
			}
			echo "</tr></table>";			
		}else{
			// draw categorized			
			$count_sections = "0";
			while($r__ = $res->fetch()){
				echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='margin-top:".(($count_sections > "0") ? "8px" : "0px").";'>
				<tr>
					<td><div class='section_title_".(($SETTINGS['language_dir'] == "rtl") ? "right" : "left")."'></div></td>
					<td width='100%' align='".(($SETTINGS['language_dir'] == "rtl") ? "right" : "left")."'><div class='section_title'><div class='section_title_text'><span onclick='toggleCategoryPane(\"".$count_sections."\")'>".lang(str_replace(" ", "_", $r__['name']), false)."</span></div></div></td>  
					<td><div class='section_title_".(($SETTINGS['language_dir'] == "rtl") ? "left" : "right")."'></div></td>
				</tr>
				</table>
				<table id='categoryPane".$count_sections."' style='".(($CategoriesState[$count_sections] == "minimized") ? "display:none;" : "")."' width='100%' border='0' cellspacing='0' cellpadding='0' class='text'>
				<tr><td align='left' style='border:0px solid #efefef; padding:0px;'>";
	
				if($_SESSION['adm_status'] == "admin"){
					$sql =  "SELECT ".TABLE_MENU.".*
							FROM ".TABLE_MENU."
								INNER JOIN ".TABLE_MENU_ACCESS_RIGHTS." ON ".TABLE_MENU.".id = ".TABLE_MENU_ACCESS_RIGHTS.".menu_id
								INNER JOIN ".TABLE_ADMINS." ON ".TABLE_MENU_ACCESS_RIGHTS.".admin_id = ".TABLE_ADMINS.".id    
							WHERE
								".TABLE_MENU.".is_menu_group = 0 AND
								".TABLE_MENU.".is_hidden = 0 AND                        
								".TABLE_MENU.".is_dashboard_icon = 1 AND
								".TABLE_MENU.".parent_id = ".(int)$r__['id']." AND 
								".TABLE_MENU_ACCESS_RIGHTS.".is_accessible = 1 AND
								".TABLE_ADMINS.".status = 'admin' AND
								".TABLE_ADMINS.".id = ".(int)$_SESSION['adm_user_id']."                        
							ORDER BY ".TABLE_MENU.".order_index ASC";
					$res2 = $db->Query($sql);				
				}else{
					$sql = "SELECT ".TABLE_MENU.".*
							FROM ".TABLE_MENU."
							WHERE is_menu_group = 0 AND is_hidden = 0 AND is_dashboard_icon = 1 AND parent_id = ".(int)$r__['id']."
							ORDER BY order_index ASC";
					$res2 = $db->Query($sql);				
				}
	
				echo "<table align='".(($SETTINGS['language_dir'] == "rtl") ? "right" : "left")."' border='0' cellpadding='0' cellspacing='2'><tr>";
				$ind = "0";
				while($r___ = $res2->fetch()){
					if($r___['file_type_id'] == "0"){       // system pages
						$page_href = $r___['page_name'];
					}else if($r___['file_type_id'] == "1"){ // static_page
						$page_href = "static_pages.php?page=".$r___['id'];
					}else if($r___['file_type_id'] == "4"){ // link
						$page_href = $r___['page_name'];					
					}else{
						$page_href = "../pages/".$r___['page_name'];
					}					

					if(($ind != 0) && ($ind % $max_icons_in_row == 0)) echo "</tr><tr>";
					echo "<td width='102px' onclick='javascript:document.location.href=\"".$page_href."\"' onmouseover='m_over(this)' onmouseout='m_out(this)' class='icon-cell' nowrap align='center' valign='top' title='".$r___['name']."'>";
					if($r___['icon'] != ""){ echo "<a href='".$page_href."'><img src='../images/icons/".$r___['icon']."' title='".$r___['name']."' width='48px' height='48px' alt='' /></a><br />"; }
					echo "<nobr><a href='".$page_href."' style='font-size:12px;'>".lang(str_replace(" ", "_", $r___['name']), false)."</a></nobr>";					
					echo "</td>";
					$ind++;
				}
				echo "</tr></table>";
				echo "</td></tr></table>";
				$count_sections++;
			}			
		}        
        ob_end_flush();
    ?>
	</td>
    <td width="2%">&nbsp;</td>    
    <?php if($SETTINGS['home_panel_status'] == "1" || $SETTINGS['alert_panel_status'] == "1"){ ?>
	<td width="<?php echo $panel_width; ?>">         
		<?php if($SETTINGS['alert_panel_status'] == "1" && $action_required){ ?>		
        <table width='100%' align='center' class="alert-panel" cellspacing='1' cellpadding='8'>
        <tr>
            <td width="5%" align="left">
				<img src='../images/action_required.png' alt=''>
            </td>
            <td align="left" width="90%">
				<b><?php echo lang('action_required'); ?>!</b>
            </td>				
            <td width="5%" align="left" valign="middle" nowrap="nowrap">
				<?php //if($_SESSION['adm_status'] == "main admin"){ ?>
				<a style="text-decoration:none;" href='home.php?act=hide_alert_panel' title='<?php echo lang('hide'); ?>'><img src='../images/close.png' alt='' /></a>
				<?php //} ?>
			</td>
        </tr>
        <tr>
            <td colspan="3">
			<?php
				echo "<ul style='margin:0px 0px 7px 0px;padding-left:15px;'>";
				foreach($arr_actions_msg as $single_msg){
					echo "<li style='margin-bottom:3px;'>".$single_msg."</li>";
				}
				echo "</ul></div>";
			?>	
            </td>
        </tr>
        </table>		
		<?php } ?>	

		<?php if($SETTINGS['home_panel_status'] == "1"){ ?>
        <table width='100%' align='center' class="home-panel" cellspacing='1' cellpadding='8'>
        <tr>
            <td width="90%" align="left"><span class="welcome"><?php echo $_SESSION['adm_username']; ?></span>
                <br /><?php echo lang('welcome_to'); ?> <?php echo $SETTINGS['panel_name']; ?>!
            </td>
            <td align="right" nowrap="nowrap" valign="middle">
				<?php echo lang('version').": "._PHP_AP_VERSION; ?>
			</td>
            <td align="left" valign="middle" nowrap="nowrap">
				<?php if($_SESSION['adm_status'] == "main admin"){ ?>
				<a style="text-decoration:none;" href='home.php?act=hide_home_panel' title='<?php echo lang('hide'); ?>'><img src='../images/close.png' alt='' /></a>
				<?php } ?>
			</td>
        </tr>
        <tr>
            <td colspan="3" align="left" style="text-align:justify;">                
				<?php $site_settings = get_site_settings(); ?>	
				<table align="center" width="100%" border="0" height="100%">
				<tr><td colspan="2" align="left"><b><?php echo lang('account_summary'); ?>:</b></td></tr>
				<tr>
					<td align="left"><?php echo lang('today'); ?></td>
					<td align='right'>
						<?php echo date("M d, Y"); ?>
					</td>
				</tr>
				<tr>
					<td align="left"><?php echo lang('last_login'); ?></td>
					<td align='right'>
						<?php
							$last_login = isset($_SESSION['last_login']) ? $_SESSION['last_login'] : ""; 
							echo my_date_format($last_login);				
						?>					
					</td>
				</tr>
				<tr>
					<td align="left"><?php echo lang('logins_count'); ?></td>
					<td align='right'>
						<?php
							$logins = isset($_SESSION['logins_count']) ? $_SESSION['logins_count'] : "0"; 
							echo $logins;				
						?>					
					</td>
				</tr>
				<tr><td colspan="2" height="9px" nowrap="nowrap"></td></tr>
				<tr><td colspan="2" align="left"><b><?php echo lang('ranks'); ?>: (<?php echo "<a href='panel_settings.php' title='".lang('edit')."'>".$SETTINGS['site_address']."</a>"; ?>)</b> <a href="<?php echo ((!preg_match("/http/i", $SETTINGS['site_address'])) ? "http://" : "").$SETTINGS['site_address']; ?>" title="Open in new window" target="_blank"><img src='../images/external_link.gif' style="margin-top:-3px;" alt='' /></a></td></tr>
				<tr>
					<td>Alexa: <?php echo $site_settings['rank_alexa']; ?></td>
					<td align='right'><a style="text-decoration:none;" href='home.php?act=update_rank'>[<?php echo lang('update'); ?>]</a></td>
				</tr>
				<tr>
					<td>Google PR: <?php echo $site_settings['rank_google']; ?></td>
					<td align='right'><?php echo lang('last_update'); ?>: <?php echo $site_settings['rank_last_updated']; ?></td>
				</tr>
				<tr><td colspan="2" height="9px" nowrap="nowrap"></td></tr>
				<tr><td colspan="2" align="left"><b><?php echo lang('help'); ?></b></td></tr>
				<tr>
					<td><?php echo lang('system_info'); ?>:</td>
					<td align='right'><a style="text-decoration:none;" href='phpinfo.php'>[<?php echo lang("show");?>]</a></td>
				</tr>				
				<tr>
					<td><?php echo lang('getting_started'); ?>:</td>
					<td align='right'><a style="text-decoration:none;" href='getting_started.php'>[<?php echo lang("show");?>]</a></td>
				</tr>				
				</table>
				
				<?php if(!($SETTINGS['alert_panel_status'] == "1" && $action_required)){ ?>		
				<br>
				<table align="center" width="100%" border="0">
				<tr><td colspan="2" align="left"><b><?php echo lang('tips'); ?>:</b></td></tr>
				<tr valign="top">
					<td align="left">1. </td>
					<td align="left">
		                To create new Menu Category select General -> Menu Manager and then
						click Add New.					
					</td>
				</tr>
				<tr valign="top">
					<td align="left">2. </td>
					<td align="left">
						General Admin Panel settings like: color schema, menu placement, datagrid
						CSS style and other could by changed from Panel Settings menu.
					</td>
				</tr>
				<tr valign="top">
					<td align="left">3. </td>
					<td align="left">
						To create new Page open Menu Manager, then select [Menu Options] from
						appropriate record and click Add New. There are 3 types of pages you
						can create: Static, Dynamic PHP Page and DataGrid Page.
					</td>
				</tr>
				<tr valign="top">
					<td align="left">4. </td>
					<td align="left">
						While creating a DataGrid Page you will be redirected to DataGrid Wizard,
						which will help you in completing the creation process. When DataGrid Page is
						created, you can easy edit it's code from DataGrid PHP Pages Manager: 
						Pages Manager -> DataGrid Pages.
					</td>
				</tr>
				</table>
				<?php } ?>
            </td>
        </tr>
        </table>
		<?php } ?>	
    </td>
	<?php } ?>	
</tr>
</table>
</body>
</html>
Return current item: Basic Announce