-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·526 lines (498 loc) · 23.3 KB
/
index.php
File metadata and controls
executable file
·526 lines (498 loc) · 23.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?php
/**
* Front-end billing package for ZPanel/Sentora xBilling Module
* Version : 1.1.0
* @author Aderemi Adewale (modpluz @ Sentora Forums)
* Email : goremmy@gmail.com
* @desc Performs all basic operations from Basic User Registration to Creation of Hosting Domains
*/
require_once('config.php');
require_once('functions/xbilling.php');
$settings = getSettings();
$captcha_disabled = 1;
$voucher_info = null;
if((!isset($settings['recaptcha_disabled_yn']) || $settings['recaptcha_disabled_yn'] == 0) && isset($settings['recaptcha_public_key']) && isset($settings['recaptcha_private_key'])){
$captcha_disabled = 0;
}
$error = 0;
$error_msg = '';
if(isset($_POST['section'])){
$voucher_id = 0;
$section = ((int) $_POST['section']) ? $_POST['section']:'1';
$package_id = isset($_POST['package_id']) ? (int) $_POST['package_id'] : 0;
$period_id = isset($_POST['period_id']) ? (int) $_POST['period_id'] : 0;
$domain_name = isset($_POST['domain']) ? filter_var($_POST['domain'], FILTER_SANITIZE_STRING) : '';
$domain_type_id = isset($_POST['domain_tid']) ? (int) ($_POST['domain_tid']) : 1;
$fullname = isset($_POST['fullname']) ? filter_var($_POST['fullname'],FILTER_SANITIZE_STRING) : '';
$email_address = isset($_POST['email_address']) ? filter_var($_POST['email_address'], FILTER_SANITIZE_STRING) : '';
$address = isset($_POST['address']) ? filter_var($_POST['address'], FILTER_SANITIZE_STRING) : '';
$postal_code = isset($_POST['postal_code']) ? filter_var($_POST['postal_code'], FILTER_SANITIZE_STRING) : '';
$phone = isset($_POST['phone']) ? filter_var($_POST['phone'], FILTER_SANITIZE_STRING) : '';
$username = isset($_POST['username']) ? filter_var($_POST['username'], FILTER_SANITIZE_STRING) : '';
if(!$package_id){
$error = 1;
$error_msg = 'Please select a valid Package.';
} elseif(!$period_id){
$error = 1;
$error_msg = 'Please select a valid Period for the selected package.';
}
if(!$error){
switch($section){
case 1:
$captcha_response = $_POST['g-recaptcha-response'];
if(!$package_id){
$error = 1;
$error_msg = 'Please select a valid package.';
} elseif(!$period_id){
$error = 1;
$error_msg = 'Please select a valid service period.';
} elseif(!$domain_name){
$error = 1;
$error_msg = 'Domain name cannot be empty.';
} elseif(!$captcha_response && !$captcha_disabled){
$error = 1;
$error_msg = 'Please enter a reCaptcha response.';
}
break;
case 2:
/*$fullname = filter_var($_POST['fullname'], FILTER_SANITIZE_STRING);
$email_address = filter_var($_POST['email_address'], FILTER_SANITIZE_STRING);
$address = filter_var($_POST['address'], FILTER_SANITIZE_STRING);
$postal_code = filter_var($_POST['postal_code'], FILTER_SANITIZE_STRING);
$phone = filter_var($_POST['phone'], FILTER_SANITIZE_STRING);
$username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
//$fullname = filter_var($_POST['firstname'], FILTER_SANITIZE_STRING);*/
if(!$fullname){
$error = 1;
$error_msg = 'Fullname cannot be empty.';
} elseif(!$email_address){
$error = 1;
$error_msg = 'Email Address cannot be empty.';
} elseif(!$username){
$error = 1;
$error_msg = 'Username cannot be empty.';
}
if(!$error){
if(!filter_var($email_address, FILTER_VALIDATE_EMAIL)){
$error = 1;
$error_msg = 'Email Address does not appear to be in a valid format.';
}
}
if(!$error){
if(checkUserName($username) <> 0){
$error = 1;
$error_msg = 'Specified username is not available.';
}
}
break;
case 3:
//is there a voucher code entered...verify code
if(filter_var($_POST['code'], FILTER_SANITIZE_STRING)){
$voucher_info = voucherInfo(filter_var($_POST['code'], FILTER_SANITIZE_STRING));
$voucher_id = $voucher_info['id'];
//die(var_dump($voucher_info));
if(!is_array($voucher_info)){
$error = 1;
$error_msg = 'Invalid voucher code supplied.';
}
}
break;
}
}
if(!$error && !$voucher_info){
$section++;
}
}
if(!isset($section)){
$section = 1;
}
if($section == 1){
$packages = getPackages();
if(is_array($packages) && !isset($packages[0])){
$pkgs[0] = $packages;
$packages = $pkgs;
unset($pkgs);
}
} elseif($section == 3){
$package_name = getPackageName($package_id);
$period_info = getPeriodInfo($package_id, $period_id);
if(is_array($period_info)){
$period_duration = $period_info['duration'];
$period_amount = number_format($period_info['amount'],2);
$period_duration .= ' Month';
if($period_info['duration'] > 1){
$period_duration .= 's';
}
if(isset($voucher_info['discount'])){
$period_amount_discount = ((float) $period_amount / 100) * (float) $voucher_info['discount'];
} else {
$period_amount_discount = 0;
}
}
} elseif($section == 4){
$new_user = registerUser();
$invoice_url = '';
if(!$new_user['error'] && $new_user['result']){
if($settings['website_billing_url']){
$invoice_url = $settings['website_billing_url'].'/view_invoice.php?invoice='.$new_user['result'];
}
unset($_POST);
} else {
$error = 1;
//$error_msg = "An internal error has occured, cannot create account at this time.";
$result_msg = $new_user['result'];
}
}
if(!isset($domain_name)){
$domain_name = '';
}
$js_header = js_header();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo($settings['company_name']);?></title>
<script src="res/jquery-1.4.2.js" type="text/javascript"></script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#header {
background: url(<?php echo($settings['company_logo_path']);
?>) no-repeat;
background-position: center;
}
</style>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//>
<!--
<?php echo($js_header);?>
//--><!]]>
</script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<div class="signup signup-body">
<div id="container">
<div class="flex-container">
<div id="header"> </div>
<?php
if($error && $error_msg){
?>
<div class="error"> <?php echo($error_msg);?> </div>
<div class="clear"> </div>
<?php
}
?>
<div id="content">
<form name="frm_order" id="frm_order" action="" method="post">
<input type="hidden" id="package_id" name="package_id" value="<?php echo($package_id);?>" />
<input type="hidden" id="period_id" name="period_id" value="<?php echo($period_id);?>" />
<input type="hidden" id="section" name="section" value="<?php echo($section);?>" />
<?php
if($section > 1){
?>
<input type="hidden" id="domain" name="domain" value="<?php echo($domain_name);?>" />
<input type="hidden" id="domain_tid" name="domain_tid" value="<?php echo($domain_type_id);?>" />
<?php
}
?>
<?php
if($section > 2){
?>
<input type="hidden" name="fullname" value="<?php echo($fullname);?>" />
<input type="hidden" name="email_address" value="<?php echo($email_address);?>" />
<input type="hidden" name="address" value="<?php echo($address);?>" />
<input type="hidden" name="postal_code" value="<?php echo($postal_code);?>" />
<input type="hidden" name="phone" value="<?php echo($phone);?>" />
<input type="hidden" name="username" value="<?php echo($username);?>" />
<input type="hidden" name="voucher_id" value="<?php echo($voucher_id);?>" />
<?php
}
?>
<?php
switch($section){
//hosting info
case 1:
if(is_array($packages)){
?>
<h3>Please select a hosting package below:</h3>
<!-- <div id="packages"> -->
<?php
foreach($packages as $pkg_idx=>$package){
$srvc_periods = $package['service_periods'];
?>
<div id="pkg_<?php echo($package['id']);?>" class="package">
<!-- <input type="radio" name="rd_package" id="rd_pkg_<?php echo($pkg_idx);?>"> -->
<span class="package"><?php echo($package['name']);?>
<div class="package_desc"> <?php echo(nl2br($package['desc']));?> </div>
<div class="package_selected" id="selected_pkg_<?php echo($package['id']);?>" style="display: none;"> selected </div>
<div id="select_pkg_<?php echo($package['id']);?>" class="package_select" onclick="_select_pkg('<?php echo($package['id']);?>');"> <img src="images/icon_ok.png" align="top" alt="select package" hspace="2" />select </div>
<input type="hidden" id="pkg_periods_<?php echo($package['id']);?>" value="<?php echo($package['service_periods']);?>" />
</div>
<!-- </div> -->
<?php
}
?>
<div class="clear"> </div>
<div id="package_periods" class="left">
<h3>Select a service period below:</h3>
<div id="service_period"> Please select a hosting package above. </div>
</div>
<div class="clear"> </div>
<div id="domain_info" class="" style="margin-right: 20px;">
<h3>Domain:</h3>
www.
<input type="text" name="domain" id="domain" size="15" value="<?php echo($domain_name);?>" />
<input type="hidden" name="domain_tid" id="domain_type_own" value="1" />
<!-- <br />
<div align="left" style="margin-left: 25px;">
<input type="radio" name="domain_tid" id="domain_type_own" value="1"<?php if(!$domain_type_id || $domain_type_id == 1){echo(' checked="checked"');}?> />
I own this domain.<br />
<input type="radio" name="domain_tid" id="domain_type_new" value="2"<?php if($domain_type_id == 2){echo(' checked="checked"');}?> />
I want to buy this domain. </div>
</div> -->
<div class="clear"> </div>
<?php if($captcha_disabled != "1") { ?>
<div id="recaptcha" class="clear" align="center" style="">
<h3>Please fill in the challenge below:</h3>
<div class="g-recaptcha" data-sitekey="<?php echo $settings['recaptcha_public_key']; ?>"></div>
</div>
<div class="clear"> </div>
<?php } ?>
<div id="btn" class="right">
<input type="submit" name="btn_submit" value="Next »" class="submit">
</div>
<?php
} else {
echo('<p> </p><div align="center" style="color: #f00;font-size:15px;">There are no hosting packages available at this time.</div>');
}
break;
//account info
case 2:
?>
<h3>Please enter new user account account information below:</h3>
<div class="clear"> </div>
<div id="account_info">
<div align="left">
<div align="left" class="left label"><span class="label">Fullname:</span></div>
<div align="left" class="left">
<input type="text" name="fullname" id="fullname" size="15" value="<?php echo($fullname);?>" />
</div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Email Address:</span> </div>
<div align="left" class="left">
<input type="text" name="email_address" id="email_address" size="15" value="<?php echo($email_address);?>" />
</div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Address:</span> </div>
<div align="left" class="left">
<textarea cols="25" rows="3" name="address"><?php echo($address);?></textarea>
</div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Postal Code:</span> </div>
<div align="left" class="left">
<input type="text" name="postal_code" id="postal_code" size="15" value="<?php echo($postal_code);?>" />
</div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Phone #:</span> </div>
<div align="left" class="left">
<input type="text" name="phone" id="phone" size="15" value="<?php echo($phone);?>" />
</div>
</div>
<div class="clear"> </div>
<h3>Control Panel Information:</h3>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Username</span> </div>
<div align="left" class="left">
<input type="text" name="username" id="username" size="10" value="<?php echo($username);?>" />
</div>
</div>
</div>
<div class="clear"> </div>
<div id="btn" class="right">
<!-- <input type="submit" name="btn_submit" value="« Back" class="submit btn" onclick="$('#section').val(0);"> -->
<input type="submit" name="btn_submit" value="Next »" class="submit">
</div>
<?php
break;
//review order
case 3:
?>
<h3>Please review your order information below:</h3>
<div class="clear"> </div>
<div id="review_order">
<h3>Hosting Information</h3>
<hr size="1" width="95%" align="left" />
<div align="left" style="padding-left: 5px;">
<div align="left" class="left label"><span class="label">Hosting Package:</span></div>
<br />
<div align="left" style="padding-left: 10px;"> <?php echo($package_name);?> for <?php echo($period_duration);?> @ <?php echo($period_amount);?> <?php echo($settings['currency']);?>
<?php if(isset($voucher_info['discount'])){?>
<!-- <br />Discount @ <?php echo $voucher_info['discount'];?>% -->
<?php } ?>
</div>
</div>
<div class="clear"> </div>
<div align="left" style="padding-left: 5px;">
<div align="left" class="left label"><span class="label">Domain:</span></div>
<br />
<div align="left" style="padding-left: 5px;">
<?php
$domain_type = ($domain_type_id == 1) ? 'I own this domain':'I want to buy this domain';
?>
<?php echo($domain_name);?>(<span class="ok"><?php echo($domain_type);?></span>) </div>
</div>
<div class="clear"> </div>
<h3>Account Information</h3>
<hr size="1" width="95%" align="left" />
<div align="left">
<div align="left" class="left label"><span class="label">Fullname:</span></div>
<div align="left" class="left"> <?php echo($fullname);?> </div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"><span class="label">Email Address:</span></div>
<div align="left" class="left"> <?php echo($email_address);?> </div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"><span class="label">Address:</span></div>
<br />
<div align="left" class="left" style="padding-left: 5px;">
<?php
if(!$address){
echo('Not Provided');
} else {
echo($address);
}
?>
</div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"><span class="label">Postal Code:</span></div>
<div align="left" class="left">
<?php
if(!$postal_code){
echo('Not Provided');
} else {
echo($postal_code);
}
?>
</div>
</div>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"><span class="label">Phone:</span></div>
<div align="left" class="left">
<?php
if(!$phone){
echo('Not Provided');
} else {
echo($phone);
}
?>
</div>
</div>
<div class="clear"> </div>
<h3>Control Panel Information</h3>
<hr size="1" width="95%" align="left" />
<div align="left">
<div align="left" class="left label"><span class="label">Username:</span></div>
<div align="left" class="left"> <?php echo($username);?> </div>
</div>
<div class="clear"> </div>
<h3>Discount Voucher</h3>
<hr size="1" width="95%" align="left" />
<div align="left">
<div align="left" class="left label"> <span class="label">
<?php if(!isset($voucher_info['discount'])){ echo 'Enter Voucher Code'; } else { echo 'Voucher';} ?>
:</span> </div>
<div align="left" class="left">
<?php if(!isset($voucher_info['discount'])){?>
<input type="text" name="code" id="voucher_code" size="10" />
<input type="submit" name="btn_voucher" value="Apply" class="submit" style="width: auto;">
<?php } else { ?>
<?php echo $voucher_info['code'];?>
<?php } ?>
</div>
</div>
<div class="clear"> </div>
<h3>Payment Total</h3>
<hr size="1" width="95%" align="left" />
<div align="left">
<div align="left" class="left label"> <span class="label">Sub Total:</span> </div>
<div align="left" class="left"> <?php echo($period_amount.' '.$settings['currency']);?> </div>
</div>
<?php if(isset($voucher_info['discount'])){?>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Discount:</span> </div>
<div align="left" class="left"> <?php echo($voucher_info['discount']);?>% <?php echo($voucher_info['type']);?> - <?php echo($period_amount_discount.' '.$settings['currency']);?> </div>
</div>
<?php } ?>
<div class="clear"> </div>
<div align="left">
<div align="left" class="left label"> <span class="label">Total:</span> </div>
<div align="left" class="left"><?php echo (float) ($period_amount - $period_amount_discount); ?> <?php echo $settings['currency'];?> </div>
</div>
<div class="clear">
<p> </p>
</div>
<div id="btn" class="right">
<input type="submit" name="btn_submit" value="« Back" class="submit btn" onclick="$('#section').val(1);">
<input type="submit" name="btn_submit" value="Complete Order »" class="submit">
</div>
</div>
<?php
break;
//Thank you
case 4:
?>
<?php if(!$error){?>
<h3 style="font-size: 20px;">Thank you for your Order!</h3>
<?php } else {?>
<h3 class="error" style="font-size: 20px; font-weight: bold;">Error!</h3>
<?php } ?>
<div class="clear"> </div>
<div id="payment_thanks">
<?php if(!$error){?>
Thank you for your interest in <?php echo($settings['company_name']);?>. <br />
<br />
An email has been sent to <?php echo($email_address);?>. <br />
<br />
Please click <a href="<?php echo($invoice_url);?>">here</a> to view your invoice.
<?php } else {?>
<div align="center"> <span class="error" style="font-size: 13px;"><?php echo($result_msg);?></span> </div>
<br/>
<div align="center"> click <a href="index.php">here</a> to start again. </div>
<?php } ?>
</div>
<?php
}
?>
</form>
</div>
</div>
<!-- closes flex-container -->
<div class="clearfix"></div>
<div id="footer">
<?php if(isset($settings['email_address'])){?>
<strong>Support:</strong> <?php echo($settings['email_address']);?><br />
<?php } ?>
Copyright © <?php echo($settings['company_name']);?> <?php echo(date("Y"));?>, All rights reserved. </div>
</div>
</div>
<!-- closes signup-body -->
</body>
</html>