PageRenderTime 35ms CodeModel.GetById 21ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/core/modcp/index.php

https://gitlab.com/hub/vbulletin
PHP | 395 lines | 361 code | 12 blank | 22 comment | 8 complexity | 5d57c13fb3e7c9bd9b689f4d8b676bb6 MD5 | raw file
  1<?php
  2/*======================================================================*\
  3|| #################################################################### ||
  4|| # vBulletin 5.0.0
  5|| # ---------------------------------------------------------------- # ||
  6|| # Copyright �2000-2013 vBulletin Solutions Inc. All Rights Reserved. ||
  7|| # This file may not be redistributed in whole or significant part. # ||
  8|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  9|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
 10|| #################################################################### ||
 11\*======================================================================*/
 12
 13// ######################## SET PHP ENVIRONMENT ###########################
 14error_reporting(E_ALL & ~E_NOTICE);
 15
 16// ##################### DEFINE IMPORTANT CONSTANTS #######################
 17define('CVS_REVISION', '$RCSfile$ - $Revision: 70525 $');
 18
 19// #################### PRE-CACHE TEMPLATES AND DATA ######################
 20global $phrasegroups, $specialtemplates, $vbulletin, $vbphrase;
 21
 22$phrasegroups = array('cphome','cpuser');
 23$specialtemplates = array();
 24global $DEVDEBUG, $cpnavjs;
 25// ########################## REQUIRE BACK-END ############################
 26require_once(dirname(__FILE__) . '/global.php');
 27
 28// ############################# LOG ACTION ###############################
 29if (empty($_REQUEST['do']))
 30{
 31	log_admin_action();
 32}
 33
 34// ########################################################################
 35// ######################### START MAIN SCRIPT ############################
 36// ########################################################################
 37$vbulletin->input->clean_array_gpc('r', array('redirect' => vB_Cleaner::TYPE_NOHTML)); # Not sure where this comes from
 38if (!empty($vbulletin->GPC['redirect']))
 39{
 40	$redirect =  vB_String::parseUrl($vbulletin->GPC['redirect']);
 41	$pathinfo = pathinfo($redirect['path']);
 42	$file = $pathinfo['filename'];
 43	parse_str($redirect['query'], $args);
 44
 45	print_stop_message2('redirecting_please_wait',$file, $args);
 46}
 47
 48// #############################################################################
 49// ############################### LOG OUT OF CP ###############################
 50// #############################################################################
 51
 52if ($_REQUEST['do'] == 'cplogout')
 53{
 54	vbsetcookie('cpsession', '', false, true, true);
 55	$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "cpsession WHERE userid = " . $vbulletin->userinfo['userid'] . " AND hash = '" . $vbulletin->db->escape_string($vbulletin->GPC[COOKIE_PREFIX . 'cpsession']) . "'");
 56	$sessionurl_js = vB::getCurrentSession()->get('sessionurl_js');
 57	if (!empty($sessionurl_js))
 58	{
 59		exec_header_redirect('index.php?' . $sessionurl_js);
 60	}
 61	else
 62	{
 63		exec_header_redirect('index.php');
 64	}
 65}
 66
 67if (empty($_REQUEST['do']))
 68{
 69	$_REQUEST['do'] = 'frames';
 70}
 71
 72// ####################################################################
 73if ($_REQUEST['do'] == 'frames')
 74{
 75	$vbulletin->input->clean_array_gpc('r', array(
 76		'loc' => vB_Cleaner::TYPE_NOHTML
 77	));
 78
 79	$navframe = '<frame src="index.php?' . vB::getCurrentSession()->get('sessionurl') . "do=nav" . iif($cpnavjs, '&amp;cpnavjs=1') . "\" name=\"nav\" scrolling=\"yes\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" border=\"no\" />\n";
 80	$headframe = '<frame src="index.php?' . vB::getCurrentSession()->get('sessionurl') . "do=head\" name=\"head\" scrolling=\"no\" noresize=\"noresize\" frameborder=\"0\" marginwidth=\"10\" marginheight=\"0\" border=\"no\" />\n";
 81	$mainframe = '<frame src="' . iif(!empty($vbulletin->GPC['loc']) AND !preg_match('#^[a-z]+:#i', $vbulletin->GPC['loc']), create_full_url($vbulletin->GPC['loc']), 'index.php?' . vB::getCurrentSession()->get('sessionurl') . 'do=home') . "\" name=\"main\" scrolling=\"yes\" frameborder=\"0\" marginwidth=\"10\" marginheight=\"10\" border=\"no\" />\n";
 82
 83?>
 84<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
 85<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo vB_Template_Runtime::fetchStyleVar('textdirection'); ?>" lang="<?php echo vB_Template_Runtime::fetchStyleVar('languagecode'); ?>">
 86<head>
 87<script type="text/javascript">
 88<!-- // get out of any containing frameset
 89if (self.parent.frames.length != 0)
 90{
 91	document.write('<span style="font: bold 10pt verdana,sans-serif">Get me out of this frame set!</span>');
 92	self.parent.location.replace(document.location.href);
 93}
 94// -->
 95</script>
 96<title><?php echo $vbulletin->options['bbtitle']; ?> <?php echo $vbphrase['moderator_control_panel']; ?></title>
 97</head>
 98
 99<?php
100
101if (vB_Template_Runtime::fetchStyleVar('textdirection') == 'ltr')
102{
103// left-to-right frameset
104?>
105<frameset cols="195,*"  framespacing="0" border="0" frameborder="0" frameborder="no" border="0">
106	<?php echo $navframe; ?>
107	<frameset rows="20,*"  framespacing="0" border="0" frameborder="0" frameborder="no" border="0">
108		<?php echo $headframe; ?>
109		<?php echo $mainframe; ?>
110	</frameset>
111</frameset>
112<?php
113}
114else
115{
116// right-to-left frameset
117?>
118<frameset cols="*,195"  framespacing="0" border="0" frameborder="0" frameborder="no" border="0">
119	<frameset rows="20,*"  framespacing="0" border="0" frameborder="0" frameborder="no" border="0">
120		<?php echo $headframe; ?>
121		<?php echo $mainframe; ?>
122	</frameset>
123	<?php echo $navframe; ?>
124</frameset>
125<?php
126}
127
128?>
129
130<noframes>
131	<body>
132		<p><?php echo $vbphrase['no_frames_support']; ?></p>
133	</body>
134</noframes>
135
136</html>
137<?php
138}
139
140// ####################################################################
141if ($_REQUEST['do'] == 'head')
142{
143	define('IS_NAV_PANEL', true);
144	print_cp_header();
145
146	$forumhomelink = fetch_seo_url('forumhome|bburl', array());
147?>
148<table border="0" width="100%" height="100%">
149<tr valign="middle">
150	<td><b><?php echo $vbphrase['moderator_control_panel']; ?></b> (vBulletin <?php echo $vbulletin->versionnumber; ?>)</td>
151	<td style="white-space:nowrap; text-align:<?php echo vB_Template_Runtime::fetchStyleVar('right'); ?>; font-weight:bold">
152			<a href="<?php echo $forumhomelink; ?>" target="_blank"><?php echo $vbphrase['forum_home_page']; ?></a>
153			|
154			<a href="index.php?<?php echo vB::getCurrentSession()->get('sessionurl'); ?>do=cplogout" onclick="return confirm('<?php echo $vbphrase['sure_you_want_to_log_out_of_cp']; ?>');"  target="_top"><?php echo $vbphrase['log_out']; ?></a>
155</td>
156</tr>
157</table>
158<?php
159	print_cp_footer();
160}
161
162// ####################################################################
163if ($_REQUEST['do'] == 'home')
164{
165
166print_cp_header($vbphrase['welcome_to_the_vbulletin_moderator_control_panel']);
167
168print_form_header('', '');
169print_table_header($vbphrase['welcome_to_the_vbulletin_moderator_control_panel']);
170print_table_footer();
171
172// *************************************
173// QUICK ADMIN LINKS
174
175//$reminders = fetch_reminders_array();
176
177print_table_start();
178print_table_header($vbphrase['quick_moderator_links']);
179
180$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
181$guestsarry = $vbulletin->db->query_first("SELECT COUNT(host) AS sessions FROM " . TABLE_PREFIX . "session WHERE userid = 0 AND lastactivity > $datecut");
182$membersarry = $vbulletin->db->query_read("SELECT DISTINCT userid FROM " . TABLE_PREFIX . "session WHERE userid <> 0 AND lastactivity > $datecut");
183$guests = intval($guestsarry['sessions']);
184$members = intval($vbulletin->db->num_rows($membersarry));
185
186$is_windows = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
187$loadavg = array();
188
189if (!$is_windows AND function_exists('exec') AND $stats = @exec('uptime 2>&1') AND trim($stats) != '' AND preg_match('#: ([\d.,]+),?\s+([\d.,]+),?\s+([\d.,]+)$#', $stats, $regs))
190{
191	$loadavg[0] = vb_number_format($regs[1], 2);
192	$loadavg[1] = vb_number_format($regs[2], 2);
193	$loadavg[2] = vb_number_format($regs[3], 2);
194}
195else if (!$is_windows AND @file_exists('/proc/loadavg') AND $stats = @file_get_contents('/proc/loadavg') AND trim($stats) != '')
196{
197	$loadavg = explode(' ', $stats);
198	$loadavg[0] = vb_number_format($loadavg[0], 2);
199	$loadavg[1] = vb_number_format($loadavg[1], 2);
200	$loadavg[2] = vb_number_format($loadavg[2], 2);
201}
202
203if (!empty($loadavg))
204{
205	print_label_row($vbphrase['server_load_averages'], "$loadavg[0]&nbsp;&nbsp;$loadavg[1]&nbsp;&nbsp;$loadavg[2] | " . construct_phrase($vbphrase['users_online_x_members_y_guests'], vb_number_format($guests + $members), vb_number_format($members), vb_number_format($guests)), '', 'top', NULL, false);
206}
207else
208{
209	print_label_row($vbphrase['users_online'], construct_phrase($vbphrase['x_y_members_z_guests'], vb_number_format($guests + $members), vb_number_format($members), vb_number_format($guests)), '', 'top', NULL, false);
210}
211
212// Legacy Hook 'mod_index_main' Removed //
213
214print_label_row($vbphrase['quick_user_finder'], '
215	<form action="user.php?do=findnames" method="post" style="display:inline">
216		<input type="hidden" name="s" value="' . vB::getCurrentSession()->get('sessionhash') . '" />
217		<input type="hidden" name="do" value="findnames" />
218	<input type="text" class="bginput" name="findname" size="30" tabindex="1" />
219	<input type="submit" class="button" value=" ' . $vbphrase['find'] . ' " tabindex="1" />
220	<input type="submit" class="button" value="' . $vbphrase['exact_match'] . '" tabindex="1" name="exact" />
221	</form>
222	', '', 'top', NULL, false
223);
224print_label_row($vbphrase['php_function_lookup'], '
225	<form action="http://www.ph' . 'p.net/manual-lookup.ph' . 'p" method="get" style="display:inline">
226	<input type="text" class="bginput" name="function" size="30" tabindex="1" />
227	<input type="submit" value=" ' . $vbphrase['find'] . ' " class="button" tabindex="1" />
228	</form>
229	', '', 'top', NULL, false
230);
231print_label_row($vbphrase['mysql_language_lookup'], '
232	<form action="http://www.mysql.com/search/" method="get" style="display:inline">
233	<input type="hidden" name="doc" value="1" />
234	<input type="hidden" name="m" value="o" />
235	<input type="text" class="bginput" name="q" size="30" tabindex="1" />
236	<input type="submit" value=" ' . $vbphrase['find'] . ' " class="button" tabindex="1" />
237	</form>
238	', '', 'top', NULL, false
239);
240print_label_row($vbphrase['useful_links'], '
241	<form style="display:inline">
242	<select onchange="if (this.options[this.selectedIndex].value != \'\') { window.open(this.options[this.selectedIndex].value); } return false;" tabindex="1" class="bginput">
243		<option value="">-- ' . $vbphrase['useful_links'] . ' --</option>' . construct_select_options(array(
244			'PHP' => array(
245				'http://www.ph' . 'p.net/' => $vbphrase['home_page'] . ' (PHP.net)',
246				'http://www.ph' . 'p.net/manual/' => $vbphrase['reference_manual'],
247				'http://www.ph' . 'p.net/downloads.ph' . 'p' => $vbphrase['download_latest_version']
248			),
249			'MySQL' => array(
250				'http://www.mysql.com/' => $vbphrase['home_page'] . ' (MySQL.com)',
251				'http://www.mysql.com/documentation/' => $vbphrase['reference_manual'],
252				'http://www.mysql.com/downloads/' => $vbphrase['download_latest_version'],
253			)
254	)) . '</select>
255	</form>
256	', '', 'top', NULL, false
257);
258print_table_footer(2, '', '', false);
259
260// *************************************
261// vBULLETIN CREDITS
262require_once(DIR . '/includes/vbulletin_credits.php');
263
264print_cp_footer();
265}
266
267// ####################################################################
268if ($_REQUEST['do'] == 'nav')
269{
270	require_once(DIR . '/includes/adminfunctions_navpanel.php');
271	print_cp_header();
272	?>
273<div>
274<img src="../cpstyles/<?php echo $vbulletin->options['cpstylefolder']; ?>/cp_logo.<?php echo $vbulletin->options['cpstyleimageext']; ?>" alt="" border="0" hspace="4" vspace="4" />
275	<?php
276	echo "</div>\n\n<div style=\"width:168px; padding: 4px\">\n";
277
278	construct_nav_spacer();
279
280	// *************************************************
281	/*
282	if (can_moderate(0, 'canannounce'))
283	{
284		construct_nav_option($vbphrase['post_new_announcement_gcphome'], 'announcement.php?do=add');
285		construct_nav_option($vbphrase['forum_manager_gcphome'], 'forum.php?do=modify');
286		construct_nav_group($vbphrase['announcements']);
287		construct_nav_spacer();
288	}
289	 */
290	// *************************************************
291	$canmoderate = false;
292	/*
293	if (can_moderate(0, 'canmoderateposts'))
294	{
295		$canmoderate = true;
296		construct_nav_option($vbphrase['moderate_threads_gcphome'], 'moderate.php?do=posts');
297		construct_nav_option($vbphrase['moderate_posts_gcphome'], 'moderate.php?do=posts#posts');
298	}
299	 */
300	/*
301	if (can_moderate(0, 'canmoderateattachments'))
302	{
303		$canmoderate = true;
304		construct_nav_option($vbphrase['moderate_attachments_gcphome'], 'moderate.php?do=attachments');
305	}
306	 */
307	/*
308	if (can_moderate_calendar())
309	{
310		$canmoderate = true;
311		construct_nav_option($vbphrase['moderate_events_gcphome'], 'moderate.php?do=events');
312	}
313	if (can_moderate(0, 'canmoderatevisitormessages'))
314	{
315		$canmoderate = true;
316		construct_nav_option($vbphrase['moderate_visitor_messages'], 'moderate.php?do=messages');
317	}
318	 */
319	if ($canmoderate)
320	{
321		construct_nav_group($vbphrase['moderation']);
322		construct_nav_spacer();
323	}
324	// *************************************************
325	$canuser = false;
326	if (can_moderate(0, 'canunbanusers') OR can_moderate(0, 'canbanusers') OR can_moderate(0, 'canviewprofile') OR can_moderate(0, 'caneditsigs') OR can_moderate(0, 'caneditavatar'))
327	{
328		$canuser = true;
329		construct_nav_option($vbphrase['search_for_users'],'user.php?do=find');
330	}
331	if (can_moderate(0, 'canbanusers'))
332	{
333		$canuser = true;
334		construct_nav_option($vbphrase['ban_user_gcphome'], 'banning.php?do=banuser');
335	}
336
337	if (can_moderate(0, 'canunbanusers') OR can_moderate(0, 'canbanusers'))
338	{
339		$canuser = true;
340		construct_nav_option($vbphrase['view_banned_users'], 'banning.php?do=modify');
341	}
342
343	if (can_moderate(0, 'canviewips'))
344	{
345		$canuser = true;
346		construct_nav_option($vbphrase['search_ip_addresses_gcphome'], 'user.php?do=doips');
347	}
348	if ($canuser)
349	{
350		construct_nav_group($vbphrase['users']);
351		construct_nav_spacer();
352	}
353	// *************************************************
354	if ($groupleader = $vbulletin->db->query_first("SELECT userid FROM " . TABLE_PREFIX . "usergroupleader WHERE userid = " . $vbulletin->userinfo['userid']) OR ($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
355	{
356		construct_nav_option($vbphrase['join_requests'], 'user.php?do=viewjoinrequests');
357		construct_nav_group($vbphrase['usergroups']);
358		construct_nav_spacer();
359	}
360	// *************************************************
361	/*
362	$canmass = false;
363	if (can_moderate(0, 'canmassmove'))
364	{
365		$canmass = true;
366		construct_nav_option($vbphrase['move'], 'thread.php?do=move');
367	}
368	if (can_moderate(0, 'canmassprune'))
369	{
370		$canmass = true;
371		construct_nav_option($vbphrase['prune'], 'thread.php?do=prune');
372	}
373	if ($canmass)
374	{
375		construct_nav_group($vbphrase['thread']);
376		construct_nav_spacer();
377	}
378	*/
379	// Legacy Hook 'mod_index_navigation' Removed //
380
381	print_nav_panel();
382
383	echo "</div>\n";
384	// *************************************************
385
386	define('NO_CP_COPYRIGHT', true);
387	unset($DEVDEBUG);
388	print_cp_footer();
389}
390
391/*======================================================================*\
392|| ####################################################################
393|| # CVS: $RCSfile$ - $Revision: 70525 $
394|| ####################################################################
395\*======================================================================*/