<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBHosting Version 2                                              # ||
|| # ---------------------------------------------------------------- # ||
|| # All PHP code in this file is ©2004 GameCrash.org.                # ||
|| # http://www.gamecrash.org (soon) | http://www.letzplay.de         # ||
|| # ---------------------------------------------------------------- # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
@set_time_limit(0);
ignore_user_abort(1);
$nozip = 1;

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('vbhosting_admincp', 'vbhosting_create');
$specialtemplates = array();

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');

// ############################# LOG ACTION ###############################
log_admin_action();

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

print_cp_header($vbphrase['vbhosting_admincp_header']);

if (empty($_REQUEST['do']))
{
	$_REQUEST['do'] = 'requests';
}

// ###################### Rebuild all style info #######################
if ($_REQUEST['do'] == 'requests')
{
	$queue = $DB_site->query("SELECT q.*, u.username FROM " . TABLE_PREFIX . "vbhosting_newforumqueue q, " . TABLE_PREFIX . "user u WHERE q.userid=u.userid");
	
	if ($DB_site->num_rows($queue) < 1)
	{
		print_stop_message('nothing_to_do');
	}
	
	print_form_header('vbhosting', 'dorequests');
	print_table_header($vbphrase['vbhosting_admincp_forumswaitingvalidation']);
	print_label_row($vbphrase['vbhosting_admincp_foruminfo'], $vbphrase['vbhosting_admincp_validate']);

	while($queueitem = $DB_site->fetch_array($queue))
	{
		$foruminfo = '';
		$foruminfo .= '<strong>' . $vbphrase['title'] . ': ' . htmlspecialchars_uni($queueitem['forumtitle']) . '</strong><br />';
		$foruminfo .= $vbphrase['vbhosting_admincp_requestedby'] . ': ' . htmlspecialchars_uni($queueitem['username']) . ' (' . vbdate($vboptions['dateformat'], $queueitem['requesttime']) . ' ' . vbdate($vboptions['timeformat'], $queueitem['requesttime']) . ')<br />';
		print_yes_no_other_row($foruminfo, 'queueitem[' . $queueitem['queueid'] . ']', $vbphrase['vbhosting_admincp_wait'], -1);
	}
	
	print_submit_row($vbphrase['update'], $vbphrase['reset']);

}

// ###################### Rebuild all style info #######################
if ($_POST['do'] == 'dorequests')
{
	require_once('./includes/functions_vbhosting.php');
	$redirtext = '';
	if (is_array($_POST['queueitem']))
	{
		$redirtext .= '<ul>';
		while(list($queueid, $validate) = each($_POST['queueitem']))
		{
			$iteminfo = $DB_site->query_first("SELECT * FROM " . TABLE_PREFIX . "vbhosting_newforumqueue WHERE queueid=$queueid");
			if ($validate == 0)
			{
				$redirtext .= '<li>' . construct_phrase($vbphrase['vbhosting_admincp_removingrequestfoforumrx'], htmlspecialchars_uni($iteminfo['forumtitle'])) . '</li>';
				$DB_site->query("DELETE FROM " . TABLE_PREFIX . "vbhosting_newforumqueue WHERE queueid=$queueid");
			}
			elseif ($validate == 1)
			{
				$redirtext .= '<li>' . construct_phrase($vbphrase['vbhosting_admincp_creatingforumrx'], htmlspecialchars_uni($iteminfo['forumtitle'])) . '</li>';
				vbhosting_create_forum($iteminfo['userid'], $iteminfo['forumtitle'], $iteminfo['forumdescription'], $iteminfo['websitelogo'], $iteminfo['websiteurl'], $iteminfo['websitetitle']);
				$DB_site->query("DELETE FROM " . TABLE_PREFIX . "vbhosting_newforumqueue WHERE queueid=$queueid");
			}
			else
			{
				$redirtext .= '<li>' . construct_phrase($vbphrase['vbhosting_admincp_keepingrequestfoforumrx'], htmlspecialchars_uni($iteminfo['forumtitle'])) . '</li>';
			}
		}
		$redirtext .= '</ul>';
	}
	
	define('CP_REDIRECT', 'vbhosting.php?do=requests');
	print_cp_message($redirtext, CP_REDIRECT);
}

print_cp_footer();

/*======================================================================*\
|| ####################################################################
|| # Downloaded: 07:08, Sat Jan 31st 2004
|| # CVS: $RCSfile: misc.php,v $ - $Revision: 1.108 $
|| ####################################################################
\*======================================================================*/
?>