Having problem with hot or not mod

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Having problem with hot or not mod
craigmack
CZ Active Member
 Codezwiz Site Donator
craigmack has been a member for over 19 year's 19 Year Member
usa.gif michigan.gif
Age: 46
Gender: Male
Fav. Sports Team: Pistons
Status: Offline
Joined: Feb 15, 2005
0.02 posts per day
Posts: 147
Points: 6,072
   
I have been trying to figure this mod out and can't seem to get it, the problem im having is that the pagination on this mod doesn't work it just refreshes the same page. I looked all over the internet to try to find the problem but i can't find it. I running 7.6 patched with sentinel the hot or not mod is version 2. I seen that it might be a issue with sentinel. Anything needed i can provide

Here is the index.php code

<?php

# ******************************************************************************
#   PHPnuke Hot or Not v1.0
#
#   for PHPnuke 5.5
#
#               Download at: http://www.trashbin.net
#
#   Copyright (C) 2002 by ::Trashbin:: http://www.trashbin.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, 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.
#
# ******************************************************************************

if ( !defined('MODULE_FILE') )
{
   die("You can't access this file directly...");
}

define('INDEX_FILE', true);
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
require_once("modules/$module_name/h_config.php");

function getlist($start, $sort, $order, $where, $catwhere, $unrated) {
   global $dbi, $prefix, $img_path, $img_width, $img_toplist, $gl_cat_id, $gl_cat_where;
   $arrimgdata = array();
   $arrratedata = array();
   $i = $start;
   if ($catwhere != "" && $gl_cat_where != "") $catwhere .= " and $gl_cat_where";
   if ($catwhere == "" && $gl_cat_where != "") $catwhere = " and $gl_cat_where";

   if ($sort != "comment") {
      $result = sql_query("select vote_id, vote_nr, vote_total/vote_nr as vote_rate, vote_dir, vote_file, vote_datetime, vote_link, vote_imgwidth, vote_imgheight, vote_1, vote_2, vote_3, vote_4, vote_5, vote_6, vote_7, vote_8, vote_9, vote_10, vote_userupload, vote_10 as comcount from ".$prefix."_hotornot_votes $where $catwhere order by vote_".$sort." ".$order." limit $start, 5", $dbi);
   } else {
      $result = sql_query("select t1.vote_id, t1.vote_nr, t1.vote_total/t1.vote_nr as vote_rate, t1.vote_dir, t1.vote_file, t1.vote_datetime, t1.vote_link, t1.vote_imgwidth, t1.vote_imgheight, t1.vote_1, t1.vote_2, t1.vote_3, t1.vote_4, t1.vote_5, t1.vote_6, t1.vote_7, t1.vote_8, t1.vote_9, t1.vote_10, t1.vote_userupload, count(t2.c_comment) as comcount from ".$prefix."_hotornot_votes t1 left join ".$prefix."_hotornot_comments t2 on t1.vote_id = t2.c_vote_id $where $catwhere group by vote_id order by comcount ".$order.", vote_rate ".$order." limit $start, 5", $dbi);
   }
   while (list($vote_id, $vote_nr, $vote_rate, $vote_dir, $vote_file, $vote_datetime, $vote_link, $vote_imgwidth, $vote_imgheight, $vote_1, $vote_2, $vote_3, $vote_4, $vote_5, $vote_6, $vote_7, $vote_8, $vote_9, $vote_10, $vote_userupload, $comcount) = sql_fetch_row($result, $dbi)) {
      $start++;
      $datetime = null;
      if (!$unrated) {         
         $datetime = formatTimeStamp($vote_datetime);
         $datetime = ""._HOTORNOTIMGLASTVOTED." :: ".$datetime;
         $datetime .= " ".substr($vote_datetime, strpos($vote_datetime, " "));
      }
      $strdata  = "<table width=\"148\" class=\"content\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
      if (!is_null($vote_link)) {
         $img_link_open = "<a href=\"javascript:void(0);\" onClick=\"window.open('".$vote_link."', 'fullsize', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=".($vote_imgwidth+50).",height=".($vote_imgheight+50)."');\">";
         $img_link_close = "</a>";
         $datetime .= "\n"._HOTORNOTFULLSIZE;
      } else {
         $img_link_open = "";
         $img_link_close = "";
      }
      $strdata .= "<tr><td>$img_link_open<img src=\"$img_path/$vote_dir/$vote_file\" width=\"$img_width\" alt=\"$datetime\" border=\"0\">$img_link_close</td></tr>\n";
      $strdata .= "<tr><td>".getVoteTable($vote_id, $i)."</td></tr>\n";
      $strdata .= "<tr><td>$vote_nr "._HOTORNOTIMGVOTE." :: "._HOTORNOTIMGRATING." ".number_format($vote_rate, 1)."</b></td></tr>\n";
      if ($vote_userupload != "") $strdata .= "<tr><td>"._HOTORNOTUSERUPLOADED." <a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;uname=$vote_userupload\">$vote_userupload</a></td></tr>\n";
      //get comments
      $result2 = sql_query("select count(*) from ".$prefix."_hotornot_comments where c_vote_id = $vote_id", $dbi);
      list($comments) = sql_fetch_row($result2, $dbi);
      $strdata .= "<tr><td align=\"$align\" title=\""._HOTORNOTCOMMENTIMAGE."\"><font class=\"xxsmall\"><a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$i&amp;state=$unrated&amp;h_op=comment&amp;id=$vote_id\">$comments "._HOTORNOTCOMMENTS."</a></font></td></tr>\n";
      $strdata .= "</table>\n";
      $arrimgdata[] = $strdata;
      $arrrate = array($vote_1, $vote_2, $vote_3, $vote_4, $vote_5, $vote_6, $vote_7, $vote_8, $vote_9, $vote_10);
      $arrratedata[] = $arrrate;
   }
   $arrdata = array($arrimgdata, $arrratedata);
   return $arrdata;
}

function printcategories() {
   global $dbi, $prefix, $gl_cat_id, $gl_cat_view;
   $result = sql_query("select cat_id, cat_title from ".$prefix."_hotornot_cat where cat_active = 0 and cat_view <= $gl_cat_view order by cat_active, cat_title", $dbi);
   echo "<form action=\"modules.php?name=Hot_Or_Not\" method=\"post\">"._HOTORNOTSELECTCAT." <select name=\"cat\">";
   echo "<option value=\"0\">"._HOTORNOTALL."</option>";
   while (list($cat_id, $cat_title) = sql_fetch_row($result, $dbi)) {
      if ($cat_id == $gl_cat_id) $sel = " SELECTED";
      echo "<option value=\"$cat_id\"$sel>$cat_title</option>";
      $sel = "";
   }
   echo "</select><input type=\"hidden\" name=\"op\" value=\"top\"> <input type=\"submit\" value=\""._HOTORNOTGO."\">";
   //echo "</form>"; //print form closing tag at end of page...layout!
}

function theindex($start, $sort, $order, $unrated = false) {
   global $dbi, $prefix, $gl_cat_id, $gl_cat_view, $gl_cat_where;
  include("header.php");
  OpenTable();
  if ($unrated)  {
     $votewhere = "where vote_nr = 0 and vote_active = 0";
  } else {
     $votewhere = "where vote_nr > 0 and vote_active = 0";
  }
 
  if ($gl_cat_id != 0) {
     $catwhere = " vote_cat_id = $gl_cat_id ";
     //get category name
     $result = sql_query("select cat_title, cat_desc from ".$prefix."_hotornot_cat where cat_id = $gl_cat_id", $dbi);
     list($cat_title, $cat_desc) = sql_fetch_row($result, $dbi);
  } else {
     $cat_title = "All";
  }
  //check which categories are active!
  if ($gl_cat_where != "") {
     $tempwhere = preg_replace("[vote_cat_id]", "cat_id", $gl_cat_where);
     $tempwhere = " and $tempwhere";
  }
  $result = sql_query("select cat_id from ".$prefix."_hotornot_cat where cat_active = 0 $tempwhere", $dbi);
  $catcount = sql_num_rows($result, $dbi);
  if ($catcount != 0) {
     while (list($cat_id) = sql_fetch_row($result, $dbi)) {
        $activecatwhere .= " or vote_cat_id = $cat_id";
     } 
     if ($activecatwhere != "") $activecatwhere = "(".substr($activecatwhere, 4).")";
     if ($catwhere !="") {
        $tempwhere = "where $catwhere";
     } else {
        $tempwhere = "where $activecatwhere";
     }
      //Get image count
      //count total
      $result = sql_query("select vote_id from ".$prefix."_hotornot_votes $tempwhere", $dbi);
      $totalcount = sql_num_rows($result, $dbi);
      //Check if start is within total count
      if ($start > $totalcount) $start = 0;
      //count total rated
     if ($catwhere != "") $catwhere = "and $catwhere";
     $tempwhere = $catwhere;
     if (($activecatwhere != "" && $gl_cat_id == 0)) {
        $tempwhere = "and $activecatwhere";
     } else {
        $tempwhere = "$catwhere";
     }
     $result = sql_query("select vote_id from ".$prefix."_hotornot_votes where vote_nr > 0 and vote_active = 0 $tempwhere", $dbi);
     $count = sql_num_rows($result, $dbi);
     if ($count == 0 && !$unrated) Header("location: modules.php?name=Hot_Or_Not&cat=$gl_cat_id&h_op=unrated"); 
     //calculate unrated
     $totalcount = $totalcount - $count;
      $end = $start + 5;
      if ($end > $count) $end = $count;
      echo "<table class=\"content\" width=\"100%\" border=\"0\"><tr><td colspan=\"2\" align=\"center\"><img src=\"modules/Hot_Or_Not/images/logo.gif\"></td></tr>";
      echo "<td colspan=\"2\" align=\"center\">"._HOTORNOTCAT.": $cat_title";
      if ($cat_desc !="") echo "<br>"._HOTORNOTCATDESC.": $cat_desc";
      echo "<br><br>$count "._HOTORNOTRATED."";
      if ($totalcount > 0) echo "<br>$totalcount "._HOTORNOTUNRATED."";
      echo "<hr></td></tr>";
      echo "<tr><td colspan=\"2\" align=\"right\">";
      printcategories();
      echo "</td></tr>";
      if ($gl_cat_view > 0) {
         global $user, $img_allow_upload;
         if (is_user($user) && $img_allow_upload == 1) echo "<tr><td colspan=\"2\" align=\"right\"><a href=\"modules.php?name=Hot_Or_Not&amp;h_op=uploadimage\">"._HOTORNOTUSERUPLOADLINK."</a></td></tr>";
      }
      echo "<tr><td colspan=\"2\" align=\"center\"><hr>";
      topMenu($start, $order, $totalcount);
       echo "</td></tr><tr><td align=\"center\" valign=\"top\"><table width=\"100%\" border=\"0\">";
       $arrdata = getlist($start, $sort, $order, $votewhere, $catwhere, $unrated);
      $arrimgdata = $arrdata[0];
      $arrratedata = $arrdata[1];
      $arrcount = count($arrimgdata);
      $align = 0;
      global $bgcolor2;
      for ($i=0;$i<$arrcount;$i++) {
         $image = "<td align=\"center\" width=\"150\" valign=\"bottom\">".$arrimgdata[$i]."</td>";
         $rates =  "<td align=\"center\" width=\"150\" valign=\"bottom\">".getRateTable($arrratedata[$i])."</td>";
         if ($align == 0) {
            echo "<tr>".$image.$rates."</tr>";
            $align = 1;
         }
         else {
            echo "<tr>".$rates.$image."</tr>";
            $align = 0;
         }
         echo "<tr><td colspan=\"2\"><hr></td></tr>";
      }
      echo "</table>";      
      echo "</tr>";
     echo "<tr><td colspan=\"2\" align=\"center\">";
     if ($unrated) {
        echo printPages($start, $sort, $totalcount, "unrated");
     } else {
        echo printPages($start, $sort, $count, "top");
     }
     echo "</td></tr></table>";
     echo "<p align=\"right\">"._HOTORNOTCOPYRIGHT."</p>";
   } else {
      echo "<table class=\"content\" width=\"100%\" border=\"0\"><tr><td align=\"center\"><img src=\"modules/Hot_Or_Not/images/logo.gif\"></td></tr>";
      echo "<tr><td align=\"center\">"._HOTORNOTNOCATEGORYACTIVE."</td></tr></table>";
      echo "</form>";
   }
  CloseTable();
  include("footer.php");

}

function topMenu($start, $order, $count) {
   $start = 0;
   global $gl_cat_id;
   echo ":: <a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=rate&amp;o=$order\">"._HOTORNOTMENURATING."</a> "
   ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=rate&amp;o=DESC\"><img src=\"modules/Hot_Or_Not/images/down.gif\" border=\"0\"></a>"
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=rate&amp;o=ASC\"><img src=\"modules/Hot_Or_Not/images/up.gif\" border=\"0\"></a>"
         ." :: <a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=nr&amp;o=$order\">"._HOTORNOTMENUVOTESNR."</a> "
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=nr&amp;o=DESC\"><img src=\"modules/Hot_Or_Not/images/down.gif\" border=\"0\"></a>"
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=nr&amp;o=ASC\"><img src=\"modules/Hot_Or_Not/images/up.gif\" border=\"0\"></a>"
         ." :: <a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=datetime&amp;o=$order\">"._HOTORNOTMENULASTVOTED."</a> "
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=datetime&amp;o=DESC\"><img src=\"modules/Hot_Or_Not/images/down.gif\" border=\"0\"></a>"
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=datetime&amp;o=ASC\"><img src=\"modules/Hot_Or_Not/images/up.gif\" border=\"0\"></a>"
         ." :: <a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=comment&amp;o=$order\">"._HOTORNOTCOMMENT."</a> "
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=comment&amp;o=DESC\"><img src=\"modules/Hot_Or_Not/images/down.gif\" border=\"0\"></a>"
         ."<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;sort=comment&amp;o=ASC\"><img src=\"modules/Hot_Or_Not/images/up.gif\" border=\"0\"></a> ::";
         if ($count > 0) {
            echo " <a href=\"modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;h_op=unrated\">"._HOTORNOTMENUUNRATED."</a> ::<br>";
         }
         echo " <hr>";
   
}

