Файловый менеджер - Редактировать - /var/www/readzy/core/src/store.php
Назад
<?php namespace readzy; use readzy\db; use Exception; use DateTime; use DateTimeZone; class store { public static function status($api) { $jsonData = file_get_contents('php://input'); $data = json_decode($jsonData); if($data){ db::query("INSERT INTO status (data, date, expires_date_formatted, product_id, transaction_id, notification_type)VALUES(?,?,?,?,?,?)", [ $jsonData, date('Y-m-d H:i:s'), date('Y-m-d H:i:s', strtotime($data->latest_receipt_info->expires_date_formatted)), $data->latest_receipt_info->product_id, $data->latest_receipt_info->transaction_id, $data->notification_type ]); return ['pass' => true]; }else{ return ['pass' => false]; } } public static function validate($api) { if(!isset($api->data['receipt'])){ return ['error' => 'Missing Receipt ID']; } try { //if($sandbox){ //$end_point = 'https://sandbox.itunes.apple.com/verifyReceipt'; //}else{ $end_point = 'https://buy.itunes.apple.com/verifyReceipt'; //} $ch = curl_init($end_point); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('receipt-data' => $api->data['receipt'], 'password' => '63852257f2ca4a90994659bd6b63bce2', 'exclude-old-transactions' => true))); $response = curl_exec($ch); $errno = curl_errno($ch); $errmsg = curl_error($ch); curl_close($ch); if ($errno !== 0) { throw new Exception($errmsg, $errno); } $data = json_decode($response); if(isset($data->status) && $data->status === 0){ if($data->latest_receipt_info[0]){ //Check date $tz = new DateTimeZone($_ENV['timezone']); $date = new DateTime($data->latest_receipt_info[0]->expires_date); $date->setTimezone($tz); if(date('Y-m-d H:i:s') <= $date->format('Y-m-d H:i:s')){ db::query("INSERT INTO log (date, uri, response, data)VALUES(?,?,?,?)", [ date('Y-m-d H:i:s'), '', 'Active:true', $api->data['receipt'] ]); return ['pass' => true, 'active' => true]; } } } } catch (Exception $ex) { db::query("INSERT INTO log (date, uri, response, data)VALUES(?,?,?,?)", [ date('Y-m-d H:i:s'), '', 'Error:true', $api->data['receipt'] ]); return ['pass' => false, 'active' => false]; } db::query("INSERT INTO log (date, uri, response, data)VALUES(?,?,?,?)", [ date('Y-m-d H:i:s'), '', 'Active:false', $api->data['receipt'] ]); return ['pass' => false, 'active' => false]; } } ?>
| ver. 1.4 |
Github
|
.
| PHP 7.0.33-0ubuntu0.16.04.16 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка