<?php
/************************************************************************/
/* ViperWeb: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Raptr & Godboko */
/* http://development.ea-hq.net */
/* */
/* 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. */
/* */
/* Based on PHP-Nuke found at http://www.phpnuke.org */
/************************************************************************/
if (!eregi("index.php", $PHP_SELF))
$index = 1;
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
if (stristr($REQUEST_URI,"mainfile")) {
Header("Location: index.php?mod=News&file=article&sid=$sid");
} elseif (!isset($sid) && !isset($tid)) {
Header("Location: index.php");
}
if ($save AND is_user($user)) {
cookiedecode($user);
sql_query("update ".$user_prefix."_users set umode='$mode', uorder='$order', thold='$thold' where uid='$cookie[0]'", $dbi);
getusrinfo($user);
$info = base64_encode("$userinfo[uid]:$userinfo[uname]:$userinfo[pass]:$userinfo[storynum]:$userinfo[umode]:$userinfo[uorder]:$userinfo[thold]:$userinfo[noscore]");
setcookie("user","$info",time()+$cookieusrtime);
}
if ($op == "Reply") {
Header("Location: index.php?mod=News&file=comments&op=Reply&pid=0&sid=$sid&mode=$mode&order=$order&thold=$thold");
}
$result = sql_query("select catid, aid, time, title, hometext, bodytext, topic, informant, notes, acomm, haspoll, pollID, score, ratings FROM ".$prefix."_stories where sid=$sid", $dbi);
list($catid, $aid, $time, $title, $hometext, $bodytext, $topic, $informant, $notes, $acomm, $haspoll, $pollID, $score, $ratings) = sql_fetch_row($result, $dbi);
if ($aid == "") {
Header("Location: index.php?mod=News");
}
sql_query("UPDATE ".$prefix."_stories SET counter=counter+1 where sid=$sid", $dbi);
$artpage = 1;
$pagetitle = "- $title";
require("includes/header.php");
$artpage = 0;
formatTimestamp($time);
$title = stripslashes($title);
$hometext = stripslashes($hometext);
$bodytext = stripslashes($bodytext);
$notes = stripslashes($notes);
if ($notes != "") {
$notes = "<br><br><b>"._NOTE."</b> <i>$notes</i>";
} else {
$notes = "";
}
if($bodytext == "") {
$bodytext = "$hometext$notes";
} else {
$bodytext = "$hometext<br><br>$bodytext$notes";
}
if($informant == "") {
$informant = $anonymous;
}
getTopics($sid);
if ($catid != 0) {
$resultx = sql_query("select title from ".$prefix."_stories_cat where catid='$catid'", $dbi);
list($title1) = sql_fetch_row($resultx, $dbi);
$title = "<a href=\"index.php?mod=News&file=categories&op=newindex&catid=$catid\"><font class=\"storycat\">$title1</font></a>: $title";
}
echo "<table width=\"100%\" border=\"0\"><tr><td valign=\"top\" width=\"100%\">\n";
themearticle($aid, $informant, $datetime, $title, $bodytext, $topic, $topicname, $topicimage, $topictext);
echo "</td><td> </td><td valign=\"top\">\n";
if ($multilingual == 1) {
$querylang = "AND (blanguage='$currentlang' OR blanguage='')";
} else {
$querylang = "";
}
/* Determine if the article has attached a poll */
if ($haspoll == 1) {
$url = sprintf("index.php?mod=Surveys&op=results&pollID=%d", $pollID);
$boxContent = "<form action=\"index.php?mod=Surveys\" method=\"post\">";
$boxContent .= "<input type=\"hidden\" name=\"pollID\" value=\"".$pollID."\">";
$boxContent .= "<input type=\"hidden\" name=\"forwarder\" value=\"".$url."\">";
$result = sql_query("SELECT pollTitle, voters FROM ".$prefix."_poll_desc WHERE pollID=$pollID", $dbi);
list($pollTitle, $voters) = sql_fetch_row($result, $dbi);
$boxTitle = _ARTICLEPOLL;
$boxContent .= "<font class=\"content\"><b>$pollTitle</b></font><br><br>\n";
$boxContent .= "<table border=\"0\" width=\"100%\">";
for($i = 1; $i <= 12; $i++) {
$result = sql_query("SELECT pollID, optionText, optionCount, voteID FROM ".$prefix."_poll_data WHERE (pollID=$pollID) AND (voteID=$i)", $dbi);
$object = sql_fetch_object($result, $dbi);
if(is_object($object)) {
$optionText = $object->optionText;
if($optionText != "") {
$boxContent .= "<tr><td valign=\"top\"><input type=\"radio\" name=\"voteID\" value=\"".$i."\"></td><td width=\"100%\"><font class=\"content\">$optionText</font></td></tr>\n";
}
}
}
$boxContent .= "</table><br><center><font class=\"content\"><input type=\"submit\" value=\""._VOTE."\"></font><br>";
if (is_user($user)) {
cookiedecode($user);
}
for($i = 0; $i < 12; $i++) {
$result = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE (pollID=$pollID) AND (voteID=$i)", $dbi);
$object = sql_fetch_object($result, $dbi);
$optionCount = $object->optionCount;
$sum = (int)$sum+$optionCount;
}
$boxContent .= "<font class=\"content\">[ <a href=\"index.php?mod=Surveys&op=results&pollID=$pollID&mode=$cookie[4]&order=$cookie[5]&thold=$cookie[6]\"><b>"._RESULTS."</b></a> | <a href=\"index.php?mod=Surveys\"><b>"._POLLS."</b></a> ]<br>";
if ($pollcomm) {
list($numcom) = sql_fetch_row(sql_query("select count(*) from ".$prefix."_pollcomments where pollID=$pollID", $dbi), $dbi);
$boxContent .= "<br>"._VOTES.": <b>$sum</b> | "._PCOMMENTS." <b>$numcom</b>\n\n";
} else {
$boxContent .= "<br>"._VOTES." <b>$sum</b>\n\n";
}
$boxContent .= "</font></center></form>\n\n";
themesidebox($boxTitle, $boxContent);
}
$result = sql_query("select title, content, active, position from ".$prefix."_blocks where blockfile='block-Login.php' $querylang", $dbi);
list($title, $content, $active, $position) = sql_fetch_row($result, $dbi);
if (($active == 1) AND ($position == "r") AND (!is_user($user))) {
loginbox();
}
$boxtitle = ""._RELATED."";
$boxstuff = "<font class=\"content\">";
$result = sql_query("select name, url from ".$prefix."_related where tid=$topic", $dbi);
while(list($name, $url) = sql_fetch_row($result, $dbi)) {
$boxstuff .= "<strong><big>·</big></strong> <a href=\"$url\" target=\"new\">$name</a><br>\n";
}
$boxstuff .= "<strong><big>·</big></strong> <a href=\"index.php?mod=Search&topic=$topic\">"._MOREABOUT." $topictext</a><br>\n";
$boxstuff .= "<strong><big>·</big></strong> <a href=\"index.php?mod=Search&author=$aid\">"._NEWSBY." $aid</a><br>\n";
$boxstuff .= "</font><br><hr noshade width=\"95%\" size=\"1\"><center><font class=\"content\"><b>"._MOSTREAD." $topictext:</b><br>\n";
global $multilingual, $currentlang;
if ($multilingual == 1) {
$querylang = "AND (alanguage='$currentlang' OR alanguage='')"; /* the OR is needed to display stories who are posted to ALL languages */
} else {
$querylang = "";
}
$result2 = sql_query("select sid, title from ".$prefix."_stories where topic=$topic $querylang order by counter desc limit 0,1", $dbi);
list($topstory, $ttitle) = sql_fetch_row($result2, $dbi);
$boxstuff .= "<a href=\"index.php?mod=News&file=article&sid=$topstory\">$ttitle</a></font></center><br>\n";
themesidebox($boxtitle, $boxstuff);
if ($ratings != 0) {
$rate = substr($score / $ratings, 0, 4);
$r_image = round($rate);
$the_image = "<br><br><img src=\"images/articles/stars-$r_image.gif\" border=\"1\"></center><br>";
} else {
$rate = 0;
$the_image = "</center><br>";
}
$ratetitle = ""._RATEARTICLE."";
$ratecontent = "<center>"._AVERAGESCORE.": <b>$rate</b><br>"._VOTES.": <b>$ratings</b>$the_image";
$ratecontent .= "<form action=\"index.php?mod=News\" method=\"post\"><center>"._RATETHISARTICLE."</center><br>";
$ratecontent .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\">";
$ratecontent .= "<input type=\"hidden\" name=\"op\" value=\"rate_article\">";
$ratecontent .= "<input type=\"radio\" name=\"score\" value=\"1\"> <img src=\"images/articles/stars-1.gif\" border=\"0\" alt=\""._BAD."\"><br>";
$ratecontent .= "<input type=\"radio\" name=\"score\" value=\"2\"> <img src=\"images/articles/stars-2.gif\" border=\"0\" alt=\""._REGULAR."\"><br>";
$ratecontent .= "<input type=\"radio\" name=\"score\" value=\"3\"> <img src=\"images/articles/stars-3.gif\" border=\"0\" alt=\""._GOOD."\"><br>";
$ratecontent .= "<input type=\"radio\" name=\"score\" value=\"4\"> <img src=\"images/articles/stars-4.gif\" border=\"0\" alt=\""._VERYGOOD."\"><br>";
$ratecontent .= "<input type=\"radio\" name=\"score\" value=\"5\"> <img src=\"images/articles/stars-5.gif\" border=\"0\" alt=\""._EXCELLENT."\"><br><br>";
$ratecontent .= "<center><input type=\"submit\" value=\""._CASTMYVOTE."\"></center></form><br>";
themesidebox($ratetitle, $ratecontent);
$optiontitle = ""._OPTIONS."";
$optionbox .= "<br><img src=\"images/print.gif\" border=\"0\" Alt=\""._PRINTER."\" width=\"16\" height=\"11\"> <a href=\"index.php?mod=News&file=print&sid=$sid\">"._PRINTER."</a><br><br>";
$optionbox .= "<img src=\"images/friend.gif\" border=\"0\" Alt=\""._FRIEND."\" width=\"16\" height=\"11\"> <a href=\"index.php?mod=News&file=friend&op=FriendSend&sid=$sid\">"._FRIEND."</a>\n";
if (is_admin($user)) {
$optionbox .= "<center><br><b>"._ADMIN."</b><br>[ <a href=\"index.php?mod=Admin&op=adminStory\">"._ADD."</a> | <a href=\"index.php?mod=Admin&op=EditStory&sid=$sid\">"._EDIT."</a> | <a href=\"index.php?mod=Admin&op=RemoveStory&sid=$sid\">"._DELETE."</a> ]</center>";
}
themesidebox($optiontitle, $optionbox);
echo "</td></tr></table>\n";
cookiedecode($user);
if ((($mode != "nocomments") OR ($acomm == 0)) AND ($articlecomm == 1)) {
include("modules/News/comments.php");
}
include ("includes/footer.php");
?>