root/admin/index.php

Revision 307, 22.6 kB (checked in by Nafania, 2 years ago)

Создаем табличку для чата (забыл совсем про нее). Меняем записи в логе о редактировании торрента и ставим flags = 9, только тогда, когда надо а не всегда. Замена везде exit на нормальные функции, которые вырубает кеш и закрывают соединение с базой, ибо это правильно. Небольшая фича на форуме, выделяем текст поста + клик на нике = быстрая цитата. Баны в чате и закрытие комментов в юзер панели. Вроде все.

Line 
1 <?php
2 /***************************************************************************</span>
3 <span class="code-comment"> *                             (admin) index.php
4  *                            -------------------
5  *   begin                : Saturday, Feb 13, 2001
6  *   copyright            : (C) 2001 The phpBB Group
7  *   email                : support@phpbb.com
8  *
9  *   $Id: index.php,v 1.40.2.8 2005/09/18 16:17:20 acydburn Exp $
10  *
11  *
12  ***************************************************************************/
13
14 /***************************************************************************
15  *
16  *   This program is free software; you can redistribute it and/or modify
17  *   it under the terms of the GNU General Public License as published by
18  *   the Free Software Foundation; either version 2 of the License, or
19  *   (at your option) any later version.
20  *
21  ***************************************************************************/
22
23 define('IN_PHPBB', 1);
24
25 //</span>
26 <span class="code-comment">// Load default header
27 //
28 $no_page_header = true;
29 $root_path = './../';</span>
30 <span class="code-lang">require($root_path . 'extension.inc');
31 require('./pagestart.' . $phpEx);
32
33 $pane = ( isset($_GET['pane']) ? $_GET['pane'] : '' );</span>
34 <span class="code-lang">
35 if ( isset($_POST['delete_cache']) ) {
36     $cache->purge();
37 }
38 elseif ( isset($_POST['delete_pics_cache']) ) {
39     if ( $dir = @opendir($root_path . '/cache/png/') ) {
40         while (($entry = readdir($dir)) !== false)
41         {
42             if ( strpos($entry, '.png') !== false )
43             {
44                 @unlink($root_path . '/cache/png/' . $entry);
45             }
46         }
47         closedir($dir);
48     }
49 }
50
51
52 //</span>
53 <span class="code-comment">// Generate relevant output
54 //
55 if( $pane == 'left' )</span>
56 <span class="code-keyword">{
57     $module = array();
58     $setmodules = 1;
59      if ( $dir = @opendir(".") ) {
60         while( $file = @readdir($dir) )
61          {
62             if( preg_match("/^admin_.*?\." . $phpEx . "$/", $file) ) {
63                         require_once('./' . $file);
64                }
65          }
66
67         @closedir($dir);
68      }
69
70      unset($setmodules);
71
72      include('./page_header_admin.'.$phpEx);
73
74     $template->set_filenames(array(
75         "body" => "../admin/index_navigate.tpl")
76      );
77
78     $template->assign_vars(array(
79         "U_FORUM_INDEX" => append_sid($root_path . 'phpbb2.php'),
80         "U_ADMIN_INDEX" => append_sid("index.$phpEx?pane=right") )
81      );
82
83      ksort($module);
84
85      $page = extract_current_page();
86     $page['page_name'];
87
88     foreach ( $module AS $cat => $action_array ) {
89         $cat = ( isset($lang[$cat]) ) ? $lang[$cat] : str_replace("/_/", " ", $cat);
90
91             $template->assign_block_vars("catrow", array(
92                         "ADMIN_CATEGORY" => $cat)
93                 );
94
95                 ksort($action_array);
96
97                 $row_count = 0;
98                 foreach ( $action_array AS $action => $file ) {
99                         $row_color = ( !($row_count%2) ) ? $theme['td_color1'] : $theme['td_color2'];
100                         $row_class = ( !($row_count%2) ) ? $theme['td_class1'] : $theme['td_class2'];
101
102                         $action = ( isset($lang[$action]) ) ? $lang[$action] : preg_replace("/_/", " ", $action);
103
104                         $template->assign_block_vars("catrow.modulerow", array(
105                                 "ROW_COLOR" => "#" . $row_color,
106                                 "ROW_CLASS" => $row_class,
107                                 'ACTIVE' => ( $page['page_name'] == $file ) ? 1 : 0,
108
109                                 "ADMIN_MODULE" => $action,
110                                 "U_ADMIN_MODULE" => append_sid($file))
111                         );
112                         $row_count++;
113
114
115                         if ( isset($action_array['submodules']) ) {
116
117                         }
118                 }
119         }
120         $template->display("body");
121         include('./page_footer_admin.'.$phpEx);
122 }
123 elseif( $pane == 'right' )
124 {
125
126         include('page_header_admin.'.$phpEx);
127
128         $template->set_filenames(array(
129                 "body" => "../admin/index_body.tpl")
130         );
131
132         //
133         // Get forum statistics
134         //
135         $total_posts = get_db_stat('postcount');
136         $total_users = get_db_stat('usercount');
137         $total_topics = get_db_stat('topiccount');
138
139         $start_date = create_date($config['onlinesince']);
140
141         $boarddays = ( time() - $config['onlinesince'] ) / 86400;
142
143         $posts_per_day = sprintf("%.2f", $total_posts / $boarddays);
144         $topics_per_day = sprintf("%.2f", $total_topics / $boarddays);
145         $users_per_day = sprintf("%.2f", $total_users / $boarddays);
146
147         $avatar_dir_size = 0;
148
149         if ($avatar_dir = @opendir($root_path . $config['avatar_path']))
150         {
151                 while( $file = @readdir($avatar_dir) )
152                 {
153                         if( $file != "." && $file != ".." )
154                         {
155                                 $avatar_dir_size += @filesize($root_path . $config['avatar_path'] . "/" . $file);
156                         }
157                 }
158                 @closedir($avatar_dir);
159                 $avatar_dir_size = mksize($avatar_dir_size);
160
161         }
162         else
163         {
164                 // Couldn't open Avatar dir.
165                 $avatar_dir_size = $lang['not_available'];
166         }
167
168         if($posts_per_day > $total_posts)
169         {
170                 $posts_per_day = $total_posts;
171         }
172
173         if($topics_per_day > $total_topics)
174         {
175                 $topics_per_day = $total_topics;
176         }
177
178         if($users_per_day > $total_users)
179         {
180                 $users_per_day = $total_users;
181         }
182
183         //
184         // DB size ... MySQL only
185         //
186         // This code is heavily influenced by a similar routine
187         // in phpMyAdmin 2.2.0
188         //
189         if( preg_match("/^mysql/", $db_type) )
190         {
191                 if( $version = $db->sql_server_info() )
192                 {
193                         if( preg_match("/(3\.23|4\.|5\.)/", $version) )
194                         {
195                                 $db_name = ( preg_match("/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)|(5\.)/", $version) ) ? "`$db_name`" : $db_name;
196
197                                 $sql = "SHOW TABLE STATUS
198                                         FROM " . $db_name;
199                                 $result = $db->sql_query($sql, 30 * 60);
200                                 if( $row = $db->sql_fetchrow($result) )
201                                 {
202
203                                         $dbsize = 0;
204                                         do
205                                         {
206                                             $type = ( isset($row['Type']) ? $row['Type'] : '' );
207                                                 if( $type != "MRG_MyISAM" )
208                                                 {
209                                                         if( $table_prefix != "" )
210                                                         {
211                                                                 if( strstr($row['Name'], $table_prefix) )
212                                                                 {
213                                                                         $dbsize += $row['Data_length'] + $row['Index_length'];
214                                                                 }
215                                                         }
216                                                         else
217                                                         {
218                                                                 $dbsize += $row['Data_length'] + $row['Index_length'];
219                                                         }
220                                                 }
221                                         }
222                                         while ( $row = $db->sql_fetchrow($result) );
223                                 } // Else we couldn't get the table status.
224                         }
225                         else
226                         {
227                                 $dbsize = $lang['na'];
228                         }
229                 }
230                 else
231                 {
232                         $dbsize = $lang['na'];
233                 }
234         }
235         else if( preg_match("/^mssql/", $db_type) )
236         {
237                 $sql = "SELECT ((SUM(size) * 8.0) * 1024.0) AS dbsize
238                         FROM sysfiles";
239                 if( $result = $db->sql_query($sql, 30 * 60) )
240                 {
241                         $dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $lang['not_available'];
242                 }
243                 else
244                 {
245                         $dbsize = $lang['na'];
246                 }
247         }
248         else
249         {
250                 $dbsize = $lang['na'];
251         }
252
253         if ( is_integer($dbsize) )
254         {
255                 $dbsize = mksize($dbsize);
256         }
257
258         //Get Tracker Statistics
259         $total_torrents = get_row_count(TORRENTS_TABLE);
260         $total_dead_torrents = get_row_count(TORRENTS_TABLE, 'WHERE visible = 0');
261         $total_requests = get_row_count(REQUESTS_TABLE);
262         $total_offers = get_row_count(OFFERS_TABLE);
263         $total_comments = get_row_count(COMMENTS_TABLE);
264         $tracker_start_date = create_date($config['onlinesince']);
265
266         $torrents_dir_size = 0;
267
268         $torrent_dir = $root_path . ( !empty($config['torrent_dir']) ? $config['torrent_dir'] : 'torrents');
269
270         if ($torrents_dir = @opendir($torrent_dir))
271         {
272                 while( $file = @readdir($torrents_dir) )
273                 {
274                         if( $file != "." && $file != ".." )
275                         {
276                                 $torrents_dir_size += @filesize($torrent_dir . "/" . $file);
277                         }
278                 }
279                 @closedir($torrents_dir);
280                 $torrents_dir_size = mksize($torrents_dir_size);
281         }
282         else
283         {
284                 $torrents_dir_size = $lang['not_available'];
285         }
286
287         $template->assign_vars(array(
288                 "NUMBER_OF_POSTS" => $total_posts,
289                 "NUMBER_OF_TOPICS" => $total_topics,
290                 "NUMBER_OF_USERS" => $total_users,
291                 "START_DATE" => $start_date,
292                 "POSTS_PER_DAY" => $posts_per_day,
293                 "TOPICS_PER_DAY" => $topics_per_day,
294                 "USERS_PER_DAY" => $users_per_day,
295                 "AVATAR_DIR_SIZE" => $avatar_dir_size,
296                 "DB_SIZE" => $dbsize,
297                 "GZIP_COMPRESSION" => ( $config['gzip_compress'] ) ? $lang['on'] : $lang['off'],
298                 "NUMBER_TORRENTS" => $total_torrents,
299                 "NUMBER_DEAD_TORRENTS" => $total_dead_torrents,
300                 'NUMBER_REQUESTS' => $total_requests,
301                 'NUMBER_OFFERS' => $total_offers,
302                 'NUMBER_COMMENTS' => $total_comments,
303                 'TRACKER_START_DATE' => $tracker_start_date,
304                 'TORRENTS_DIR_SIZE' => $torrents_dir_size)
305         );
306         //
307         // End forum statistics
308         //
309
310         //
311         // Get users online information.
312         //
313         $sql = "SELECT u.uid, u.name AS username, u.user_session_time, u.user_session_page, u.class, u.warneduntil, u.parked, u.enabled, u.donor, s.session_logged_in, s.session_ip, s.session_start
314                 FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
315                 WHERE s.session_logged_in = " . TRUE . "
316                         AND u.uid = s.session_user_id
317                         AND u.uid <> " . ANONYMOUS . "
318                         AND s.session_time >= " . ( time() - $config['online_time'] ) . "
319                 ORDER BY u.user_session_time DESC";
320         $result_reg = $db->sql_query($sql);
321
322         $sql = "SELECT session_page, session_logged_in, session_time, session_ip, session_start
323                 FROM " . SESSIONS_TABLE . "
324                 WHERE session_logged_in = 0
325                         AND session_time >= " . ( time() - $config['online_time'] ) . "
326              GROUP BY session_ip
327                 ORDER BY session_time DESC";
328         $result_guest = $db->sql_query($sql);
329
330         $sql = "SELECT forum_name, forum_id
331                 FROM " . FORUMS_TABLE;
332         $forums_result = $db->sql_query($sql);
333         while($forumsrow = $db->sql_fetchrow($forums_result))
334         {
335             $forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name'];
336         }
337
338         $reg_userid_ary = array();
339
340         if( $row = $db->sql_fetchrow($result_reg) )
341         {
342                 $registered_users = 0;
343
344                 do
345                 {
346                         if( !in_array($row['uid'], $reg_userid_ary) )
347                         {
348                                 $reg_userid_ary[] = $row['uid'];
349
350                                 $username = $row['username'];
351
352                                 $registered_users++;
353                                 $hidden = FALSE;
354
355                                 preg_match('#^([a-z0-9/]+)#i', $row['user_session_page'], $on_page);
356
357                                 if (sizeof($on_page)) {
358                                         switch ($on_page[1])
359                                         {
360                                             case 'phpbb2' :
361                                                     preg_match('#page=([a-z]+)#', $row['user_session_page'], $on_page);
362                                                     if (!sizeof($on_page)) {
363                                                         $on_page[1] = '';
364                                                     }
365                                                     switch ($on_page[1])
366                                                     {
367                                                                 case 'posting':
368                                                                         $location = $lang['posting_message'];
369                                                                         $location_url = "index.$phpEx?pane=right";
370                                                                         break;
371                                                                 case 'search':
372                                                                         $location = $lang['searching_forums'];
373                                                                         $location_url = "index.$phpEx?pane=right";
374                                                                         break;
375                                                                 default:
376                                                                         $location = $lang['forum_index'];
377                                                                         $location_url = "index.$phpEx?pane=right";
378                                                                 break;
379                                                         }
380                                                  break;
381                                                  case 'admin/index' :
382                                                          $location = $lang['forum_index'];
383                                                          $location_url = "index.$phpEx?pane=right";
384                                                  break;
385                                                  default:
386                                                          $location_url = $root_path . $row['user_session_page'];
387                                                          $location = substr($row['user_session_page'], 0, 40);
388                                                  break;
389                                         }
390                                 }
391                                 else
392                                 {
393                                         $location_url = $root_path . $row['user_session_page'];
394                                         $location = substr($row['user_session_page'], 0, 40);
395                                 }
396
397                                 $row_color = ( $registered_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
398                                 $row_class = ( $registered_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
399
400                                 $reg_ip = $row['session_ip'];
401
402                                 $template->assign_block_vars("reg_user_row", array(
403                                         "ROW_COLOR" => "#" . $row_color,
404                                         "ROW_CLASS" => $row_class,
405                                         "USERNAME" => get_user_class_color($row['class'], $username),
406                                         'USER_ICONS' => get_user_icons($row),
407                                         "STARTED" => create_date($row['session_start']),
408                                         "LASTUPDATE" => create_date($row['user_session_time']),
409                                         "FORUM_LOCATION" => htmlspecialchars($location),
410                                         "IP_ADDRESS" => $reg_ip,
411
412                                         "U_WHOIS_IP" => "http://network-tools.com/default.asp?host=$reg_ip",
413                                         "U_USER_PROFILE" => append_sid("admin_users.$phpEx?mode=edit&amp;" . POST_USERS_URL . "=" . $row['uid']),
414                                         "U_FORUM_LOCATION" => append_sid(htmlspecialchars($location_url)))
415                                 );
416                         }
417                 }
418                 while ( $row = $db->sql_fetchrow($result_reg) );
419
420         }
421
422         //
423         // Guest users
424         //
425         $guest_users = 0;
426
427         if( $row = $db->sql_fetchrow($result_guest) )
428         {
429
430                 do
431                 {
432                         $guest_userip_ary[] = $row['session_ip'];
433                         $guest_users++;
434
435                                 preg_match('#^([a-z0-9/]+)#i', $row['session_page'], $on_page);
436
437                                 if (sizeof($on_page)) {
438                                         switch ($on_page[1])
439                                         {
440                                             case 'phpbb2' :
441                                                     preg_match('#page=([a-z]+)#', $row['session_page'], $on_page);
442                                                     if (!sizeof($on_page)) {
443                                                         $on_page[1] = '';
444                                                     }
445                                                     switch ($on_page[1])
446                                                     {
447                                                                 case 'posting':
448                                                                         $location = $lang['posting_message'];
449                                                                         $location_url = "index.$phpEx?pane=right";
450                                                                         break;
451                                                                 case 'search':
452                                                                         $location = $lang['searching_forums'];
453                                                                         $location_url = "index.$phpEx?pane=right";
454                                                                         break;
455                                                                 default:
456                                                                         $location = $lang['forum_index'];
457                                                                         $location_url = "index.$phpEx?pane=right";
458                                                                 break;
459                                                         }
460                                                         $location = $lang['forum_index'];
461                                                         $location_url = "index.$phpEx?pane=right";
462                                                  break;
463                                                  case 'admin/index' :
464                                                          $location = $lang['forum_index'];
465                                                          $location_url = "index.$phpEx?pane=right";
466                                                  break;
467                                                  default:
468                                                          $location_url = $root_path . $row['session_page'];
469                                                          $location = substr($row['session_page'], 0, 40);
470                                                  break;
471                                         }
472                                 }
473                                 else
474                                 {
475                                         $location_url = $root_path . $row['session_page'];
476                                         $location = substr($row['session_page'], 0, 40);
477                                 }
478
479                         $row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
480                         $row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
481
482                         $guest_ip = $row['session_ip'];
483
484                         $template->assign_block_vars("guest_user_row", array(
485                                 "ROW_COLOR" => "#" . $row_color,
486                                 "ROW_CLASS" => $row_class,
487                                 "USERNAME" => $lang['guest'],
488                                 "STARTED" => create_date($row['session_start']),
489                                 "LASTUPDATE" => create_date($row['session_time']),
490                                 "FORUM_LOCATION" => htmlspecialchars($location),
491                                 "IP_ADDRESS" => $guest_ip,
492
493                                 "U_WHOIS_IP" => "http://network-tools.com/default.asp?host=$guest_ip",
494                                 "U_FORUM_LOCATION" => append_sid(htmlspecialchars($location_url)))
495                         );
496                 }
497                 while ( $row = $db->sql_fetchrow($result_guest) );
498
499         }
500
501         if ( $registered_users == 0 ) {
502                 $l_r_user_s = $lang['reg_users_zero_total'];
503         }
504         else if ( $registered_users == 1 ) {
505                 $l_r_user_s = $lang['reg_user_total'];
506         }
507         else {
508                 $l_r_user_s = $lang['reg_users_total'];
509         }
510
511         if ( $guest_users == 0 ) {
512                 $l_g_user_s = $lang['guest_users_zero_total'];
513         }
514         else if ( $guest_users == 1 ) {
515                 $l_g_user_s = $lang['guest_user_total'];
516         }
517         else {
518             $l_g_user_s = $lang['guest_users_total'];
519         }
520
521         $l_online_users = sprintf($l_r_user_s, $registered_users);
522         $l_online_users .= sprintf($l_g_user_s, $guest_users);
523
524         $template->assign_vars(array(
525             "ONLINE_USERS_COUNT" => $l_online_users)
526         );
527
528         $template->display("body");
529
530         include('./page_footer_admin.'.$phpEx);
531
532 }
533 else
534 {
535         //
536         // Generate frameset
537         //
538         $template->set_filenames(array(
539                 "body" => "../admin/index_frameset.tpl")
540         );
541
542         $template->assign_vars(array(
543                 "S_FRAME_NAV" => append_sid("index.$phpEx?pane=left"),
544                 "S_FRAME_MAIN" => append_sid("index.$phpEx?pane=right"))
545         );
546
547         header ("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
548         header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
549
550        $template->display("body");
551
552         gc();
553
554 }
555
556 ?>
Note: See TracBrowser for help on using the browser.