if (!
defined("LOADED_AS_MODULE")) { die ("You can't access this file directly...");
}
$index = 1;
} else {
$index = 0;
}
// Check if the entered topic, catid and allstories vars are numeric
(isset($GLOBALS['allstories']) && !
empty($GLOBALS['allstories']) && !
is_numeric($GLOBALS['allstories'])) ) {
include 'header.php';
OpenTable();
CloseTable();
include 'footer.php';
}
//End of check
modules_get_language();
include_once("modules/$ModName/funcs.php");
automatednews();
/**
* Prints out the index
* Prints out the index screen.
* @return none
* @author FB
*/
function theindex()
{
global $themeOverrideCategory;
$allstories = &$GLOBALS['allstories'];
// Furbo: to stop hacking vars on the url
$topic = pnVarCleanFromInput('topic');
$catid = pnVarCleanFromInput('catid');
// end furbo hack stop
$startnum = pnVarCleanFromInput('startnum');
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$currentlang = pnUserGetLang();
if (pnConfigGetVar('multilingual') == 1) {
$column = &$pntable['stories_column'];
$querylang = "AND ($column[alanguage]='$currentlang' OR $column[alanguage]='')"; /* the OR is needed to display stories who are posted to ALL languages */
} else {
$querylang = '';
}
// use a theme override if we're displaying a category
if ((!
empty($catid)) &&
($catid >
0)) { $column = &$pntable['stories_cat_column'];
$result =& $dbconn->Execute("SELECT $column[themeoverride]
FROM $pntable[stories_cat]
WHERE $column[catid]='".(int)pnVarPrepForStore($catid)."'");
//list($themeOverrideCategory) = $result->fields;
if ($result) $themeOverrideCategory = $result->fields[0];
}
include 'header.php';
//OpenTable();
$column = &$pntable['topics_column'];
$result =& $dbconn->Execute("SELECT $column[topicid], $column[topicname], " .
"$column[topicimage], $column[topictext] FROM " .
"$pntable[topics] WHERE $column[topicid]='".(int)pnVarPrepForStore($topic)."'");
list($topicid,
$topicname,
$topicimage,
$topictext) =
$result->
fields;
echo "<div style=\"text-align:center\">";
if (!
empty($topicimage)) { echo "<img src=\"".pnConfigGetVar
('tipath').
"$topicimage\"" .
"border=\"0\" alt=\"\"><br /><br />";
}
echo '<h1>' . _THISISTOPIC . pnVarPrepForDisplay
($topictext) .
'</h1>' . _FOLLOWINGNEWS;
//CloseTable();
//OpenTable();
$column = &$pntable['stories_cat_column'];
$result =& $dbconn->Execute("SELECT $column[title] FROM $pntable[stories_cat]
WHERE $column[catid]=".(int)pnVarPrepForStore($catid)."");
list($title) =
$result->
fields;
echo '<h1>' . _THISISTOPIC . pnVarPrepForDisplay
($topictext) .
'</h1>' . _FOLLOWINGNEWS;
//CloseTable();
}
if (pnUserLoggedIn()) {
$storynum = pnUserGetVar('storynum');
}
$storynum = pnConfigGetVar('storyhome');
}
// start eugeniobaldi 20020310
// When you view stories for Catid or for topic , you can select of view all stories
/*if ((!empty($catid)) or (!empty($topic))) {
if(!empty($allstories) && $allstories == 1) {
$storynum = 999;
} else {
//magicx : Removed instances of <br />
echo "<a class=\"pn-normal\" href=\"modules.php?op=modload&name=News&file=index&catid=$catid&topic=$topic&allstories=1\">"._SEEALL."</a><br /><br />";
}
}*/
$allstories = 0;
// end eugeniobaldi 20020310
$storcol = &$pntable['stories_column'];
$storcatcol = &$pntable['stories_cat_column'];
$topiccol = &$pntable['topics_column'];
if (!
empty($catid) && !
empty($topic)) { // show only one category and one topic $result =& $dbconn->Execute("UPDATE $pntable[topics] SET $topiccol[counter]=$topiccol[counter]+1 WHERE $topiccol[topicid]='".(int)pnVarPrepForStore($topic)."'");
if($dbconn->ErrorNo() != 0) {
error_log("DB Error updating $pntable[topics]: " . $dbconn->ErrorNo() . ": "
. $dbconn->ErrorMsg());
}
$dbconn->Execute("UPDATE $pntable[stories_cat] SET $storcatcol[counter]=$storcatcol[counter]+1 WHERE $storcatcol[catid]='".(int)pnVarPrepForStore($catid)."'");
if($dbconn->ErrorNo()<>0) {
error_log("DB Error updating $pntable[stories_cat]: " . $dbconn->ErrorNo() . ": "
. $dbconn->ErrorMsg());
}
$whereclause = "$topiccol[topicid]='".(int)pnVarPrepForStore($topic)."' AND $storcol[catid]='".(int)pnVarPrepForStore($catid)."' ";
} else if (!
empty($catid)) { // show only one category $dbconn->Execute("UPDATE $pntable[stories_cat] SET $storcatcol[counter]=$storcatcol[counter]+1 WHERE $storcatcol[catid]='".(int)pnVarPrepForStore($catid)."'");
if($dbconn->ErrorNo() != 0) {
error_log("DB Error updating $pntable[stories_cat]: " . $dbconn->ErrorNo() . ": "
. $dbconn->ErrorMsg());
}
$whereclause = "$storcol[catid]='".(int)pnVarPrepForStore($catid)."' ";
} else if (!
empty($topic)) { // show only one category $dbconn->Execute("UPDATE $pntable[topics] SET $topiccol[counter]=$topiccol[counter]+1 WHERE $topiccol[topicid]='".(int)pnVarPrepForStore($topic)."'");