function getVoteTable($vote_id, $start=0) {
global $gl_cat_id;
//$doc = "modules.php?name=Hot_Or_Not&amp;cat=$gl_cat_id&amp;i=$start&amp;v_nr=$vote_id&amp;v_rate=";
//get url
$doc = $_SERVER['PHP_SELF'];
$doc .= "?".$_SERVER['QUERY_STRING'];
//backwards compatibility for version older then PHP 4.2.0
//$doc = "modules.php?".$HTTP_SERVER_VARS['QUERY_STRING']
$doc .= "&amp;v_nr=$vote_id&amp;v_rate=";
$votetable .= "<table class=\"xxsmall\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
$votetable .= "<tr>\n";
   for ($i=1;$i<=10;$i++) {
      $img = $i;
      if ($img < 10) $img = "0$img";
      $votetable .= "<td width=\"10%\" height=\"16\" valign=\"middle\" align=\"center\" title=\""._HOTORNOTIMGRATE."$i\"><a href=\"".$doc.$i."\"><img src=\"modules/Hot_Or_Not/images/rate_$img.gif\" border=\"0\"></a></td>\n";
   }
$votetable .= "</tr></table>\n";   
   
return $votetable;

}

function getRateTable($arrrate) {
   
   $ratetable .= "<table width=\"100%\" height=\"150\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
   //$arrrate = $arrdata[0];
   //calculate total votes
   for ($i=0;$i<10;$i++) {
      $total = $total + $arrrate[$i];
      if ($arrrate[$i] > $h) $h = $arrrate[$i];
   }
   $count = count($arrrate);
   $ratetable .= "<tr><td align=\"center\" colspan=\"10\">"._HOTORNOTIMGRATETABLE."</td></tr>\n";
   $ratetable .= "<tr><td align=\"center\" colspan=\"10\">&nbsp;</td></tr>\n";
   $ratetable .= "<tr>";
   for ($i=1;$i<=$count;$i++) {
      $vote_nr = $arrrate[$i-1];
      if ($arrrate[$i-1] != 0) {
         $width = number_format(($arrrate[$i-1]/$h)*150, 0);
      } else {
         $width=0;
      }
      $ratetable .= "<td valign=\"bottom\" align=\"center\" title=\"$i: ".$arrrate[$i-1]." out of $total "._HOTORNOTIMGVOTE."\">";
      if ($width != 0) {
         $ratetable .= "<img src=\"modules/Hot_Or_Not/images/rate.gif\" height=\"$width\" width=\"10\">";
      } else {
         $ratetable .= "<img src=\"modules/Hot_Or_Not/images/pixel.gif\" height=\"$width\" width=\"10\">";
      }
      $ratetable .= "&nbsp;</td>\n";
   }
   $ratetable .= "</tr><tr>";
   for ($i=1;$i<=$count;$i++) {
      $ratetable .= "<td align=\"center\" width=\"10\"><b>$i</b></td>\n";
   }
   $ratetable .= "</tr></table>\n";
   
   return $ratetable;
}

function printPages($start, $sort, $count, $h_op) {
   global $gl_cat_id;
   $j=0;
   $pages = number_format(($count/5), 1);
   $pages++;
   if ($start - 5 < 0) {
     $content .= "Back";
  }
  else {
     $content .= "<a href=\"modules.php?name=Hot_Or_Not&amp;h_op=$h_op&amp;cat=$gl_cat_id&amp;sort=$sort&amp;i=".($start-5)."\">Back</a>";   
  }
  $content .= "&nbsp;::&nbsp;";
   for ($i=1;$i<$pages;$i++) {
      if ($j != $start) {
      $content .= "<a href=\"modules.php?name=Hot_Or_Not&amp;h_op=$h_op&amp;cat=$gl_cat_id&amp;sort=$sort&amp;i=$j\">$i</a> ";
   } else {
      $content .= "<b><u>$i</u></b> ";
   }
      $j = $j + 5;
   }
   $content .= " :: ";
   if ($start + 5 < $count) {
     $content .= "<a href=\"modules.php?name=Hot_Or_Not&amp;h_op=$h_op&amp;cat=$gl_cat_id&amp;sort=$sort&amp;i=".($start+5)."\">Next</a>";   
  }
  else {
     $content .= "Next";
  }
   return $content;
}

function gettablecontent() {
  global $dbi, $prefix;
  $files = array();
  $i = 0;
   //get images from table and put in 2 dimensional array $files[dir][file_number] = file_name
  $result = sql_query("select vote_dir, vote_file from ".$prefix."_hotornot_votes order by vote_dir, vote_file", $dbi);
  while (list($vote_dir, $vote_file) = sql_fetch_row($result, $dbi)) {
     $files[$vote_dir][$i] = $vote_file;
     $i++;
  }
  return $files;
}

function comment($id = 1, $add = 0, $comments, $i, $cat = 0, $state = 0, $alter = 0, $cid = 0) {
   global $prefix, $dbi, $img_path, $user, $cookie, $img_width, $img_fullsize, $img_comment, $user;
   //check if id is given
   if ($id == "" || $id ==0) $id = 1;
   if ($cat == "") $cat = 0;
   if ($state == 1) $unrated = "&amp;h_op=unrated";
   //check if user is allowed to post comments
  $add_comments = 1;
   //determine user!
   if (is_user($user)) {
      cookiedecode($user);
      $c_user = $cookie[1];
   } else {
      $c_user = "Anonymous";
   }
  if ($img_comment == 0) {
     if ($c_user == "Anonymous") $add_comments = 0;
  }   
   //check if image exists
   $result = sql_query("select vote_id, vote_dir, vote_file, vote_link, vote_imgwidth, vote_imgheight, vote_nr, vote_total/vote_nr as vote_rate from ".$prefix."_hotornot_votes where vote_id = $id", $dbi);
   list($vote_id, $vote_dir, $vote_file, $vote_link, $vote_imgwidth, $vote_imgheight, $vote_nr, $vote_rate) = sql_fetch_row($result, $dbi);
   if ($vote_id == $id) {
      include("header.php");
    OpenTable();
      //check if comment has to be added!!
      if (($add == 1 || $add == 2 || $add == 3) && $add_comments == 1) {
         //check if comment is filled in
         if ($comments != "") {
            //insert comments
            //first strip comment not allowing html in comment!
            //also filter for bad words.
            $comments = FixQuotes(filter_text($comments, "nohtml"));
            if ($add == 1) $sql = "insert into ".$prefix."_hotornot_comments (c_vote_id, c_datetime, c_user, c_comment) values ($id, now(), '$c_user', '$comments')";
            if ($add == 2) $sql = "update ".$prefix."_hotornot_comments set c_datetime = now(), c_comment = '$comments' where c_id = $cid";
            if ($add == 3) $sql = "delete from ".$prefix."_hotornot_comments where c_id = $cid";
            echo $sql;
            sql_query($sql, $dbi);
            //redirect to image
            Header("location: modules.php?name=Hot_Or_Not&h_op=comment&cat=$cat&i=$i&id=$id");
         }
      }
      //if edit, get comments from database
      if ($cid > 0 && ($alter == 1 || $alter == 2)) {
         $result = sql_query("select c_comment from ".$prefix."_hotornot_comments where c_id = $cid and c_user = '$c_user' and c_vote_id = $id", $dbi);
         if (sql_num_rows($result, $dbi) == 1) {
            if ($alter == 1) {
               //get comments to edit!
               list($comments) = sql_fetch_row($result, $dbi);
            }
            elseif ($alter == 2) {
               //delete comments
               sql_query("delete from ".$prefix."_hotornot_comments where c_id = $cid and c_user = '$c_user' and c_vote_id = $id", $dbi);
            }
         } else {
            //redirect to image
            Header("location: modules.php?name=Hot_Or_Not&h_op=comment&cat=$cat&i=$i&id=$id");
         }
      }
      //print page
      if ($img_fullsize == 0) $imagewidth = "width=\"$img_width\"";
    echo "<table width=\"90%\" border=\"0\"><tr><td align=\"center\">";
    echo "<img src=\"modules/Hot_Or_Not/images/logo.gif\"><br><br></td></tr>";
    if ($add_comments == 1) echo "<tr><td align=\"center\">"._HOTORNOTADDCOMMENTS."</td></tr>";
    if ($add_comments == 0) echo "<tr><td align=\"center\">"._HOTORNOTCOMMENTS1."</td></tr>";
    if ($vote_link != "") {
       $img_link_open = "<a href=\"javascript:void(0);\" onClick=\"window.open('".$vote_link."', 'fullsize', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=".($vote_imgwidth+50).",height=".($vote_imgheight+50)."');\">";
         $img_link_close = "</a>";
      }
      $vote_rate = number_format($vote_rate, 1);
    echo "<tr><td align=\"center\">$img_link_open<img src=\"$img_path/$vote_dir/$vote_file\" $imagewidth border=\"0\">$img_link_close</td></tr>";
    echo "<tr><td align=\"center\">$vote_nr "._HOTORNOTIMGVOTE." :: "._HOTORNOTIMGRATING." $vote_rate</b></td></tr>";
    if ($add_comments == 1) {
       //print form to add comments
       echo "<tr><td align=\"center\"><form action=\"modules.php?name=Hot_Or_Not\" method=\"post\">";
       echo _HOTORNOTCOMMENT.": <input type=\"text\" name=\"comments\" size=\"50\" maxlength=\"255\" value=\"$comments\">&nbsp;";
       if ($alter == 1) {
          echo "<input type=\"submit\" value=\""._HOTORNOTEDIT."\">";
          echo "<input type=\"hidden\" name=\"add\" value=\"2\">";
          echo "<input type=\"hidden\" name=\"cid\" value=\"$cid\">";
       } elseif ($alter == 2) {
          echo "<input type=\"submit\" value=\""._HOTORNOTDELETE."\">";
          echo "<input type=\"hidden\" name=\"add\" value=\"3\">";
          echo "<input type=\"hidden\" name=\"cid\" value=\"$cid\">";          
       } else {
          echo "<input type=\"submit\" value=\""._HOTORNOTADD."\">";
          echo "<input type=\"hidden\" name=\"add\" value=\"1\">";
       }
       echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
       echo "<input type=\"hidden\" name=\"cat\" value=\"$cat\">";
       echo "<input type=\"hidden\" name=\"i\" value=\"$i\">";
       echo "<input type=\"hidden\" name=\"h_op\" value=\"comment\"></td></tr>";
     } else {
        echo "<tr><td align=\"center\">"._HOTORNOTPOSTCOMMENTS."</td></tr>";   
     }
     //back to index link
     echo "<tr><td align=\"right\"><a href=\"modules.php?name=Hot_Or_Not$unrated&amp;cat=$cat&amp;i=$i\">"._HOTORNOTBACK."</a><br><br><br></td></tr>";
    //print existing comments
    if ($alter != 1) {
       if ($c_user != "Anonymous") $a_user = $c_user;
       $result = sql_query("select c_id, c_datetime, c_user, c_comment from ".$prefix."_hotornot_comments where c_vote_id = $id", $dbi);
       while (list($cid, $c_datetime, $c_user, $c_comment) = sql_fetch_row($result, $dbi)) {
          echo "<tr><td>"._HOTORNOTPOSTEDBY.": $c_user ($c_datetime)";
          if ($a_user == $c_user) {
             echo "  [<a href=\"modules.php?name=Hot_Or_Not&amp;h_op=comment&amp;cat=$cat&amp;cid=$cid&amp;id=$id&amp;alter=2\">"._HOTORNOTDELCOMMENT."</a>] [<a href=\"modules.php?name=Hot_Or_Not&amp;h_op=comment&amp;cat=$cat&amp;cid=$cid&amp;id=$id&amp;alter=1\">"._HOTORNOTEDITCOMMENT."]";
          }       
          echo "</td></tr><tr><td>$c_comment</td></tr>";
       }
     }
    echo "</table>";
    CloseTable();
    include("footer.php");
   }
   
}

