[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/includes/ -> functions_admin.php (source)

   1  <?php
   2  /*=======================================================================
   3   Nuke-Evolution Basic: Enhanced PHP-Nuke Web Portal System
   4   =======================================================================*/
   5  
   6  /***************************************************************************
   7   *                            functions_admin.php
   8   *                            -------------------
   9   *   begin                : Saturday, Feb 13, 2001
  10   *   copyright            : (C) 2001 The phpBB Group
  11   *   email                : support@phpbb.com
  12   *
  13   *   Id: functions_admin.php,v 1.5.2.3 2002/07/19 17:03:47 psotfx Exp
  14   *
  15   ***************************************************************************/
  16  
  17  /***************************************************************************
  18  * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)
  19  *
  20  * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test
  21  * and debugging completed by the Elite Nukers and site members.
  22  *
  23  * You run this package at your sole risk. Nuke Cops and affiliates cannot
  24  * be held liable if anything goes wrong. You are advised to test this
  25  * package on a development system. Backup everything before implementing
  26  * in a production environment. If something goes wrong, you can always
  27  * backout and restore your backups.
  28  *
  29  * Installing and running this also means you agree to the terms of the AUP
  30  * found at Nuke Cops.
  31  *
  32  * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based
  33  * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
  34  * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is
  35  * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the
  36  * invalid_session error message.
  37  ***************************************************************************/
  38  
  39  /***************************************************************************
  40   *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
  41   *   by Tom Nitzschner (tom@toms-home.com)
  42   *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
  43   *
  44   *   As always, make a backup before messing with anything. All code
  45   *   release by me is considered sample code only. It may be fully
  46   *   functual, but you use it at your own risk, if you break it,
  47   *   you get to fix it too. No waranty is given or implied.
  48   *
  49   *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
  50   *   then on my site. All original header code and copyright messages will be maintained
  51   *   to give credit where credit is due. If you modify this, the only requirement is
  52   *   that you also maintain all original copyright messages. All my work is released
  53   *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
  54   *
  55   ***************************************************************************/
  56  
  57  /***************************************************************************
  58   *
  59   *   This program is free software; you can redistribute it and/or modify
  60   *   it under the terms of the GNU General Public License as published by
  61   *   the Free Software Foundation; either version 2 of the License, or
  62   *   (at your option) any later version.
  63   *
  64  **************************************************************************/
  65  
  66  /*****[CHANGES]**********************************************************
  67  -=[Mod]=-
  68        Attachment Mod                           v2.4.1       07/20/2005
  69   ************************************************************************/
  70  
  71  //
  72  // Simple version of jumpbox, just lists authed forums
  73  //
  74  
  75  if (!defined('IN_PHPBB'))
  76  {
  77      die('Hacking attempt');
  78  }
  79  
  80  function make_forum_select($box_name, $ignore_forum = false, $select_forum = '')
  81  {
  82          global $db, $userdata;
  83  
  84          $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
  85  
  86          $sql = 'SELECT f.forum_id, f.forum_name
  87              FROM ' . CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f
  88              WHERE f.cat_id = c.cat_id 
  89          ORDER BY c.cat_order, f.forum_order';
  90          if ( !($result = $db->sql_query($sql)) )
  91          {
  92                  message_die(GENERAL_ERROR, 'Couldn not obtain forums information', '', __LINE__, __FILE__, $sql);
  93          }
  94  
  95          $forum_list = '';
  96          while( $row = $db->sql_fetchrow($result) )
  97          {
  98                  if ( $is_auth_ary[$row['forum_id']]['auth_read'] && $ignore_forum != $row['forum_id'] )
  99                  {
 100                          $selected = ( $select_forum == $row['forum_id'] ) ? ' selected="selected"' : '';
 101                          $forum_list .= '<option value="' . $row['forum_id'] . '"' . $selected .'>' . $row['forum_name'] . '</option>';
 102                  }
 103          }
 104          $db->sql_freeresult($result);
 105  
 106          $forum_list = ( $forum_list == '' ) ? '<option value="-1">-- ! No Forums ! --</option>' : '<select name="' . $box_name . '">' . $forum_list . '</select>';
 107  
 108          return $forum_list;
 109  }
 110  
 111  //
 112  // Synchronise functions for forums/topics
 113  //
 114  function sync($type, $id = false)
 115  {
 116          global $db;
 117  
 118          switch($type)
 119          {
 120                  case 'all forums':
 121                          $sql = "SELECT forum_id
 122                                  FROM " . FORUMS_TABLE;
 123                          if ( !($result = $db->sql_query($sql)) )
 124                          {
 125                                  message_die(GENERAL_ERROR, 'Could not get forum IDs', '', __LINE__, __FILE__, $sql);
 126                          }
 127  
 128                          while( $row = $db->sql_fetchrow($result) )
 129                          {
 130                                  sync('forum', $row['forum_id']);
 131                          }
 132                          $db->sql_freeresult($result);
 133                             break;
 134  
 135                  case 'all topics':
 136                          $sql = "SELECT topic_id
 137                                  FROM " . TOPICS_TABLE;
 138                          if ( !($result = $db->sql_query($sql)) )
 139                          {
 140                                  message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
 141                          }
 142  
 143                          while( $row = $db->sql_fetchrow($result) )
 144                          {
 145                                  sync('topic', $row['topic_id']);
 146                          }
 147                          $db->sql_freeresult($result);
 148                          break;
 149  
 150                    case 'forum':
 151                          $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total
 152                                  FROM " . POSTS_TABLE . "
 153                                  WHERE forum_id = '$id'";
 154                          if ( !($result = $db->sql_query($sql)) )
 155                          {
 156                                  message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
 157                          }
 158  
 159                          if ( $row = $db->sql_fetchrow($result) )
 160                          {
 161                                  $last_post = ( $row['last_post'] ) ? $row['last_post'] : 0;
 162                                  $total_posts = ($row['total']) ? $row['total'] : 0;
 163                          }
 164                          else
 165                          {
 166                                  $last_post = 0;
 167                                  $total_posts = 0;
 168                          }
 169                          $db->sql_freeresult($result);
 170                          
 171                          $sql = "SELECT COUNT(topic_id) AS total
 172                                  FROM " . TOPICS_TABLE . "
 173                                  WHERE forum_id = '$id'";
 174                          if ( !($result = $db->sql_query($sql)) )
 175                          {
 176                                  message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql);
 177                          }
 178  
 179                          $total_topics = ( $row = $db->sql_fetchrow($result) ) ? ( ( $row['total'] ) ? $row['total'] : 0 ) : 0;
 180  
 181                          $sql = "UPDATE " . FORUMS_TABLE . "
 182                                  SET forum_last_post_id = '$last_post', forum_posts = '$total_posts', forum_topics = '$total_topics'
 183                                  WHERE forum_id = '$id'";
 184                          if ( !$db->sql_query($sql) )
 185                          {
 186                                  message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
 187                          }
 188                          $db->sql_freeresult($result);
 189                          break;
 190  
 191                  case 'topic':
 192                          $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts
 193                                  FROM " . POSTS_TABLE . "
 194                                  WHERE topic_id = '$id'";
 195                          if ( !($result = $db->sql_query($sql)) )
 196                          {
 197                                  message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
 198                          }
 199  
 200                          if ( $row = $db->sql_fetchrow($result) )
 201                          {
 202                  if ($row['total_posts'])
 203                  {
 204                      // Correct the details of this topic
 205                      $sql = 'UPDATE ' . TOPICS_TABLE . ' 
 206                          SET topic_replies = ' . ($row['total_posts'] - 1) . ', topic_first_post_id = ' . $row['first_post'] . ', topic_last_post_id = ' . $row['last_post'] . "
 207                          WHERE topic_id = $id";
 208  
 209                      if (!$db->sql_query($sql))
 210                      {
 211                          message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
 212                      }
 213                  }
 214                  else
 215                  {
 216                      // There are no replies to this topic
 217                      // Check if it is a move stub
 218                      $sql = 'SELECT topic_moved_id 
 219                          FROM ' . TOPICS_TABLE . " 
 220                          WHERE topic_id = $id";
 221  
 222                      if (!($result = $db->sql_query($sql)))
 223                      {
 224                          message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
 225                      }
 226  
 227                      if ($row = $db->sql_fetchrow($result))
 228                      {
 229                          if (!$row['topic_moved_id'])
 230                          {
 231                              $sql = 'DELETE FROM ' . TOPICS_TABLE . " WHERE topic_id = $id";
 232              
 233                              if (!$db->sql_query($sql))
 234                              {
 235                                  message_die(GENERAL_ERROR, 'Could not remove topic', '', __LINE__, __FILE__, $sql);
 236                              }
 237                          }
 238                      }
 239  
 240                      $db->sql_freeresult($result);
 241                  }
 242                          }
 243  /*****[BEGIN]******************************************
 244   [ Mod:    Attachment Mod                      v2.4.1 ]
 245   ******************************************************/
 246                          attachment_sync_topic($id);
 247  /*****[END]********************************************
 248   [ Mod:    Attachment Mod                      v2.4.1 ]
 249   ******************************************************/
 250                          break;
 251          }
 252  
 253          return true;
 254  }
 255  
 256  ?>


Generated: Wed Jun 6 11:38:01 2007 Cross-referenced by PHPXref 0.7