<?php
require_once 'auctionsManager.php';
require_once 'conf.php';
// set max_execution_time in php.ini
//2678400 month or if safe_mode is turned of use this function
set_time_limit(18000);
@ini_set('memory_limit','128M');
//with this function you can send allert about script via email
function sendMail($body){
$to = "recipient@example.com";
$subject = "Urgent Problem with Allegro WebApi!";
mail($to, $subject, $body);
}
function auctionsIn($allegro,$logs){
if ($handle = opendir(constant('AUCTIONS_DIR'))) {
while(($file = readdir($handle))!=false){
if( substr($file,0,3) == 'ftp' ){
$ourFileHandle = fopen(constant('AUCTIONS_DIR').'/tmp/'.$file, 'w') or die("can't open file");
fclose($ourFileHandle);
copy(constant('AUCTIONS_DIR').$file,constant('AUCTIONS_DIR').'/tmp/'.$file);
unlink(constant('AUCTIONS_DIR').$file);
$itemsCount=$allegro->loadFile(constant('AUCTIONS_DIR').'/tmp/'.$file);
unlink(constant('AUCTIONS_DIR').'/tmp/'.$file);
$logs->log(" SEND ".$itemsCount." items send to Allegro.");
//break;
}
}
}
return $rushHour;
}
$logs = new Logs();
$logs->log(" START Script started.");
$allegro=new AuctionsManager();
//echo "-".memory_get_usage() . "-memory usage\r\n";
if($allegro==false)log(" ERR Sorry, I could not initiate connection.");
else{
auctionsIn($allegro,$logs);
$allegro->checkSold();
//$allegro->checkNotSold();
unset($allegro);
}
?>
|