Location: PHPKode > projects > PSlash > pslash-0.70/html/index.php
<?

###############################################################################
# Copyright (C) 2000  Derek Leung
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# You may modify your copy or copies of this Program or any portion of it,
# but you must cause the modified files to carry prominent notices stating 
# that you changed the files and the date of any change.  And you are required 
# to keep a copy of this License along with this Program.
#
# You are not required to accept this License, since you have not signed it. 
# However, nothing else grants you permission to modify or distribute this 
# Program or its derivative works. These actions are prohibited by law if 
# you do not accept this License. Therefore, by modifying or distributing 
# this Program (or any work based on this Program), you indicate your 
# acceptance of this License to do so, and all its terms and conditions 
# for copying, distributing or modifying this Program or works based on it.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# See the GNU General Public License for more details.
# http://www.opensource.org/licenses/gpl-license.html
###############################################################################

// you have to put the following two lines at the top in order to get the webstatz to work.

require("mainfile.php");
$lvc_include_dir = $config[visitor_path];
require($lvc_include_dir.'new-visitor.inc.php');

global $myTopic, $config;

	$userArray = getCookie($config[user_cookie_name]);
	$index[sidebox] = 1;	// Show blocks on the right column

	if (!IsSet($myTopic)) {
		$myTopic = $config[def_theme];
	} 

	$topics=getTopics();
	if (!in_array($myTopic,$topics)) {
		$myTopic = $config[def_theme];
	} 

	ps_header($index);

	showTopicLinks($topics);
	
	// Determine the amount of articles, which are displayed
	$settingArray = getCookie($config[setting_cookie_name]);
	if ($settingArray[storynum] != "") {
		$storynum = $settingArray[storynum];	// User setting
	} else {
		$storynum = $config[limitnews];	// See config.php
	}

	// build info for next page
	if ($page == "" || $page == 1) {
		$startNum = 0;
	} else {
		$startNum = ($page-1) * $storynum;
	}

	// Build query string form, if no topic, default is Main.
	$sql="SELECT * FROM ps_stories ";
	if ($myTopic != $config[def_theme]) {
		$sql.="WHERE topic = '".$myTopic."' ";
	} else {
		#get a list of topic that do not have its own topic page, they all fall into the Default topic.
		$displayStr = getTopicsWithNoSection();
		$sql.="WHERE topic = '".$myTopic."' or topic in ($displayStr) ";	
	}

	// building info for next page use
	$idxNumRow = mysql_num_rows(mysql_query($sql));
	$idxStartNum = $startNum + $storynum;
	$sql.="ORDER BY time DESC LIMIT $startNum,$storynum";


	// Query the database
	$result	= @mysql_query($sql);
	if(!$result) {
		echo mysql_errno(). ": ".mysql_error(). "<br>";
		exit();
	}

	if (mysql_num_rows($result) > 0) {
		$topics_disabled=getTopicsDisabled();
		// Process the query
		while ( $fields = @mysql_fetch_array($result)) {
			// Translate fields into variables
			$sid		= $fields["sid"];
			$aid		= $fields["aid"];
			$subject	= $fields["title"] ;
			$fulltext	= $fields["full_text"] ;
			$comments	= $fields["comments"] ;
			$topic		= $fields["topic"] ;
			$informant	= $fields["informant"] ;
			$fullcount = strlen($fulltext);
			$totalcount = strlen($introtext) + $fullcount;

			if (!in_array($topic,$topics_disabled)) {
				$morelink = "( ";
				$morelink .= "<a href=\"article.php?sid=$sid&myTopic=$myTopic\">";
				//	   if ( $fullcount > $config[abstractlen]) {	
	   			$morelink .= translate("Read more...");
				$morelink .= "</a> | " ;
				//	   } else {
				//		$morelink .= "</b></a> " ;
				//	   }
				
				$query = mysql_query("SELECT count(tid) FROM ps_comments where sid=$sid");
				if(!$query) {
					$count = 0;
				} else  {
					list($count) = mysql_fetch_array($query);
				}
				mysql_free_result($query);
				$morelink .= "<a href=\"article.php?sid=$sid&myTopic=$myTopic\">";
				$morelink .= $count ." ";
				if($count != 1) {
					$morelink .= translate( "comments");
				} else {
					$morelink .= translate( "comment");
				}

				$morelink .= "</a> ) ";
				
				$datetime = formatTimestamp($fields["time"]);
				$fulltext = myNl2Br(check_words($fulltext));
				$subject = check_words($subject);
				themeindex($aid, $datetime, $subject, $myTopic, $fulltext, $comments, $morelink, $topic);
			}
			unset($fields,$aid, $datetime, $subject, $fulltext, $comments, $morelink, $topic);
		}
  

	} else {
		echo "<hr><h3>".translate("No more stories")."</h3>";
		$noStory = "true";
	}

	mysql_free_result($result);
	echo "<hr>";

	// now we make the next page link
	if ($noStory != "true") {
		if ($page == "") {
			$page = 2;
		} else {
			$page = $page +1;
		} 
	}
	if ($idxNumRow >= $idxStartNum) {
		echo "<center><a href=\"index.php?page=$page&myTopic=$myTopic\">[" . translate("Older News ==>") . "]</a></center>";
	}
	ps_footer($index);
	unset ($config);

?>
Return current item: PSlash