<?PHP 

include("config.php");

if ((!isset($_POST['delete']) && !isset($_POST['validate'])) || !is_admin()) {
	header('Location: '.$site_url);
	die("validation_error");
}

if (isset($_POST['delete'])) {	
	// convert the array to a SQL friendly format
	$deleteList = "(".implode(',', $_POST['delete']).")";
	$deleteList = mysql_real_escape_string($deleteList);
	
	// build the SQL query to delete the edits that are bad
	$sql = "DELETE FROM ".$prefix."Runshops WHERE runshop_id IN $deleteList";
			  
	mysql_query($sql) or die(mysql_error());
}

if (isset($_POST['validate'])) {
	// convert the array to a SQL friendly format
	$idlist = "(".implode(',', $_POST['validate']).")";
	$idList = mysql_real_escape_string($idlist);
	
	// build the SQL query
	$sql = "UPDATE ".$prefix."Runshops
			  SET runshop_valid = 1
			  WHERE runshop_id IN $idlist;";
			  
			  
			  //echo $sql; exit;
	mysql_query($sql) or die(mysql_error());
	
}

header('Location: '.$site_url.'/validate.php');

?>