1<?php
2
3use WHMCS\Database\Capsule;
4
5function XUIONEConfigOption() {
6 $head_return = '';
7 if (basename($_SERVER["SCRIPT_NAME"]) == 'configproducts.php') {
8 $check = Capsule::table('tblproducts')
9 ->where('servertype', '=', 'XUIONE')
10 ->where('id', '=', $_REQUEST['id'])
11 ->get();
12 } elseif (basename($_SERVER["SCRIPT_NAME"]) == 'configaddons.php') {
13 $check = Capsule::table('tbladdons')
14 ->where('module', '=', 'XUIONE')
15 ->wherenotIn('server_group_id', [0])
16 ->where('id', '=', $_REQUEST['id'])
17 ->get();
18 }
19 if ($_REQUEST['action'] == 'edit' || $_REQUEST['action'] == 'manage') {
20 if (isset($check) && !empty($check)) {
21 $head_return .= '
22 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
23 <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
24 <script type="text/javascript">
25 function customfield(){
26 if($("#conf-dialog-custom-fieldXUIONE").is(":data(dialog)"))
27 {
28 $("#conf-dialog-custom-fieldXUIONE").dialog("destroy");
29 }
30 $("#conf-dialog-custom-fieldXUIONE").attr("title", "Product Custom Fields");
31 $("#conf-dialog-custom-fieldXUIONE").html("<p style=\"text-align:center\"><img src=\"images/loading.gif\" alt=\"loading...\"/></p>");
32 $("#conf-dialog-custom-fieldXUIONE").dialog({minWidth: 650});
33 val = $(this).parent().find("input").val();
34 var selectedoption=jQuery("select[name=\'packageconfigoption[2]\']").val();
35 jQuery.post("../modules/servers/XUIONE/XtreamConfig.php",{stormajax:"create-config",id:"' . $_REQUEST['id'] . '",conf_id:"' . $_REQUEST['conf_id'] . '",selected_conf_id:selectedoption}, function(data){
36 $("#conf-dialog-custom-fieldXUIONE").html(data);
37 });
38 }
39 </script>
40 <div id="conf-dialog-custom-fieldXUIONE" title="">
41 </div>';
42 $head_return .= '
43 <script type="text/javascript">
44 jQuery(document).ready(function () {
45 jQuery("input[type=radio][name=paytype]").change(function() {
46 if($(this).attr("id") == "PayType-OneTime")
47 {
48 var productSelect = jQuery("select[name=\'packageconfigoption[2]\']").val();
49 if(productSelect != "reselleraccount" && productSelect != "resellercredits" && productSelect != "superreselleraccount" && productSelect != "addonpackage" )
50 {
51 $("#tblModuleSettings tbody tr td").filter(function () {
52 return $(this).text() === "Billing Months";
53 }).show();
54 jQuery("input[name=\'packageconfigoption[21]\']").attr("type","number");
55 jQuery("input[name=\'packageconfigoption[21]\']").attr("min","0");
56 jQuery("input[name=\'packageconfigoption[21]\']").attr("max","100");
57 jQuery("input[name=\'packageconfigoption[21]\']").parent().show();
58 }
59
60 }
61 else
62 {
63 $("#tblModuleSettings tbody tr td").filter(function () {
64 return $(this).text() === "Billing Months";
65 }).hide();
66 jQuery("input[name=\'packageconfigoption[21]\']"
67 ).parent().hide();
68 }
69 });
70 jQuery(document).ajaxComplete(function () {
71 var ConditionForProductAndAddon = "' . basename($_SERVER['PHP_SELF']) . '";
72 if(ConditionForProductAndAddon == "configproducts.php")
73 {
74 jQuery("select[name=\'packageconfigoption[2]\'] option[value=\'addonpackage\']").remove();
75 }
76
77 var selectedoption = jQuery("select[name=\'packageconfigoption[2]\']").val();
78 enablefieldinxtream(selectedoption)
79 jQuery("select[name=\'packageconfigoption[2]\']").change(function () {
80 enablefieldinxtream(this.value);
81 });
82 jQuery("input[name=\'packageconfigoption[10]\']").attr("readonly", "readonly");
83 jQuery("input[name=\'packageconfigoption[22]\']").attr("readonly", "readonly");
84
85 $("input[type=radio][name=\'packageconfigoption[5]\']").change(function () {
86 if (this.value == "Yes")
87 {
88 $("#tblModuleSettings tbody tr td").filter(function () {
89 return $(this).text() === "Trial Hours";
90 }).show();
91 jQuery("input[name=\'packageconfigoption[18]\']").parent().show();
92 $("#tblModuleSettings tbody tr td").filter(function () {
93 return $(this).text() === "Billing Months";
94 }).hide();
95 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
96
97 }
98 else
99 {
100 $("#tblModuleSettings tbody tr td").filter(function () {
101 return $(this).text() === "Trial Hours";
102 }).hide();
103 jQuery("input[name=\'packageconfigoption[18]\']").parent().hide();
104 if ($("#PayType-OneTime").prop("checked"))
105 {
106 var productSelect = jQuery("select[name=\'packageconfigoption[2]\']").val();
107 if(productSelect != "reselleraccount" && productSelect != "resellercredits" && productSelect != "superreselleraccount" && productSelect != "addonpackage" )
108 {
109 $("#tblModuleSettings tbody tr td").filter(function () {
110 return $(this).text() === "Billing Months";
111 }).show();
112 jQuery("input[name=\'packageconfigoption[21]\']").attr("type","number");
113 jQuery("input[name=\'packageconfigoption[21]\']").attr("min","0");
114 jQuery("input[name=\'packageconfigoption[21]\']").attr("max","100");
115 jQuery("input[name=\'packageconfigoption[21]\']").parent().show();
116 }
117 }
118 }
119 });
120 });
121 });
122 function enablefieldinxtream($value) {
123 if ($value == "resellercredits") {
124 showallconfigfirst();
125 $("#tblModuleSettings tbody tr td").filter(function () {
126 return $(this).text() === "Max Con." || $(this).text() === "Trial Hours" || $(this).text() === "Billing Months" || $(this).text() === "Packages";
127 }).hide();
128 jQuery("input[name=\'packageconfigoption[4]\']").parent().hide();
129 jQuery("input[name=\'packageconfigoption[6]\']").parent().parent().parent().hide();
130 jQuery("input[name=\'packageconfigoption[8]\']").parent().parent().parent().hide();
131 jQuery("input[name=\'packageconfigoption[19]\']").parent().parent().parent().hide();
132 jQuery("input[name=\'packageconfigoption[20]\']").parent().parent().parent().hide();
133 jQuery("select[name=\'packageconfigoption[9]\']").parent().parent().hide();
134 jQuery("select[name=\'packageconfigoption[12]\']").parent().parent().hide();
135 jQuery("input[name=\'packageconfigoption[14]\']").parent().parent().hide();
136 jQuery("input[name=\'packageconfigoption[15]\']").parent().parent().parent().hide();
137 jQuery("input[name=\'packageconfigoption[17]\']").parent().parent().parent().hide();
138 jQuery("input[name=\'packageconfigoption[18]\']").parent().hide();
139 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
140 jQuery("input[name=\'packageconfigoption[22]\']").parent().hide();
141 } else if ($value == "reselleraccount") {
142 showallconfigfirst();
143 $("#tblModuleSettings tbody tr td").filter(function () {
144 return $(this).text() === "Fill Credits" || $(this).text() === "Trial Hours" || $(this).text() === "Select Xtream Super-Reseller" || $(this).text() === "Do you want to sync Credit to X.C Panel?"|| $(this).text() === "Billing Months" || $(this).text() === "Watch Streams!" || $(this).text() === "Select XUI Super-Reseller Group" || $(this).text() === "Packages";
145 }).hide();
146 jQuery("input[name=\'packageconfigoption[4]\']").parent().parent().hide();
147 jQuery("input[name=\'packageconfigoption[6]\']").parent().parent().parent().hide();
148 jQuery("input[name=\'packageconfigoption[8]\']").parent().parent().parent().hide();
149 jQuery("input[name=\'packageconfigoption[19]\']").parent().parent().parent().hide();
150 jQuery("input[name=\'packageconfigoption[20]\']").parent().parent().parent().hide();
151 jQuery("select[name=\'packageconfigoption[9]\']").parent().parent().hide();
152 jQuery("input[name=\'packageconfigoption[11]\']").parent().parent().hide();
153 jQuery("select[name=\'packageconfigoption[13]\']").parent().hide();
154 jQuery("input[name=\'packageconfigoption[15]\']").parent().parent().parent().hide();
155 jQuery("input[name=\'packageconfigoption[18]\']").parent().parent().hide();
156 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
157 jQuery("input[name=\'packageconfigoption[22]\']").parent().hide();
158
159
160 } else if ($value == "streamline" || $value == "streamlineonly" || $value == "streamlineeng" || $value == "streamlineengmag") {
161 showallconfigfirst();
162 $("#tblModuleSettings tbody tr td").filter(function () {
163 return $(this).text() === "Fill Credits" || $(this).text() === "Trial Hours" || $(this).text() === "Select Xtream Reseller Group" || $(this).text() === "Do you want to sync Credit to X.C Panel?"|| $(this).text() === "Billing Months" || $(this).text() === "Packages";
164 }).hide();
165 jQuery("input[name=\'packageconfigoption[3]\']").parent().hide();
166 jQuery("select[name=\'packageconfigoption[12]\']").parent().hide();
167 jQuery("select[name=\'packageconfigoption[13]\']").parent().parent().hide();
168 jQuery("input[name=\'packageconfigoption[18]\']").parent().hide();
169 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
170 jQuery("input[name=\'packageconfigoption[22]\']").parent().hide();
171 var istrail = jQuery("input[name=\'packageconfigoption[5]\']:checked").val();
172 if (istrail == "Yes") {
173 $("#tblModuleSettings tbody tr td").filter(function () {
174 return $(this).text() === "Trial Hours";
175 }).show();
176 jQuery("input[name=\'packageconfigoption[18]\']").parent().show();
177
178 $("#tblModuleSettings tbody tr td").filter(function () {
179 return $(this).text() === "Billing Months";
180 }).hide();
181 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
182 }
183 else
184 {
185 if ($("#PayType-OneTime").prop("checked"))
186 {
187 var productSelect = jQuery("select[name=\'packageconfigoption[2]\']").val();
188 if(productSelect != "reselleraccount" && productSelect != "resellercredits" && productSelect != "superreselleraccount" && productSelect != "addonpackage" )
189 {
190 $("#tblModuleSettings tbody tr td").filter(function () {
191 return $(this).text() === "Billing Months";
192 }).show();
193 jQuery("input[name=\'packageconfigoption[21]\']").attr("type","number");
194 jQuery("input[name=\'packageconfigoption[21]\']").attr("min","0");
195 jQuery("input[name=\'packageconfigoption[21]\']").attr("max","100");
196 jQuery("input[name=\'packageconfigoption[21]\']").parent().show();
197 }
198 }
199 }
200 } else if ($value == "magdevice" || $value == "engdevice") {
201 showallconfigfirst();
202 $("#tblModuleSettings tbody tr td").filter(function () {
203 return $(this).text() === "Fill Credits" || $(this).text() === "Trial Hours" || $(this).text() === "ISP Lock" || $(this).text() === "Select Xtream Reseller Group" || $(this).text() === "Do you want to sync Credit to X.C Panel?" || $(this).text() === "Packages";
204 }).hide();
205 jQuery("input[name=\'packageconfigoption[3]\']").parent().parent().hide();
206 jQuery("input[name=\'packageconfigoption[6]\']").parent().parent().hide();
207 jQuery("input[name=\'packageconfigoption[7]\']").parent().parent().parent().hide();
208 jQuery("input[name=\'packageconfigoption[19]\']").parent().parent().parent().hide();
209 jQuery("select[name=\'packageconfigoption[12]\']").parent().parent().hide();
210 jQuery("select[name=\'packageconfigoption[13]\']").parent().parent().hide();
211 jQuery("input[name=\'packageconfigoption[18]\']").parent().hide();
212 jQuery("input[name=\'packageconfigoption[22]\']").parent().hide();
213 var istrail = jQuery("input[name=\'packageconfigoption[5]\']:checked").val();
214 if (istrail == "Yes")
215 {
216 $("#tblModuleSettings tbody tr td").filter(function () {
217 return $(this).text() === "Trial Hours";
218 }).show();
219 jQuery("input[name=\'packageconfigoption[18]\']").parent().show();
220
221 $("#tblModuleSettings tbody tr td").filter(function () {
222 return $(this).text() === "Billing Months";
223 }).hide();
224 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
225 }
226 else
227 {
228 if ($("#PayType-OneTime").prop("checked"))
229 {
230 var productSelect = jQuery("select[name=\'packageconfigoption[2]\']").val();
231 if(productSelect != "reselleraccount" && productSelect != "resellercredits" && productSelect != "superreselleraccount" && productSelect != "addonpackage" )
232 {
233 $("#tblModuleSettings tbody tr td").filter(function () {
234 return $(this).text() === "Billing Months";
235 }).show();
236 jQuery("input[name=\'packageconfigoption[21]\']").attr("type","number");
237 jQuery("input[name=\'packageconfigoption[21]\']").attr("min","0");
238 jQuery("input[name=\'packageconfigoption[21]\']").attr("max","100");
239 jQuery("input[name=\'packageconfigoption[21]\']").parent().show();
240 }
241 }
242 }
243 } else if ($value == "superreselleraccount") {
244 showallconfigfirst();
245 $("#tblModuleSettings tbody tr td").filter(function () {
246 return $(this).text() === "Trial Hours" || $(this).text() === "Billing Months" || $(this).text() === "Packages";
247 }).hide();
248 jQuery("input[name=\'packageconfigoption[4]\']").parent().parent().hide();
249 jQuery("input[name=\'packageconfigoption[6]\']").parent().parent().parent().hide();
250 jQuery("input[name=\'packageconfigoption[8]\']").parent().parent().parent().hide();
251 jQuery("input[name=\'packageconfigoption[19]\']").parent().parent().parent().hide();
252 jQuery("input[name=\'packageconfigoption[20]\']").parent().parent().parent().hide();
253 jQuery("select[name=\'packageconfigoption[9]\']").parent().parent().hide();
254 jQuery("input[name=\'packageconfigoption[11]\']").parent().parent().parent().hide();
255 jQuery("select[name=\'packageconfigoption[12]\']").parent().parent().hide();
256 jQuery("input[name=\'packageconfigoption[15]\']").parent().parent().parent().hide();
257 jQuery("input[name=\'packageconfigoption[18]\']").parent().parent().hide();
258 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
259 jQuery("input[name=\'packageconfigoption[22]\']").parent().hide();
260 } else if ($value == "addonpackage") {
261 showallconfigfirst();
262 $("#tblModuleSettings tbody tr td").filter(function () {
263 return $(this).text() === "Trial Hours" || $(this).text() === "Billing Months" || $(this).text() === "Select XUI Super-Reseller Group";
264 }).hide();
265 jQuery("input[name=\'packageconfigoption[4]\']").parent().parent().hide();
266 jQuery("input[name=\'packageconfigoption[6]\']").parent().parent().parent().hide();
267 jQuery("input[name=\'packageconfigoption[8]\']").parent().parent().parent().hide();
268 jQuery("input[name=\'packageconfigoption[19]\']").parent().parent().parent().hide();
269 jQuery("input[name=\'packageconfigoption[20]\']").parent().parent().parent().hide();
270 jQuery("select[name=\'packageconfigoption[9]\']").parent().parent().hide();
271 jQuery("input[name=\'packageconfigoption[11]\']").parent().parent().parent().hide();
272 jQuery("select[name=\'packageconfigoption[12]\']").parent().parent().hide();
273 jQuery("input[name=\'packageconfigoption[15]\']").parent().parent().parent().hide();
274 jQuery("input[name=\'packageconfigoption[18]\']").parent().parent().hide();
275 jQuery("input[name=\'packageconfigoption[21]\']").parent().hide();
276 jQuery("input[name=\'packageconfigoption[14]\']").parent().parent().hide();
277 jQuery("select[name=\'packageconfigoption[13]\']").parent().hide();
278 }
279 }
280 function showallconfigfirst() {
281 $("#tblModuleSettings tbody tr td").filter(function () {
282 return $(this).text() === "Watch Streams!" || $(this).text() === "Trial Hours" || $(this).text() === "ISP Lock" || $(this).text() === "MAG Portal link" || $(this).text() === "Max Con." || $(this).text() === "Is this Product for Reseller?" || $(this).text() === "Select XUI Super-Reseller Group" || $(this).text() === "Fill Credits" || $(this).text() === "Select Xtream Reseller Group" || $(this).text() === "Packages";
283 }).show();
284
285 jQuery("input[name=\'packageconfigoption[3]\']").parent().parent().show();
286 jQuery("input[name=\'packageconfigoption[3]\']").parent().show();
287 jQuery("input[name=\'packageconfigoption[4]\']").parent().show();
288
289 jQuery("input[name=\'packageconfigoption[5]\']").parent().parent().parent().show();
290 jQuery("input[name=\'packageconfigoption[5]\']").parent().parent().show();
291 jQuery("input[name=\'packageconfigoption[6]\']").parent().parent().show();
292
293 jQuery("input[name=\'packageconfigoption[7]\']").parent().parent().show();
294 jQuery("input[name=\'packageconfigoption[8]\']").parent().show();
295 jQuery("input[name=\'packageconfigoption[8]\']").parent().parent().parent().show();
296 jQuery("input[name=\'packageconfigoption[19]\']").parent().show();
297 jQuery("input[name=\'packageconfigoption[19]\']").parent().parent().parent().show();
298 jQuery("input[name=\'packageconfigoption[20]\']").parent().show();
299 jQuery("input[name=\'packageconfigoption[20]\']").parent().parent().parent().show();
300
301 jQuery("select[name=\'packageconfigoption[9]\']").parent().parent().show();
302 jQuery("select[name=\'packageconfigoption[10]\']").parent().parent().show();
303 jQuery("select[name=\'packageconfigoption[10]\']").parent().parent().parent().show();
304
305 jQuery("input[name=\'packageconfigoption[11]\']").parent().parent().show();
306 jQuery("select[name=\'packageconfigoption[12]\']").parent().show();
307 jQuery("select[name=\'packageconfigoption[12]\']").parent().parent().show();
308
309 jQuery("select[name=\'packageconfigoption[13]\']").parent().parent().parent().show();
310 jQuery("select[name=\'packageconfigoption[13]\']").parent().show();
311 jQuery("select[name=\'packageconfigoption[13]\']").parent().parent().show();
312
313 jQuery("input[name=\'packageconfigoption[14]\']").parent().show();
314 jQuery("input[name=\'packageconfigoption[15]\']").parent().parent().show();
315 jQuery("input[name=\'packageconfigoption[15]\']").parent().parent().parent().show();
316
317 jQuery("input[name=\'packageconfigoption[17]\']").parent().parent().show();
318 jQuery("input[name=\'packageconfigoption[18]\']").parent().parent().show();
319 jQuery("input[name=\'packageconfigoption[18]\']").parent().parent().parent().show();
320
321 jQuery("input[name=\'packageconfigoption[22]\']").parent().show();
322 }
323 function tariffPlan() {
324 var bouquetval = jQuery("input[name=\'packageconfigoption[10]\']").val();
325 var SecVar = "load-storm-tariff";
326 if ($("#conf-dialogXUIONE").is(":data(dialog)"))
327 {
328 $("#conf-dialogXUIONE").dialog("destroy");
329 }
330 $("#conf-dialogXUIONE").attr("title", " Bouquets ");
331 $("#conf-dialogXUIONE").html("<p style=\"text-align:center\"><img src=\"images/loading.gif\" alt=\"loading...\"/></p>");
332 $("#conf-dialogXUIONE").dialog({minWidth: 650});
333 jQuery.post("../modules/servers/XUIONE/XtreamConfig.php", {stormajax: "load-plans", id: "' . $_REQUEST['id'] . '", conf_id:bouquetval,sectionIs:SecVar }, function (data) {
334 $("#conf-dialogXUIONE").html(data);
335 });
336 }
337 function tariffPlanForPcakage() {
338 var bouquetval = jQuery("input[name=\'packageconfigoption[22]\']").val();
339 var SecVar = "load-package-addon";
340 if ($("#conf-dialogXUIONE").is(":data(dialog)"))
341 {
342 $("#conf-dialogXUIONE").dialog("destroy");
343 }
344 $("#conf-dialogXUIONE").attr("title", " Bouquets ");
345 $("#conf-dialogXUIONE").html("<p style=\"text-align:center\"><img src=\"images/loading.gif\" alt=\"loading...\"/></p>");
346 $("#conf-dialogXUIONE").dialog({minWidth: 650});
347 jQuery.post("../modules/servers/XUIONE/XtreamConfig.php", {stormajax: "load-plans", id: "' . $_REQUEST['id'] . '", conf_id:bouquetval,sectionIs:SecVar}, function (data) {
348 $("#conf-dialogXUIONE").html(data);
349 });
350 }
351</script>
352 <div id="conf-dialogXUIONE" title="">
353 </div>';
354 }
355 }
356 return $head_return;
357}
358
359function XtreamMAGCheckOne($params) {
360 if (isset($params['filename']) && !empty($params['filename']) && $params['filename'] == 'cart') {
361 if ($params['action'] == 'confproduct') {
362 if (isset($_SESSION['cart']['cartsummarypid'])) {
363 $xtreamConfig = Capsule::table('mod_XUIOneConfig')->get();
364 $returndata = array();
365 if (isset($xtreamConfig) && !empty($xtreamConfig)) {
366 foreach ($xtreamConfig as $config) {
367 $returndata[$config->setting] = $config->value;
368 }
369 }
370 $data = checkproductcustomfieldsOne($_SESSION['cart']['cartsummarypid'], $returndata['checkmagdevice']);
371 $username = checkproductcustomfieldsOne($_SESSION['cart']['cartsummarypid'], 'Username');
372 $password = checkproductcustomfieldsOne($_SESSION['cart']['cartsummarypid'], 'Password');
373 if (isset($returndata['configoption_field_name']) && !empty($returndata['configoption_field_name']))
374 $extra = checkproductconfigoptionOne($_SESSION['cart']['cartsummarypid'], $returndata['configoption_field_name']);
375 }
376//Extra Connections
377 return <<<HTML
378 <script type="text/javascript">
379 $(document).ready(function(){
380 $(document).on('ifChecked', '#customfield{$data['id']}', function(event) {
381 jQuery('#customfield{$username['id']}').parent().hide(1000);
382 jQuery('#customfield{$password['id']}').parent().hide(1000);
383 jQuery('#inputConfigOption{$extra['id']}').parent().parent().hide(1000);
384 });
385 $(document).on('ifUnchecked', '#customfield{$data['id']}', function(event) {
386 jQuery('#customfield{$username['id']}').parent().show(1000);
387 jQuery('#customfield{$password['id']}').parent().show(1000);
388 });
389})
390
391 </script>
392HTML;
393 }
394 }
395}
396
397function checkproductcustomfieldsOne($product_id, $customfieldkey) {
398 $config = Capsule::table('tblproducts')
399 ->where('servertype', '=', 'XUIONE')
400 ->where('id', '=', $product_id)
401 ->get();
402 if (isset($config) && !empty($config)) {
403 $fieldId = Capsule::table('tblcustomfields')
404 ->where('fieldname', '=', $customfieldkey)
405 ->where('type', '=', 'product')
406 ->where('relid', '=', $product_id)
407 ->select('tblcustomfields.id')
408 ->get();
409 return (array) $fieldId[0];
410 }
411 return'';
412}
413
414function checkproductconfigoptionOne($product_id, $configfieldname) {
415 $config = Capsule::table('tblproducts')
416 ->where('servertype', '=', 'XUIONE')
417 ->where('id', '=', $product_id)
418 ->get();
419 if (isset($config) && !empty($config)) {
420 $configuration = Capsule::table('tblproductconfigoptions')
421 ->join('tblproductconfiglinks', 'tblproductconfigoptions.gid', '=', 'tblproductconfiglinks.gid')
422 ->where('tblproductconfiglinks.pid', '=', $product_id)
423 ->where('tblproductconfigoptions.optionname', '=', $configfieldname)
424 ->select('tblproductconfigoptions.id')
425 ->get();
426 return (array) $configuration[0];
427 }
428 return'';
429}
430
431//Check Connection
432function XUIONETestConnectionHooks($productId) {
433
434 $servers = Capsule::table('tblproducts')
435 ->join('tblservergroupsrel', 'tblproducts.servergroup', '=', 'tblservergroupsrel.groupid')
436 ->join('tblservers', 'tblservergroupsrel.serverid', '=', 'tblservers.id')
437 ->where('tblproducts.id', '=', $productId)
438 ->select('tblservers.*')
439 ->get();
440 if (isset($servers) && !empty($servers)) {
441
442 foreach ($servers as $server) {
443
444 $sqlusername = $server->username;
445 $sqlpassword = decrypt($server->password);
446 $sqldbname = $server->accesshash;
447 $sqlhost = $server->ipaddress;
448 list($sqldbname, $sqlport) = explode(':', $sqldbname);
449 if (isset($sqlport) && !empty($sqlport))
450 $con = mysqli_connect($sqlhost, $sqlusername, $sqlpassword, $sqldbname, $sqlport);
451 else
452 $con = mysqli_connect($sqlhost, $sqlusername, $sqlpassword, $sqldbname);
453
454// Check connection
455 if (!$con) {
456 XUIONE_WHMCSReconnect();
457 logModuleCall('XUIONE', 'Check Connection', 'Connection', "Failed to connect to MySQL: " . mysqli_connect_error(), '', '');
458 return true;
459 }
460 }
461 }
462 return $con;
463}
464
465add_hook("ClientAreaFooterOutput", 1, "XtreamMAGCheckOne"); #This hook runs on the load of every client area page
466
467add_hook("AdminAreaHeadOutput", 1, "XUIONEConfigOption"); #This hook runs on every admin area page load and can accept a return of information to be added to the <head> of your output.
468
469
470add_hook('AfterConfigOptionsUpgrade', 1, function($vars) {
471 include_once('XUIONE.php');
472 $serviceid = Capsule::select("SELECT relid FROM tblupgrades WHERE id = '" . $vars['upgradeid'] . "'");
473 $command = 'GetClientsProducts';
474 $postData = array(
475 'serviceid' => $serviceid[0]->relid,
476 );
477
478 $results = localAPI($command, $postData, GetAdminIdForLocalAPIOne());
479 $getprod = array();
480 $nameval = array();
481 $name = array();
482 $eConnection = array();
483 $action = 'configupgrade';
484 $selectpid = Capsule::select("SELECT id AS pid , servertype AS moduletype, servergroup AS serverid, configoption1, configoption2, configoption3, configoption4, configoption5, configoption6, configoption7, configoption8, configoption9,
485 configoption10, configoption11, configoption12, configoption13, configoption14, configoption15, configoption16, configoption17, configoption18,
486 configoption19, configoption20, configoption21, configoption22, configoption23, configoption24 FROM tblproducts WHERE id = '" . $results['products']['product'][0]['pid'] . "'");
487
488 foreach ($results['products']['product'][0]['customfields']['customfield'] as $fields) {
489 $name[$fields['name']] = $fields['value'];
490 }
491 $array1 = array('serviceid' => $results['products']['product'][0]['id'], 'clientid' => $results['products']['product'][0]['clientid'], 'status' => $results['products']['product'][0]['status'], 'username' => $results['products']['product'][0]['username'], 'password' => $results['products']['product'][0]['password']);
492 $array2 = config_opt_extraconOne($selectpid[0]);
493 $vars = array_merge($array1, $array2);
494 $vars['customfields'] = $name;
495 $vars['configoptions']['Extra Connections'] = $results['products']['product'][0]['configoptions']['configoption'][0]['value'];
496 $vars['action'] = $action;
497 XUIONE_ChangePackage($vars);
498});
499
500function GetAdminIdForLocalAPIOne() {
501 $admin = Capsule::table('tbladmins')
502 ->where('roleid', '=', 1)
503 ->get();
504 $adminUsername = $admin[0]->username;
505 return $adminUsername;
506}
507
508function config_opt_extraconOne($data) {
509 if (is_object($data)) {
510 $data = get_object_vars($data);
511 }
512 if (is_array($data)) {
513 return array_map(__FUNCTION__, $data);
514 } else {
515 return $data;
516 }
517}