/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Async
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Async/CronController.php (4227B)
Auth->allow();
}
public function every5minutes()
{
if (isset($_GET['key']) && trim($_GET['key']) == "YaI7kr7HKx8ncUagsE2i") {
//$this->checkRecharge();
}
die('All good');
}
public function everyDay()
{
if (isset($_GET['key']) && trim($_GET['key']) == "YaI7kr7HKx8ncUagsE2i") {
//$this->cancelApay();
}
die('All good');
}
public function everyMonth()
{
if (isset($_GET['key']) && trim($_GET['key']) == "YaI7kr7HKx8ncUagsE2i") {
//$this->sendMonthlyCiel(date('n', strtotime("-1 months")), date('Y', strtotime("-1 months")));
}
die('All good');
}
public function cancelApay()
{
$this->loadModel("Orders");
$orders = $this->Orders->find('all')
->where(['Orders.active' => true])
->where(['Orders.order_status_id' => STATUS_APAY])
->where(['Orders.created < ' => new Time('Today')])
->order(['Orders.created' => 'ASC'])
->all();
if (!empty($orders)) {
foreach ($orders as $order) {
$this->Orders->setStatus($order->id, STATUS_CANC, "Comanda a fost anulată. (CRON)");
}
} else {
echo 'No entries | ';
}
}
public function checkRecharge($operator_id = 3)
{
//Only Telekom
$this->loadModel("Orders");
$orders = $this->Orders->find('all')
->where(['Orders.active' => true])
->where(['Orders.order_status_id' => STATUS_INVC])
->where(['Orders.gatewayID IS NULL'])
//->where(['Orders.operator_id' => $operator_id])
->where(['Orders.recharge_retries >= ' => 1])
->where(['Orders.prcId IS NULL'])
->where(['Orders.created > ' => new Time('-10 hours')])
->order(['Orders.created' => 'ASC'])
->limit(2)
->all();
if (!empty($orders)) {
foreach ($orders as $order) {
$this->doRecharge($order->id, false, hexdec(rand(1, 9999999)));
echo 'Recharge #' . $order->id . ' | ';
}
} else {
echo 'No entries | ';
}
}
public function sendMonthlyCiel($month = false, $year = false)
{
if (!$year || !is_numeric($year) || $year < 2020 || $year > date('Y')) {
$year = date('Y');
}
if (!$month || !is_numeric($month) || $month < 1 || $month > 12) {
$month = date('n');
}
$filename = "zoomdigital-" . $year . '-' . str_pad((string) $month, 2, "0", STR_PAD_LEFT) . '.xml';
$filepath = CACHE . 'ciel' . DS;
if (!is_dir($filepath)) {
mkdir($filepath, 0755, true);
}
$url = Router::url(['_ext' => 'xml', 'controller' => 'Cron', 'action' => 'doCiel', $month, $year], true);
set_time_limit(0);
$xml_file = file_get_contents($url);
$xml_file = str_replace(array('
', ''), '', $xml_file);
file_put_contents($filepath . $filename, $xml_file);
}
function array_to_xml($array, &$xml_user_info)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
if (!is_numeric($key)) {
$subnode = $xml_user_info->addChild($key);
$this->array_to_xml($value, $subnode);
} else {
$subnode = $xml_user_info->addChild(key($array[$key]));
$this->array_to_xml($value[key($array[$key])], $subnode);
}
} else {
$xml_user_info->addChild($key, html_entity_decode($value));
}
}
}
}