<?PHP
include"../inc/var.php";
include "../inc/connect.php";
include $server_inc."/whm_functions.php";

dbbackup($email_admin, $server_backup, $dbhost, $dbuser, $dbpass, $db, $http_admin, $http_images, $which);

$query="select ";
$query.="count(*) ";
$query.="from ";
$query.="session_history ";
$query.="where ";
$query.="locked='1'";

$rs0=mysql_fetch_row(mysql_query($query));

$session_history_count=$rs0[0];

if ($session_history_count>0)
	{
	$query0="select ";
	$query0.="subject, ";
	$query0.="message, ";
	$query0.="default_email ";
	$query0.="from ";
	$query0.="email_templates ";
	$query0.="where ";
	$query0.="emid='40' ";
	$query0.="limit 0, 1";

	$rs0=mysql_fetch_row(mysql_query($query0));

	$subject=stripslashes(trim($rs0[0]));
	$message=stripslashes(trim($rs0[1]));
	$default_email=stripslashes(trim($rs0[2]));
	$generate_date=date("m/d/Y h:i:s a");

	$subject=str_replace("{{incomplete_orders}}", $session_history_count, $subject);
	$subject=str_replace("{{generate_date}}", $generate_date, $subject);

	$message=str_replace("{{incomplete_orders}}", $session_history_count, $message);
	$message=str_replace("{{generate_date}}", $generate_date, $message);

	$headers="From: ".(($default_email!="")?"".$default_email."":"".$email_admin."")."";
	$headers.="\nReply-To: ".$email_admin;
	$headers.="\nX-Mailer: PHP/".phpversion();
	$headers.="\nX-Priority: 1"; 

	mail($email_admin, $subject, $message, $headers);
	}

mysql_close($dblink);
?>