[ Index ]
 

Code source de PHP NUKE 7.9

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

title

Body

[fermer]

/includes/ -> functions_admin.php (source)

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


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