|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* m'Manager | Invoices Management System |
|
4
|
|
|
* |
|
5
|
|
|
* This content is released under the Proprietary License (Proprietary) |
|
6
|
|
|
* |
|
7
|
|
|
* Copyright (c) 2017, Eric Claver AKAFFOU - All Rights Reserved |
|
8
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited |
|
9
|
|
|
* Proprietary and confidential |
|
10
|
|
|
* |
|
11
|
|
|
* @package m'Manager |
|
12
|
|
|
* @author Eric Claver AKAFFOU |
|
13
|
|
|
* @copyright Copyright (c) 2017, on'Eric Computing, Inc. (https://www.onericcomputing.com/) |
|
14
|
|
|
* @license https://www.mmanager.fr Proprietary License |
|
15
|
|
|
* @link https://codecanyon.net/item/mmanager-invoices-management-system/19866435?s_rank=1 |
|
16
|
|
|
* @since Version 1.0.0 |
|
17
|
|
|
* @filesource |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Mmanager; |
|
21
|
|
|
|
|
22
|
|
|
use Mmanager\Domain\Repository\Customer\CustomerRepository; |
|
23
|
|
|
use Mmanager\Domain\Repository\Invoice\InvoiceRepository; |
|
24
|
|
|
use Mmanager\Persistence\Adapter\CodeIgniter\CIQueryBuilder; |
|
25
|
|
|
use Mmanager\Logger\FileLogger; |
|
26
|
|
|
use Mmanager\Logger\FileLoggerFactory; |
|
27
|
|
|
|
|
28
|
|
|
class Mmanager |
|
29
|
|
|
{ |
|
30
|
|
|
protected $user_id; |
|
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); |
|
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; |
|
81
|
|
|
|
|
82
|
|
|
$loggerFactory = new FileLoggerFactory($filePath); |
|
83
|
|
|
$logger = $loggerFactory->createLogger(); |
|
84
|
|
|
|
|
85
|
|
|
$logger->log($log_msg); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: