| [ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * (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.7 2005/02/21 18:37:02 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 // 26 // Load default header 27 // 28 $no_page_header = TRUE; 29 $phpbb_root_path = "./../"; 30 require ('./../extension.inc'); 31 require('./pagestart.' . $phpEx); 32 33 // --------------- 34 // Begin functions 35 // 36 function inarray($needle, $haystack) 37 { 38 for($i = 0; $i < sizeof($haystack); $i++ ) 39 { 40 if( $haystack[$i] == $needle ) 41 { 42 return true; 43 } 44 } 45 return false; 46 } 47 // 48 // End functions 49 // ------------- 50 51 // 52 // Generate relevant output 53 // 54 if( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' ) 55 { 56 $dir = @opendir("."); 57 58 $setmodules = 1; 59 while( $file = @readdir($dir) ) 60 { 61 if( preg_match("/^admin_.*?\." . $phpEx . "$/", $file) ) 62 { 63 include($file); 64 } 65 } 66 67 @closedir($dir); 68 69 unset($setmodules); 70 71 include('./page_header_admin.'.$phpEx); 72 73 $template->set_filenames(array( 74 "body" => "admin/index_navigate.tpl") 75 ); 76 77 $template->assign_vars(array( 78 "U_FORUM_INDEX" => append_sid("index.$phpEx"), 79 "U_FORUM_PREINDEX" => append_sid("modules.$phpEx?name=Forums&file=index"), 80 "U_ADMIN_INDEX" => append_sid("index.$phpEx?pane=right"), 81 82 "L_FORUM_INDEX" => $lang['Main_index'], 83 "L_ADMIN_INDEX" => $lang['Admin_Index'], 84 "L_PREVIEW_FORUM" => $lang['Preview_forum']) 85 ); 86 87 ksort($module); 88 89 while( list($cat, $action_array) = each($module) ) 90 { 91 $cat = ( !empty($lang[$cat]) ) ? $lang[$cat] : preg_replace("/_/", " ", $cat); 92 93 $template->assign_block_vars("catrow", array( 94 "ADMIN_CATEGORY" => $cat) 95 ); 96 97 ksort($action_array); 98 99 $row_count = 0; 100 while( list($action, $file) = each($action_array) ) 101 { 102 $row_color = ( !($row_count%2) ) ? $theme['td_color1'] : $theme['td_color2']; 103 $row_class = ( !($row_count%2) ) ? $theme['td_class1'] : $theme['td_class2']; 104 105 $action = ( !empty($lang[$action]) ) ? $lang[$action] : preg_replace("/_/", " ", $action); 106 107 $template->assign_block_vars("catrow.modulerow", array( 108 "ROW_COLOR" => "#" . $row_color, 109 "ROW_CLASS" => $row_class, 110 111 "ADMIN_MODULE" => $action, 112 "U_ADMIN_MODULE" => append_sid($file)) 113 ); 114 $row_count++; 115 } 116 } 117 118 $template->pparse("body"); 119 120 include('./page_footer_admin.'.$phpEx); 121 } 122 elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) 123 { 124 125 include('./page_header_admin.'.$phpEx); 126 127 $template->set_filenames(array( 128 "body" => "admin/index_body.tpl") 129 ); 130 131 $template->assign_vars(array( 132 "L_WELCOME" => $lang['Welcome_phpBB'], 133 "L_ADMIN_INTRO" => $lang['Admin_intro'], 134 "L_FORUM_STATS" => $lang['Forum_stats'], 135 "L_WHO_IS_ONLINE" => $lang['Who_is_Online'], 136 "L_USERNAME" => $lang['Username'], 137 "L_LOCATION" => $lang['Location'], 138 "L_LAST_UPDATE" => $lang['Last_updated'], 139 "L_IP_ADDRESS" => $lang['IP_Address'], 140 "L_STATISTIC" => $lang['Statistic'], 141 "L_VALUE" => $lang['Value'], 142 "L_NUMBER_POSTS" => $lang['Number_posts'], 143 "L_POSTS_PER_DAY" => $lang['Posts_per_day'], 144 "L_NUMBER_TOPICS" => $lang['Number_topics'], 145 "L_TOPICS_PER_DAY" => $lang['Topics_per_day'], 146 "L_NUMBER_USERS" => $lang['Number_users'], 147 "L_USERS_PER_DAY" => $lang['Users_per_day'], 148 "L_BOARD_STARTED" => $lang['Board_started'], 149 "L_AVATAR_DIR_SIZE" => $lang['Avatar_dir_size'], 150 "L_DB_SIZE" => $lang['Database_size'], 151 "L_FORUM_LOCATION" => $lang['Forum_Location'], 152 "L_STARTED" => $lang['Login'], 153 "L_GZIP_COMPRESSION" => $lang['Gzip_compression']) 154 ); 155 156 // 157 // Get forum statistics 158 // 159 $total_posts = get_db_stat('postcount'); 160 $total_users = get_db_stat('usercount'); 161 $total_topics = get_db_stat('topiccount'); 162 163 $start_date = create_date($board_config['default_dateformat'], $board_config['board_startdate'], $board_config['board_timezone']); 164 165 $boarddays = ( time() - $board_config['board_startdate'] ) / 86400; 166 167 $posts_per_day = sprintf("%.2f", $total_posts / $boarddays); 168 $topics_per_day = sprintf("%.2f", $total_topics / $boarddays); 169 $users_per_day = sprintf("%.2f", $total_users / $boarddays); 170 171 $avatar_dir_size = 0; 172 173 if ($avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path'])) 174 { 175 while( $file = @readdir($avatar_dir) ) 176 { 177 if( $file != "." && $file != ".." ) 178 { 179 $avatar_dir_size += @filesize($phpbb_root_path . $board_config['avatar_path'] . "/" . $file); 180 } 181 } 182 @closedir($avatar_dir); 183 184 // 185 // This bit of code translates the avatar directory size into human readable format 186 // Borrowed the code from the PHP.net annoted manual, origanally written by: 187 // Jesse (jesse@jess.on.ca) 188 // 189 if($avatar_dir_size >= 1048576) 190 { 191 $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . " MB"; 192 } 193 else if($avatar_dir_size >= 1024) 194 { 195 $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . " KB"; 196 } 197 else 198 { 199 $avatar_dir_size = $avatar_dir_size . " Bytes"; 200 } 201 202 } 203 else 204 { 205 // Couldn't open Avatar dir. 206 $avatar_dir_size = $lang['Not_available']; 207 } 208 209 if($posts_per_day > $total_posts) 210 { 211 $posts_per_day = $total_posts; 212 } 213 214 if($topics_per_day > $total_topics) 215 { 216 $topics_per_day = $total_topics; 217 } 218 219 if($users_per_day > $total_users) 220 { 221 $users_per_day = $total_users; 222 } 223 224 // 225 // DB size ... MySQL only 226 // 227 // This code is heavily influenced by a similar routine 228 // in phpMyAdmin 2.2.0 229 // 230 if( preg_match("/^mysql/", SQL_LAYER) ) 231 { 232 $sql = "SELECT VERSION() AS mysql_version"; 233 if($result = $db->sql_query($sql)) 234 { 235 $row = $db->sql_fetchrow($result); 236 $version = $row['mysql_version']; 237 238 if( preg_match("/^(3\.23|4\.)/", $version) ) 239 { 240 $db_name = ( preg_match("/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)/", $version) ) ? "`$dbname`" : $dbname; 241 242 $sql = "SHOW TABLE STATUS 243 FROM " . $db_name; 244 if($result = $db->sql_query($sql)) 245 { 246 $tabledata_ary = $db->sql_fetchrowset($result); 247 248 $dbsize = 0; 249 for($i = 0; $i < count($tabledata_ary); $i++) 250 { 251 if( $tabledata_ary[$i]['Type'] != "MRG_MyISAM" ) 252 { 253 if( $table_prefix != "" ) 254 { 255 if( strstr($tabledata_ary[$i]['Name'], $table_prefix) ) 256 { 257 $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; 258 } 259 } 260 else 261 { 262 $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; 263 } 264 } 265 } 266 } // Else we couldn't get the table status. 267 } 268 else 269 { 270 $dbsize = $lang['Not_available']; 271 } 272 } 273 else 274 { 275 $dbsize = $lang['Not_available']; 276 } 277 } 278 else if( preg_match("/^mssql/", SQL_LAYER) ) 279 { 280 $sql = "SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize 281 FROM sysfiles"; 282 if( $result = $db->sql_query($sql) ) 283 { 284 $dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $lang['Not_available']; 285 } 286 else 287 { 288 $dbsize = $lang['Not_available']; 289 } 290 } 291 else 292 { 293 $dbsize = $lang['Not_available']; 294 } 295 296 if ( is_integer($dbsize) ) 297 { 298 if( $dbsize >= 1048576 ) 299 { 300 $dbsize = sprintf("%.2f MB", ( $dbsize / 1048576 )); 301 } 302 else if( $dbsize >= 1024 ) 303 { 304 $dbsize = sprintf("%.2f KB", ( $dbsize / 1024 )); 305 } 306 else 307 { 308 $dbsize = sprintf("%.2f Bytes", $dbsize); 309 } 310 } 311 312 $template->assign_vars(array( 313 "NUMBER_OF_POSTS" => $total_posts, 314 "NUMBER_OF_TOPICS" => $total_topics, 315 "NUMBER_OF_USERS" => $total_users, 316 "START_DATE" => $start_date, 317 "POSTS_PER_DAY" => $posts_per_day, 318 "TOPICS_PER_DAY" => $topics_per_day, 319 "USERS_PER_DAY" => $users_per_day, 320 "AVATAR_DIR_SIZE" => $avatar_dir_size, 321 "DB_SIZE" => $dbsize, 322 "GZIP_COMPRESSION" => ( $board_config['gzip_compress'] ) ? $lang['ON'] : $lang['OFF']) 323 ); 324 // 325 // End forum statistics 326 // 327 328 // 329 // Get users online information. 330 // 331 $sql = "SELECT u.user_id, u.username, u.user_session_time, u.user_session_page, s.session_logged_in, s.session_ip, s.session_start 332 FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s 333 WHERE s.session_logged_in = " . TRUE . " 334 AND u.user_id = s.session_user_id 335 AND u.user_id <> " . ANONYMOUS . " 336 AND s.session_time >= " . ( time() - 300 ) . " 337 ORDER BY u.user_session_time DESC"; 338 if(!$result = $db->sql_query($sql)) 339 { 340 message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql); 341 } 342 $onlinerow_reg = $db->sql_fetchrowset($result); 343 344 $sql = "SELECT session_page, session_logged_in, session_time, session_ip, session_start 345 FROM " . SESSIONS_TABLE . " 346 WHERE session_logged_in = 0 347 AND session_time >= " . ( time() - 300 ) . " 348 ORDER BY session_time DESC"; 349 if(!$result = $db->sql_query($sql)) 350 { 351 message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql); 352 } 353 $onlinerow_guest = $db->sql_fetchrowset($result); 354 355 $sql = "SELECT forum_name, forum_id 356 FROM " . FORUMS_TABLE; 357 if($forums_result = $db->sql_query($sql)) 358 { 359 while($forumsrow = $db->sql_fetchrow($forums_result)) 360 { 361 $forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name']; 362 } 363 } 364 else 365 { 366 message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql); 367 } 368 369 $reg_userid_ary = array(); 370 371 if( count($onlinerow_reg) ) 372 { 373 $registered_users = 0; 374 375 for($i = 0; $i < count($onlinerow_reg); $i++) 376 { 377 if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) ) 378 { 379 $reg_userid_ary[] = $onlinerow_reg[$i]['user_id']; 380 381 $username = $onlinerow_reg[$i]['username']; 382 383 if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) 384 { 385 $registered_users++; 386 $hidden = FALSE; 387 } 388 else 389 { 390 $hidden_users++; 391 $hidden = TRUE; 392 } 393 394 if( $onlinerow_reg[$i]['user_session_page'] < 1 ) 395 { 396 switch($onlinerow_reg[$i]['user_session_page']) 397 { 398 case PAGE_INDEX: 399 $location = $lang['Forum_index']; 400 $location_url = "index.$phpEx?pane=right"; 401 break; 402 case PAGE_POSTING: 403 $location = $lang['Posting_message']; 404 $location_url = "index.$phpEx?pane=right"; 405 break; 406 case PAGE_LOGIN: 407 $location = $lang['Logging_on']; 408 $location_url = "index.$phpEx?pane=right"; 409 break; 410 case PAGE_SEARCH: 411 $location = $lang['Searching_forums']; 412 $location_url = "index.$phpEx?pane=right"; 413 break; 414 case PAGE_PROFILE: 415 $location = $lang['Viewing_profile']; 416 $location_url = "index.$phpEx?pane=right"; 417 break; 418 case PAGE_VIEWONLINE: 419 $location = $lang['Viewing_online']; 420 $location_url = "index.$phpEx?pane=right"; 421 break; 422 case PAGE_VIEWMEMBERS: 423 $location = $lang['Viewing_member_list']; 424 $location_url = "index.$phpEx?pane=right"; 425 break; 426 case PAGE_PRIVMSGS: 427 $location = $lang['Viewing_priv_msgs']; 428 $location_url = "index.$phpEx?pane=right"; 429 break; 430 case PAGE_FAQ: 431 $location = $lang['Viewing_FAQ']; 432 $location_url = "index.$phpEx?pane=right"; 433 break; 434 default: 435 $location = $lang['Forum_index']; 436 $location_url = "index.$phpEx?pane=right"; 437 } 438 } 439 else 440 { 441 $location_url = append_sid("admin_forums.$phpEx?mode=editforum&" . POST_FORUM_URL . "=" . $onlinerow_reg[$i]['user_session_page']); 442 $location = $forum_data[$onlinerow_reg[$i]['user_session_page']]; 443 } 444 445 $row_color = ( $registered_users % 2 ) ? $theme['td_color1'] : $theme['td_color2']; 446 $row_class = ( $registered_users % 2 ) ? $theme['td_class1'] : $theme['td_class2']; 447 448 $reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']); 449 450 $template->assign_block_vars("reg_user_row", array( 451 "ROW_COLOR" => "#" . $row_color, 452 "ROW_CLASS" => $row_class, 453 "USERNAME" => $username, 454 "STARTED" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['session_start'], $board_config['board_timezone']), 455 "LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['user_session_time'], $board_config['board_timezone']), 456 "FORUM_LOCATION" => $location, 457 "IP_ADDRESS" => $reg_ip, 458 459 "U_WHOIS_IP" => "http://www.geektools.com/cgi-bin/proxy.cgi?query=$reg_ip&targetnic=auto", 460 "U_USER_PROFILE" => append_sid("admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $onlinerow_reg[$i]['user_id']), 461 "U_FORUM_LOCATION" => append_sid($location_url)) 462 ); 463 } 464 } 465 466 } 467 else 468 { 469 $template->assign_vars(array( 470 "L_NO_REGISTERED_USERS_BROWSING" => $lang['No_users_browsing']) 471 ); 472 } 473 474 // 475 // Guest users 476 // 477 if( count($onlinerow_guest) ) 478 { 479 $guest_users = 0; 480 481 for($i = 0; $i < count($onlinerow_guest); $i++) 482 { 483 $guest_userip_ary[] = $onlinerow_guest[$i]['session_ip']; 484 $guest_users++; 485 486 if( $onlinerow_guest[$i]['session_page'] < 1 ) 487 { 488 switch( $onlinerow_guest[$i]['session_page'] ) 489 { 490 case PAGE_INDEX: 491 $location = $lang['Forum_index']; 492 $location_url = "index.$phpEx?pane=right"; 493 break; 494 case PAGE_POSTING: 495 $location = $lang['Posting_message']; 496 $location_url = "index.$phpEx?pane=right"; 497 break; 498 case PAGE_LOGIN: 499 $location = $lang['Logging_on']; 500 $location_url = "index.$phpEx?pane=right"; 501 break; 502 case PAGE_SEARCH: 503 $location = $lang['Searching_forums']; 504 $location_url = "index.$phpEx?pane=right"; 505 break; 506 case PAGE_PROFILE: 507 $location = $lang['Viewing_profile']; 508 $location_url = "index.$phpEx?pane=right"; 509 break; 510 case PAGE_VIEWONLINE: 511 $location = $lang['Viewing_online']; 512 $location_url = "index.$phpEx?pane=right"; 513 break; 514 case PAGE_VIEWMEMBERS: 515 $location = $lang['Viewing_member_list']; 516 $location_url = "index.$phpEx?pane=right"; 517 break; 518 case PAGE_PRIVMSGS: 519 $location = $lang['Viewing_priv_msgs']; 520 $location_url = "index.$phpEx?pane=right"; 521 break; 522 case PAGE_FAQ: 523 $location = $lang['Viewing_FAQ']; 524 $location_url = "index.$phpEx?pane=right"; 525 break; 526 default: 527 $location = $lang['Forum_index']; 528 $location_url = "index.$phpEx?pane=right"; 529 } 530 } 531 else 532 { 533 $location_url = append_sid("admin_forums.$phpEx?mode=editforum&" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']); 534 $location = $forum_data[$onlinerow_guest[$i]['session_page']]; 535 } 536 537 $row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2']; 538 $row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2']; 539 540 $guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']); 541 542 $template->assign_block_vars("guest_user_row", array( 543 "ROW_COLOR" => "#" . $row_color, 544 "ROW_CLASS" => $row_class, 545 "USERNAME" => $lang['Guest'], 546 "STARTED" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_start'], $board_config['board_timezone']), 547 "LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['board_timezone']), 548 "FORUM_LOCATION" => $location, 549 "IP_ADDRESS" => $guest_ip, 550 551 "U_WHOIS_IP" => "http://www.geektools.com/cgi-bin/proxy.cgi?query=$guest_ip&targetnic=auto", 552 "U_FORUM_LOCATION" => append_sid($location_url)) 553 ); 554 } 555 556 } 557 else 558 { 559 $template->assign_vars(array( 560 "L_NO_GUESTS_BROWSING" => $lang['No_users_browsing']) 561 ); 562 } 563 // Check for new version 564 $current_version = explode('.', '2' . $board_config['version']); 565 $minor_revision = (int) $current_version[2]; 566 567 $errno = 0; 568 $errstr = $version_info = ''; 569 570 if ($fsock = @fsockopen('www.phpbb.com', 80, $errno, $errstr)) 571 { 572 @fputs($fsock, "GET /updatecheck/20x.txt HTTP/1.1\r\n"); 573 @fputs($fsock, "HOST: www.phpbb.com\r\n"); 574 @fputs($fsock, "Connection: close\r\n\r\n"); 575 576 $get_info = false; 577 while (!@feof($fsock)) 578 { 579 if ($get_info) 580 { 581 $version_info .= @fread($fsock, 1024); 582 } 583 else 584 { 585 if (@fgets($fsock, 1024) == "\r\n") 586 { 587 $get_info = true; 588 } 589 } 590 } 591 @fclose($fsock); 592 593 $version_info = explode("\n", $version_info); 594 $latest_head_revision = (int) $version_info[0]; 595 $latest_minor_revision = (int) $version_info[2]; 596 $latest_version = (int) $version_info[0] . '.' . (int) $version_info[1] . '.' . (int) $version_info[2]; 597 598 if ($latest_head_revision == 2 && $minor_revision == $latest_minor_revision) 599 { 600 $version_info = '<p style="color:green">' . $lang['Version_up_to_date'] . '</p>'; 601 } 602 else 603 { 604 $version_info = '<p style="color:red">' . $lang['Version_not_up_to_date']; 605 $version_info .= '<br />' . sprintf($lang['Latest_version_info'], $latest_version) . sprintf($lang['Current_version_info'], '2' . $board_config['version']) . '</p>'; 606 } 607 } 608 else 609 { 610 if ($errstr) 611 { 612 $version_info = '<p style="color:red">' . sprintf($lang['Connect_socket_error'], $errstr) . '</p>'; 613 } 614 else 615 { 616 $version_info = '<p>' . $lang['Socket_functions_disabled'] . '</p>'; 617 } 618 } 619 620 $version_info .= '<p>' . $lang['Mailing_list_subscribe_reminder'] . '</p>'; 621 622 623 $template->assign_vars(array( 624 'VERSION_INFO' => $version_info, 625 'L_VERSION_INFORMATION' => $lang['Version_information']) 626 ); 627 628 $template->pparse("body"); 629 630 include('./page_footer_admin.'.$phpEx); 631 632 } 633 else 634 { 635 // 636 // Generate frameset 637 // 638 $template->set_filenames(array( 639 "body" => "admin/index_frameset.tpl") 640 ); 641 642 $template->assign_vars(array( 643 "S_FRAME_NAV" => append_sid("index.$phpEx?pane=left"), 644 "S_FRAME_MAIN" => append_sid("index.$phpEx?pane=right")) 645 ); 646 647 header ("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"); 648 header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 649 650 $template->pparse("body"); 651 652 $db->sql_close(); 653 exit; 654 655 } 656 657 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |