[ Index ]
 

Code source de PHP NUKE 7.9

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/News/ -> index.php (source)

   1  <?php
   2  
   3  /************************************************************************/

   4  /* PHP-NUKE: Web Portal System                                          */

   5  /* ===========================                                          */

   6  /*                                                                      */

   7  /* Copyright (c) 2005 by Francisco Burzi                                */

   8  /* http://phpnuke.org                                                   */

   9  /*                                                                      */

  10  /* This program is free software. You can redistribute it and/or modify */

  11  /* it under the terms of the GNU General Public License as published by */

  12  /* the Free Software Foundation; either version 2 of the License.       */

  13  /************************************************************************/

  14  
  15  if (!defined('MODULE_FILE')) {
  16      die ("You can't access this file directly...");
  17  }
  18  
  19  define('INDEX_FILE', true);
  20  require_once ("mainfile.php");
  21  $module_name = basename(dirname(__FILE__));
  22  get_lang($module_name);
  23  
  24  function theindex($new_topic="0") {
  25     global $db, $storyhome, $topicname, $topicimage, $topictext, $datetime, $user, $cookie, $nukeurl, $prefix, $multilingual, $currentlang, $articlecomm, $sitename, $user_news, $userinfo;
  26          if (is_user($user)) { getusrinfo($user); }
  27      $new_topic = intval($new_topic);
  28      if ($multilingual == 1) {
  29          $querylang = "AND (alanguage='$currentlang' OR alanguage='')";
  30      } else {
  31          $querylang = "";
  32      }
  33      include ("header.php");
  34      automated_news();
  35          if (isset($userinfo['setstorynum']) AND $user_news == 1) {
  36                  $storynum = $userinfo['setstorynum'];
  37      } else {
  38          $storynum = $storyhome;
  39      }
  40      if ($new_topic == 0) {
  41          $qdb = "WHERE (ihome='0' OR catid='0')";
  42          $home_msg = "";
  43      } else {
  44          $qdb = "WHERE topic='$new_topic'";
  45          $result_a = $db->sql_query("SELECT topictext FROM ".$prefix."_topics WHERE topicid='$new_topic'");
  46          $row_a = $db->sql_fetchrow($result_a);
  47          $numrows_a = $db->sql_numrows($result_a);
  48          $topic_title = filter($row_a['topictext'], "nohtml");
  49          OpenTable();
  50          if ($numrows_a == 0) {
  51              echo "<center><font class=\"title\">$sitename</font><br><br>"._NOINFO4TOPIC."<br><br>[ <a href=\"modules.php?name=News\">"._GOTONEWSINDEX."</a> | <a href=\"modules.php?name=Topics\">"._SELECTNEWTOPIC."</a> ]</center>";
  52          } else {
  53              $db->sql_query("UPDATE ".$prefix."_topics SET counter=counter+1");
  54              echo "<center><font class=\"title\">$sitename: $topic_title</font><br><br>"
  55              ."<form action=\"modules.php?name=Search\" method=\"post\">"
  56              ."<input type=\"hidden\" name=\"topic\" value=\"$new_topic\">"
  57              .""._SEARCHONTOPIC.": <input type=\"name\" name=\"query\" size=\"30\">&nbsp;&nbsp;"
  58              ."<input type=\"submit\" value=\""._SEARCH."\">"
  59              ."</form>"
  60              ."[ <a href=\"index.php\">"._GOTOHOME."</a> | <a href=\"modules.php?name=Topics\">"._SELECTNEWTOPIC."</a> ]</center>";
  61          }
  62          CloseTable();
  63          echo "<br>";
  64      }
  65      $result = $db->sql_query("SELECT sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes, acomm, score, ratings FROM ".$prefix."_stories $qdb $querylang ORDER BY sid DESC limit $storynum");
  66      while ($row = $db->sql_fetchrow($result)) {
  67          $s_sid = intval($row['sid']);
  68          $catid = intval($row['catid']);
  69          $aid = filter($row['aid'], "nohtml");
  70          $title = filter($row['title'], "nohtml");
  71          $time = $row['time'];
  72          $hometext = filter($row['hometext']);
  73          $bodytext = filter($row['bodytext']);
  74          $comments = intval($row['comments']);
  75          $counter = intval($row['counter']);
  76          $topic = intval($row['topic']);
  77          $informant = filter($row['informant'], "nohtml");
  78          $notes = filter($row['notes']);
  79          $acomm = intval($row['acomm']);
  80          $score = intval($row['score']);
  81          $ratings = intval($row['ratings']);
  82          if ($catid > 0) {
  83              $row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories_cat WHERE catid='$catid'"));
  84              $cattitle = stripslashes(check_html($row2['title'], "nohtml"));
  85          }
  86          getTopics($s_sid);
  87          formatTimestamp($time);
  88          $subject = filter($subject, "nohtml");
  89          $introcount = strlen($hometext);
  90          $fullcount = strlen($bodytext);
  91          $totalcount = $introcount + $fullcount;
  92          $c_count = $comments;
  93          $r_options = "";
  94          if (isset($userinfo['umode'])) { $r_options .= "&amp;mode=".$userinfo['umode']; }
  95          if (isset($userinfo['uorder'])) { $r_options .= "&amp;order=".$userinfo['uorder']; }
  96          if (isset($userinfo['thold'])) { $r_options .= "&amp;thold=".$userinfo['thold']; }
  97          $story_link = "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$s_sid$r_options\">";
  98          $morelink = "(";
  99          if ($fullcount > 0 OR $c_count > 0 OR $articlecomm == 0 OR $acomm == 1) {
 100              $morelink .= "$story_link<b>"._READMORE."</b></a> | ";
 101          } else {
 102              $morelink .= "";
 103          }
 104          if ($fullcount > 0) { $morelink .= "$totalcount "._BYTESMORE." | "; }
 105          if ($articlecomm == 1 AND $acomm == 0) {
 106              if ($c_count == 0) { $morelink .= "$story_link"._COMMENTSQ."</a>"; } elseif ($c_count == 1) { $morelink .= "$story_link$c_count "._COMMENT."</a>"; } elseif ($c_count > 1) { $morelink .= "$story_link$c_count "._COMMENTS."</a>"; }
 107          }
 108          $sid = intval($s_sid);
 109          if ($catid != 0) {
 110              $row3 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories_cat WHERE catid='$catid'"));
 111              $title1 = filter($row3['title'], "nohtml");
 112              $title = "<a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\"><font class=\"storycat\">$title1</font></a>: $title";
 113              $morelink .= " | <a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\">$title1</a>";
 114          }
 115          if ($score != 0) {
 116              $rated = substr($score / $ratings, 0, 4);
 117          } else {
 118              $rated = 0;
 119          }
 120          $morelink .= " | "._SCORE." $rated";
 121          $morelink .= ")";
 122          $morelink = str_replace(" |  | ", " | ", $morelink);
 123          themeindex($aid, $informant, $datetime, $title, $counter, $topic, $hometext, $notes, $morelink, $topicname, $topicimage, $topictext);
 124      }
 125      include ("footer.php");
 126  }
 127  
 128  function rate_article($sid, $score, $random_num="0", $gfx_check) {
 129      global $prefix, $db, $ratecookie, $sitename, $r_options, $sitekey, $gfx_chk, $module_name;
 130      if (isset($random_num)) {
 131          $datekey = date("F j");
 132          $rcode = hexdec(md5($_SERVER['HTTP_USER_AGENT'] . $sitekey . $random_num . $datekey));
 133          $code = substr($rcode, 2, 3);
 134          if (extension_loaded("gd") AND $code != $gfx_check AND $gfx_chk != 0) {
 135              mt_srand ((double)microtime()*1000000);
 136              $maxran = 1000000;
 137              $random_num = mt_rand(0, $maxran);
 138              include ("header.php");
 139              title("$sitename: "._ARTICLERATING."");
 140              OpenTable();
 141              $row = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories WHERE sid='$sid'"));
 142              $row[title] = filter($row[title], "nohtml");
 143              echo "<center><a href=\"modules.php?name=$module_name&file=article&sid=$sid$r_options\"><b>".$row['title']."</b></a><br>"._ARTICLERATING.": <img src=\"images/articles/stars-$score.gif\" border=\"0\" alt=\"$score/5\" title=\"$score/5\"> ($score/5)<br><br>";
 144              echo ""._TOFINISHRATINGERROR."<br><br>";
 145              echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
 146              echo ""._SECURITYCODE.":<br><img src='?gfx=gfx_little&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'><br><br>\n";
 147              echo ""._TYPESECCODE.":<br><input type=\"text\" NAME=\"gfx_check\" SIZE=\"3\" MAXLENGTH=\"3\"><br>\n";
 148              echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num\"><br>\n";
 149              echo "<input type=\"hidden\" name=\"score\" value=\"$score\"><br>\n";
 150              echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n";
 151              echo "<input type=\"hidden\" name=\"op\" value=\"rate_article\">";
 152              echo "<input type=\"submit\" value=\""._CASTMYVOTE."\"></font></center></form>";
 153              CloseTable();
 154              include ("footer.php");
 155              die();
 156          } else {
 157              $score = intval($score);
 158              $sid = intval($sid);
 159              if ($score) {
 160                  if ($score > 5) { $score = 5; }
 161                  if ($score < 1) { $score = 1; }
 162                  if ($score != 1 AND $score != 2 AND $score != 3 AND $score != 4 AND $score != 5) {
 163                      Header("Location: index.php");
 164                      die();
 165                  }
 166                  $ip = $_SERVER['REMOTE_ADDR'];
 167                  $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_stories WHERE sid='$sid' AND rating_ip='$ip'"));
 168                  if ($num != 0) {
 169                      Header("Location: modules.php?name=News&op=rate_complete&sid=$sid&rated=1");
 170                      die();
 171                  }
 172                  if (isset($ratecookie)) {
 173                      $rcookie = base64_decode($ratecookie);
 174                      $rcookie = addslashes($rcookie);
 175                      $r_cookie = explode(":", $rcookie);
 176                  }
 177                  for ($i=0; $i < sizeof($r_cookie); $i++) {
 178                      if ($r_cookie[$i] == $sid) {
 179                          $a = 1;
 180                      }
 181                  }
 182                  if ($a == 1) {
 183                      Header("Location: modules.php?name=News&op=rate_complete&sid=$sid&rated=1");
 184                      die();
 185                  } else {
 186                      $ip = $_SERVER['REMOTE_ADDR'];
 187                      $result = $db->sql_query("update ".$prefix."_stories set score=score+$score, ratings=ratings+1, rating_ip='$ip' where sid='$sid'");
 188                      $info = base64_encode("$rcookie$sid:");
 189                      setcookie("ratecookie","$info",time()+86400);
 190                      update_points(7);
 191                      Header("Location: modules.php?name=News&op=rate_complete&sid=$sid&score=$score");
 192                  }
 193              } else {
 194                  include ("header.php");
 195                  title("$sitename: "._ARTICLERATING."");
 196                  OpenTable();
 197                  echo "<center>"._DIDNTRATE."<br><br>"
 198                  .""._GOBACK."</center>";
 199                  CloseTable();
 200                  include ("footer.php");
 201              }
 202          }
 203      } else {
 204          mt_srand ((double)microtime()*1000000);
 205          $maxran = 1000000;
 206          $random_num = mt_rand(0, $maxran);
 207          if (extension_loaded("gd") AND $gfx_chk != 0 ) {
 208              include ("header.php");
 209              title("$sitename: "._ARTICLERATING."");
 210              OpenTable();
 211              $row = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories WHERE sid='$sid'"));
 212              echo "<center><a href=\"modules.php?name=$module_name&file=article&sid=$sid$r_options\"><b>".$row['title']."</b></a><br>"._ARTICLERATING.": <img src=\"images/articles/stars-$score.gif\" border=\"0\" alt=\"$score/5\" title=\"$score/5\"> ($score/5)<br><br>";
 213              echo ""._TOFINISHRATING."<br><br>";
 214              echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
 215              echo ""._SECURITYCODE.":<br><img src='?gfx=gfx_little&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'><br><br>\n";
 216              echo ""._TYPESECCODE.":<br><input type=\"text\" NAME=\"gfx_check\" SIZE=\"3\" MAXLENGTH=\"3\"><br>\n";
 217              echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num\"><br>\n";
 218              echo "<input type=\"hidden\" name=\"score\" value=\"$score\"><br>\n";
 219              echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\">\n";
 220              echo "<input type=\"hidden\" name=\"op\" value=\"rate_article\">";
 221              echo "<input type=\"submit\" value=\""._CASTMYVOTE."\"></font></center></form>";
 222              CloseTable();
 223              include ("footer.php");
 224          } else {
 225              $random_num = "$random_num";
 226              $gfx_check = "$code";
 227              Header("Location: modules.php?name=$module_name&op=rate_article&sid=$sid&score=$score&random_num=$random_num");
 228          }
 229      }
 230  }
 231  
 232  function rate_complete($sid, $rated=0, $score) {
 233      global $sitename, $user, $cookie, $module_name, $userinfo;
 234      $r_options = "";
 235      if (is_user($user)) {
 236                  getusrinfo($user);
 237          if (isset($userinfo['umode'])) { $r_options .= "&amp;mode=".$userinfo['umode']; }
 238          if (isset($userinfo['uorder'])) { $r_options .= "&amp;order=".$userinfo['uorder']; }
 239          if (isset($userinfo['thold'])) { $r_options .= "&amp;thold=".$userinfo['thold']; }
 240      }
 241      include ("header.php");
 242      title("$sitename: "._ARTICLERATING."");
 243      OpenTable();
 244      if ($rated == 0) {
 245          $row = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories WHERE sid='$sid'"));
 246          $row[title] = filter($row[title], "nohtml");
 247          echo "<center><a href=\"modules.php?name=$module_name&file=article&sid=$sid$r_options\"><b>".$row['title']."</b></a><br>"._YOURATEDARTICLE.": <img src=\"images/articles/stars-$score.gif\" border=\"0\" alt=\"$score/5\" title=\"$score/5\"> ($score/5)<br><br>";
 248          echo "<center>"._THANKSVOTEARTICLE."<br><br>"
 249          ."[ <a href=\"modules.php?name=$module_name&amp;file=article&amp;sid=$sid$r_options\">"._BACKTOARTICLEPAGE."</a> ]</center>";
 250      } elseif ($rated == 1) {
 251          echo "<center>"._ALREADYVOTEDARTICLE."<br><br>"
 252          ."[ <a href=\"modules.php?name=$module_name&amp;file=article&amp;sid=$sid$r_options\">"._BACKTOARTICLEPAGE."</a> ]</center>";
 253      }
 254      CloseTable();
 255      include ("footer.php");
 256  }
 257  
 258  if (!(isset($new_topic))) { $new_topic = 0; }
 259  if (!(isset($op))) { $op = ""; }
 260  
 261  switch ($op) {
 262  
 263      default:
 264      theindex($new_topic);
 265      break;
 266  
 267      case "rate_article":
 268      rate_article($sid, $score, $random_num, $gfx_check);
 269      break;
 270  
 271      case "rate_complete":
 272      rate_complete($sid, $rated, $score);
 273      break;
 274  
 275  }
 276  
 277  ?>


Généré le : Sun Apr 1 11:11:59 2007 par Balluche grâce à PHPXref 0.7