<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System !                                 */
/* ===========================                                          */
/*                                                                      */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2003 by Philippe Brunier   */
/*                                                                      */
/************************************************************************/
/*                                                                      */
/* Add-on Copyright (c) 2000 by Jeff Lambert (jeffx@ican.net)           */
/* http://www.qchc.com                                                  */
/*                                                                      */
/************************************************************************/
/*                                                                      */
/* 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.       */
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {include ("mainfile.php");}
global $pdst; $pdst="1";

function display_score($score) {
   if ($ibid=theme_image("blue.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/blue.gif";}
   $image = "<img src=$imgtmp>";
   if ($ibid=theme_image("bluehalf.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/bluehalf.gif";}
   $halfimage = "<img src=$imgtmp>";
   if ($ibid=theme_image("star.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/star.gif";}
   $full = "<img src=$imgtmp>";

   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() {
   global $admin, $sitename, $user, $cookie, $short_review;

   include ('header.php');
   OpenTable();
   echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
   echo translate("Write a Review for")." $sitename";
   echo "</TD></TR></TABLE>\n";
   echo "<br />".translate("Please enter information according to the specifications")."<br />\n";

   echo "<form method=POST action=reviews.php>
        <b>".translate("Product Title")." :</b><br />
        <input CLASS=\"TEXTBOX_STANDARD\" type=text name=title size=40 maxlength=150>&nbsp;
        <i>".translate("Name of the Reviewed Product.")."</i><br /><br />
        <b>".translate("Review")." :</b><br />
        <TEXTAREA CLASS=\"TEXTBOX\" name=text rows=15 wrap=virtual cols=40></TEXTAREA><br />
        <i>".translate("Your actual review. Please observe proper grammar! Make it at least 100 words, OK? You may also use HTML tags if you know how to use them.")."</i><br /><br />
        <b>".translate("Your name")." :</b><br />";
   if ($user) {
      $result=mysql_query("select name, email from users where uname='$cookie[1]'");
      list($name, $email) = mysql_fetch_row($result);
   }
   echo "<input CLASS=\"TEXTBOX_STANDARD\" type=text name=reviewer size=40 maxlength=100 value=\"$name\"><br />
        <i>".translate("Your Full Name. Required.")."</i><br /><br />
        <b>".translate("Your email")." :</b><br />
        <input CLASS=\"TEXTBOX_STANDARD\" type=text name=email size=40 maxlength=100 value=\"$email\"><br />
        <i>".translate("Your E-mail address. Required.")."</i><br /><br />
        <b>".translate("Score")." :</b><br />
        <select CLASS=\"TEXTBOX_STANDARD\" 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>".translate("Select from 1=poor to 10=excelent.")."</i><br /><br />";
   if (!$short_review) {
      echo "<b>".translate("Related Link")." :</b><br />
           <input CLASS=\"TEXTBOX_STANDARD\" type=text name=url size=40 maxlength=100 value=\"\"><br />
           <i>".translate("Product Official Website. Make sure your URL starts by")."<font class=\"ROUGE\"> \"http://\".</font></i><br /><br />
           <b>".translate("Link title")." :</b><br />
           <input CLASS=\"TEXTBOX_STANDARD\" type=text name=url_title size=40 maxlength=50><br />
           <i>".translate("Required if you have a related link, otherwise not required.")."</i><br /><br />";
      if ($admin) {
         echo "<b>".translate("Image filename")." :</b><br />
              <input CLASS=\"TEXTBOX_STANDARD\" type=text name=cover size=40 maxlength=100></font><br />
              <i>".translate("Name of the cover image, located in images/reviews/. Not required.")."</i><br /><br />";
      }
   }
   echo translate("Please make sure that the information entered is 100% valid and uses proper grammar and capitalization. For instance, please do not enter your text in ALL CAPS, as it will be rejected.")."<br /><br />";
   echo "<input type=hidden name=op value=preview_review><input CLASS=\"BOUTON_STANDARD\" type=submit value=".translate("Preview")."> <input CLASS=\"BOUTON_STANDARD\" type=button onClick=history.go(-1) value=".translate("Go Back")."></form>";
   CloseTable();
   include ("footer.php");
}

function preview_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id) {
   global $admin, $short_review;

   $title = stripslashes(check_html($title, "nohtml"));
   $text = stripslashes(removeHack(nl2br($text)));
   $reviewer = stripslashes(check_html($reviewer, "nohtml"));
   $url_title = stripslashes(check_html($url_title, "nohtml"));

   include ('header.php');
   OpenTable();
   echo "<form method=post action=reviews.php>";
   if ($title == "") {
      $error = 1;
      echo translate("Invalid Title... can not be blank")."<br />";
   }
   if ($text == "") {
      $error = 1;
      echo translate("Invalid review text... can not be blank")."<br />";
   }
   if (($score < 1) || ($score > 10)) {
      $error = 1;
      echo translate("Invalid score... must be between 1 and 10")."<br />";
   }
   if (($hits < 0) && ($id != 0)) {
      $error = 1;
      echo translate("Hits must be a positive integer")."<br />";
   }
   if ($reviewer == "" || $email == "") {
      $error = 1;
      echo translate("You must enter both your name and your email")."<br />";
   } else if ($reviewer != "" && $email != "")
      if (!(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email))) {
         $error = 1;
         echo translate("Invalid email (eg: you@hotmail.com)")."<br />";
      }

   if ((($url_title != "" && $url =="") || ($url_title == "" && $url != "")) and (!$short_reviews)) {
      $error = 1;
      echo translate("You must enter BOTH a link title and a related link or leave both blank")."<br />";
   } else if (($url != "") && (!(eregi('(^http[s]*:[/]+)(.*)', $url)))) {
      $url = "http://" . $url;
   }

   if ($error == 1) {
      echo "<br /><input CLASS=\"BOUTON_STANDARD\" type=button onClick=history.go(-1) value=".translate("Go Back").">";
   } else {
      global $gmt;
      $fdate=date(str_replace("%","",translate("linksdatestring")),time()+($gmt*3600));
      echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
      echo translate("Waiting Reviews");
      echo "</TD></TR></TABLE>\n";
      echo "<br />\n";
      echo translate("Added:")." $fdate";
      echo "<HR noshade size=1 CLASS=\"ONGL\">";
      echo "<FONT CLASS=\"TITREA\">$title</FONT><br />";
      if ($cover != "")
         echo "<img src=images/reviews/$cover align=right hspace=10 vspace=10>";
      echo "<FONT color=\"$textcolor1\">$text</FONT>";
      echo "<HR noshade size=1 CLASS=\"ONGL\">";
      echo "<b>".translate("Reviewer:")."</b> <a href=mailto:$email CLASS=\"NOIR\" target=_blank>$reviewer</a><br />";
      echo "<b>".translate("Score:")."</b> ";
      display_score($score);
      if ($url != "")
         echo "<br /><b>".translate("Related Link")." :</b> <a href=\"$url\" target=_blank CLASS=\"NOIR\">$url_title</a>";
      if ($id != 0) {
         echo "<br /><b>".translate("Review ID")." :</b> $id<br />";
         echo "<b>".translate("Hits")." :</b> $hits<br />";
      }
      $text = urlencode($text);
      echo "<input type=hidden name=id value=$id>
            <input type=hidden name=hits value=\"$hits\">
            <input type=hidden name=op value=send_review>
            <input type=hidden name=date value=\"$fdate\">
            <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=op value=add_reviews>";
            echo "<br /><br />".translate("Does this look right?")."&nbsp;&nbsp;";
            echo "<input CLASS=\"BOUTON_STANDARD\" type=submit value=".translate("Yes").">&nbsp;&nbsp;<input CLASS=\"BOUTON_STANDARD\" type=button onClick=history.go(-1) value=".translate("No").">";
      if ($id != 0)
         $word = translate("modified");
      else
         $word = translate("added");
      if ($admin)
         echo "<br /><br /><b>".translate("Note:")."</b> ".translate("Currently logged in as admin... this review will be")." $word ".translate("immediately").".";
   }
   echo "</FORM>";
   CloseTable();
   include ("footer.php");
}

function send_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id) {
   global $admin;

   include ('header.php');
   $title = stripslashes(FixQuotes(check_html($title, "nohtml")));
   $text = stripslashes(Fixquotes(urldecode(removeHack($text))));
   OpenTable();
   echo "<br /><center>".translate("Thanks for submitting this review")."";
   if ($id != 0)
      echo " ".translate("modification")."";
   else
      echo ", $reviewer";
   echo "<br /><br />";
   if (($admin) && ($id == 0)) {
      mysql_query("INSERT INTO reviews VALUES (NULL, '$date', '$title', '$text', '$reviewer', '$email', '$score', '$cover', '$url', '$url_title', '1')");
      echo translate("It is now available in the reviews database.");
   } else if (($admin) && ($id != 0)) {
      mysql_query("UPDATE reviews SET date='$date', title='$title', text='$text', reviewer='$reviewer', email='$email', score='$score', cover='$cover', url='$url', url_title='$url_title', hits='$hits' where id='$id'");
      echo translate("It is now available in the reviews database.");
   } else {
      mysql_query("INSERT INTO reviews_add VALUES (NULL, '$date', '$title', '$text', '$reviewer', '$email', '$score', '$url', '$url_title')");
      echo translate("The editors will look at your submission. It should be available soon!");
   }
   echo "<br /><br />[ <a href=\"reviews.php\" CLASS=\"NOIR\">".translate("Back to Reviews Index")."</a> ]<br /></center>";
   CloseTable();
   include ("footer.php");
}

function reviews($field, $order) {
   include ('header.php');
   opentable();
   echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
   echo translate("Welcome to Reviews Section");
   echo "</TD></TR></TABLE>\n";
   $result = mysql_query("select title, description from reviews_main");
   list($title, $description) = mysql_fetch_row($result);
   echo "<br /><b>$title</b><br /><br />$description<br /><br />";
   echo "<center>";
   echo "[ <a href=reviews.php?op=write_review CLASS=\"NOIR\">".translate("Write a Review")."</a> ]<br /><br />\n";
   if ($order!="ASC" and $order!="DESC") $order="ASC";
   switch ($field) {
          case "reviewer":
               $result = mysql_query("SELECT id, title, hits, reviewer, score, date FROM reviews ORDER by reviewer $order");
               break;

          case "score":
               $result = mysql_query("SELECT id, title, hits, reviewer, score, date FROM reviews ORDER by score $order");
               break;

          case "hits":
               $result = mysql_query("SELECT id, title, hits, reviewer, score, date FROM reviews ORDER by hits $order");
               break;

          case "date":
               $result = mysql_query("SELECT id, title, hits, reviewer, score, date FROM reviews ORDER by id $order");
               break;

          default:
               $result = mysql_query("SELECT id, title, hits, reviewer, score, date FROM reviews ORDER by title $order");
               break;
   }
   $numresults = mysql_numrows($result);
   if ($numresults > 0) {
      if ($ibid=theme_image("download/up.gif")) {$imgtmpU=$ibid;} else {$imgtmpU="images/download/up.gif";}
      if ($ibid=theme_image("download/down.gif")) {$imgtmpD=$ibid;} else {$imgtmpD="images/download/down.gif";}
      echo "<TABLE BORDER=0 WIDTH=100% CELLPADDING=1 CELLSPACING=1 CLASS=\"HEADER\">
            <TR>
            <TD CLASS=\"BOX\" ALIGN=LEFT><a href=reviews.php?op=sort&field=date&order=ASC><img src=$imgtmpU border=0 width=15 height=9 Alt=\"Date\"></a> Date <a href=reviews.php?op=sort&field=date&order=DESC><img src=$imgtmpD border=0 width=15 height=9 Alt=\"".translate("Sort Descending")."\"></a>
            </TD>
            <TD CLASS=\"BOX\" ALIGN=LEFT><a href=reviews.php?op=sort&field=title&order=ASC><img src=$imgtmpU border=0 width=15 height=9 Alt=\"".translate("Sort Ascending")."\"></a> ".translate("Title")." <a href=reviews.php?op=sort&field=title&order=DESC><img src=$imgtmpD border=0 width=15 height=9 Alt=\"".translate("Sort Descending")."\"></a>
            </TD>
            <TD CLASS=\"BOX\" align=center nowrap>
            <a href=reviews.php?op=sort&field=reviewer&order=ASC><img src=$imgtmpU border=0 width=15 height=9 Alt=\"".translate("Sort Ascending")."\"></a> ".translate("Posted by")." <a href=reviews.php?op=sort&field=reviewer&order=DESC><img src=$imgtmpD border=0 width=15 height=9 Alt=\"".translate("Sort Descending")."\"></a>
            </TD>
            <TD CLASS=\"BOX\" align=center nowrap>
            <a href=reviews.php?op=sort&field=score&order=ASC><img src=$imgtmpU border=0 width=15 height=9 Alt=\"".translate("Sort Ascending")."\"></a> Score <a href=reviews.php?op=sort&field=score&order=DESC><img src=$imgtmpD border=0 width=15 height=9 Alt=\"".translate("Sort Descending")."\"></a>
            </TD>
            <TD CLASS=\"BOX\" align=center nowrap>
            <a href=reviews.php?op=sort&field=hits&order=ASC><img src=$imgtmpU border=0 width=15 height=9 Alt=\"".translate("Sort Ascending")."\"></a> Hits <a href=reviews.php?op=sort&field=hits&order=DESC><img src=$imgtmpD border=0 width=15 height=9 Alt=\"".translate("Sort Descending")."\"></a>
            </TD>
            </TR>";
      while ($myrow=mysql_fetch_array($result)) {
         $title = $myrow["title"];
         $id = $myrow["id"];
         $reviewer = $myrow["reviewer"];
         $email = $myrow["email"];
         $score = $myrow["score"];
         $hits = $myrow["hits"];
         $date = $myrow["date"];
         $rowcolor = tablos();
         echo "<TR $rowcolor>
               <TD WIDTH=15% align=left><font size=1>".f_date ($date)."</font></TD>
               <TD WIDTH=40%><a href=reviews.php?op=showcontent&id=$id CLASS=\"NOIR\">$title</a></TD>
               <TD WIDTH=18%>";
         if ($reviewer != "")
            echo "<center>$reviewer</center>";
         echo "</TD><TD WIDTH=18%><center>";
         display_score($score);
         echo "</center></TD><TD WIDTH=14%><center>$hits</center></TD></TR>";
      }
      echo "</TABLE>";
   }
   echo "<br />$numresults ".translate("Total Review(s) found.")."<br /><br />";
   echo "[ <a href=reviews.php?op=write_review CLASS=\"NOIR\">".translate("Write a Review")."</a> ]\n";

   mysql_free_result($result);
   CloseTable();
   include ("footer.php");
}

function postcomment($id, $title) {
   global $user, $cookie, $AllowableHTML, $anonymous, $anonpost;

   if (!$user and !$anonpost) {
      header("location: reviews.php");
   }

   include("header.php");
   $title = removeHack(urldecode($title));
   OpenTable();
   echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
   echo translate("Comment on the Review:")." ".stripslashes($title);
   echo "</TD></TR></TABLE>\n";
   echo "<br /><FORM action=reviews.php method=post>";
   if (!$user) {
      echo "<b>".translate("Your Nickname:")."</b> $anonymous [ <a href=user.php CLASS=\"NOIR\">".translate("Create</a> an account")." ]<br /><br />";
      $cookie[1] = $anonymous;
   } else {
      echo "<b>".translate("Your Nickname:")."</b> $cookie[1]<br /><br />";
   }
   echo "
   <input type=hidden name=uname value=$cookie[1]>
   <input type=hidden name=id value=$id>
   <b>".translate("This Product Score:")."</b>
   <select CLASS=\"TEXTBOX_STANDARD\" 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><br /><br />
   <b>".translate("Your Comment:")."</b><br />
   <textarea CLASS=\"TEXTBOX\" name=comments rows=10 cols=40></textarea><br />
   ".translate("Allowed HTML:")."<br />&nbsp;";
   while (list($key,)= each($AllowableHTML)) echo " &lt;".$key."&gt;";
   echo "<br /><br />
   <input type=hidden name=op value=savecomment>
   <input CLASS=\"BOUTON_STANDARD\" type=submit value=".translate("Submit").">
   </form>";
   CloseTable();
   include("footer.php");
}

function savecomment($xanonpost, $uname, $id, $score, $comments) {
   global $language, $anonymous;
   if ($xanonpost) {
      $uname = $anonymous;
   }
   $comments = stripslashes(FixQuotes(removeHack($comments)));
   mysql_query("insert into reviews_comments values (NULL, '$id', '$uname', now(), '$comments', '$score')");
   redirect_url("reviews.php");
}

function f_date ($xdate) {
   $year = substr($xdate,0,4);
   $month = substr($xdate,5,2);
   $day = substr($xdate,8,2);
   $fdate=date(str_replace("%","",translate("linksdatestring")),mktime (0,0,0,$month,$day,$year));
   return $fdate;
}

function r_comments($id, $title) {
   global $admin, $anonymous;

   settype($id,"integer");
   $result = mysql_query("select cid, userid, date, comments, score from reviews_comments where rid='$id'");
   echo "<br />";
   while(list($cid, $uname, $date, $comments, $score) = mysql_fetch_row($result)) {
      OpenTable();
      $fdate=f_date($date);
      if ($uname == $anonymous) {
         echo translate("Posted by")." $uname ".translate("on")." $fdate<br />";
      } else {
         echo translate("Posted by")." <a href=user.php?op=userinfo&uname=$uname CLASS=\"NOIR\">$uname</a> ".translate("on")." $fdate<br />";
      }
      echo translate("My Score:")." ";
      display_score($score);
      if ($admin) {
          echo "<P align=right><b>".translate("Admin:")."</b> [ <a href=reviews.php?op=del_comment&cid=$cid&id=$id CLASS=\"ROUGE\">".translate("Delete")."</a> ]</font><hr noshade size=1></P><br />";
      } else {
          echo "</font><hr noshade size=1><br /><br />";
      }
      echo nl2br(filter_text($comments));
      CloseTable();
   }
}

function showcontent($id) {
   global $admin;
   include ('header.php');
   OpenTable();

   settype($id,"integer");
   mysql_query("UPDATE reviews SET hits=hits+1 WHERE id='$id'");
   $result = mysql_query("SELECT * FROM reviews WHERE id='$id'");
   echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
   echo translate("Reviews");
   echo "</TD></TR></TABLE>\n";
   echo "<br />";
   $myrow =  mysql_fetch_array($result);
   $id =  $myrow["id"];
   $fdate=f_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"];
   echo "<b>".translate("Added:")."</b> $fdate<br />";
   echo "<HR noshade size=1 CLASS=\"ONGL\">";
   echo "<FONT CLASS=\"TITREA\">$title</FONT><br />";
   if ($cover != "")
      echo "<img src=\"images/reviews/$cover\" align=right hspace=10 vspace=10>";
   echo "<FONT color=\"$textcolor1\">$text</FONT>";
   echo "<HR noshade size=1 CLASS=\"ONGL\">";
   if ($admin)
      echo "<P align=right><b>".translate("Admin:")."</b> [ <a href=\"reviews.php?op=mod_review&id=$id\" CLASS=\"NOIR\">".translate("Edit")."</a> | <a href=reviews.php?op=del_review&id_del=$id CLASS=\"ROUGE\">".translate("Delete")."</a> ]</P>";
   if ($reviewer != "")
      echo "<b>".translate("Reviewer:")."</b> <a href=mailto:$email target=_blank CLASS=\"NOIR\">$reviewer</a><br />";
   if ($score != "")
      echo "<b>".translate("Score:")."</b> ";
   display_score($score);
   if ($url != "")
      echo "<br /><b>".translate("Related Link:")."</b> <a href=\"$url\" target=_blank CLASS=\"NOIR\">$url_title</a>";
   echo "<br /><b>".translate("Hits:")."</b> $hits";

   mysql_free_result($result);
   $title = urlencode($title);
   echo "<br /><br /><center>[ <a href=\"reviews.php?op=postcomment&id=$id&title=$title\" CLASS=\"NOIR\">".translate("Comments")."</a> ]&nbsp;&nbsp;[ <a href=reviews.php CLASS=\"NOIR\">".translate("Back to Reviews Index")."</a> ]</center>";
   CloseTable();
   r_comments($id, $title);
   include ("footer.php");
}

function mod_review($id) {
   global $admin;
   include ('header.php');
   OpenTable();

   settype($id,"integer");
   if (($id == 0) || (!($admin)))
      echo "This function must be passed argument id, or you are not admin.";
   else if (($id != 0) && ($admin)) {
      $result = mysql_query("select * from reviews where id = '$id'");
      $myrow =  mysql_fetch_array($result);
      $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"];
      echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
      echo translate("Review Modification");
      echo "</TD></TR></TABLE>\n";
      echo "<br />";
      echo "<FORM method=POST action=reviews.php?op=preview_review><input type=hidden name=id value=$id>";
      echo "<TABLE BORDER=0 WIDTH=100%>
           <TR>
           <TD WIDTH=20%><b>".translate("Date:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX_STANDARD\" TYPE=text NAME=date SIZE=15 VALUE=\"$date\" MAXLENGTH=10></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Title:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX\" TYPE=text NAME=title SIZE=34 MAXLENGTH=150 value=\"$title\"></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Text:")."</b></TD>
           <TD><TEXTAREA CLASS=\"TEXTBOX\" name=text rows=20 wrap=virtual cols=33>$text</TEXTAREA></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Reviewer:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX_STANDARD\" TYPE=text NAME=reviewer SIZE=34 MAXLENGTH=100 value=\"$reviewer\"></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Email:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX\" TYPE=text NAME=email value=\"$email\" SIZE=34 MAXLENGTH=100></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Score:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX_STANDARD\" TYPE=text NAME=score value=\"$score\" size=3 maxlength=2></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Link:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX\" TYPE=text NAME=url value=\"$url\" size=34 maxlength=100></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Link title:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX\" TYPE=text NAME=url_title value=\"$url_title\" size=34 maxlength=50></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Cover image:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX\" TYPE=text NAME=cover value=\"$cover\" size=34 maxlength=100></TD>
           </TR><TR>
           <TD WIDTH=20%><b>".translate("Hits:")."</b></TD>
           <TD><INPUT CLASS=\"TEXTBOX_STANDARD\" TYPE=text NAME=hits value=\"$hits\" size=6 maxlength=5></TD>
           </TR>
           </TABLE><br />";
      echo "<input type=hidden name=op value=preview_review><input CLASS=\"BOUTON_STANDARD\" type=submit value=\"".translate("Preview Modifications")."\">&nbsp;&nbsp;<input CLASS=\"BOUTON_STANDARD\" type=button onClick=history.go(-1) value=".translate("Cancel")."></form>";
      mysql_free_result($result);
   }
   CloseTable();
   include ("footer.php");
}

function del_review($id_del) {
   global $admin;
   if ($admin) {
      mysql_query("delete from reviews where id='$id_del'");
      mysql_query("delete from reviews_comments where rid='$id_del'");
   }
   redirect_url("reviews.php");
}

function del_comment($cid, $id) {
   global $admin;
   if ($admin) {
      mysql_query("delete from reviews_comments where cid='$cid'");
   }
   redirect_url("reviews.php?op=showcontent&id=$id");
}

switch ($op) {
   case "showcontent":
        showcontent($id);
        break;

   case "write_review":
        write_review();
        break;

   case "preview_review":
        preview_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id);
        break;

   case "add_reviews":
        send_review($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id);
        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;

   case "sort":
        reviews($field,$order);
        break;

   default:
        reviews("date","DESC");
        break;
}
?>