├── .gitignore ├── README.md ├── composer.json ├── dist ├── empty └── ranger-whmcs.zip ├── scripts └── PackageModule.php └── src ├── .gitignore ├── LICENSE ├── composer.json ├── composer.lock ├── examples └── basic │ ├── .gitignore │ ├── composer.json │ ├── composer.lock │ ├── lib │ └── Ranger │ │ ├── Context.php │ │ ├── License.php │ │ └── ServerConnection.php │ └── validate.php ├── hooks.php ├── lib ├── App │ ├── ClientConnection.php │ ├── Context.php │ ├── License.php │ └── LicenseStore.php ├── ModuleParams.php └── Ranger.php ├── ranger.php ├── resources └── email_templates │ ├── welcome_basic.html │ └── welcome_basic.txt └── templates ├── error.tpl └── overview.tpl /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .idea 3 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
{$license->ranger_key}
" : 'Not generated',
82 | 'License Status' => "{$licenseStatus->label} — {$licenseStatus->description}",
83 | 'Valid IPs' => 'IP ranges may be used (10.0.1.0/24)',
84 | 'Valid Hostnames' => '',
85 | 'Valid Directories' => '',
86 | '' => 'Multiple environments can be added. Separate values with commas (1.1.1.1, 8.8.8.8). Remove a constraint to not validate against it. Constraints are not case sensitive.'
87 | ];
88 | }
89 | catch(\Exception $e)
90 | {
91 | return ['Error' => $e->getMessage()];
92 | }
93 | }
94 |
95 | function ranger_AdminServicesTabFieldsSave(array $params)
96 | {
97 | try
98 | {
99 | // Build the params
100 | $params = new ModuleParams($params);
101 |
102 | // Get the license
103 | $license = License::formWithWhmcsService($params->getService());
104 |
105 | $formatRestriction = function($restriction)
106 | {
107 | return trim(\Illuminate\Support\Str::lower($restriction));
108 | };
109 |
110 | if(isset($_REQUEST['ranger_valid_ips']))
111 | {
112 | $formInputValue = $formatRestriction($_REQUEST['ranger_valid_ips']);
113 | $license->validIps = $formInputValue ? array_map($formatRestriction, explode(",", htmlspecialchars_decode($formInputValue))) : null;
114 | }
115 |
116 | if(isset($_REQUEST['ranger_valid_hostnames']))
117 | {
118 | $formInputValue = $formatRestriction($_REQUEST['ranger_valid_hostnames']);
119 | $license->validHostnames = $formInputValue ? array_map($formatRestriction, explode(",", htmlspecialchars_decode($formInputValue))) : null;
120 | }
121 |
122 | if(isset($_REQUEST['ranger_valid_directories']))
123 | {
124 | $formInputValue = $formatRestriction($_REQUEST['ranger_valid_directories']);
125 | $license->validDirectories = $formInputValue ? array_map($formatRestriction, explode(",", htmlspecialchars_decode($formInputValue))) : null;
126 | }
127 | }
128 | catch(\Exception $e)
129 | {
130 | //
131 | }
132 | }
133 |
134 | function ranger_Reissue(array $params)
135 | {
136 | try
137 | {
138 | // Build the params
139 | $params = new ModuleParams($params);
140 |
141 | // Get the license
142 | $license = License::formWithWhmcsService($params->getService());
143 |
144 | // Set the state
145 | $license->status = 'reissued';
146 |
147 | return "success";
148 | }
149 | catch(\Exception $e)
150 | {
151 | return $e->getMessage();
152 | }
153 | }
154 |
155 | function ranger_SuspendAccount(array $params)
156 | {
157 | return 'success';
158 | }
159 |
160 | function ranger_UnsuspendAccount(array $params)
161 | {
162 | return 'success';
163 | }
164 |
165 | function ranger_TerminateAccount(array $params)
166 | {
167 | return 'success';
168 | }
169 |
170 | function ranger_AdminCustomButtonArray()
171 | {
172 | return
173 | [
174 | "Reissue" => "reissue"
175 | ];
176 | }
177 |
178 | function ranger_ClientAreaCustomButtonArray(array $params)
179 | {
180 | try
181 | {
182 | // Build the params
183 | $params = new ModuleParams($params);
184 |
185 | $buttons = [];
186 |
187 | if($params->clientCanReissue)
188 | {
189 | $buttons['Reissue'] = 'reissue';
190 | }
191 |
192 | return $buttons;
193 | }
194 | catch(\Exception $e)
195 | {
196 | return [];
197 | }
198 | }
199 |
200 | function ranger_ClientArea(array $params)
201 | {
202 | try
203 | {
204 | // Build the params
205 | $params = new ModuleParams($params);
206 |
207 | // Get the license
208 | $license = License::formWithWhmcsService($params->getService());
209 |
210 | return
211 | [
212 | 'tabOverviewModuleOutputTemplate' => 'overview.tpl',
213 |
214 | 'templateVariables' =>
215 | [
216 | 'ranger' =>
217 | [
218 | 'license' =>
219 | [
220 | 'key' => $license->ranger_key,
221 | 'clientCanReissue' => $params->clientCanReissue,
222 | 'status' => $licenseStatus = $license->getStatus(),
223 | 'environment' =>
224 | [
225 | 'ips' => $license->validIps,
226 | 'hostnames' => $license->validHostnames,
227 | 'directories' => $license->validDirectories,
228 | ]
229 | ]
230 | ]
231 | ],
232 | ];
233 | }
234 | catch(\Exception $e)
235 | {
236 | return
237 | [
238 | 'tabOverviewModuleOutputTemplate' => 'error.tpl',
239 |
240 | 'templateVariables' =>
241 | [
242 | 'ranger' =>
243 | [
244 | 'error' => $e->getMessage()
245 | ]
246 | ],
247 | ];
248 | }
249 | }
250 |
251 |
--------------------------------------------------------------------------------
/src/resources/email_templates/welcome_basic.html:
--------------------------------------------------------------------------------
1 | Dear {$client_name},
2 |Thanks for ordering {$service_product_name}, it's now available to download from your client area. Your license key is available in there too, but we've pasted it below for your offline records.
3 |{$ranger_license_key}
4 |Thank you for choosing {$company_name}, your business is greatly appreciated.
5 |If you have any questions or concerns, please do not hesitate to contact us.
6 |{$signature}
-------------------------------------------------------------------------------- /src/resources/email_templates/welcome_basic.txt: -------------------------------------------------------------------------------- 1 | Dear {$client_name}, 2 | 3 | Thanks for ordering {$service_product_name}, it's now available to download from your client area. Your license key is available in there too, but we've pasted it below for your offline records. 4 | 5 | {$ranger_license_key} 6 | 7 | Thank you for choosing {$company_name}, your business is greatly appreciated. 8 | 9 | If you have any questions or concerns, please do not hesitate to contact us. 10 | 11 | {$signature} -------------------------------------------------------------------------------- /src/templates/error.tpl: -------------------------------------------------------------------------------- 1 |{$ranger.license.key}
66 |
67 | {else}
68 |
69 | Your license hasn't been generated yet
70 | 71 | {/if} 72 | 73 |Reissuing your license will allow you to change where it's installed. The installation environment will be locked next time the license is validated.
92 | 93 | {if $ranger.license.clientCanReissue} 94 | 95 | {if $ranger.license.status->status == 'locked'} 96 | 97 | Reissue 98 | 99 | {elseif $ranger.license.status->status == 'reissued'} 100 | 101 | {if $modulecustombuttonresult && $smarty.get.a == 'reissue'} 102 | 103 | {if $modulecustombuttonresult == 'success'} 104 | 105 |When you use the license key, it'll be validated against your previous installation environments. The information below shows where your license is currently available to use. If you wish to change environments, you may reissue your license.
150 | 151 |{$envProperty|htmlentities}
{$envProperty|htmlentities}
{$envProperty|htmlentities}