[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_plugins/forum/ -> forum_mod.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_plugins/forum/forum_mod.php,v $
  14  |     $Revision: 1.10 $
  15  |     $Date: 2006/01/05 09:06:46 $
  16  |     $Author: sweetas $
  17  +----------------------------------------------------------------------------+
  18  */
  19  if (!defined('e107_INIT')) { exit; }
  20  
  21  @include_once e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_admin.php';
  22  @include_once e_PLUGIN.'forum/languages/English/lan_forum_admin.php';
  23      
  24  function forum_thread_moderate($p)
  25  {
  26      global $sql;
  27      foreach($p as $key => $val) {
  28          if (preg_match("#(.*?)_(\d+)_x#", $key, $matches))
  29          {
  30              $act = $matches[1];
  31              $id = intval($matches[2]);
  32               
  33              switch($act)
  34              {
  35                  case 'lock' :
  36                  $sql->db_Update("forum_t", "thread_active='0' WHERE thread_id='$id' ");
  37                  return FORLAN_CLOSE;
  38                  break;
  39                   
  40                  case 'unlock' :
  41                  $sql->db_Update("forum_t", "thread_active='1' WHERE thread_id='$id' ");
  42                  return FORLAN_OPEN;
  43                  break;
  44                   
  45                  case 'stick' :
  46                  $sql->db_Update("forum_t", "thread_s='1' WHERE thread_id='$id' ");
  47                  return FORLAN_STICK;
  48                  break;
  49                   
  50                  case 'unstick' :
  51                  $sql->db_Update("forum_t", "thread_s='0' WHERE thread_id='$id' ");
  52                  return FORLAN_UNSTICK;
  53                  break;
  54                   
  55                  case 'delete' :
  56                  return forum_delete_thread($id);
  57                  break;
  58                   
  59              }
  60          }
  61      }
  62  }
  63      
  64  function forum_delete_thread($thread_id)
  65  {
  66      global $sql;
  67      @require_once(e_PLUGIN.'forum/forum_class.php');
  68      $f =& new e107forum;
  69      $sql->db_Select("forum_t", "*", "thread_id='".intval($thread_id)."' ");
  70      $row = $sql->db_Fetch();
  71       
  72      if ($row['thread_parent'])
  73      {
  74          // post is a reply?
  75          $sql->db_Delete("forum_t", "thread_id='".intval($thread_id)."' ");
  76          // dec forum reply count by 1
  77          $sql->db_Update("forum", "forum_replies=forum_replies-1 WHERE forum_id='".$row['thread_forum_id']."'");
  78          // dec thread reply count by 1
  79          $sql->db_Update("forum_t", "thread_total_replies=thread_total_replies-1 WHERE thread_id='".$row['thread_parent']."'");
  80          // dec user forum post count by 1
  81          $tmp = explode(".", $row['thread_user']);
  82          $uid = intval($tmp[0]);
  83          if($uid > 0)
  84          {
  85              $sql->db_Update("user", "user_forums=user_forums-1 WHERE user_id='".$uid."'");
  86          }
  87          // update lastpost info
  88          $f->update_lastpost('thread', $row['thread_parent']);
  89          $f->update_lastpost('forum', $row['thread_forum_id']);
  90          return FORLAN_154;
  91      }
  92      else
  93      {
  94          // post is thread
  95          // delete poll if there is one
  96          $sql->db_Delete("poll", "poll_datestamp='".intval($thread_id)."'");
  97          //decrement user post counts
  98          forum_userpost_count("WHERE thread_id = '".intval($thread_id)."' OR thread_parent = '".intval($thread_id)."'", "dec");
  99          // delete replies and grab how many there were
 100          $count = $sql->db_Delete("forum_t", "thread_parent='".intval($thread_id)."'");
 101          // delete the post itself
 102          $sql->db_Delete("forum_t", "thread_id='".intval($thread_id)."'");
 103          // update thread/reply counts
 104          $sql->db_Update("forum", "forum_threads=forum_threads-1, forum_replies=forum_replies-$count WHERE forum_id='".$row['thread_forum_id']."'");
 105          // update lastpost info
 106          $f->update_lastpost('forum', $row['thread_forum_id']);
 107          return FORLAN_6.($count ? ", ".$count." ".FORLAN_7."." : ".");
 108      }
 109  }
 110  
 111  function forum_userpost_count($where = "", $type = "dec")
 112  {
 113      global $sql;
 114  
 115      $qry = "
 116      SELECT thread_user, count(thread_user) AS cnt FROM #forum_t 
 117      {$where}
 118      GROUP BY thread_user
 119      ";
 120  
 121      if($sql->db_Select_gen($qry))
 122      {
 123          $uList = $sql->db_getList();
 124          foreach($uList as $u)
 125          {
 126              $tmp = explode(".", $u['thread_user']);
 127              $uid = intval($tmp[0]);
 128              if($uid > 0)
 129              {
 130                  if("set" == $type)
 131                  {
 132                      $sql->db_Update("user", "user_forums={$u['cnt']} WHERE user_id='".$uid."'");
 133                  }
 134                  else
 135                  {
 136                      $sql->db_Update("user", "user_forums=user_forums-{$u['cnt']} WHERE user_id='".$uid."'");
 137                  }
 138              }
 139          }
 140      }
 141  }
 142  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7