Просмотр файла admin/index.php

Размер файла: 15.01Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. define('IN_PHPBB', 1);
  7.  
  8. $no_page_header = TRUE;
  9. $phpbb_root_path = "./../";
  10. require($phpbb_root_path . 'extension.inc');
  11. require('./pagestart.' . $phpEx);
  12.  
  13. function inarray($needle, $haystack)
  14. {
  15. for($i = 0; $i < sizeof($haystack); $i++ )
  16. {
  17. if( $haystack[$i] == $needle )
  18. {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }
  24.  
  25. if( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' || isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' )
  26. {
  27. $dir = @opendir(".");
  28.  
  29. $setmodules = 1;
  30. while( $file = @readdir($dir) )
  31. {
  32. if( preg_match("/^admin_.*?\." . $phpEx . "$/", $file) )
  33. {
  34. include('./' . $file);
  35. }
  36. }
  37.  
  38. @closedir($dir);
  39.  
  40. unset($setmodules);
  41.  
  42. include('./page_header_admin.'.$phpEx);
  43.  
  44. $template->set_filenames(array(
  45. "body" => "admin/index_navigate.tpl")
  46. );
  47.  
  48. $template->assign_vars(array(
  49. "U_FORUM_INDEX" => append_sid("../index.$phpEx"),
  50. "U_ADMIN_INDEX" => append_sid("index.$phpEx?pane=left"),
  51.  
  52. "L_FORUM_INDEX" => $lang['Main_index'],
  53. "L_ADMIN_INDEX" => $lang['Admin_Index'],
  54. "L_PREVIEW_FORUM" => $lang['Preview_forum'])
  55. );
  56.  
  57. ksort($module);
  58.  
  59. while( list($cat, $action_array) = each($module) )
  60. {
  61. $cat = ( !empty($lang[$cat]) ) ? $lang[$cat] : preg_replace("/_/", " ", $cat);
  62.  
  63. $template->assign_block_vars("catrow", array(
  64. "ADMIN_CATEGORY" => $cat)
  65. );
  66.  
  67. ksort($action_array);
  68.  
  69. $row_count = 0;
  70. while( list($action, $file) = each($action_array) )
  71. {
  72. $row_color = '';
  73. $row_class = ( !($row_count%2) ) ? 'row_easy' : 'row_hard';
  74.  
  75. $action = ( !empty($lang[$action]) ) ? $lang[$action] : preg_replace("/_/", " ", $action);
  76.  
  77. $template->assign_block_vars("catrow.modulerow", array(
  78. "ROW_COLOR" => "#" . $row_color,
  79. "ROW_CLASS" => $row_class,
  80.  
  81. "ADMIN_MODULE" => $action,
  82. "U_ADMIN_MODULE" => append_sid($file))
  83. );
  84. $row_count++;
  85. }
  86. }
  87.  
  88. $template->pparse("body");
  89.  
  90. include('./page_footer_admin.'.$phpEx);
  91. }
  92. elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'statistic' )
  93. {
  94.  
  95. include('./page_header_admin.'.$phpEx);
  96.  
  97. $template->set_filenames(array(
  98. "body" => "admin/index_body.tpl")
  99. );
  100.  
  101. $template->assign_vars(array(
  102. "L_WELCOME" => $lang['Welcome_phpBB'],
  103. "L_ADMIN_INTRO" => $lang['Admin_intro'],
  104. "L_FORUM_STATS" => $lang['Forum_stats'],
  105. "L_WHO_IS_ONLINE" => $lang['Who_is_Online'],
  106. "L_USERNAME" => $lang['Username'],
  107. "L_LOCATION" => $lang['Location'],
  108. "L_LAST_UPDATE" => $lang['Last_updated'],
  109. "L_IP_ADDRESS" => $lang['IP_Address'],
  110. "L_STATISTIC" => $lang['Statistic'],
  111. "L_VALUE" => $lang['Value'],
  112. "L_NUMBER_POSTS" => $lang['Number_posts'],
  113. "L_POSTS_PER_DAY" => $lang['Posts_per_day'],
  114. "L_NUMBER_TOPICS" => $lang['Number_topics'],
  115. "L_TOPICS_PER_DAY" => $lang['Topics_per_day'],
  116. "L_NUMBER_USERS" => $lang['Number_users'],
  117. "L_USERS_PER_DAY" => $lang['Users_per_day'],
  118. "L_BOARD_STARTED" => $lang['Board_started'],
  119. "L_AVATAR_DIR_SIZE" => $lang['Avatar_dir_size'],
  120. "L_DB_SIZE" => $lang['Database_size'],
  121. "L_FORUM_LOCATION" => $lang['Forum_Location'],
  122. "L_STARTED" => $lang['Login'],
  123. "L_GZIP_COMPRESSION" => $lang['Gzip_compression'])
  124. );
  125.  
  126. $total_posts = get_db_stat('postcount');
  127. $total_users = get_db_stat('usercount');
  128. $total_topics = get_db_stat('topiccount');
  129.  
  130. $start_date = create_date($board_config['default_dateformat'], $board_config['board_startdate'], $board_config['board_timezone']);
  131.  
  132. $boarddays = ( time() - $board_config['board_startdate'] ) / 86400;
  133.  
  134. $posts_per_day = sprintf("%.2f", $total_posts / $boarddays);
  135. $topics_per_day = sprintf("%.2f", $total_topics / $boarddays);
  136. $users_per_day = sprintf("%.2f", $total_users / $boarddays);
  137.  
  138. $avatar_dir_size = 0;
  139.  
  140. if ($avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path']))
  141. {
  142. while( $file = @readdir($avatar_dir) )
  143. {
  144. if( $file != "." && $file != ".." )
  145. {
  146. $avatar_dir_size += @filesize($phpbb_root_path . $board_config['avatar_path'] . "/" . $file);
  147. }
  148. }
  149. @closedir($avatar_dir);
  150.  
  151. if($avatar_dir_size >= 1048576)
  152. {
  153. $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . " MB";
  154. }
  155. else if($avatar_dir_size >= 1024)
  156. {
  157. $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . " KB";
  158. }
  159. else
  160. {
  161. $avatar_dir_size = $avatar_dir_size . " Bytes";
  162. }
  163.  
  164. }
  165. else
  166. {
  167. $avatar_dir_size = $lang['Not_available'];
  168. }
  169.  
  170. if($posts_per_day > $total_posts)
  171. {
  172. $posts_per_day = $total_posts;
  173. }
  174.  
  175. if($topics_per_day > $total_topics)
  176. {
  177. $topics_per_day = $total_topics;
  178. }
  179.  
  180. if($users_per_day > $total_users)
  181. {
  182. $users_per_day = $total_users;
  183. }
  184.  
  185. if( preg_match("/^mysql/", SQL_LAYER) )
  186. {
  187. $sql = "SELECT VERSION() AS mysql_version";
  188. if($result = $db->sql_query($sql))
  189. {
  190. $row = $db->sql_fetchrow($result);
  191. $version = $row['mysql_version'];
  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) ) ? "`$dbname`" : $dbname;
  196.  
  197. $sql = "SHOW TABLE STATUS
  198. FROM " . $db_name;
  199. if($result = $db->sql_query($sql))
  200. {
  201. $tabledata_ary = $db->sql_fetchrowset($result);
  202.  
  203. $dbsize = 0;
  204. for($i = 0; $i < count($tabledata_ary); $i++)
  205. {
  206. if( $tabledata_ary[$i]['Type'] != "MRG_MyISAM" )
  207. {
  208. if( $table_prefix != "" )
  209. {
  210. if( strstr($tabledata_ary[$i]['Name'], $table_prefix) )
  211. {
  212. $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
  213. }
  214. }
  215. else
  216. {
  217. $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
  218. }
  219. }
  220. }
  221. }
  222. }
  223. else
  224. {
  225. $dbsize = $lang['Not_available'];
  226. }
  227. }
  228. else
  229. {
  230. $dbsize = $lang['Not_available'];
  231. }
  232. }
  233. else if( preg_match("/^mssql/", SQL_LAYER) )
  234. {
  235. $sql = "SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize
  236. FROM sysfiles";
  237. if( $result = $db->sql_query($sql) )
  238. {
  239. $dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $lang['Not_available'];
  240. }
  241. else
  242. {
  243. $dbsize = $lang['Not_available'];
  244. }
  245. }
  246. else
  247. {
  248. $dbsize = $lang['Not_available'];
  249. }
  250.  
  251. if ( is_integer($dbsize) )
  252. {
  253. if( $dbsize >= 1048576 )
  254. {
  255. $dbsize = sprintf("%.2f MB", ( $dbsize / 1048576 ));
  256. }
  257. else if( $dbsize >= 1024 )
  258. {
  259. $dbsize = sprintf("%.2f KB", ( $dbsize / 1024 ));
  260. }
  261. else
  262. {
  263. $dbsize = sprintf("%.2f Bytes", $dbsize);
  264. }
  265. }
  266.  
  267. $template->assign_vars(array(
  268. "NUMBER_OF_POSTS" => $total_posts,
  269. "NUMBER_OF_TOPICS" => $total_topics,
  270. "NUMBER_OF_USERS" => $total_users,
  271. "START_DATE" => $start_date,
  272. "POSTS_PER_DAY" => $posts_per_day,
  273. "TOPICS_PER_DAY" => $topics_per_day,
  274. "USERS_PER_DAY" => $users_per_day,
  275. "AVATAR_DIR_SIZE" => $avatar_dir_size,
  276. "DB_SIZE" => $dbsize,
  277. "GZIP_COMPRESSION" => ( $board_config['gzip_compress'] ) ? $lang['ON'] : $lang['OFF'])
  278. );
  279.  
  280. $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
  281. FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
  282. WHERE s.session_logged_in = " . TRUE . "
  283. AND u.user_id = s.session_user_id
  284. AND u.user_id <> " . ANONYMOUS . "
  285. AND s.session_time >= " . ( time() - 300 ) . "
  286. ORDER BY u.user_session_time DESC";
  287. if(!$result = $db->sql_query($sql))
  288. {
  289. message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql);
  290. }
  291. $onlinerow_reg = $db->sql_fetchrowset($result);
  292.  
  293. $sql = "SELECT session_page, session_logged_in, session_time, session_ip, session_start
  294. FROM " . SESSIONS_TABLE . "
  295. WHERE session_logged_in = 0
  296. AND session_time >= " . ( time() - 300 ) . "
  297. ORDER BY session_time DESC";
  298. if(!$result = $db->sql_query($sql))
  299. {
  300. message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql);
  301. }
  302. $onlinerow_guest = $db->sql_fetchrowset($result);
  303.  
  304. $sql = "SELECT forum_name, forum_id
  305. FROM " . FORUMS_TABLE;
  306. if($forums_result = $db->sql_query($sql))
  307. {
  308. while($forumsrow = $db->sql_fetchrow($forums_result))
  309. {
  310. $forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name'];
  311. }
  312. }
  313. else
  314. {
  315. message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql);
  316. }
  317.  
  318. $reg_userid_ary = array();
  319.  
  320. if( count($onlinerow_reg) )
  321. {
  322. $registered_users = 0;
  323.  
  324. for($i = 0; $i < count($onlinerow_reg); $i++)
  325. {
  326. if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) )
  327. {
  328. $reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
  329.  
  330. $username = $onlinerow_reg[$i]['username'];
  331.  
  332. if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
  333. {
  334. $registered_users++;
  335. $hidden = FALSE;
  336. }
  337. else
  338. {
  339. $hidden_users++;
  340. $hidden = TRUE;
  341. }
  342.  
  343. if( $onlinerow_reg[$i]['user_session_page'] < 1 )
  344. {
  345. switch($onlinerow_reg[$i]['user_session_page'])
  346. {
  347. case PAGE_INDEX:
  348. $location = $lang['Forum_index'];
  349. $location_url = "index.$phpEx?pane=right";
  350. break;
  351. case PAGE_POSTING:
  352. $location = $lang['Posting_message'];
  353. $location_url = "index.$phpEx?pane=right";
  354. break;
  355. case PAGE_LOGIN:
  356. $location = $lang['Logging_on'];
  357. $location_url = "index.$phpEx?pane=right";
  358. break;
  359. case PAGE_SEARCH:
  360. $location = $lang['Searching_forums'];
  361. $location_url = "index.$phpEx?pane=right";
  362. break;
  363. case PAGE_PROFILE:
  364. $location = $lang['Viewing_profile'];
  365. $location_url = "index.$phpEx?pane=right";
  366. break;
  367. case PAGE_VIEWONLINE:
  368. $location = $lang['Viewing_online'];
  369. $location_url = "index.$phpEx?pane=right";
  370. break;
  371. case PAGE_VIEWMEMBERS:
  372. $location = $lang['Viewing_member_list'];
  373. $location_url = "index.$phpEx?pane=right";
  374. break;
  375. case PAGE_PRIVMSGS:
  376. $location = $lang['Viewing_priv_msgs'];
  377. $location_url = "index.$phpEx?pane=right";
  378. break;
  379. case PAGE_FAQ:
  380. $location = $lang['Viewing_FAQ'];
  381. $location_url = "index.$phpEx?pane=right";
  382. break;
  383. case PAGE_ALBUM:
  384. $location = $lang['Album'];
  385. $location_url = "index.$phpEx?pane=right";
  386. break;
  387. default:
  388. $location = $lang['Forum_index'];
  389. $location_url = "index.$phpEx?pane=right";
  390. }
  391. }
  392. else
  393. {
  394. $location_url = append_sid("admin_forums.$phpEx?mode=editforum&amp;" . POST_FORUM_URL . "=" . $onlinerow_reg[$i]['user_session_page']);
  395. $location = $forum_data[$onlinerow_reg[$i]['user_session_page']];
  396. }
  397.  
  398. $row_color = '';
  399. $row_class = ( $registered_users % 2 ) ? 'row_easy' : 'row_hard';
  400.  
  401. $reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
  402.  
  403. $template->assign_block_vars("reg_user_row", array(
  404. "ROW_COLOR" => "#" . $row_color,
  405. "ROW_CLASS" => $row_class,
  406. "USERNAME" => $username,
  407. "STARTED" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['session_start'], $board_config['board_timezone']),
  408. "LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['user_session_time'], $board_config['board_timezone']),
  409. "FORUM_LOCATION" => $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 . "=" . $onlinerow_reg[$i]['user_id']),
  414. "U_FORUM_LOCATION" => append_sid($location_url))
  415. );
  416. }
  417. }
  418.  
  419. }
  420. else
  421. {
  422. $template->assign_vars(array(
  423. "L_NO_REGISTERED_USERS_BROWSING" => $lang['No_users_browsing'])
  424. );
  425. }
  426.  
  427. if( count($onlinerow_guest) )
  428. {
  429. $guest_users = 0;
  430.  
  431. for($i = 0; $i < count($onlinerow_guest); $i++)
  432. {
  433. $guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
  434. $guest_users++;
  435.  
  436. if( $onlinerow_guest[$i]['session_page'] < 1 )
  437. {
  438. switch( $onlinerow_guest[$i]['session_page'] )
  439. {
  440. case PAGE_INDEX:
  441. $location = $lang['Forum_index'];
  442. $location_url = "index.$phpEx?pane=right";
  443. break;
  444. case PAGE_POSTING:
  445. $location = $lang['Posting_message'];
  446. $location_url = "index.$phpEx?pane=right";
  447. break;
  448. case PAGE_LOGIN:
  449. $location = $lang['Logging_on'];
  450. $location_url = "index.$phpEx?pane=right";
  451. break;
  452. case PAGE_SEARCH:
  453. $location = $lang['Searching_forums'];
  454. $location_url = "index.$phpEx?pane=right";
  455. break;
  456. case PAGE_PROFILE:
  457. $location = $lang['Viewing_profile'];
  458. $location_url = "index.$phpEx?pane=right";
  459. break;
  460. case PAGE_VIEWONLINE:
  461. $location = $lang['Viewing_online'];
  462. $location_url = "index.$phpEx?pane=right";
  463. break;
  464. case PAGE_VIEWMEMBERS:
  465. $location = $lang['Viewing_member_list'];
  466. $location_url = "index.$phpEx?pane=right";
  467. break;
  468. case PAGE_PRIVMSGS:
  469. $location = $lang['Viewing_priv_msgs'];
  470. $location_url = "index.$phpEx?pane=right";
  471. break;
  472. case PAGE_FAQ:
  473. $location = $lang['Viewing_FAQ'];
  474. $location_url = "index.$phpEx?pane=right";
  475. break;
  476. default:
  477. $location = $lang['Forum_index'];
  478. $location_url = "index.$phpEx?pane=right";
  479. }
  480. }
  481. else
  482. {
  483. $location_url = append_sid("admin_forums.$phpEx?mode=editforum&amp;" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']);
  484. $location = $forum_data[$onlinerow_guest[$i]['session_page']];
  485. }
  486.  
  487. $row_color = '';
  488. $row_class = ( $guest_users % 2 ) ? 'row_easy' : 'row_hard';
  489.  
  490. $guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
  491.  
  492. $template->assign_block_vars("guest_user_row", array(
  493. "ROW_COLOR" => "#" . $row_color,
  494. "ROW_CLASS" => $row_class,
  495. "USERNAME" => $lang['Guest'],
  496. "STARTED" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_start'], $board_config['board_timezone']),
  497. "LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['board_timezone']),
  498. "FORUM_LOCATION" => $location,
  499. "IP_ADDRESS" => $guest_ip,
  500.  
  501. "U_WHOIS_IP" => "http://network-tools.com/default.asp?host=$guest_ip",
  502. "U_FORUM_LOCATION" => append_sid($location_url))
  503. );
  504. }
  505.  
  506. }
  507. else
  508. {
  509. $template->assign_vars(array(
  510. "L_NO_GUESTS_BROWSING" => $lang['No_users_browsing'])
  511. );
  512. }
  513.  
  514. $template->pparse("body");
  515.  
  516. include('./page_footer_admin.'.$phpEx);
  517.  
  518. }
  519. else
  520. {
  521. include('./page_header_admin.'.$phpEx);
  522. $template->set_filenames(array(
  523. "body" => "admin/index_frameset.tpl")
  524. );
  525.  
  526. $template->assign_vars(array(
  527. "S_FRAME_NAV" => append_sid("index.$phpEx?pane=left"),
  528. "S_FRAME_MAIN" => append_sid("index.$phpEx?pane=statistic"),
  529. "admin_forums" => append_sid("admin_forums.$phpEx"),
  530. "admin_forumauth" => append_sid("admin_forumauth.$phpEx"),
  531. "admin_forum_prune" => append_sid("admin_forum_prune.$phpEx"),
  532. "mass_email" => append_sid("mass_email.$phpEx"),
  533.  
  534. "NEWS" => append_sid("/news/admin_control.$phpEx"))
  535.  
  536. );
  537.  
  538. $template->pparse("body");
  539. include('./page_footer_admin.'.$phpEx);
  540.  
  541. $db->sql_close();
  542. exit;
  543.  
  544. }
  545.  
  546. ?>