@@ -22,8 +22,8 @@ |
||
| 22 | 22 | |
| 23 | 23 | class StdoutLogger implements LoggerInterface |
| 24 | 24 | { |
| 25 | - public function log(string $message) |
|
| 26 | - { |
|
| 27 | - echo $message; |
|
| 28 | - } |
|
| 25 | + public function log(string $message) |
|
| 26 | + { |
|
| 27 | + echo $message; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -22,5 +22,5 @@ |
||
| 22 | 22 | |
| 23 | 23 | interface LoggerInterface |
| 24 | 24 | { |
| 25 | - public function log(string $message); |
|
| 25 | + public function log(string $message); |
|
| 26 | 26 | } |
@@ -22,18 +22,18 @@ |
||
| 22 | 22 | |
| 23 | 23 | class FileLogger implements LoggerInterface |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - private $filePath; |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + private $filePath; |
|
| 29 | 29 | |
| 30 | - public function __construct(string $filePath) |
|
| 31 | - { |
|
| 32 | - $this->filePath = $filePath; |
|
| 33 | - } |
|
| 30 | + public function __construct(string $filePath) |
|
| 31 | + { |
|
| 32 | + $this->filePath = $filePath; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function log(string $message) |
|
| 36 | - { |
|
| 37 | - file_put_contents($this->filePath, $message . PHP_EOL, FILE_APPEND); |
|
| 38 | - } |
|
| 35 | + public function log(string $message) |
|
| 36 | + { |
|
| 37 | + file_put_contents($this->filePath, $message . PHP_EOL, FILE_APPEND); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -34,6 +34,6 @@ |
||
| 34 | 34 | |
| 35 | 35 | public function log(string $message) |
| 36 | 36 | { |
| 37 | - file_put_contents($this->filePath, $message . PHP_EOL, FILE_APPEND); |
|
| 37 | + file_put_contents($this->filePath, $message.PHP_EOL, FILE_APPEND); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | |
| 23 | 23 | class StdoutLoggerFactory implements LoggerFactory |
| 24 | 24 | { |
| 25 | - public function createLogger(): LoggerInterface |
|
| 26 | - { |
|
| 27 | - return new StdoutLogger(); |
|
| 28 | - } |
|
| 25 | + public function createLogger(): LoggerInterface |
|
| 26 | + { |
|
| 27 | + return new StdoutLogger(); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -27,61 +27,61 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Mmanager |
| 29 | 29 | { |
| 30 | - protected $user_id; |
|
| 30 | + protected $user_id; |
|
| 31 | 31 | |
| 32 | - public function __construct() { |
|
| 33 | - $this->Customer = new CustomerRepository(new CIQueryBuilder); |
|
| 34 | - $this->Invoice = new InvoiceRepository(new CIQueryBuilder); |
|
| 35 | - $this->user_id = get_user_id(); |
|
| 36 | - } |
|
| 37 | - public function setUserID($user_id = null) { |
|
| 38 | - $this->user_id = isset($user_id) ? $user_id : get_user_id(); |
|
| 39 | - return $this; |
|
| 40 | - } |
|
| 41 | - public function getUserID() |
|
| 42 | - { |
|
| 43 | - return $this->user_id; |
|
| 44 | - } |
|
| 45 | - public static function getUrl($request_url) { |
|
| 46 | - $ch = curl_init(); |
|
| 47 | - curl_setopt($ch, CURLOPT_URL, $request_url); |
|
| 48 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); |
|
| 49 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 50 | - $response = curl_exec($ch); |
|
| 51 | - curl_close($ch); |
|
| 32 | + public function __construct() { |
|
| 33 | + $this->Customer = new CustomerRepository(new CIQueryBuilder); |
|
| 34 | + $this->Invoice = new InvoiceRepository(new CIQueryBuilder); |
|
| 35 | + $this->user_id = get_user_id(); |
|
| 36 | + } |
|
| 37 | + public function setUserID($user_id = null) { |
|
| 38 | + $this->user_id = isset($user_id) ? $user_id : get_user_id(); |
|
| 39 | + return $this; |
|
| 40 | + } |
|
| 41 | + public function getUserID() |
|
| 42 | + { |
|
| 43 | + return $this->user_id; |
|
| 44 | + } |
|
| 45 | + public static function getUrl($request_url) { |
|
| 46 | + $ch = curl_init(); |
|
| 47 | + curl_setopt($ch, CURLOPT_URL, $request_url); |
|
| 48 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); |
|
| 49 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 50 | + $response = curl_exec($ch); |
|
| 51 | + curl_close($ch); |
|
| 52 | 52 | |
| 53 | - return $response; |
|
| 54 | - } |
|
| 55 | - public static function isValidLicense() { |
|
| 56 | - $request_url = 'https://www.mmanager.fr/process.php?r=cl&rf='.base_url().'&pc='.get_option('purchase_code'); |
|
| 57 | - return self::getUrl($request_url); |
|
| 58 | - } |
|
| 59 | - public static function expire() { |
|
| 60 | - $validity = self::isValidLicense(); |
|
| 61 | - if ($validity == 1) { |
|
| 62 | - return '<span style="color:green">'. strtoupper(__('label_never')).'</span>'; |
|
| 63 | - } else { |
|
| 64 | - return '<span style="color:red">'.strtoupper(__('message_contact_reseller_support')).'</span>'; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - public static function LicenseDetails() { |
|
| 68 | - return '<p><span><strong>'. __('label_license_details'). '</strong></span><ul><li>'.__('label_domain'). rtrim(base_url(), '/').'</li><li>Status: '. is_valid_license(self::isValidLicense()).'</li><li>Expires: '. self::expire().'</li></ul></em></p>'; |
|
| 69 | - } |
|
| 70 | - public static function render($module, $view_file, $data = null, $return = false) { |
|
| 71 | - return __render($module, $view_file, $data, $return); |
|
| 72 | - } |
|
| 73 | - public static function write_log($log_msg, $folder, $extension) |
|
| 74 | - { |
|
| 75 | - if (!file_exists($folder)) |
|
| 76 | - { |
|
| 77 | - // create directory. |
|
| 78 | - mkdir($folder, 0777, true); |
|
| 79 | - } |
|
| 80 | - $filePath = $folder.'/log-' . date('Y-m-d') . '.'.$extension; |
|
| 53 | + return $response; |
|
| 54 | + } |
|
| 55 | + public static function isValidLicense() { |
|
| 56 | + $request_url = 'https://www.mmanager.fr/process.php?r=cl&rf='.base_url().'&pc='.get_option('purchase_code'); |
|
| 57 | + return self::getUrl($request_url); |
|
| 58 | + } |
|
| 59 | + public static function expire() { |
|
| 60 | + $validity = self::isValidLicense(); |
|
| 61 | + if ($validity == 1) { |
|
| 62 | + return '<span style="color:green">'. strtoupper(__('label_never')).'</span>'; |
|
| 63 | + } else { |
|
| 64 | + return '<span style="color:red">'.strtoupper(__('message_contact_reseller_support')).'</span>'; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + public static function LicenseDetails() { |
|
| 68 | + return '<p><span><strong>'. __('label_license_details'). '</strong></span><ul><li>'.__('label_domain'). rtrim(base_url(), '/').'</li><li>Status: '. is_valid_license(self::isValidLicense()).'</li><li>Expires: '. self::expire().'</li></ul></em></p>'; |
|
| 69 | + } |
|
| 70 | + public static function render($module, $view_file, $data = null, $return = false) { |
|
| 71 | + return __render($module, $view_file, $data, $return); |
|
| 72 | + } |
|
| 73 | + public static function write_log($log_msg, $folder, $extension) |
|
| 74 | + { |
|
| 75 | + if (!file_exists($folder)) |
|
| 76 | + { |
|
| 77 | + // create directory. |
|
| 78 | + mkdir($folder, 0777, true); |
|
| 79 | + } |
|
| 80 | + $filePath = $folder.'/log-' . date('Y-m-d') . '.'.$extension; |
|
| 81 | 81 | |
| 82 | - $loggerFactory = new FileLoggerFactory($filePath); |
|
| 83 | - $logger = $loggerFactory->createLogger(); |
|
| 82 | + $loggerFactory = new FileLoggerFactory($filePath); |
|
| 83 | + $logger = $loggerFactory->createLogger(); |
|
| 84 | 84 | |
| 85 | - $logger->log($log_msg); |
|
| 86 | - } |
|
| 85 | + $logger->log($log_msg); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -59,25 +59,25 @@ |
||
| 59 | 59 | public static function expire() { |
| 60 | 60 | $validity = self::isValidLicense(); |
| 61 | 61 | if ($validity == 1) { |
| 62 | - return '<span style="color:green">'. strtoupper(__('label_never')).'</span>'; |
|
| 62 | + return '<span style="color:green">'.strtoupper(__('label_never')).'</span>'; |
|
| 63 | 63 | } else { |
| 64 | 64 | return '<span style="color:red">'.strtoupper(__('message_contact_reseller_support')).'</span>'; |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | public static function LicenseDetails() { |
| 68 | - return '<p><span><strong>'. __('label_license_details'). '</strong></span><ul><li>'.__('label_domain'). rtrim(base_url(), '/').'</li><li>Status: '. is_valid_license(self::isValidLicense()).'</li><li>Expires: '. self::expire().'</li></ul></em></p>'; |
|
| 68 | + return '<p><span><strong>'.__('label_license_details').'</strong></span><ul><li>'.__('label_domain').rtrim(base_url(), '/').'</li><li>Status: '.is_valid_license(self::isValidLicense()).'</li><li>Expires: '.self::expire().'</li></ul></em></p>'; |
|
| 69 | 69 | } |
| 70 | 70 | public static function render($module, $view_file, $data = null, $return = false) { |
| 71 | 71 | return __render($module, $view_file, $data, $return); |
| 72 | 72 | } |
| 73 | 73 | public static function write_log($log_msg, $folder, $extension) |
| 74 | 74 | { |
| 75 | - if (!file_exists($folder)) |
|
| 75 | + if ( ! file_exists($folder)) |
|
| 76 | 76 | { |
| 77 | 77 | // create directory. |
| 78 | 78 | mkdir($folder, 0777, true); |
| 79 | 79 | } |
| 80 | - $filePath = $folder.'/log-' . date('Y-m-d') . '.'.$extension; |
|
| 80 | + $filePath = $folder.'/log-'.date('Y-m-d').'.'.$extension; |
|
| 81 | 81 | |
| 82 | 82 | $loggerFactory = new FileLoggerFactory($filePath); |
| 83 | 83 | $logger = $loggerFactory->createLogger(); |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function __construct($platform = null, $api_key = null) { |
| 33 | 33 | |
| 34 | - $this->platform = isset($platform) ? $platform: null; |
|
| 35 | - $this->api_key = isset($api_key) ? $api_key: null; |
|
| 34 | + $this->platform = isset($platform) ? $platform : null; |
|
| 35 | + $this->api_key = isset($api_key) ? $api_key : null; |
|
| 36 | 36 | } |
| 37 | 37 | /** |
| 38 | 38 | * @return mixed |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | switch ($platform) { |
| 84 | 84 | case 'clickatell': |
| 85 | - $url = "https://platform.clickatell.com/messages/http/send?apiKey=". $api_key. "&to=".$phone_number."&content=".$message; |
|
| 85 | + $url = "https://platform.clickatell.com/messages/http/send?apiKey=".$api_key."&to=".$phone_number."&content=".$message; |
|
| 86 | 86 | break; |
| 87 | 87 | } |
| 88 | 88 | // Get cURL resource |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | array( |
| 100 | 100 | 'time' => date('Y-m-d h:i:sa'), |
| 101 | 101 | 'to' => $resp['messages'][0]['to'], |
| 102 | - 'status' => 1 == $resp['messages'][0]['accepted'] ? "success": "failed", |
|
| 102 | + 'status' => 1 == $resp['messages'][0]['accepted'] ? "success" : "failed", |
|
| 103 | 103 | 'errorCode' => $resp['messages'][0]['errorCode'], |
| 104 | 104 | 'errorDescription' => $resp['messages'][0]['errorDescription'] |
| 105 | 105 | ) |