function uploadimage($upload = 0, $uploadmsg = "", $upload_cat_id, $img_upnametmp, $img_upname, $img_uptype, $img_upsize, $img_path_resize) {
   global $prefix, $dbi, $img_path, $gl_cat_view, $gl_cat_where, $img_upload_maxsize, $img_upload_types, $user, $cookie;
   include("header.php");
   if (!is_user($user)) {
      Header ("Location:index.php");
   }
   $username = $cookie[1];
   OpenTable();
  echo "<table width=\"90%\" border=\"0\"><tr><td align=\"center\">";
  echo "<img src=\"modules/Hot_Or_Not/images/logo.gif\"><br><br></td></tr>";
  echo "<td align=\"center\" class=\"title\">"._HOTORNOTUSERUPLOADIMG." $username</td></tr>";
  echo "</table>";
  //handle uploaded image
   if ($upload == 1) {
      global $img_width, $img_upload_types, $img_upload_dir, $img_os, $img_resize_upl, $img_magick_path, $nukeurl;
      $img_updir = $img_upload_dir;
      //set upload dest path!
      $img_upl_path = "$img_path/$img_updir/";
      //check image name and category
      if ($img_upname != "" && $upload_cat_id > 0) {
         //check image types
         if (strstr($img_upload_types, $img_uptype)) {
            //check image size
            if ($img_upsize <= $img_upload_maxsize) {
               //check if file is uploaded, then save it!
               if (is_uploaded_file($img_upnametmp)) {
                  //fix uploaded filename!!
                  $realname = ereg_replace("[^-A-Za-z0-9._]", "", ereg_replace(" ", "_", ereg_replace("%20|^-", "_", $img_upname)));
                  if ($img_resize_upl == 1) {
                     //Now make a fullsize filename!
                     $img_fullsizename = "fullsize/".$username."_".$realname;
                     copy($img_upnametmp, "$img_upl_path/".$img_fullsizename);
                     copy($img_upnametmp, "$img_upl_path/".$username."_$realname");
                  } else {
                     //copy uploaded file to dest dir
                     copy($img_upnametmp, "$img_upl_path/".$username."_$realname");
                  }
                  $count = 0;
                  $tempname = $realname;
                  //resize the image
                  if ($img_resize_upl == 1) {
                     //set source path
                     $img_resize_src = $img_path_resize."/$img_path/$img_updir/".$img_fullsizename;
                     //set destination path
                     $img_resize_dest = $img_path_resize."/$img_path/$img_updir/".$username."_$realname";
                     //convert forward to backslash for win32 environment
                     if ($img_os == "win32") {
                        $img_resize_src = ereg_replace("[//]", "\\", $img_resize_src);
                        $img_resize_dest = ereg_replace("[//]", "\\", $img_resize_dest);
                     }
                     exec($img_magick_path." -resize $img_width $img_resize_src $img_resize_dest");
                  }
                  if ($img_resize_upl == 1) {
                     $vote_link = "$nukeurl$img_path/$img_updir/".$img_fullsizename;
                  } else {
                     $vote_link = "$nukeurl$img_path/$img_updir/".$username."_$realname";
                  }
                  //only insert when image is not in database!!!
                  $result = sql_query("select vote_id from ".$prefix."_hotornot_votes where vote_dir = '$img_updir' and vote_file = '$username_$realname'", $dbi);
                  $count = sql_num_rows($result, $dbi);
                  if ($count == 0) {
                     //get imagesize!
                     $img_size = @getimagesize($vote_link);
                     $vote_imgwidth = $img_size[0];
                     $vote_imgheight = $img_size[1];
                     sql_query("insert into ".$prefix."_hotornot_votes (vote_cat_id, vote_dir, vote_file, vote_link, vote_imgwidth, vote_imgheight, vote_userupload) values ($upload_cat_id, '$img_updir', '".$username."_$realname', '$vote_link', $vote_imgwidth, $vote_imgheight, '$username')", $dbi);
                     $result = sql_query("select vote_id from ".$prefix."_hotornot_votes where vote_dir = '$img_updir/$username' and vote_file = '$realname'", $dbi);
                     $uploadmsg = ""._HOTORNOTUSERUPLOADNEWIMG."<br>";
                  } else {
                     $uploadmsg = ""._HOTORNOTUSERUPLOADUPDIMG."<br>";
                  }
                  echo "<center><a href=\"$vote_link\" target=\"blank\"><img src=\"$img_path/$img_updir/".$username."_$realname\" width=\"$img_width\" border=\"0\"></a>";
                  list($vote_id) = sql_fetch_row($result, $dbi);
                  echo "<br>$uploadmsg<br><a href=\"modules.php?name=Hot_Or_Not&amp;h_op=comment&amp;cat=$upload_cat_id&amp;id=$vote_id\">Click here to comment image</a><br>";
                  echo "<a href=\"modules.php?name=Hot_Or_Not&amp;cat=$upload_cat_id&amp;i=0\">"._HOTORNOTBACK."</a></center>";
               }
            } else {
                  //file to big!
                  echo "<center>Maximum upload size: ".($img_upload_maxsize/1000)." kb.<br>";
                  echo "You tried to upload an image of ".($img_upsize/1000)." kb<br>";
                  echo "Please decrease the size of the image and try again!</center>";
            }
         } else {
               echo "<center>Image of type: ".$img_uptype." not allowed!<br>";
               echo "Please convert the image and try again!</center>";
         }
      }
   } else {
      //get directories where userupload is allowed
      $where = preg_replace("[vote_cat_id]", "cat_id", $gl_cat_where);
      $result = sql_query("select cat_id, cat_title from ".$prefix."_hotornot_cat where $where and cat_userupload = 0", $dbi);
      if (sql_num_rows($result, $dbi) > 0) {      
         echo "<form ENCTYPE=\"multipart/form-data\" method=\"post\" action=\"modules.php?name=Hot_Or_Not&amp;h_op=uploadimage\">";
         echo "<input type=\"hidden\" name=\"h_op\" value=\"uploadimage\">"
             ."<input type=\"hidden\" name=\"upload\" value=\"1\">"
                 .""._HOTORNOTCAT.": <select name=\"upload_cat_id\">";
         while (list($cat_id, $cat_title) = sql_fetch_row($result, $dbi)) {
            //assume that there are no file in the directory!!!
            echo "<option value=\"$cat_id\">$cat_title</option>";
         }
          echo "</select><br><br>"
              .""._HOTORNOTUPLOADFILE.": <input type=\"file\" name=\"userfile\" size=\"50\">";
           echo "<br><br><input type=\"submit\" value=\""._HOTORNOTUPLOAD."\"></form>";
           echo ""._HOTORNOTMAXUPLOADSIZE.": ".($img_upload_maxsize/1000)." kb<br>"._HOTORNOTMAXUPLOADTYPES.": ";
           $types = str_replace("|", ", ", $img_upload_types);
          echo $types;
       } else {
          echo _HOTORNOTNOUPLOADCAT;
       }
   }
   CloseTable();
   include("footer.php");
}

