<?php // $Id: index.php,v 1.19 2001/12/04 00:50:29 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
// ----------------------------------------------------------------------
// Filename: modules/Sections/index.php
// Original Author: Francisco Burzi
// Purpose: displays the special sections on the site
// ----------------------------------------------------------------------
if (!defined("LOADED_AS_MODULE")) {
die ("You can't access this file directly...");
}
include 'mainfile.php';
$ModName = basename( dirname( __FILE__ ) );
modules_get_language();
function listsections()
{
global $sitename, $pntable, $ModName, $dbconn;
include ('header.php');
if (!authorised(0, 'Sections::Section', '::', ACCESS_OVERVIEW)) {
echo _SECTIONSNOAUTH;
include 'footer.php';
}
$column = &$pntable['sections_column'];
$result = $dbconn->Execute("SELECT $column[secid], $column[secname], $column[image]
FROM $pntable[sections] ORDER BY $column[secname]");
//FTO . Test database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
OpenTable();
echo "<center><font class=\"pn-title\">"._SECWELCOME." $sitename.</font><br><br>"
."<font class=\"pn-normal\">"._YOUCANFIND."</font></center><br><br>"
."<table border=\"0\" align=\"center\"><tr>";
$count = 0;
//FTO USe EOF for the loop
//FTO while(list($secid, $secname, $image) = $result->fields) {
while(!$result->EOF) {
list($secid, $secname, $image) = $result->fields;
$result->MoveNext();
if (authorised(0, 'Sections::Section', "$secname::$secid", ACCESS_READ)) {
if ($count == 2) {
echo "</tr><tr>";
$count = 0;
}
echo "<td><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=listarticles&secid=$secid\"><img src=\"images/sections/$image\" border=\"0\" Alt=\"$secname\"></a></td>";
$count++;
}
}
$result->Close();
echo "</tr></table>";
CloseTable();
include ('footer.php');
}
function listarticles($secid) {
global $pntable, $multilingual, $currentlang, $ModName, $dbconn; /* ML globals and querylang added */
if ($multilingual == 1) {
$column = &$pntable['seccont_column'];
$querylang = "AND ($column[slanguage]='$currentlang' OR $column[slanguage]='')"; /* the OR is needed to display stories who are posted to ALL languages */
} else {
$querylang = "";
}
include ('header.php');
OpenTable();
$column = &$pntable['sections_column'];
$result = $dbconn->Execute("SELECT $column[secname]
FROM $pntable[sections]
WHERE $column[secid]=$secid");
//FTO . Test database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
list($secname) = $result->fields;
$result->Close();
if (!authorised(0, 'Sections::Section', "$secname::$secid", ACCESS_READ)) {
echo _SECTIONSARTICLENOAUTH;
CloseTable();
include 'footer.php';
return;
}
$column = &$pntable['seccont_column'];
$result = $dbconn->Execute("SELECT $column[artid], $column[secid], $column[title],
$column[content], $column[counter]
FROM $pntable[seccont]
WHERE $column[secid]=$secid $querylang");
//FTO . Test database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
$column = &$pntable['sections_column'];
$result2 = $dbconn->Execute("SELECT $column[image]
FROM $pntable[sections]
WHERE $column[secid]=$secid");
//FTO . Test database error
if (!$result2) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
list($image) = $result2->fields;
echo "<center><img src=\"images/sections/$image\" border=\"0\" alt=\"\"><br><br>"
."<font class=\"pn-title\">"
._THISISSEC." $secname.<br>"._FOLLOWINGART."</font></center><br><br>"
."<table border=\"0\" align=\"center\">";
//FTO . Use EOF for the loop
// while(list($artid, $secid, $title, $content, $counter) = $result->fields) {
while(!$result->EOF) {
list($artid, $secid, $title, $content, $counter) = $result->fields;
$result->MoveNext();
if (authorised(0, 'Sections::Article', "$title:$secname:$artid", ACCESS_READ)) {
echo "<tr><td align=\"left\" nowrap>"
."<strong><big>·</big></strong> "
."<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=viewarticle&artid=$artid\">$title</a> ($counter "._READS.")"
." <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=printpage&artid=$artid\"><img src=\"modules/$ModName/images/print.gif\" border=\"0\" Alt=\""._PRINTER."\" width=\"15\" height=\"11\"></a>"
."</td></tr>";
}
}
echo "</table>"
."<br><br><br><center>"
."<font class=\"pn-normal\">[ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index\">"._SECRETURN."</a> ]</font></center>";
CloseTable();
$result->Close();
include ('footer.php');
}
function viewarticle($artid, $page)
{
global $pntable, $ModName, $dbconn;
include("header.php");
if (!isset($page)) {
$page = 1;
}
if (($page == 1) OR ($page == "")) {
$column = &$pntable['seccont_column'];
$result = $dbconn->Execute("UPDATE $pntable[seccont]
SET $column[counter]=$column[counter]+1
WHERE $column[artid]='$artid'");
}
$column = &$pntable['seccont_column'];
$result = $dbconn->Execute("SELECT $column[artid], $column[secid], $column[title],
$column[content], $column[counter]
FROM $pntable[seccont]
WHERE $column[artid]=$artid");
//FTO . Test database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
list($artid, $secid, $title, $content, $counter) = $result->fields;
$column = &$pntable['sections_column'];
$result2 = $dbconn->Execute("SELECT $column[secid], $column[secname]
FROM $pntable[sections] WHERE $column[secid]=$secid");
//FTO . Test database error
if (!$result2) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
list($secid, $secname) = $result2->fields;
$words = sizeof(explode(" ", $content));
echo "<center>";
OpenTable();
if (!authorised(0, 'Sections::Article', "$title:$secname:$artid", ACCESS_READ)) {
echo _SECTIONSARTICLENOAUTH;
CloseTable();
include 'footer.php';
}
$contentpages = explode( "<!--pagebreak-->", $content );
$pageno = count($contentpages);
if ( $page=="" || $page < 1 )
$page = 1;
if ( $page > $pageno )
$page = $pageno;
$arrayelement = (int)$page;
$arrayelement --;
echo "<font class=\"pn-title\">$title</font><br><br>";
if ($pageno > 1) {
echo "<font class=\"pn-normal\">"._PAGE.": $page/$pageno</font><br>";
}
echo "<font class=\"pn-normal\">($words "._TOTALWORDS.")</font><br>"
."<font class=\"pn-normal\">($counter "._READS.")</font> "
."<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=printpage&artid=$artid\"><img src=\"modules/$ModName/images/print.gif\" border=\"0\" Alt=\""._PRINTER."\" width=\"15\" height=\"11\"></a>"
."</font><br><br><br><br>";
echo "<font class=\"pn-normal\">$contentpages[$arrayelement]</font>";
if($page >= $pageno) {
$next_page = "";
} else {
$next_pagenumber = $page + 1;
if ($page != 1) {
$next_page .= "<img src=\"modules/$ModName/images/blackpixel.gif\" width=\"10\" height=\"2\" border=\"0\" alt=\"\"> ";
}
$next_page .= "<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=viewarticle&artid=$artid&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?op=modload&name=$ModName&file=index&req=viewarticle&artid=$artid&page=$next_pagenumber\"><img src=\"modules/$ModName/images/right.gif\" border=\"0\" alt=\""._NEXT."\"></a>";
}
if($page <= 1) {
$previous_page = "";
} else {
$previous_pagenumber = $page - 1;
$previous_page = "<a href=\"modules.php?op=modload&name=$ModName&file=index&req=viewarticle&artid=$artid&page=$previous_pagenumber\"><img src=\"modules/$ModName/images/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a href=\"modules.php?op=modload&name=$ModName&file=index&req=viewarticle&artid=$artid&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
}
echo "</td></tr>"
."<tr><td align=\"center\">"
."$previous_page $next_page<br><br>"
."[ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=listarticles&secid=$secid\">"._BACKTO." $secname</a> | "
."<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&listsections\">"._SECINDEX."</a> ]";
CloseTable();
echo "</center>";
$result->Close();
$result2->Close();
include ('footer.php');
}
function PrintSecPage($artid)
{
global $site_logo, $nukeurl, $sitename, $datetime, $pntable, $ModName, $dbconn;
$column = &$pntable['seccont_column'];
$result=$dbconn->Execute("SELECT $column[title], $column[content] , $column[secid]
FROM $pntable[seccont]
WHERE $column[artid]=$artid");
//FTO . Test database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
list($title, $content, $secid) = $result->fields;
$column = &$pntable['sections_column'];
$result2 = $dbconn->Execute("SELECT $column[secname]
FROM $pntable[sections]
WHERE $column[secid]=$secid");
//FTO . Test database error
if (!$result2) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
list($secname) = $result2->fields;
if (!authorised(0, 'Sections::Article', "$title:$secname:$artid", ACCESS_READ)) {
echo _SECTIONSARTICLENOAUTH;
CloseTable();
include 'footer.php';
return;
}
echo "<html><head><title>$sitename</title></head>"
."<body bgcolor=\"#FFFFFF\" text=\"#000000\">"
."<table border=\"0\"><tr><td>"
."<table border=\"0\" width=\"640\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#000000\"><tr><td>"
."<table border=\"0\" width=\"640\" cellpadding=\"20\" cellspacing=\"1\" bgcolor=\"#FFFFFF\"><tr><td>"
."<center>"
."<img src=\"images/$site_logo\" border=\"0\" alt=\"\"><br><br>"
."<font class=\"pn-title\">"
."$title</font><br>"
."</center><font class=\"pn-normal\">"
."$content<br><br>";
echo "</td></tr></table></td></tr></table>"
."<br><br><center>"
."<font class=\"pn-normal\">"
._COMESFROM." $sitename<br>"
."<a class=\"pn-normal\" href=\"$nukeurl\">$nukeurl</a></font><br><br>"
."</center>"
."</td></tr></table>"
."</body></html>";
}
switch($req) {
case "viewarticle":
viewarticle($artid, $page);
break;
case "listarticles":
listarticles($secid);
break;
case "printpage":
PrintSecPage($artid);
break;
default:
listsections();
break;
}
?>