Location: PHPKode > projects > eBlog > index.php
<?php

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: index.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_once 'includes/global.php';

$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
	
$defaultTemplate = $template;
$copyrights = "&copy; " . date("Y") . " " . $lang_admin_globalRights1;
$tree_map = $lang_blog_recentTopics;

$equalWidth = 100/$topicsPP;
$topicsList = "";
$counter = 0;
$cellCounter = 1;
$query  = "SELECT * FROM eblog_topics ORDER BY id DESC";
$result = mysql_query($query);
while(($row = mysql_fetch_array($result, MYSQL_ASSOC))&&($counter < $topicsPP))
{	
	$counter++;
	$cellCounter++;
	
	$rowID = $row['id'];
	$rowSec = $row['sec'];
	$rowTitle = $row['title'];
	$rowDate = $row['date'];
	$rowContent = $row['contents'];
	$rowThumb = $row['thumb'];
	$rowAllViewers = $row['allviewers'];
	
	if(strlen($rowContent) > $wrap)
	$rowContent = substr($rowContent, 0, $wrap-3).'...';
	
	$lengthX = strlen($rowThumb);
	$rowThumb = substr($rowThumb, 3, $lengthX);	
	if(empty($rowThumb))
	$rowThumb = "images/noThumb.jpg";
	
	$result3 = mysql_query("SELECT title FROM eblog_sections WHERE id = '$rowSec'");	
	$row3 = mysql_fetch_row($result3);
	$rowSecName = $row3[0];

	
	$readLink = "<a href=\"topics.php?action=show&id=$rowID\" $popupDefine>$lang_blog_readMore</a>";
	
	$imageLink = "href=\"topics.php?action=show&id=$rowID\" title=\"$rowTitle\" $popupDefine";	
	
	

	if($enablethumb == 1)
	{
		$static_value = array ($readLink, $imageLink, $rowTitle, $thumb_width, $thumb_height, $bw, $rowThumb);
		$static_name = array ("{readLink}","{imageLink}", "{rowTitle}", "{thumb_width}", "{thumb_height}", "{bw}", "{rowThumb}");
		$file = $new_template->load_template ("templates/$defaultTemplate/thumb.html");
		$output = $new_template->replace_static($static_name, $static_value, $file);	
		if($cellCounter > $topicPR)
		{
			$end = "</td></tr><tr>";
			$cellCounter = 1;
		}
		else
		{
			$end = "</td>";
		}
		$start = "<td align=\"center\" width=\"$equalWidth\" valign=\"top\">";
		
	}
	else
	{
		$static_value = array ($readLink, $imageLink, $rowTitle, $thumb_width, $thumb_height, $bw, $rowThumb,
							   $lang_blog_topicViewers, $rowAllViewers, $lang_blog_date, $rowDate, $lang_blog_inSec,
							   $rowSecName
							  );
		$static_name = array ("{readLink}","{imageLink}", "{rowTitle}", "{thumb_width}", "{thumb_height}", "{bw}", "{rowThumb}",
							  "{lang_blog_topicViewers}", "{rowAllViewers}", "{lang_blog_date}", "{rowDate}", "{lang_blog_inSec}",
							   "{rowSecName}"
							 );
		$file = $new_template->load_template ("templates/$defaultTemplate/block.html");
		$output = $new_template->replace_static($static_name, $static_value, $file);		
	}	
		
	
	$topicsList = $topicsList . $start . $output . $end;
}

$temp = $topicPR + 1;
if(($cellCounter > 1)&&($enablethumb == 1))
{
	$innerCounter = $temp - $cellCounter;
	while ($innerCounter > 0)
	{
		$topicsList = $topicsList . "<td  width=\"$EqualCellWidth%\">&nbsp;</td>";
		$innerCounter = $innerCounter - 1;
	}
	$topicsList = $topicsList . "</tr>";
}

if($enablethumb == 0)
$topicsList = "<td>" . $topicsList . "</td>";

$topicsList = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"5\"><tr>" . $topicsList . "</tr></table>";

if($counter < 1)
{
	$topicsList = $lang_blog_noTopics;
}

$page_content = $page_content . $topicsList;


$static_value = array ($lang_blog_secionsList, $sections_list);
$static_name = array ("{lang_blog_secionsList}","{sections_list}");
$file = $new_template->load_template ("templates/$defaultTemplate/sideMenu.html");
$side_menu = $new_template->replace_static($static_name, $static_value, $file);




$static_value = array (
						$blog_windows_encoding, $blog_slogan, $lang_blog_search, $lang_blog_recentTopics,
					    $tree_map, $css, $side_menu,$page_content, $blog_dir, $blog_name,
					    $meta, $social_networks, $copyrights, $lang_blog_emailMe, $lang_blog_joinMyMainingList,
					    $lang_blog_MyFriends, $lang_blog_visitors, $visitors,$popupDefine
					  );
					  
					  
$static_name  = array (
					   "{blog_windows_encoding}","{blog_slogan}","{lang_blog_search}", "{lang_blog_recentTopics}",
					   "{tree_map}", "{css}", "{side_menu}", "{page_content}", "{blog_dir}", "{blog_name}",
					   "{meta}", "{social_networks}", "{copyrights}", "{lang_blog_emailMe}", "{lang_blog_joinMyMainingList}",
					   "{lang_blog_MyFriends}", "{lang_blog_visitors}", "{visitors}", "{popupDefine}"
					  );

$header = $new_template->load_template ("templates/$defaultTemplate/header.html");
$body = $new_template->load_template ("templates/$defaultTemplate/layout.html");
$footer = $new_template->load_template ("templates/$defaultTemplate/footer.html");
$template = $new_template->replace_static($static_name, $static_value, $header . $body	. $footer);
echo $template;

mysql_close($conn);

?>
Return current item: eBlog