Código PHP:
<?php
include ('config.cron.php');
include ('/libs/php/class.queue.php');
echo '<pre>';
$queue=new Queue();
//Opening new document
$handle = fopen(_PROJECTS_DIR."/temp/cron-queue-".date("Y-m-d").'.log', "a+");
fwrite($handle, "\n =================== START ===================== ".date("Y-m-d H:i")."\n");
fflush($handle);
//Checking the server status and queue storage
$serverOn=$queue->checkServer()?true:false;
$queueEmpty=$queue->checkIsEmpty()?true:false;
$send=$serverOn?$queueEmpty?false:true:false;
$msg=$serverOn?"Server OK...":"Server OK...";
$msg.=$queueEmpty?"Queue Empty\n":"Queue have msg\n";
if($send){
$sql = "SELECT count(idQueue) FROM MsgQueue";
$cont= $db->GetOne($sql);
//Looping for all msg from the queue
for ($i=1;$i<=$cont;$i++){
$fifo=$queue->getMsg($queue->fifo());
//Preparing the line of the msg
$msg="MSG ID".$fifo['idQueue']."\n"."MSG REQUEST:".$fifo['request']."\n\n";
//Checking if the resend function has been successful
$msg.=$queue->resendMsg()?"Send...Successful":"\n\nSend...Unsuccessful!\n";
fwrite($handle,$msg);
fflush($handle);
}
}
else{
fwrite ($handle, $msg);
}
fwrite($handle, "\n =================== FINISH ===================== ".date("Y-m-d H:i")."\n");
fflush($handle);
fclose($handle);
?>
Un saludo