forked from retailcrm/tiu-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.php
More file actions
33 lines (25 loc) · 789 Bytes
/
run.php
File metadata and controls
33 lines (25 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require(__DIR__ . "/classes/ApiHelper.php");
require(__DIR__ . "/config/config.php");
if (! file_exists(__DIR__ . "/logs")) {
mkdir(__DIR__ . "/logs");
}
if (file_exists(__DIR__ . "/logs/cookie.txt")) {
unlink(__DIR__ . "/logs/cookie.txt");
}
$lockFile = __DIR__ . "/run.lock";
if (file_exists($lockFile)) {
if ((int)file_get_contents($lockFile) > time()) {
echo "script is busy";
exit();
}
}
file_put_contents("run.lock", strtotime('+5 minutes'));
if (file_exists(__DIR__ . "/logs/sync.log")) {
$config['date_from'] = file_get_contents(__DIR__ . "/logs/sync.log");
}
$apiHelper = new ApiHelper($config);
if ($apiHelper->processXMLOrders()) {
unlink($lockFile);
file_put_contents(__DIR__ . "/logs/sync.log", date('Y-m-d H:i:s'));
}