Skip to content

Instantly share code, notes, and snippets.

@zmiulan
Last active May 7, 2021 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zmiulan/c78212506c0ec590cf10ffe4e09ef3a9 to your computer and use it in GitHub Desktop.
Save zmiulan/c78212506c0ec590cf10ffe4e09ef3a9 to your computer and use it in GitHub Desktop.
Переоткрытие смены для kkmserver
<?php $ch = curl_init();
// обратите внимание на IP:порт, поменяйте на свои
$options = array(
CURLOPT_URL => 'https://127.0.0.1:5893/Execute',
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => '',
CURLOPT_HEADER => true,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($ch, CURLOPT_STDERR, $fp);
// будет закрыта смена кассы под номером 1
// обратите внимание на параметр NumDevice, укажите нужный Вам, если у вас своя конфигурация
$data = array("Command" => "CloseShift","NumDevice" => 1);
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
// настройки логин/пасс для ккмсервера
$username = "User";
$password = "Password";
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
$response = curl_exec($ch);
$curlError = 0;
if(curl_errno($ch))
{
$curlError = curl_error($ch);
$responseArray = array('httpError' => $curlError);
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$responseArray = array(
'headers' => $headers,
'body' => $body,
'httpStatusCode' => $httpStatusCode,
'httpError' => $curlError
);
}
curl_close($ch);
//var_dump($responseArray);
<?php $ch = curl_init();
// обратите внимание на IP:порт, поменяйте на свои
$options = array(
CURLOPT_URL => 'https://127.0.0.1:5893/Execute',
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => '',
CURLOPT_HEADER => true,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($ch, CURLOPT_STDERR, $fp);
// будет открыта смена кассы под номером 1
// обратите внимание на параметр NumDevice, укажите нужный Вам, если у вас своя конфигурация
$data = array("Command" => "OpenShift","NumDevice" => 1);
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
// настройки логин/пасс для ккмсервера
$username = "User";
$password = "Password";
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
$response = curl_exec($ch);
$curlError = 0;
if(curl_errno($ch))
{
$curlError = curl_error($ch);
$responseArray = array('httpError' => $curlError);
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$responseArray = array(
'headers' => $headers,
'body' => $body,
'httpStatusCode' => $httpStatusCode,
'httpError' => $curlError
);
}
curl_close($ch);
//var_dump($responseArray);
0 0 * * * /home/kkmserver/shift.sh
#/bin/bash
cd "$(dirname "$0")"
php -f ./closeshift.php
php -f ./openshift.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment