<?php
/* MyTickets [   by = www.phpx3.com   ]
* Faha1ad2@hotmail.com
* Writed By : Fahad S. Al-ghudaier
* All Right Reseved (C) 2010
*/
session_start();
include("Admin_Function.php");
head('rtl','','');
includes();
check_session();

$language			= array();
$language['lang1']	= 'المعذرة ... يوجد خطأ بالمعطيات !!!';
$language['lang2']	= 'كلمة المرور خاطئة !';


if($permission['top_man'] == 1){ }else{
	show("no_permission.php");
	down();
	die();
}
if(empty($_GET['step'])){
	redirect('admin.php',0);
	die();
}



if($_GET['step'] == 'empty'){
	if(empty($_GET['ok'])){
		show('aus.php');
		down();
		die();
	}
	if(empty($_GET['password']) OR $_GET['password'] != $GLOBALS['tools_password']){
		echo '<script>alert("'.$language['lang2'].'")</script>';
		show('aus.php');
		down();
		die();
	}
	
	$delete	= mysql_query("DELETE FROM `tickets`");
	$delete2= mysql_query("DELETE FROM `reply");
	
	if($delete AND $delete2){
		ok('admin.php',5);
	}else{
		echo mysql_error();
	}
}



if($_GET['step'] == 'empty_old'){
	if(empty($_GET['ok'])){
		show('aus.php');
		down();
		die();
	}
	include('../include/config.php');
	if(! isset($tools_password)){ $tools_password=$GLOBALS['tools_password']; }
	if(empty($_GET['password']) OR $_GET['password'] != $tools_password){
		echo '<script>alert("'.$language['lang2'].'")</script>';
		show('aus.php');
		down();
		die();
	}
	
	$query	= mysql_query("SELECT `id` FROM `tickets` WHERE `new`='2'");
	if(mysql_num_rows($query) == 0){ ok('admin.php',2); down(); die(); }
	$TOTTAL = 0;
	while($rows	= mysql_fetch_array($query)){
		$delete = mysql_query("DELETE FROM `reply` WHERE `id`='".$rows['id']."'");
		$delete2= mysql_query("DELETE FROM `tickets` WHERE `id`='".$rows['id']."'");
		if($TOTTAL == 10){
			sleep(3);
			$TOTTAL = 0;
		}
		$TOTTAL = $TOTTAL+1;
	}
	
	if($delete AND $delete2){
		ok('admin.php',5);
	}else{
		echo mysql_error();
	}
}




	
down();
?>