Location: PHPKode > projects > eBlog > includes/global.php
<?php

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: includes/global.php                                  *
 *               By: Emuci inc.                                           *
 *          Website: http://www.emuci.com                                 *
 *        Copyright: (C) 2010 Emcui inc.                                  *
 *                                                                        *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *                                                                        *
 *   This script is NOT freeware and is subjected to Emuci terms of use   *
 *   located in the docs folder.                                          *
 *                                                                        *
 *                                                                        *
 *************************************************************************/
 
 
 
include 'config.php';
include_once 'session.php';
include_once 'template.php';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ($lang_erorr_connectivity);
mysql_select_db($dbname);




// settings
$result = mysql_query("SELECT * FROM eblog_settings WHERE id = '1'");	
$row = mysql_fetch_row($result);
$blog_name = $row[1];
$site_url = $row[2];
$meta = $row[6];
$css = $row[7];
$badWords = $row[8];
$replaceWords = $row[9];
$allowComments = $row[10];
$visitors = $row[11];
$lang = $row[13];
$template = $row[14];
$popup = $row[15]; 
$enable1 = $row[16]; 
$enable2 = $row[17]; 	
$enable3 = $row[18]; 
$enable4 = $row[19]; 
$enablethumb = $row[20];
$thumb_width = $row[21];
$thumb_height = $row[22];		
$sort_by = $row[23];
$sort_order = $row[24];
$autoValidate = $row[25];
$location = $row[26];
$topicsPP = $row[27];
$monthsPL = $row[28];
$cellPR = $row[29];
$topicPR = $row[30];	
$ww = $row[31];
$wh = $row[32];
$GPP = $row[33];
$bw = $row[34];
$wrap = $row[35];	





// load language
include('lang/' . $lang . '.php');


// popup style
if($popup == 3){
	$popupDefine = "onclick=\"window.open(this,'popup','width=$ww,height=$wh,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0'); return false;\"";
}
else if($popup == 2)
{
	$popupDefine = " onclick=\"
Modalbox.show(this.href, {title: this.title, width: 850}); return false;\"";
}
else if($popup == 1)
{
	$popupDefine = "onclick=\"return hs.htmlExpand(this, { objectType: 'iframe' } )\"";
}
else
{
	$popupDefine = "";
}




// sections
$query  = "SELECT * FROM eblog_sections";
$result = mysql_query($query);
$counter = 0;
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

	
	$rowID = $row['id'];
	$rowTitle = $row['title'];
	$rowParent = $row['parent'];
	
	if(empty($rowParent)){		
	$sections_list = $sections_list . "<li><a href=\"sections.php?action=show&id=$rowID\">$rowTitle</a></li>";
	}
	$counter++;
}



// pages
$query  = "SELECT * FROM eblog_pages";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

	
	$rowID = $row['id'];
	$rowTitle = $row['title'];
	$rowType = $row['type'];
	$rowURL = $row['url'];
	$rowWindow = $row['window'];
	$rowVisible = $row['visible'];
	$rowStatus = $row['status'];
	
	if($rowWindow == 1){$openPageIn = "";}
	if($rowWindow == 2){$openPageIn = "target=\"_blank\"";}
	
	
	if(($rowVisible == 1)&&($rowStatus == 1)){
	
			if($rowType == 2)
			{
				$sections_list = $sections_list . "<li><a href=\"$rowURL\" $openPageIn>$rowTitle</a></li>";
			}
			else
			{
				$sections_list = $sections_list . "<li><a href=\"pages.php?id=$rowID\" title=\"$rowTitle\" $popupDefine>$rowTitle</a></li>";		
			}
		}
	
	
	$counter++;
}	

	
	$sections_list = $sections_list . "<li><a href=\"guestbook.php\"  title=\"$lang_blog_guestbook\" $popupDefine>$lang_blog_guestbook</a></li>";









// archieve
$thisYEAR = date("Y");
$thisMonth = date("m");
$monthsToShow = $monthsPL;
$counter = 0;
while ($counter < $monthsToShow)
{	

	if($thisMonth == 1){$thisMonthName = $lang_blog_01;}
	if($thisMonth == 2){$thisMonthName = $lang_blog_02;}
	if($thisMonth == 3){$thisMonthName = $lang_blog_03;}
	if($thisMonth == 4){$thisMonthName = $lang_blog_04;}
	if($thisMonth == 5){$thisMonthName = $lang_blog_05;}
	if($thisMonth == 6){$thisMonthName = $lang_blog_06;}
	if($thisMonth == 7){$thisMonthName = $lang_blog_07;}
	if($thisMonth == 8){$thisMonthName = $lang_blog_08;}
	if($thisMonth == 9){$thisMonthName = $lang_blog_09;}
	if($thisMonth == 10){$thisMonthName = $lang_blog_10;}
	if($thisMonth == 11){$thisMonthName = $lang_blog_11;}
	if($thisMonth == 12){$thisMonthName = $lang_blog_12;}


	$archive = $archive . "<li><a href=\"archive.php?action=show&month=$thisMonth&year=$thisYEAR\" class=\"normalfont\">$thisMonthName, $thisYEAR</a></li>";

	
	$counter++;
	$thisMonth--;
	
	if($thisMonth < 1){
	$thisMonth = 12;
	$thisYEAR--;
	}		
}






// statistics

	// 1 : Get the total number of visitors
	$query  = "SELECT * FROM eblog_settings";
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$blog_info = $blog_info . "<li>" . $lang_blog_visitors . ": " . $row['visitors'] . "</li>";
	}	
	
	// 2 : Calculate topics
	$query  = "SELECT * FROM eblog_topics";
	$result = mysql_query($query);	
	$totalTopics = 0;
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$totalTopics++;
	}
	$blog_info = $blog_info .  "<li>" . $lang_blog_topics . ": " . $totalTopics . "</li>";
	
	// 3 : Calculate comments
	$query  = "SELECT * FROM eblog_comments";
	$result = mysql_query($query);
	$totalComments = 0;	
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$totalComments++;
	}
	$blog_info = $blog_info .  "<li>" . $lang_blog_comments . ": " . $totalComments . "</li>";
	
	


	
// socialmarks
if($blog_dir == "ltr")
$direction = "left";
else
$direction = "right";
	
$social_networks = "
<table cellpadding=\"0\" cellspacing=\"9\" border=\"0\">
<tr>
";	

$query  = "SELECT * FROM eblog_social";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

	$rowName = $row['name'];
	$rowLink = $row['link'];
	$rowImage = $row['image'];
	$social_networks = $social_networks . "<td><a target=\"_blank\" href=\"$rowLink\"><img  border=\"0\" src=\"$rowImage\"></a></td>";	
}

$social_networks = $social_networks . "</tr></table>";			


$MonthsArray = array(
			 "01" => $lang_blog_01,
			 "02" => $lang_blog_02,
			 "03" => $lang_blog_03,
			 "04" => $lang_blog_04,
			 "05" => $lang_blog_05,
			 "06" => $lang_blog_06,
			 "07" => $lang_blog_07,
			 "08" => $lang_blog_08,
			 "09" => $lang_blog_09,
			 "10" => $lang_blog_10,			 			 
			 "11" => $lang_blog_11,
			 "12" => $lang_blog_12
			 );
			 
				
mysql_close($conn);			


?>
Return current item: eBlog