2015-09-07 18:09:12 +03:00
|
|
|
|
<?php
|
|
|
|
|
require(__DIR__ . "/classes/ApiHelper.php");
|
|
|
|
|
require(__DIR__ . "/config/config.php");
|
|
|
|
|
|
|
|
|
|
if (! file_exists(__DIR__ . "/logs"))
|
|
|
|
|
mkdir(__DIR__ . "/logs");
|
2015-11-05 16:43:03 +03:00
|
|
|
|
|
2015-09-07 18:09:12 +03:00
|
|
|
|
if (file_exists(__DIR__ . "/logs/cookie.txt"))
|
|
|
|
|
unlink(__DIR__ . "/logs/cookie.txt");
|
|
|
|
|
|
|
|
|
|
$lockFile = __DIR__ . "/run.lock";
|
2015-11-05 16:43:03 +03:00
|
|
|
|
|
2015-09-07 18:09:12 +03:00
|
|
|
|
if (file_exists($lockFile)) {
|
|
|
|
|
if ((int)file_get_contents($lockFile) > time()) {
|
|
|
|
|
echo "script is busy";
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-05 16:43:03 +03:00
|
|
|
|
|
2015-09-07 18:09:12 +03:00
|
|
|
|
file_put_contents("run.lock", strtotime('+5 minutes'));
|
|
|
|
|
|
2015-11-05 16:43:03 +03:00
|
|
|
|
if (file_exists(__DIR__ . "/logs/sync.log")) {
|
|
|
|
|
$config['date_from'] = file_get_contents(__DIR__ . "/logs/sync.log");
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 18:09:12 +03:00
|
|
|
|
$apiHelper = new ApiHelper($сonfig);
|
|
|
|
|
|
|
|
|
|
if ($apiHelper->processXMLOrders())
|
2015-11-05 16:43:03 +03:00
|
|
|
|
unlink($lockFile);
|