<?php // $Id: index.php,v 1.43 2001/12/06 23:19:29 nkame Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on: Reviews Addon
// Copyright (c) 2000 by Jeff Lambert (hide@address.com)
// http://www.qchc.com
// More scripts on http://www.jeffx.qchc.com
// 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/Reviews/index.php
// Original Author of file: Jeff Lambert
// Purpose of file: Reviews system
// ----------------------------------------------------------------------
if (!defined("LOADED_AS_MODULE")) {
die ("You can't access this file directly...");
}
include 'mainfile.php';
/*Credits to Edgar Miller -- http://www.bosna.de/ from his post on PHP-Nuke
( http://phpnuke.org/article.php?sid=2010&mode=nested&order=0&thold=0 )
*/
$ModName = basename( dirname( __FILE__ ) );
modules_get_language();
function alpha() {
global $ModName;
$alphabet = array ("A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0");
$num = count($alphabet) - 1;
echo "<center><font class=\"pn-normal\">[ ";
$counter = 0;
while (list(, $ltr) = each($alphabet)) {
echo "<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$ltr\">$ltr</a>";
if ( $counter == round($num/2) ) {
echo " ]\n<br>\n[ ";
} elseif ( $counter != $num ) {
echo " | \n";
}
$counter++;
}
echo " ]<br><br></font></center>\n\n\n";
if (authorised(0, 'Reviews::', '::', ACCESS_COMMENT)){
echo "<center><font class=\"pn-normal\">[ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=write_review\">"._WRITEREVIEW."</a> ]</font></center><br><br>\n\n";
}
}
function display_score($score) {
global $ModName;
$image = "<img src=\"modules/$ModName/images/blue.gif\" alt=\"\">";
$halfimage = "<img src=\"modules/$ModName/images/bluehalf.gif\" alt=\"\">";
$full = "<img src=\"modules/$ModName/images/star.gif\" alt=\"\">";
if ($score == 10) {
for ($i=0; $i < 5; $i++)
echo "$full";
} else if ($score % 2) {
$score -= 1;
$score /= 2;
for ($i=0; $i < $score; $i++)
echo "$image";
echo "$halfimage";
} else {
$score /= 2;
for ($i=0; $i < $score; $i++)
echo "$image";
}
}
function write_review() { /* ML added rlanguage , dropdown with available languages , currentlang is pre-selected */
global $sitename, $user, $pntable, $dbconn, $currentlang, $ModName;
include ('header.php');
if (!(authorised(0, 'Reviews::', '::', ACCESS_COMMENT))) {
echo _REVIEWSADDNOAUTH;
include 'footer.php';
return;
}
$userinfo = getusrinfo($user);
OpenTable();
echo "
<font class=\"pn-normal\"><b>"._WRITEREVIEWFOR." $sitename</b><br><br>
<i>"._ENTERINFO."</i><br><br>
<form method=\"post\" action=\"modules.php\">
<input type=\"hidden\" name=\"op\" value=\"modload\">
<input type=\"hidden\" name=\"name\" value=\"$ModName\">
<input type=\"hidden\" name=\"file\" value=\"index\">
<b>"._PRODUCTTITLE.":</b><br>
<input type=\"text\" name=\"title\" size=\"50\" maxlength=\"150\"><br>
<i>"._NAMEPRODUCT."</i><br>";
echo "<br><b>"._LANGUAGE.": </b>"
."<select name=\"rlanguage\">";
// ML BEGIN
$lang = languagelist();
$sel_lang[$currentlang] = ' selected';
print '<option value="">'._ALL.'</option>';
$handle = opendir('language');
while ($f = readdir($handle))
{
if (is_dir("language/$f") && $lang[$f])
{
$langlist[$f] = $lang[$f];
}
}
asort($langlist);
foreach ($langlist as $k=>$v)
{
print "<option value=\"$k\"$sel_lang[$k]>$v</option>\n";
}
echo "</select>";
echo "<br><br><b>"._REVIEW.":</b><br>"
."<textarea name=\"text\" rows=\"15\" wrap=\"virtual\" cols=\"60\"></textarea><br>";
if (authorised(0, 'Reviews::', '::', ACCESS_ADD)) {
echo ""._PAGEBREAK."<br>";
}
echo "
<i>"._CHECKREVIEW."</i><br><br>
<b>"._YOURNAME.":</b><br>";
echo "<input type=\"text\" name=\"reviewer\" size=\"41\" maxlength=\"40\" value=\"$userinfo[name]\"><br>
<i>"._FULLNAMEREQ."</i><br><br>
<b>"._REMAIL.":</b><br>
<input type=\"text\" name=\"email\" size=\"40\" maxlength=\"80\" value=\"$userinfo[email]\"><br>
<i>"._REMAILREQ."</i><br><br>
<b>"._SCORE."</b><br>
<select name=\"score\">
<option name=\"score\" value=\"10\">10</option>
<option name=\"score\" value=\"9\">9</option>
<option name=\"score\" value=\"8\">8</option>
<option name=\"score\" value=\"7\">7</option>
<option name=\"score\" value=\"6\">6</option>
<option name=\"score\" value=\"5\">5</option>
<option name=\"score\" value=\"4\">4</option>
<option name=\"score\" value=\"3\">3</option>
<option name=\"score\" value=\"2\">2</option>
<option name=\"score\" value=\"1\">1</option>
</select>
<i>"._SELECTSCORE."</i><br><br>
<b>"._RELATEDLINK.":</b><br>
<input type=\"text\" name=\"url\" size=\"40\" maxlength=\"100\" value=\"http://\"><br>
<i>"._PRODUCTSITE."</i><br><br>
<b>"._LINKTITLE.":</b><br>
<input type=\"text\" name=\"url_title\" size=\"40\" maxlength=\"50\"><br>
<i>"._LINKTITLEREQ."</i><br><br>";
if (authorised(0, 'Reviews::', '::', ACCESS_ADD)) {
echo "
<b>"._RIMAGEFILE.":</b><br>
<input type=\"text\" name=\"cover\" size=\"40\" maxlength=\"100\"><br>
<i>"._RIMAGEFILEREQ."</i><br><br>";
}
echo "<i>"._CHECKINFO."</i><br><br>";
echo "<input type=\"hidden\" name=\"req\" value=\"preview_review\">
<input type=\"submit\" value=\""._PREVIEW."\"> <input type=\"button\" onClick=\"history.go(-1)\" value=\""._CANCEL."\"></font></form>";
CloseTable();
include ("footer.php");
}
function preview_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage) {
global $ModName;
if (strpos($text, "<!--pagebreak-->") !== false) {
$text = str_replace("<!--pagebreak-->","<!--pagebreak-->",$text);
}
$title = stripslashes(check_html($title, "nohtml"));
$text = stripslashes(check_html($text, ""));
$reviewer = stripslashes(check_html($reviewer, "nohtml"));
$url_title = stripslashes(check_html($url_title, "nohtml"));
include ('header.php');
if (!(authorised(0, 'Reviews::', '::', ACCESS_COMMENT))) {
echo _REVIEWSADDNOAUTH;
include 'footer.php';
return;
}
OpenTable();
echo "<form method=\"post\" action=\"modules.php\">
<input type=\"hidden\" name=\"op\" value=\"modload\">
<input type=\"hidden\" name=\"name\" value=\"$ModName\">
<input type=\"hidden\" name=\"file\" value=\"index\">
<font class=\"pn-normal\">";
if ($title == "") {
$error = 1;
echo ""._INVALIDTITLE."<br>";
}
if ($text == "") {
$error = 1;
echo ""._INVALIDTEXT."<br>";
}
if (($score < 1) || ($score > 10)) {
$error = 1;
echo ""._INVALIDSCORE."<br>";
}
if (($hits < 0) && ($id != 0)) {
$error = 1;
echo ""._INVALIDHITS."<br>";
}
if ($reviewer == "" || $email == "") {
$error = 1;
echo ""._CHECKNAME."<br>";
} else if ($reviewer != "" && $email != "") {
$email = pn_validation_mail($email);
if ($email == -1) {
$error = 1;
/* eregi checks for a valid email! works nicely for me! */
/* nkame: centralization of mail validation */
echo ""._INVALIDEMAIL."<br>";
}
$url = pn_validation_url($url, 0);
if (($url_title != "" && $url == -1) || ($url_title == "" && !empty($url))) {
$error = 1;
echo ""._INVALIDLINK."<br>";
}/* else if (($url != "") && (!(eregi('(^http[s]*:[/]+)(.*)', $url))))
$url = "http://" . $url;*/
/* If the user ommited the http, this nifty eregi will add it */
// nkame: centralization of url checking. 'http://' is added as well
if ($error == 1)
echo "<br>"._GOBACK."";
else
{
if ($date == "")
$date = date("Y-m-d H:i:s", time());
$year2 = substr($date,0,4);
$month = substr($date,5,2);
$day = substr($date,8,2);
$fdate = date("F jS Y",mktime (0,0,0,$month,$day,$year2));
echo "<table border=\"0\" width=\"100%\"><tr><td colspan=\"2\">";
echo "<p><font class=\"pn-title\"><i><b>$title</b></i></font><br>";
echo "<blockquote><p><font class=\"pn-normal\">";
if ($cover != "")
echo "<img src=\"modules/$ModName/images/$cover\" align=\"right\" border=\"1\" vspace=\"2\" alt=\"\">";
echo "$text<p>";
echo "<b>"._ADDED."</b> $fdate<br>";
echo "<b>"._LANGUAGE."</b> $rlanguage<br>"; /* ML Added rlanguage for display */
echo "<b>"._REVIEWER."</b> <a class=\"pn-normal\" href=\"mailto:$email\">$reviewer</a><br>";
echo "<b>"._SCORE."</b> ";
display_score($score);
if ($url != "")
echo "<br><b>"._RELATEDLINK.":</b> <a class=\"pn-normal\" href=\"$url\" target=\"new\">$url_title</a>";
if ($id != 0) {
echo "<br><b>"._REVIEWID.":</b> $id<br>";
echo "<b>"._HITS.":</b> $hits<br>";
}
echo "</font></blockquote>";
echo "</td></tr></table>";
$text = urlencode($text);
echo "<p><i>"._LOOKSRIGHT."</i> ";
echo "<input type=\"hidden\" name=\"id\" value=$id>
<input type=\"hidden\" name=\"hits\" value=\"$hits\">
<input type=\"hidden\" name=\"req\" value=send_review>
<input type=\"hidden\" name=\"date\" value=\"$date\">
<input type=\"hidden\" name=\"title\" value=\"$title\">
<input type=\"hidden\" name=\"text\" value=\"$text\">
<input type=\"hidden\" name=\"reviewer\" value=\"$reviewer\">
<input type=\"hidden\" name=\"email\" value=\"$email\">
<input type=\"hidden\" name=\"score\" value=\"$score\">
<input type=\"hidden\" name=\"url\" value=\"$url\">
<input type=\"hidden\" name=\"url_title\" value=\"$url_title\">
<input type=\"hidden\" name=\"cover\" value=\"$cover\">
<input type=\"hidden\" name=\"rlanguage\" value=\"$rlanguage\">
<input type=\"submit\" name=\"req\" value=\""._YES."\"> <input type=\"button\" onClick=\"history.go(-1)\" value=\""._NO."\">";
if($id != 0) {
$word = ""._RMODIFIED."";
} else {
$word = ""._RADDED."";
}
if (authorised(0, 'Reviews::', '::', ACCESS_ADD)) {
echo "<br><br><b>"._NOTE."</b> "._ADMINLOGGED." $word.";
}
}
}
CloseTable();
include ("footer.php");
}
function send_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage) {
global $admin, $EditedMessage, $pntable, $dbconn, $ModName;
csrfcheck();
include ('header.php');
if (!(authorised(0, 'Reviews::', '::', ACCESS_COMMENT))) {
echo _REVIEWSSUBMITNOAUTH;
include 'footer.php';
return;
}
if (strpos($text, "<!--pagebreak-->") !== false) {
$text = str_replace("<!--pagebreak-->","<!--pagebreak-->",$text);
}
$title = stripslashes(FixQuotes(check_html($title, "nohtml")));
$text = stripslashes(Fixquotes(urldecode(check_html($text, ""))));
if (strpos($text, "<!--pagebreak-->") !== false) {
$text = str_replace("<!--pagebreak-->","<!--pagebreak-->",$text);
}
OpenTable();
echo "<br><center><font class=\"pn-normal\">"._RTHANKS."</font>";
if ($id != 0)
echo "<font class=\"pn-normal\">"._MODIFICATION."</font>";
else
echo "<font class=\"pn-normal\">, $reviewer";
echo "!</font><br>";
if ($id == 0) {
// New review
if (!(authorised(0, 'Reviews::', "$title::", ACCESS_COMMENT))) {
echo _REVIEWSSUBMITNOAUTH;
CloseTable();
include 'footer.php';
return;
}
if (authorised(0, 'Reviews::', "$title::", ACCESS_ADD)) {
// Add immediately
$column = &$pntable['reviews_column'];
// FTO : Add SEQ suffix to avoid conflict name with ORACLE
$newid = $dbconn->GenId("{$pntable['reviews']}_SEQ");
$result = $dbconn->Execute("INSERT INTO $pntable[reviews] ($column[id], $column[date], $column[title], $column[text], $column[reviewer], $column[email], $column[score], $column[cover], $column[url], $column[url_title], $column[hits], $column[rlanguage]) VALUES ($newid, '$date', '$title', '$text', '$reviewer', '$email', '$score', '$cover', '$url', '$url_title', '1', '$rlanguage')");
if($dbconn->ErrorNo()<>0) {
error_log("ERROR 1 : " . $dbconn->ErrorMsg());
}
echo "<font class=\"pn-normal\">"._ISAVAILABLE."</font>";
} else {
// Add to waiting list
$column = &$pntable['reviews_add_column'];
// FTO : Add SEQ suffix to avoid conflict name with ORACLE
$nextid = $dbconn->GenId("{$pntable['reviews_add']}_SEQ");
$result = $dbconn->Execute("INSERT INTO $pntable[reviews_add] ($column[id], $column[date], $column[title], $column[text], $column[reviewer], $column[email], $column[score], $column[url], $column[url_title], $column[rlanguage]) VALUES ($nextid, '$date', '$title', '$text', '$reviewer', '$email', '$score', '$url', '$url_title', '$rlanguage')");
if($dbconn->ErrorNo()<>0) {
error_log("ERROR 1 : " . $dbconn->ErrorMsg());
}
echo "<font class=\"pn-normal\">"._EDITORWILLLOOK."</font>";
}
} else {
// Updated review
if (!(authorised(0, 'Reviews::', "$title::$id", ACCESS_EDIT))) {
echo _REVIEWSEDITNOAUTH;
CloseTable();
include 'footer.php';
return;
}
$column = &$pntable['reviews_column'];
$result = $dbconn->Execute("UPDATE $pntable[reviews] SET $column[date]='$date', $column[title]='$title', $column[text]='$text', $column[reviewer]='$reviewer', $column[email]='$email', $column[score]='$score', $column[cover]='$cover', $column[url]='$url', $column[url_title]='$url_title', $column[hits]='$hits', $column[rlanguage]='$rlanguage' where $column[id] = $id");
if($dbconn->ErrorNo()<>0) {
error_log("ERROR 2 : " . $dbconn->ErrorMsg());
}
echo "<font class=\"pn-normal\">"._ISAVAILABLE."</font>";
}
echo "<br><br><font class=\"pn-normal\">[ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index\">"._RBACK."</a> ]</font><br></center>";
CloseTable();
include ("footer.php");
}
function reviews_index() {
global $bgcolor4, $bgcolor2, $pntable, $dbconn, $multilingual, $currentlang, $ModName;
include ('header.php');
$column = &$pntable['reviews_column'];
if ($multilingual == 1) {
$querylang = "($column[rlanguage]='$currentlang' OR $column[rlanguage]='')";
} else {
$querylang = "";
}
OpenTable();
echo "<table border=\"0\" width=\"95%\" CELLPADDING=\"2\" CELLSPACING=\"4\" align=\"center\">
<tr><td colspan=\"2\"><center><font class=\"pn-title\">"._RWELCOME."</font></center><br><br><br>";
$column = &$pntable['reviews_main_column'];
$result = $dbconn->Execute("SELECT $column[title], $column[description] FROM $pntable[reviews_main]");
list($title, $description) = $result->fields;
echo "<center><font class=\"pn-normal\"><b>$title</b><br><br>$description</font></center>";
echo "<br><br><br>";
alpha();
echo "</td></tr>";
echo "<tr><td width=\"50%\" bgcolor=\"$bgcolor2\"><b>"._10MOSTPOP."</b></td>";
echo "<td width=\"50%\" bgcolor=\"$bgcolor2\"><b>"._10MOSTREC."</b></td></tr>";
$column = &$pntable['reviews_column'];
$popquery = buildSimpleQuery('reviews', array ('id', 'title', 'hits'), $querylang, "$column[hits] DESC", 10);
$result_pop = $dbconn->Execute($popquery);
$x = 0;
//FTO : Test EOF and database error
if (!$result_pop) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while (!$result_pop->EOF) {
list($id, $title, $hits) = $result_pop->fields;
$result_pop->MoveNext();
$ida[$x] = $id;
$titlea[$x] = $title;
$hitsa[$x] = $hits;
$x++;
}
$recquery = buildSimpleQuery('reviews', array ('id', 'title', 'date', 'hits'), $querylang, "$column[date] DESC", 10);
$result_rec = $dbconn->Execute($recquery);
$x = 0;
//FTO : Test EOF and database error
if (!$result_rec) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while (!$result_rec->EOF) {
list($id, $title, $hits) = $result_rec->fields;
$result_rec->MoveNext();
$idb[$x] = $id;
$titleb[$x] = $title;
$hitsb[$x] = $hits;
$x++;
}
$y = 1;
for ($x = 0; $x < 10; $x++) {
echo "<tr>";
// list($id, $title, $hits)=$result_pop->fields;
$id = $ida[$x];
$title = $titlea[$x];
$hits = $hitsa[$x];
if (authorised(0, 'Reviews::', "$title::$id", ACCESS_READ)) {
echo "<td width=\"50%\" bgcolor=\"$bgcolor4\"><font class=\"pn-normal\">$y) <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=showcontent&id=$id\">$title</a></font></td>";
} else {
echo "<td width=\"50%\" bgcolor=\"$bgcolor4\"><font class=\"pn-normal\">$y)</font></td>";
}
// list($id, $title, , $hits)=$result_rec->fields;
$id = $idb[$x];
$title = $titleb[$x];
$hits = $hitsb[$x];
if (authorised(0, 'Reviews::', "$title::$id", ACCESS_READ)) {
echo "<td width=\"50%\" bgcolor=\"$bgcolor4\"><font class=\"pn-normal\">$y) <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=showcontent&id=$id\">$title</a></font></td>";
} else {
echo "<td width=\"50%\" bgcolor=\"$bgcolor4\"><font class=\"pn-normal\">$y)</font></td>";
}
echo "</tr>";
$y++;
}
echo "<tr><td colspan=\"2\"><br></td></tr>";
$result = $dbconn->Execute("SELECT count(*) FROM $pntable[reviews]");
list($numresults) = $result->fields;
echo "<tr><td colspan=\"2\"><center><font class=\"pn-sub\">"._THEREARE."
$numresults "._REVIEWSINDB."</font></center></td></tr></table>";
/* memory flush */
$result_pop->Close();
$result_rec->Close();
$result->Close();
CloseTable();
include ("footer.php");
}
function reviews($letter, $field, $order) {
global $bgcolor4, $sitename, $pntable, $dbconn, $multilingual, $currentlang, $ModName; /* ML added ml globals */
include ('header.php');
if ($multilingual == 1) {
$column = &$pntable['reviews_column'];
$querylang = "AND ( $column[rlanguage] ='$currentlang' OR $column[rlanguage] = '')";
} else {
$querylang = "";
}
OpenTable();
echo "<center><b>$sitename "._REVIEWS."</b><br>";
echo "<i>"._REVIEWSLETTER." \"$letter\"</i><br><br>";
$column = &$pntable['reviews_column'];
$query = "SELECT $column[id], $column[title], $column[hits], $column[reviewer], $column[score]
FROM $pntable[reviews]
WHERE UPPER($column[title]) LIKE '$letter%'
$querylang ";
switch ($field) {
case "reviewer":
$query .= " ORDER by reviewer $order";
break;
case "score":
$query .= " ORDER by score $order";
break;
case "hits":
$query .= " ORDER by hits $order";
break;
default:
$query .= " ORDER by title $order";
break;
}
$result = $dbconn->Execute($query);
if ($result->EOF) {
echo "<font class=\"pn-normal\"><i><b>"._NOREVIEWS." \"$letter\"</b></i></font><br><br>";
} else {
echo "<TABLE BORDER=\"0\" width=\"100%\" CELLPADDING=\"2\" CELLSPACING=\"4\">
<tr>
<td width=\"50%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"LEFT\"><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=title&order=ASC\"><img src=\"modules/$ModName/images/up.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTASC."\"></a><font class=\"pn-normal\"><B> "._PRODUCTTITLE." </B></font><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=title&order=DESC\"><img src=\"modules/$ModName/images/down.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTDESC."\"></a>
</td>
<td width=\"18%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=reviewer&order=ASC\"><img src=\"modules/$ModName/images/up.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTASC."\"></a><font class=\"pn-normal\"><B> "._REVIEWER." </B></font><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=reviewer&order=desc\"><img src=\"modules/$ModName/images/down.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTDESC."\"></a>
</td>
<td width=\"18%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=score&order=ASC\"><img src=\"modules/$ModName/images/up.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTASC."\"></a><font class=\"pn-normal\"><B> "._SCORE." </B></font><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=score&order=DESC\"><img src=\"modules/$ModName/images/down.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTDESC."\"></a>
</td>
<td width=\"14%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=hits&order=ASC\"><img src=\"modules/$ModName/images/up.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTASC."\"></a><font class=\"pn-normal\"><B> "._HITS." </B></font><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=$letter&field=hits&order=DESC\"><img src=\"modules/$ModName/images/down.gif\" border=\"0\" width=\"15\" height=\"9\" Alt=\""._SORTDESC."\"></a>
</td>
</tr>";
$numshown=0;
while(!$result->EOF) {
$myrow = $result->GetRowAssoc(false);
$result->MoveNext();
$title = $myrow['title'];
$id = $myrow['id'];
$reviewer = $myrow['reviewer'];
$email = $myrow['email'];
$score = $myrow['score'];
$hits = $myrow['hits'];
if (authorised(0, 'Reviews::', "$title::$id", ACCESS_READ)) {
echo "<tr>
<td width=\"50%\" bgcolor=\"$bgcolor4\"><a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=showcontent&id=$id\">$title</a></td>
<td width=\"18%\" bgcolor=\"$bgcolor4\">";
if ($reviewer != "")
echo "<font class=\"pn-normal\"><center>$reviewer</center></font>";
echo "</td><td width=\"18%\" bgcolor=\"$bgcolor4\"><center>";
display_score($score);
echo "</center></td><td width=\"14%\" bgcolor=\"$bgcolor4\"><font class=\"pn-normal\"><center>$hits</center></font></td>
</tr>";
$numshown++;
}
}
echo "</TABLE>";
echo "<br><font class=\"pn-sub\">$numshown "._TOTALREVIEWS."</font><br><br>";
}
echo "[ <a class=\"pn-normal\"href=\"modules.php?op=modload&name=$ModName&file=index\">"._RETURN2MAIN."</a> ]</center>";
/* memory flush */
$result->Close();
CloseTable();
include ("footer.php");
}
function postcomment($id, $title) {
global $user, $cookie, $AllowableHTML, $anonymous, $ModName;
include("header.php");
cookiedecode($user);
$title = urldecode($title);
OpenTable();
echo "<center><font class=\"pn-normal\"><b>"._REVIEWCOMMENT." $title</b><br><br></font></center>
<form action=\"modules.php\" method=\"post\">
<input type=\"hidden\" name=\"op\" value=\"modload\">
<input type=\"hidden\" name=\"name\" value=\"$ModName\">
<input type=\"hidden\" name=\"file\" value=\"index\">
";
if (!(authorised(0, 'Reviews::', "$title::$id", ACCESS_COMMENT))) {
echo _REVIEWSCOMMENTNOAUTH;
include 'footer.php';
return;
}
if (!is_user($user)) {
echo "<font class=\"pn-normal\"><b>"._YOURNICK."</b> $anonymous [ "._RCREATEACCOUNT." ]<br><br>";
$uname = $anonymous;
} else {
echo "<font class=\"pn-normal\"><b>"._YOURNICK."</b> $cookie[1]<br>
<input type=checkbox name=xanonpost> "._POSTANON."<br><br>";
$uname = $cookie[1];
}
echo "
<input type=hidden name=uname value=$uname>
<input type=hidden name=id value=$id>
<b>"._SELECTSCORE."</b>
<select name=score>
<option value=10>10</option>
<option value=9>9</option>
<option value=8>8</option>
<option value=7>7</option>
<option value=6>6</option>
<option value=5>5</option>
<option value=4>4</option>
<option value=3>3</option>
<option value=2>2</option>
<option value=1>1</option>
</select><br><br>
<b>"._YOURCOMMENT."</b><br>
<textarea name=comments rows=10 cols=70></textarea><br>
"._ALLOWEDHTML."<br>";
while (list($key,)= each($AllowableHTML)) echo " <".$key.">";
echo "<br><br>
<input type=\"hidden\" name=\"req\" value=\"savecomment\">
<input type=\"submit\" value=\"Submit\">
</font></form>";
CloseTable();
include("footer.php");
}
function savecomment($xanonpost, $uname, $id, $score, $comments) {
global $anonymous, $user, $cookie, $pntable, $dbconn, $ModName;
csrfcheck();
// jgm - need to get review title for proper authorisation
if (!(authorised(0, 'Reviews::', "::$id", ACCESS_COMMENT))) {
include 'header.php';
echo _REVIEWSCOMMENTNOAUTH;
include 'footer.php';
return;
}
if ($xanonpost) {
$uname = $anonymous;
}
$comments = stripslashes(FixQuotes(check_html($comments)));
$column = &$pntable['reviews_comments_column'];
// FTO : Add SEQ suffix to avoid conflict name with ORACLE
$newid = $dbconn->GenId("{$pntable['reviews_comments_column']}_SEQ");
//FTO Use a php date time to stay compatible with
// all databases.
$now=$dbconn->DBTimeStamp(mktime());
$result = $dbconn->Execute("INSERT INTO $pntable[reviews_comments] ($column[cid], $column[rid], $column[userid], $column[date], $column[comments], $column[score]) VALUES ($newid, '$id', '$uname', $now, '$comments', '$score')");
if($dbconn->ErrorNo()<>0)
{
error_log("ERROR 4 : " . $dbconn->ErrorMsg());
}
pnRedirect('modules.php?op=modload&name='.$ModName.'&file=index');
}
function r_comments($id, $title) {
global $admin, $pntable, $dbconn, $ModName;
$column = &$pntable['reviews_comments_column'];
$result = $dbconn->Execute("SELECT $column[cid], $column[userid], $column[date], $column[comments], $column[score]
FROM $pntable[reviews_comments]
WHERE $column[rid]='$id'
ORDER BY $column[date] DESC");
//FTO : Test EOF and database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$result->EOF) {
list($cid, $uname, $date, $comments, $score) = $result->fields;
$result->MoveNext();
OpenTable();
$title = urldecode($title);
echo "<font class=\"pn-normal\"><b>$title</b><br>";
if ($uname == "Anonymous") {
echo ""._POSTEDBY." $uname "._ON." $date<br>";
} else {
echo ""._POSTEDBY." <a class=\"pn-normal\" href=\"user.php?op=userinfo&uname=$uname\">$uname</a> "._ON." $date<br>";
}
echo ""._MYSCORE." ";
display_score($score);
if (is_admin($admin)) {
echo "<br><b>"._ADMIN."</b> [ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=del_comment&cid=$cid&id=$id\">"._DELETE."</a> ]</font><hr noshade size=1><br><br>";
} else {
echo "</font><hr noshade size=1><br><br>";
}
$comments = FixQuotes(nl2br(filter_text($comments)));
echo "<font class=\"pn-normal\">$comments</font>";
CloseTable();
echo "<br>";
}
}
function showcontent($id, $page) {
global $admin, $next_page, $uimages, $pntable, $dbconn, $ModName;
include ('header.php');
csrfcheck();
// jgm - need to get review title for proper authorisation
if (!(authorised(0, 'Reviews::', "::$id", ACCESS_READ))) {
echo _REVIEWSREADNOAUTH;
include 'footer.php';
return;
}
OpenTable();
if (($page == 1) OR ($page == "")) {
$column = &$pntable['reviews_column'];
$result = $dbconn->Execute("UPDATE $pntable[reviews] SET $column[hits]=$column[hits]+1 WHERE $column[id]=$id");
if($dbconn->ErrorNo()<>0)
{
error_log("ERROR 5 : " . $dbconn->ErrorMsg());
}
}
$column = &$pntable['reviews_column'];
$query = getSelectAllColumnsFrom ('reviews', "$column[id]=$id");
$result = $dbconn->Execute($query);
echo "<center><TABLE BORDER=\"0\" CELLPADDING=\"3\" CELLSPACING=\"3\" width=\"95%\"><tr><td width=\"100%\"><P>";
// fifers - not sure why we break these out. assoc array is fine to use!!
$myrow = $result->GetRowAssoc(false);
$result->MoveNext();
$id = $myrow['id'];
$date = $myrow['date'];
$year = substr($date,0,4);
$month = substr($date,5,2);
$day = substr($date,8,2);
$fdate = date("F jS Y",mktime (0,0,0,$month,$day,$year));
$title = $myrow['title'];
$text = $myrow['text'];
$cover = $myrow['cover'];
$reviewer = $myrow['reviewer'];
$email = $myrow['email'];
$hits = $myrow['hits'];
$url = $myrow['url'];
$url_title = $myrow['url_title'];
$score = $myrow['score'];
$rlanguage = $myrow['rlanguage']; /* ML added */
$contentpages = explode( "<!--pagebreak-->", $text );
$pageno = count($contentpages);
if ( $page=="" || $page < 1 )
$page = 1;
if ( $page > $pageno )
$page = $pageno;
$arrayelement = (int)$page;
$arrayelement --;
echo "<p><font class=\"pn-title\"><b><i>$title</i></b></font><br>";
echo "<p align=justify><font class=\"pn-normal\">";
if ($cover != "")
echo "<img src=\"modules/$ModName/images/$cover\" align=right border=1 vspace=2 alt=\"\">";
echo "$contentpages[$arrayelement]</font><p><font class=\"pn-normal\">";
if (authorised(0, 'Reviews::', "$title::$id", ACCESS_EDIT)) {
echo "<b>"._ADMIN."</b> [ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=mod_review&id=$id\">"._EDIT."</a> ";
if (authorised(0, 'Reviews::', "$title::$id", ACCESS_DELETE)) {
echo "| <a class=\"pn-normal\" href=modules.php?op=modload&name=$ModName&file=index&req=del_review&id_del=$id>"._DELETE."</a> ";
}
echo "]";
}
echo "<br>";
echo "<b>"._ADDED."</b> $fdate<br>";
if ($reviewer != "")
echo "<b>"._REVIEWER."</b> <a class=\"pn-normal\" href=\"mailto:$email\">$reviewer</a><br>";
if ($score != "")
echo "<b>"._SCORE."</b> ";
display_score($score);
if ($url != "")
echo "<br><b>"._RELATEDLINK.":</b> <a class=\"pn-normal\" href=\"$url\" target=new>$url_title</a>";
echo "<br><b>"._HITS.":</b> $hits";
echo "<br><b>"._LANGUAGE.":</b> $rlanguage"; /* ML ADDED */
if ($pageno > 1) {
echo "<br><b>"._PAGE.":</b> $page/$pageno<br>";
}
echo "</font>";
echo "</td></tr></TABLE>";
echo "</CENTER>";
// memory flush
$result->Close();
$title = urlencode($title);
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=showcontent&id=$id&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=showcontent&id=$id&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 class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=showcontent&id=$id&page=$previous_pagenumber\"><img src=\"modules/$ModName/images/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=showcontent&id=$id&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
}
echo "</td></tr>"
."<tr><td align=\"center\">"
."$previous_page $next_page<br><br>"
."<font class=\"pn-normal\">[ <a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index\">"._RBACK."</a> | "
."<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=postcomment&id=$id&title=$title\">"._REPLYMAIN."</a> ]</font>";
CloseTable();
if (($page == 1) OR ($page == "")) {
echo "<br>";
r_comments($id, $title);
}
include ("footer.php");
}
function mod_review($id) {
global $admin, $pntable, $dbconn, $ModName, $rlanguage, $currentlang;
if ($multilingual == 1) {
$querylang = "AND (rlanguage='$currentlang' OR rlanguage='')";
} else {
$querylang = "";
}
include ('header.php');
OpenTable();
if ($id != 0) {
$column = &$pntable['reviews_column'];
$query = getSelectAllColumnsFrom ('reviews', "$column[id]=$id");
$result = $dbconn->Execute($query);
if (!$result->EOF) {
$myrow = $result->GetRowAssoc(false);
$result->MoveNext();
$id = $myrow["id"];
$date = $myrow["date"];
$title = $myrow["title"];
$text = $myrow["text"];
$cover = $myrow["cover"];
$reviewer = $myrow["reviewer"];
$email = $myrow["email"];
$hits = $myrow["hits"];
$url = $myrow["url"];
$url_title = $myrow["url_title"];
$score = $myrow["score"];
$rlanguage = $myrow["rlanguage"]; /* ML ADDED */
}
else
{
// Might have been given an invalid ID - blank it
$id = "";
}
$result->Close();
if (!(authorised(0, 'Reviews::', "$title::$id", ACCESS_EDIT))) {
echo _REVIEWSEDITNOAUTH;
CloseTable();
include 'footer.php';
return;
}
echo "<center><font class=\"pn-normal\"><b>"._REVIEWMOD."</b></font></center><br><br>";
echo "<form method=\"post\" action=\"modules.php\">
<input type=\"hidden\" name=\"op\" value=\"modload\">
<input type=\"hidden\" name=\"name\" value=\"$ModName\">
<input type=\"hidden\" name=\"file\" value=\"index\">
<input type=\"hidden\" name=\"req\" value=\"preview_review\">
<input type=hidden name=id value=$id>";
echo "<TABLE BORDER=0 width=100%>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._RDATE."</b></font></font></td>
<td><INPUT TYPE=text NAME=date SIZE=15 VALUE=\"$date\" MAXLENGTH=10></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._RTITLE."</b></font></font></td>
<td><INPUT TYPE=text NAME=title SIZE=50 MAXLENGTH=150 value=\"$title\"></td>
</tr>
<tr>
<td width=12%><b>"._LANGUAGE."</b></td>
<td><select name=\"rlanguage\">";
$lang = languagelist();
$sel_lang[$currentlang] = ' selected';
print '<option value="">'._ALL.'</option>';
$handle = opendir('language');
while ($f = readdir($handle)) {
if (is_dir("language/$f") && $lang[$f]) {
$langlist[$f] = $lang[$f];
}
}
asort($langlist);
foreach ($langlist as $k=>$v) {
print "<option value=\"$k\"$sel_lang[$k]>$v</option>\n";
}
echo "</select></td>
</tr>
<tr>
<tr>
<td width=12%><b>"._RTEXT."</b></td>
<td><TEXTAREA class=\"pn-normal\" name=text rows=20 wrap=virtual cols=60>$text</TEXTAREA></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._REVIEWER."</b></font></td>
<td><INPUT TYPE=text NAME=reviewer SIZE=41 MAXLENGTH=40 value=\"$reviewer\"></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._REVEMAIL."</b></font></td>
<td><INPUT TYPE=text NAME=email value=\"$email\" SIZE=30 MAXLENGTH=80></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._SCORE."</b></font></td>
<td><INPUT TYPE=text NAME=score value=\"$score\" size=3 maxlength=2></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._RLINK."</b></font></td>
<td><INPUT TYPE=text NAME=url value=\"$url\" size=30 maxlength=100></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._RLINKTITLE."</b></font></td>
<td><INPUT TYPE=text NAME=url_title value=\"$url_title\" size=30 maxlength=50></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._COVERIMAGE."</b></font></td>
<td><INPUT TYPE=text NAME=cover value=\"$cover\" size=30 maxlength=100></td>
</tr>
<tr>
<td width=12%><font class=\"pn-normal\"><b>"._HITS.":</b></font></td>
<td><INPUT TYPE=text NAME=hits value=\"$hits\" size=5 maxlength=5></td>
</tr>
</TABLE>";
echo "<input type=\"hidden\" name=\"req\" value=\"preview_review\"><input type=\"submit\" value=\""._PREMODS."\"> <input type=button onClick=history.go(-1) value="._CANCEL."></form>";
} else {
echo _REVIEWSINVALIDID;
}
CloseTable();
include ("footer.php");
}
function del_review($id_del) {
global $admin, $pntable, $dbconn, $ModName;
csrfcheck();
$column = &$pntable['reviews_column'];
$result = $dbconn->Execute("SELECT $column[title]
FROM $pntable[reviews]
WHERE $column[id]=$id_del");
list($title) = $result->fields;
$result->Close();
if (!(authorised(0, 'Reviews::', "$title::$id_del", ACCESS_DELETE))) {
echo _REVIEWSDELNOAUTH;
CloseTable();
include 'footer.php';
return;
}
$dbconn->Execute("DELETE FROM $pntable[reviews] WHERE {$pntable['reviews_column']['id']}=$id_del");
$dbconn->Execute("DELETE FROM $pntable[reviews_comments] WHERE {$pntable['reviews_comments_column']['rid']}='$id_del'");
pnRedirect('modules.php?op=modload&name='.$ModName.'&file=index');
}
function del_comment($cid, $id) {
global $admin, $pntable, $dbconn, $ModName;
csrfcheck();
$column = &$pntable['reviews_column'];
$result = $dbconn->Execute("SELECT $column[title]
FROM $pntable[reviews]
WHERE $column[id]=$id");
list($title) = $result->fields;
if (!(authorised(0, 'Reviews::', "$title::$id", ACCESS_DELETE))) {
echo _REVIEWSDELNOAUTH;
CloseTable();
include 'footer.php';
return;
}
$dbconn->Execute("DELETE FROM $pntable[reviews_comments] WHERE {$pntable['reviews_comments_column']['cid']}='$cid'");
pnRedirect('modules.php?op=modload&name='.$ModName.'&file=index');
}
//FTO. Just to stop the warning
if (!isset($req)) $req="";
switch($req) {
case "A":
reviews(A, $field, $order);
break;
case "B":
reviews(B, $field, $order);
break;
case "C":
reviews(C, $field, $order);
break;
case "D":
reviews(D, $field, $order);
break;
case "E":
reviews(E, $field, $order);
break;
case "F":
reviews(F, $field, $order);
break;
case "G":
reviews(G, $field, $order);
break;
case "H":
reviews(H, $field, $order);
break;
case "I":
reviews(I, $field, $order);
break;
case "J":
reviews(J, $field, $order);
break;
case "K":
reviews(K, $field, $order);
break;
case "L":
reviews(L, $field, $order);
break;
case "M":
reviews(M, $field, $order);
break;
case "N":
reviews(N, $field, $order);
break;
case "O":
reviews(O, $field, $order);
break;
case "P":
reviews(P, $field, $order);
break;
case "Q":
reviews(Q, $field, $order);
break;
case "R":
reviews(R, $field, $order);
break;
case "S":
reviews(S, $field, $order);
break;
case "T":
reviews(T, $field, $order);
break;
case "U":
reviews(U, $field, $order);
break;
case "V":
reviews(V, $field, $order);
break;
case "W":
reviews(W, $field, $order);
break;
case "X":
reviews(X, $field, $order);
break;
case "Y":
reviews(Y, $field, $order);
break;
case "Z":
reviews(Z, $field, $order);
break;
case "1":
reviews(1, $field, $order);
break;
case "2":
reviews(2, $field, $order);
break;
case "3":
reviews(3, $field, $order);
break;
case "4":
reviews(4, $field, $order);
break;
case "5":
reviews(5, $field, $order);
break;
case "6":
reviews(6, $field, $order);
break;
case "7":
reviews(7, $field, $order);
break;
case "8":
reviews(8, $field, $order);
break;
case "9":
reviews(9, $field, $order);
break;
case "showcontent":
showcontent($id, $page);
break;
case "write_review":
write_review();
break;
case "preview_review":
preview_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage);
break;
case ""._YES."":
send_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage);
break;
case "del_review":
del_review($id_del);
break;
case "mod_review":
mod_review($id);
break;
case "postcomment":
postcomment($id, $title);
break;
case "savecomment":
savecomment($xanonpost, $uname, $id, $score, $comments);
break;
case "del_comment":
del_comment($cid, $id);
break;
default:
reviews_index();
break;
}
?>