(file) Return to index.php CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / phpBB2 / admin

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

Rizwan Kassim
Powered by
ViewCVS 0.9.2