Verzeichnisstruktur phpBB-2.0.0


Veröffentlicht
03.04.2002

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

functions_admin.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 5.31 KiB


001  <?php
002  /***************************************************************************
003   *                            functions_admin.php
004   *                            -------------------
005   *   begin                : Saturday, Feb 13, 2001
006   *   copyright            : (C) 2001 The phpBB Group
007   *   email                : support@phpbb.com
008   *
009   *   $Id$
010   *
011   *
012   ***************************************************************************/
013   
014  /***************************************************************************
015   *
016   *   This program is free software; you can redistribute it and/or modify
017   *   it under the terms of the GNU General Public License as published by
018   *   the Free Software Foundation; either version 2 of the License, or
019   *   (at your option) any later version.
020   *
021   *
022   ***************************************************************************/
023   
024  //
025  // Simple version of jumpbox, just lists authed forums
026  //
027  function make_forum_select($box_name, $ignore_forum = false, $select_forum = '')
028  {
029      global $db, $userdata, $lang;
030   
031      $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
032   
033      $sql = 'SELECT f.forum_id, f.forum_name
034          FROM ' . CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f
035          WHERE f.cat_id = c.cat_id 
036          ORDER BY c.cat_order, f.forum_order';
037      if ( !($result = $db->sql_query($sql)) )
038      {
039          message_die(GENERAL_ERROR, 'Couldn not obtain forums information', '', __LINE__, __FILE__, $sql);
040      }
041   
042      $forum_list = '';
043      while( $row = $db->sql_fetchrow($result) )
044      {
045          if ( $is_auth_ary[$row['forum_id']]['auth_read'] && $ignore_forum != $row['forum_id'] )
046          {
047              $selected = ( $select_forum == $row['forum_id'] ) ? ' selected="selected"' : '';
048              $forum_list .= '<option value="' . $row['forum_id'] . '"' . $selected .'>' . $row['forum_name'] . '</option>';
049          }
050      }
051   
052      $forum_list = ( $forum_list == '' ) ? $lang['No_forums'] : '<select name="' . $box_name . '">' . $forum_list . '</select>';
053   
054      return $forum_list;
055  }
056   
057  //
058  // Synchronise functions for forums/topics
059  //
060  function sync($type, $id = false)
061  {
062      global $db;
063   
064      switch($type)
065      {
066          case 'all forums':
067              $sql = "SELECT forum_id
068                  FROM " . FORUMS_TABLE;
069              if ( !($result = $db->sql_query($sql)) )
070              {
071                  message_die(GENERAL_ERROR, 'Could not get forum IDs', '', __LINE__, __FILE__, $sql);
072              }
073   
074              while( $row = $db->sql_fetchrow($result) )
075              {
076                  sync('forum', $row['forum_id']);
077              }
078                 break;
079   
080          case 'all topics':
081              $sql = "SELECT topic_id
082                  FROM " . TOPICS_TABLE;
083              if ( !($result = $db->sql_query($sql)) )
084              {
085                  message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
086              }
087   
088              while( $row = $db->sql_fetchrow($result) )
089              {
090                  sync('topic', $row['topic_id']);
091              }
092              break;
093   
094            case 'forum':
095              $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total 
096                  FROM " . POSTS_TABLE . "  
097                  WHERE forum_id = $id";
098              if ( !($result = $db->sql_query($sql)) )
099              {
100                  message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
101              }
102   
103              if ( $row = $db->sql_fetchrow($result) )
104              {
105                  $last_post = ( $row['last_post'] ) ? $row['last_post'] : 0;
106                  $total_posts = ($row['total']) ? $row['total'] : 0;
107              }
108              else
109              {
110                  $last_post = 0;
111                  $total_posts = 0;
112              }
113   
114              $sql = "SELECT COUNT(topic_id) AS total
115                  FROM " . TOPICS_TABLE . "
116                  WHERE forum_id = $id";
117              if ( !($result = $db->sql_query($sql)) )
118              {
119                  message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql);
120              }
121   
122              $total_topics = ( $row = $db->sql_fetchrow($result) ) ? ( ( $row['total'] ) ? $row['total'] : 0 ) : 0;
123   
124              $sql = "UPDATE " . FORUMS_TABLE . "
125                  SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics
126                  WHERE forum_id = $id";
127              if ( !$db->sql_query($sql) )
128              {
129                  message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
130              }
131              break;
132   
133          case 'topic':
134              $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts
135                  FROM " . POSTS_TABLE . "
136                  WHERE topic_id = $id";
137              if ( !($result = $db->sql_query($sql)) )
138              {
139                  message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
140              }
141   
142              if ( $row = $db->sql_fetchrow($result) )
143              {
144                  if ($row['total_posts'])
145                  {
146                      // Correct the details of this topic
147                      $sql = 'UPDATE ' . TOPICS_TABLE . 
148                          SET topic_replies = ' . ($row['total_posts'] - 1) . ', topic_first_post_id = ' . $row['first_post'] . ', topic_last_post_id = ' . $row['last_post'] . "
149                          WHERE topic_id = $id";
150   
151                      if (!$db->sql_query($sql))
152                      {
153                          message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
154                      }
155                  }
156                  else
157                  {
158                      // There are no replies to this topic
159                      // Check if it is a move stub
160                      $sql = 'SELECT topic_moved_id 
161                          FROM ' . TOPICS_TABLE . " 
162                          WHERE topic_id = $id";
163   
164                      if (!($result = $db->sql_query($sql)))
165                      {
166                          message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
167                      }
168   
169                      if ($row = $db->sql_fetchrow($result))
170                      {
171                          if (!$row['topic_moved_id'])
172                          {
173                              $sql = 'DELETE FROM ' . TOPICS_TABLE . " WHERE topic_id = $id";
174              
175                              if (!$db->sql_query($sql))
176                              {
177                                  message_die(GENERAL_ERROR, 'Could not remove topic', '', __LINE__, __FILE__, $sql);
178                              }
179                          }
180                      }
181   
182                      $db->sql_freeresult($result);
183                  }
184              }
185              break;
186      }
187      
188      return true;
189  }
190   
191  ?>