//check img/page nr
if (!isset($i) || $i < 5) $i = 0;
//check sort order
if (!isset($o) || ($o != 'ASC' && $o != 'DESC')) $o = 'DESC';
//check sort field
$sort_check = array('datetime', 'rate', 'nr', 'comment');
if (!isset($sort) || !in_array($sort, $sort_check)) $sort = 'rate';

//check view rights!!!
global $admin, $user;
$gl_cat_view = 0;
if (is_user($user)) $gl_cat_view = 1;
if (is_admin($admin)) $gl_cat_view = 2;

//Get >Active< Category!!!
global $prefix, $dbi;
if (!is_null($cat) && $cat != "") {
   $result = sql_query("select cat_id from ".$prefix."_hotornot_cat where cat_id = $cat and cat_view <= $gl_cat_view and cat_active = 0", $dbi);
   list($gl_cat_id) = sql_fetch_row($result, $dbi);
}

//If no category or a not-active category get first active category from table
if (is_null($gl_cat_id) && $cat != 0) {
   $result = sql_query("select cat_id from ".$prefix."_hotornot_cat where cat_active = 0 and cat_view <= $gl_cat_view order by cat_title", $dbi);
   list($gl_cat_id) = sql_fetch_row($result, $dbi);   
}

//Select all categories!!!
if ($cat == 0) {
   $gl_cat_id = 0;
   //create where statement to only included allowed categories
   $result = sql_query("select cat_id from ".$prefix."_hotornot_cat where cat_view <= $gl_cat_view and cat_active = 0", $dbi);
   while (list($cat_id) = sql_fetch_row($result, $dbi)) {
      $gl_cat_where .= "$cat_id,";
   }
   if ($gl_cat_where != "") {
      $gl_cat_where = "vote_cat_id IN (".substr($gl_cat_where, 0, strlen($gl_cat_where) - 1).")";
   }
}

//call appropiate function
switch ($h_op) {
  case "top":
     theindex($i, $sort, $o);
  break;
   case "unrated":
      theindex($i, $sort, $o, true);
   break;
   case "comment":
      comment($id, $add, $comments, $i, $cat, $state, $alter, $cid);
   break;
   case "uploadimage":
      if ($upload == 1) {
         $img_upnametmp = $HTTP_POST_FILES['userfile']['tmp_name'];
         $img_upname = $HTTP_POST_FILES['userfile']['name'];
         $img_uptype = $HTTP_POST_FILES['userfile']['type'];
         $img_upsize = $HTTP_POST_FILES['userfile']['size'];
         $img_path_resize = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
      }
      uploadimage($upload, $uploadmsg, $upload_cat_id, $img_upnametmp, $img_upname, $img_uptype, $img_upsize, $img_path_resize);
   break;
   default:
      theindex($i, $sort, $o);
   break;
}

?>



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum