Joywork/cron/checkZipalPackageStatus.php
2026-05-22 21:21:54 +03:00

81 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
set_time_limit(0);
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Проверка статуса объектов на Zipal.ru</title>
</head>
<body>
<?php
$sql = "SELECT id, user_id, zipal_id from advertising_package_object_publish WHERE sended = 1 and published = 1 and active = 1";
$rez_obj = mysql_query($sql);
while($object = mysql_fetch_assoc($rez_obj)) {
$objId = $object['id'];
$curUser = new User();
$curUser->get($object['user_id']);
$requestToSend = [];
$login = $curUser->zipal_login;
$password = $curUser->zipal_password;
if (empty($login) || empty($password)) {
$login = $curUser->agencyZipalLogin;
$password = $curUser->agencyZipalPassword;
}
$requestToSend = [];
$requestToSend['login'] = $login;
$requestToSend['password'] = $password;
$requestToSend['method'] = 'GetStatus';
$requestToSend['request'] = [];
$requestToSend['request']['requestType'] = 'GetStatusRequestType';
$requestToSend['request']['id'] = $object['zipal_id'];
$request = json_encode($requestToSend);
//echo $request;
//echo "<br/>";
$user_agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; HTC_Touch_Diamond2_T5353; Windows Phone 6.5)';
//делаем запрос к zipal
$result = curl_request_zipal_json("https://zipal.ru/ws/json", $object['user_id'], $user_agent, $request);
echo $result;
$jsonResult = json_decode($result, true);
if ($jsonResult['resultCode'] == "FAIL") {
//нет такого объекта
$sql = "UPDATE advertising_package_object_publish SET active = 0 WHERE id = $objId";
mysql_query($sql);
} else {
if ($jsonResult['resultCode'] == "OK") {
if ($jsonResult['result']['status'] == "PUBLISHED") {
//все ок
} else {
//статус поменялся - меняем и у нас
$sql = "UPDATE advertising_package_object_publish SET active = 0 WHERE id = $objId";
mysql_query($sql);
}
}
}
//sleep(1);
}
?>
</body>
</html>