<?php
// File: $Id: index.php,v 1.37 2001/12/04 00:50:28 gregorrothfuss Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 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. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of this file: Francisco Burzi
// Purpose of this file:
// ----------------------------------------------------------------------
//===FTO Add IS NULL for every SQL clauses
//ORACLEDONE
if (!defined("LOADED_AS_MODULE")) {
die ("You can't access this file directly...");
}
include 'mainfile.php';
$myts = new MyTextSanitizer; // MyTextSanitizer object
$index = 1;
$ModName = $GLOBALS['name'];
modules_get_language();
pninclude_once("modules/$ModName/funcs.php");
automatednews();
/**
* Display messages
* Display messages, if there are any
* @return none
* @author FB
*/
function MessageBox() { /* ML Changes completely for the multiple and ml message system */
global $user, $pntable, $dbconn, $multilingual, $currentlang; /* added multilingual globals */
global $myts;
$column = &$pntable['message_column'];
if ($multilingual == 1) {
//===FTO Add IS NULL for every SQL clauses
$querylang = "AND ($column[mlanguage]='$currentlang' OR $column[mlanguage]='' OR $column[mlanguage] IS NULL)";
} else {
$querylang = "";
}
$column = &$pntable['message_column'];
$result = $dbconn->Execute("SELECT $column[mid], $column[title], $column[content], $column[date], $column[expire], $column[view]
FROM $pntable[message]
WHERE $column[active]=1 $querylang");
//FTO : Test EOF and database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$result->EOF) {
list($mid, $title, $content, $mdate, $expire, $view) = $result->fields;
$title = $myts->makeTareaData4Show($title);
$content = $myts->makeTareaData4Show($content);
if ($title != "" && $content != "") {
if ($expire == 0) {
$remain = _UNLIMITED;
} else {
$etime = (($mdate+$expire)-time())/3600;
$etime = (int)$etime;
if ($etime < 1) {
$remain = _EXPIRELESSHOUR;
} else {
$remain = ""._EXPIREIN." $etime "._HOURS."";
}
}
if (($view == 4) && (authorised(0, 'Messages::', "$title::$mid", ACCESS_ADMIN))) {
// view == 4 - messages only to be seen by administrators
OpenTable();
echo "<center><font class=\"pn-title\"><b>$title</b></font></center><br>\n"
."<font class=\"pn-normal\">$content</font>"
."<br><br><center><font class=\"pn-normal\">[' "._MVIEWADMIN." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ']</font></center>";
CloseTable();
echo "<br>";
} elseif (($view == 3) && ((!is_user($user)) || (authorised(0, 'Messages::', "$title::$mid", ACCESS_ADMIN)))) {
// view == 3 - messages only to be seen by non-users (and admins)
OpenTable();
echo "<center><font class=\"pn-title\"><b>$title</b></font></center><br>\n"
."<font class=\"pn-normal\">$content</font>";
if (authorised(0, 'Messages::', "$title::$mid", ACCESS_EDIT)) {
echo "<br><br><center><font class=\"pn-normal\">[' "._MVIEWANON." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ']</font></center>";
}
CloseTable();
echo "<br>";
} elseif (($view == 2) && ((is_user($user)) || (authorised(0, 'Messages::', "$title::$mid", ACCESS_ADMIN)))) {
// view == 2 - messages only to be seen by users (and admins)
OpenTable();
echo "<center><font class=\"pn-title\"><b>$title</b></font></center><br>\n"
."<font class=\"pn-normal\">$content</font>";
if (authorised(0, 'Messages::', "$title::$mid", ACCESS_EDIT)) {
echo "<br><br><center><font class=\"pn-normal\">[' "._MVIEWUSERS." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ']</font></center>";
}
CloseTable();
echo "<br>";
} elseif ($view == 1) {
// view == 1 - messages to be seen by everyeon
OpenTable();
echo "<center><font class=\"pn-title\"><b>$title</b></font></center><br>\n"
."<font class=\"pn-normal\">$content</font>";
if (authorised(0, 'Messages::', "$title::$mid", ACCESS_EDIT)) {
echo "<br><br><center><font class=\"pn-normal\">[' "._MVIEWALL." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ']</font></center>";
}
CloseTable();
echo "<br>";
}
if ($expire != 0) {
$past = time() - $expire;
if ($mdate < $past) {
$column = &$pntable['message_column'];
$result2 = $dbconn->Execute("UPDATE $pntable[message]
SET $column[active]=0
WHERE $column[mid]=$mid");
//FTO : Test database error
if (!$result2) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
}
}
}
$result->MoveNext();
}
return;
}
/**
* Prints out the index
* Prints out the index screen.
* @return none
* @author FB
*/
function theindex()
{
global $storyhome, $httpref, $httprefmax, $topicname, $topicimage,
$topictext, $user, $cookie, $nukeurl, $pntable, $multilingual,
$currentlang, $catid, $myts, $topic, $dbconn;
global $themeOverrideCategory;
global $autolinkpref;
global $ModName;
global $postnuke_theme;
if ($multilingual == 1) {
$column = &$pntable['stories_column'];
//===FTO Add IS NULL for every SQL clauses
$querylang = "AND ($column[alanguage]='$currentlang' OR $column[alanguage]='' OR $column[alanguage] IS NULL)"; /* 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]=$catid");
list($themeOverrideCategory) = $result->fields;
}
include 'header.php';
// include the message box only if we're not displaying a category
if (empty($catid) && empty($topic)) {
MessageBox();
}
if (is_user($user) && !empty($cookie[3])) {
$storynum = $cookie[3];
} else {
$storynum = $storyhome;
}
$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]=$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]=$catid");
if($dbconn->ErrorNo()<>0) {
error_log("DB Error updating $pntable[stories_cat]: "
. $dbconn->ErrorNo() . ": "
. $dbconn->ErrorMsg());
}
$whereclause = "$topiccol[topicid]=$topic AND $storcol[catid]=$catid ";
} else if (!empty($catid)) { // show only one category
$dbconn->Execute("UPDATE $pntable[stories_cat] SET $storcatcol[counter]=$storcatcol[counter]+1 WHERE $storcatcol[catid]=$catid");
if($dbconn->ErrorNo()<>0) {
error_log("DB Error updating $pntable[stories_cat]: "
. $dbconn->ErrorNo() . ": "
. $dbconn->ErrorMsg());
}
$whereclause = "$storcol[catid]=$catid ";
} else if (!empty($topic)) { // show only one category
$dbconn->Execute("UPDATE $pntable[topics] SET $topiccol[counter]=$topiccol[counter]+1 WHERE $topiccol[topicid]=$topic");
if($dbconn->ErrorNo()<>0) {
error_log("DB Error updating $pntable[topics]: "
. $dbconn->ErrorNo() . ": "
. $dbconn->ErrorMsg());
}
$whereclause = "($topiccol[topicid]=$topic OR $topiccol[topicid]=0) AND ($storcol[ihome]=0 OR $storcol[catid]=0) ";
} else {
$whereclause = "$storcol[ihome]=0";
}
$articles = getArticles($whereclause, "$storcol[sid] DESC", $storynum);
foreach ($articles as $row) {
// $info is array holding raw information.
// Used below and also passed to the theme - jgm
$info = genArticleInfo($row);
// Need to at least have overview permissions on this story
if (authorised(0, 'Stories::', "$info[aid]:$info[cattitle]:$info[sid]", ACCESS_OVERVIEW)) {
// $links is an array holding pure URLs to
// specific functions for this article.
// Used below and also passed to the theme - jgm
$links = genArticleLinks($info);
// $preformat is an array holding chunks of
// preformatted text for this article.
// Used below and also passed to the theme - jgm
$preformat = genArticlePreformat($info, $links);
if ($postnuke_theme) {
themeindex($info['aid'], $info['informant'], $info['longdatetime'], $info['catandtitle'], $info['counter'], $info['topic'], $preformat['hometext'], $info['notes'], $preformat['more'], $info['topicname'], $info['topicimage'], $info['topictext'], $info, $links, $preformat);
} else {
themeindex($info['aid'], $info['informant'], $info['longdatetime'], $info['catandtitle'], $info['counter'], $info['topic'], $preformat['hometext'], $info['notes'], $preformat['more'], $info['topicname'], $info['topicimage'], $info['topictext']);
}
}
}
include 'footer.php';
}
theindex();
?>