vi posto il codice.. modules/News/includes/theindex.php
- Codice: Seleziona tutto
<?
if (eregi(basename(__FILE__), $PHP_SELF)) {
die ("You can't access this file directly...");
}
$config_np[ncolumns]=1;
$pntable[stories]=$prefix."_stories";
$pntable[topics]=$prefix."_topics";
function theindex($new_topic=0) {
global $dbi, $storyhome, $topicname, $topicimage, $topictext, $datetime, $user, $cookie, $nukeurl, $pntable, $multilingual, $currentlang, $articlecomm, $sitename;
if ($multilingual == 1) {
$querylang = "AND (alanguage='$currentlang' OR alanguage='')";
} else {
$querylang = "";
}
include("header.php");
automated_news();
if (isset($cookie[3])) {
$storynum = $cookie[3];
} else {
$storynum = $storyhome;
}
if ($new_topic == 0) {
$qdb = "WHERE (ihome='0' OR catid='0')";
$home_msg = "";
} else {
$qdb = "WHERE topic='$new_topic'";
$res = sql_query("select topictext from $pntable[topics] where topicid='$new_topic'", $dbi);
list($topic_title) = sql_fetch_row($res, $dbi);
OpenTable();
if (sql_num_rows($res, $dbi) == 0) {
echo "<center><font class=\"title\">$sitename</font><br><br>"._NOINFO4TOPIC."<br><br>[ <a href=\"modules.php?name=News\">"._GOTONEWSINDEX."</a> | <a href=\"modules.php?name=Topics\">"._SELECTNEWTOPIC."</a> ]</center>";
} else {
echo "<center><font class=\"title\">$sitename: $topic_title</font><br><br>"
."<form action=\"modules.php?name=Search\" method=\"post\">"
."<input type=\"hidden\" name=\"topic\" value=\"$new_topic\">"
.""._SEARCHONTOPIC.": <input type=\"name\" name=\"query\" size=\"30\"> "
."<input type=\"submit\" value=\""._SEARCH."\">"
."</form>"
."[ <a href=\"index.php\">"._GOTOHOME."</a> | <a href=\"modules.php?name=Topics\">"._SELECTNEWTOPIC."</a> ]</center>";
}
CloseTable();
echo "<br>";
}
#####################################################
/* Hack by Jata */
global $module_name, $config_np,$page;
$newslink="modules.php?name=$module_name";
if (!isset($page)) { $page = 1; }
$pagesize=$config_np[ncolumns]*intval(($storynum+$config_np[ncolumns]-1)/$config_np[ncolumns]);
$min = $pagesize * ($page - 1); // This is where we start our record set from
$max = $pagesize; // This is how many rows to select
$count = "SELECT count(sid) as total FROM $pntable[stories] ";
$select= "SELECT sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes, acomm, score, ratings FROM $pntable[stories] ";
$limit = "DESC limit $min, $max";
$count_result = sql_query("$count $qdb $querylang", $dbi);
$num_rows_per_order = mysql_result($count_result,0,0);
$result = sql_query("$select $qdb $querylang ORDER BY sid $limit", $dbi);
$num_articles = sql_num_rows($result,$dbi);
$count=0;
while ($row = sql_fetch_row($result,$dbi))
{
$rows[]=$row;
$count++;
}
$crows=intval(($count+$config_np[ncolumns]-1)/$config_np[ncolumns]);
$cnt=0;
$colcount=0;
echo ("<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\" align=\"center\">");
echo ("<tr>");
for($i=0;$i<($crows*$config_np[ncolumns]);$i++)
{
$j=$config_np[ncolumns]*$cnt+$colcount;
if($cnt==0)
echo ("<td width=\"".intval(100/$config_np[ncolumns])."%\"valign=\"top\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\" width=\"100%\">");
if($j<$count)
{
list($s_sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant, $notes, $acomm, $score, $ratings) =$rows[$j];
#########################################################################
# $result = sql_query("$select $qdb $querylang ORDER BY sid $limit", $dbi);
# while (list($s_sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant, $notes, $acomm, $score, $ratings) = sql_fetch_row($result, $dbi)) {
if ($catid > 0) {
list($cattitle) = sql_fetch_row(sql_query("select title from $pntable[stories]_cat where catid='$catid'", $dbi), $dbi);
}
getTopics_np($s_sid);
formatTimestamp($time);
$subject = stripslashes($subject);
$hometext = stripslashes($hometext);
$notes = stripslashes($notes);
$introcount = strlen($hometext);
$fullcount = strlen($bodytext);
$totalcount = $introcount + $fullcount;
$c_count = $comments;
$r_options = "";
if (isset($cookie[4])) { $r_options .= "&mode=$cookie[4]"; }
if (isset($cookie[5])) { $r_options .= "&order=$cookie[5]"; }
if (isset($cookie[6])) { $r_options .= "&thold=$cookie[6]"; }
if (is_user($user)) {
$the_icons = " | <a href=\"modules.php?name=News&file=print&sid=$s_sid\"><img src=\"images/print.gif\" border=\"0\" Alt=\""._PRINTER."\" width=\"16\" height=\"11\"></a> <a href=\"modules.php?name=News&file=friend&op=FriendSend&sid=$s_sid\"><img src=\"images/friend.gif\" border=\"0\" Alt=\""._FRIEND."\" width=\"16\" height=\"11\"></a>";
} else {
$the_icons = "";
}
$story_link = "<a href=\"modules.php?name=News&file=article&sid=$s_sid$r_options\">";
$morelink = "(";
if (($fullcount > 0) OR ($c_count > 0)) {
$morelink .= "$story_link<b>"._READMORE."</b></a> | ";
} else {
$morelink .= "";
}
if ($fullcount > 0) { $morelink .= "$totalcount "._BYTESMORE." | "; }
if ($articlecomm == 1 AND $acomm == 0) {
if ($c_count == 0) { $morelink .= "$story_link"._COMMENTSQ."</a>"; } elseif ($c_count == 1) { $morelink .= "$story_link$c_count "._COMMENT."</a>"; } elseif ($c_count > 1) { $morelink .= "$story_link$c_count "._COMMENTS."</a>"; }
}
if ($fullcount == 0 AND $acomm == 1) {
$morelink .= "$story_link<b>"._READMORE."</b></a>";
if (!is_user($user)) {
$morelink .= " | ";
}
}
$morelink .= "$the_icons";
$sid = $s_sid;
if ($catid != 0) {
$resultm = sql_query("select title from $pntable[stories]_cat where catid='$catid'", $dbi);
list($title1) = sql_fetch_row($resultm, $dbi);
$title = "<a href=\"modules.php?name=News&file=categories&op=newindex&catid=$catid\"><font class=\"storycat\">$title1</font></a>: $title";
$morelink .= " | <a href=\"modules.php?name=News&file=categories&op=newindex&catid=$catid\">$title1</a>";
}
if ($score != 0) {
$rated = substr($score / $ratings, 0, 4);
} else {
$rated = 0;
}
$morelink .= " | "._SCORE." $rated";
$morelink .= ")";
$morelink = str_replace(" | | ", " | ", $morelink);
#######################################################
/* Hack by Jata */
if(!$topicimage)
{
$topicimage="AllTopics.gif";
}
echo ("<tr><td>");
themeindex($aid, $informant, $datetime, $title, $counter, $topic, $hometext, $notes, $morelink, $topicname, $topicimage, $topictext);
echo ("</td></tr>");
$cnt++;
if($cnt>=$crows)
{
$cnt=0;
$colcount++;
echo ("</table></td>");
}
}
}
if($cnt) echo ("</table></td>");
elseif($colcount<$config_np[ncolumns]) echo ("</table></td>");
echo ("</tr></table>");
####################################################
/* Hack by Jata */
OpenTable();
echo "\t<table width='100%' cellspacing='0' cellpadding='0' border=0><tr>";
if ( $num_rows_per_order > $pagesize ) {
$total_pages = ceil($num_rows_per_order / $pagesize); // How many pages are we dealing with here ??
$prev_page = $page - 1;
if ( $prev_page > 0 ) {
echo "<td align='left' width='15%'><a href=\"$newslink&page=$prev_page$qqq\">";
echo "<img src=\"modules/$module_name/images/left.gif\" border=\"0\" Alt=\""._PREVIOUS." ($prev_page)\"></a></td>";
} else {
echo "<td width='15%'> </td>\n";
}
echo "<td align='center' width='70%'>";
echo "<font class=tiny>$num_rows_per_order "._STORIESFOUND." ($total_pages "._PAGES.", $num_articles "._SHOWN.")</font>";
echo "</td>";
$next_page = $page + 1;
if ( $next_page <= $total_pages ) {
echo "<td align='right' width='15%'><a href=\"$newslink&page=$next_page$qqq\">";
echo "<img src=\"modules/$module_name/images/right.gif\" border=\"0\" Alt=\"Next Page ($next_page)\"></a></td>";
} else {
echo "<td width='15%'> </td></tr>\n";
}
/* Added a numbered page list, only shows up to 50 pages. */
echo "<tr><td colspan=\"3\" align=\"center\">";
echo " <font class=tiny>[ </font>";
for($n=1; $n < $total_pages; $n++) {
if ($n == $page) {
echo "<font class=tiny><b>$n</b></font></a>";
} else {
echo "<a href=\"$newslink&page=$n$qqq\">";
echo "<font class=tiny>$n</font></a>";
}
if($n >= 50) { // if more than 50 pages are required, break it at 50.
$break = true;
break;
} else { // guess not.
echo "<font class=tiny> | </font>";
}
}
if(!isset($break)) { // are we sopposed to break ?
if ($n == $page) {
echo "<font class=tiny><b>$n</b></font></a>";
} else {
echo "<a href=\"$newslink&page=$total_pages$qqq\">";
echo "<font class=tiny>$n</font></a>";
}
}
echo " <font class=tiny>]</font> ";
echo "</td></tr>";
/* This is where it ends */
}else{ // or we dont have any users..
echo "<td align='center'>";
echo "<font class=tiny>$num_rows_per_order "._STORIESFOUND."</font>";
echo "</td></tr>";
}
echo "\n</table><br>\n";
Closetable();
####################################################
include("footer.php");
}
function getTopics_np($s_sid) {
global $topicname, $topicimage, $topictext, $pntable, $dbi;
$sid = $s_sid;
$result = sql_query("SELECT topic FROM $pntable[stories] where sid=$sid", $dbi);
list($topic) = sql_fetch_row($result, $dbi);
$result = sql_query("SELECT topicid, topicname, topicimage, topictext FROM $pntable[topics] where topicid=$topic", $dbi);
list($topicid, $topicname, $topicimage, $topictext) = sql_fetch_row($result, $dbi);
}
?>




