417 | |
---|---|
Line | |
1 | <?php |
2 | set_include_path(get_include_path() . PATH_SEPARATOR . '/home/ssp/flysip_web/lib'); |
3 | |
4 | /* you can find libraries included below in /home/ssp/flysip_web/lib directory */ |
5 | include 'html.php'; |
6 | include 'xmlrpc/xmlrpc.inc'; |
7 | |
8 | $currencies = array( |
9 | 'USD' => 'USD', |
10 | 'NZD' => 'NZD' |
11 | /* ... and so on */ |
12 | ); |
13 | |
14 | $tzs = array( |
15 | '97' => 'Africa/Abidjan', |
16 | '145' => 'Africa/Accra', |
17 | '129' => 'Africa/Addis_Ababa', |
18 | '119' => 'Africa/Algiers', |
19 | '125' => 'Africa/Asmera', |
20 | '213' => 'Africa/Bamako' |
21 | /* ... and so on */ |
22 | ); |
23 | |
24 | function createAccount() { |
25 | |
26 | $params = array(new xmlrpcval(array("username" => new xmlrpcval('${N:[8][8][8][0-9][0-9][0-9][0-9]}', "string"), |
27 | "web_password" => new xmlrpcval('${P:8}', "string"), |
28 | "authname" => new xmlrpcval('${C:username}', "string"), |
29 | "voip_password" => new xmlrpcval('${P:7}', "string"), |
30 | "i_tariff" => new xmlrpcval("50", "int"), /* replace with your i_tariff */ |
31 | "i_time_zone" => new xmlrpcval(get_par('i_time_zone'), "int"), |
32 | "i_lang" => new xmlrpcval("en", "string"), |
33 | "balance" => new xmlrpcval("0.0", "double"), /* set needed value */ |
34 | "credit_limit" => new xmlrpcval("0.0", "double"), /* set needed value */ |
35 | "blocked" => new xmlrpcval("", "int"), |
36 | "max_sessions" => new xmlrpcval("", "int"), |
37 | "max_credit_time" => new xmlrpcval("3600", "int"), |
38 | "translation_rule" => new xmlrpcval("", "string"), |
39 | "cli_translation_rule" => new xmlrpcval("", "string"), |
40 | "cpe_number" => new xmlrpcval("", "string"), |
41 | "i_export_type" => new xmlrpcval("2", "int"), |
42 | "reg_allowed" => new xmlrpcval("1", "int"), |
43 | "trust_cli" => new xmlrpcval("", "int"), |
44 | "disallow_loops" => new xmlrpcval("", "int"), |
45 | "vm_password" => new xmlrpcval('${N:[0-9][0-9][0-9][0-9][0-9][0-9]}', "string"), |
46 | "vm_enabled" => new xmlrpcval("1", "int"), |
47 | "vm_notify_emails" => new xmlrpcval(get_par('vm_notify_emails'), "string"), |
48 | "vm_forward_emails" => new xmlrpcval(get_par('vm_forward_emails'), "string"), |
49 | "vm_del_after_fwd" => new xmlrpcval("", "int"), |
50 | "company_name" => new xmlrpcval(get_par('company_name'), "string"), |
51 | "salutation" => new xmlrpcval(get_par('salutation'), "string"), |
52 | "first_name" => new xmlrpcval(get_par('first_name'), "string"), |
53 | "mid_init" => new xmlrpcval("", "string"), |
54 | "last_name" => new xmlrpcval(get_par('last_name'), "string"), |
55 | "street_addr" => new xmlrpcval(get_par('street_addr'), "string"), |
56 | "state" => new xmlrpcval(get_par('state'), "string"), |
57 | "postal_code" => new xmlrpcval(get_par('postal_code'), "string"), |
58 | "city" => new xmlrpcval(get_par('city'), "string"), |
59 | "country" => new xmlrpcval(get_par('country'), "string"), |
60 | "contact" => new xmlrpcval("", "string"), |
61 | "phone" => new xmlrpcval(get_par('phone'), "string"), |
62 | "fax" => new xmlrpcval(get_par('fax'), "string"), |
63 | "alt_phone" => new xmlrpcval(get_par('alt_phone'), "string"), |
64 | "alt_contact" => new xmlrpcval("", "string"), |
65 | "email" => new xmlrpcval(get_par('email'), "string"), |
66 | "cc" => new xmlrpcval(get_par('cc'), "string"), |
67 | "bcc" => new xmlrpcval(get_par('bcc'), "string"), |
68 | "payment_currency" => new xmlrpcval(get_par('payment_currency'), "string"), |
69 | "payment_method" => new xmlrpcval("1", "int"), |
70 | "on_payment_action" => new xmlrpcval("", "int"), |
71 | "min_payment_amount"=> new xmlrpcval("", "double"), |
72 | "lifetime" => new xmlrpcval("-1", "int"), |
73 | "preferred_codec" => new xmlrpcval("18", "int"), |
74 | "use_preferred_codec_only" => new xmlrpcval("", "int"), |
75 | "welcome_call_ivr" => new xmlrpcval("", "int") |
76 | ), 'struct')); |
77 | $msg = new xmlrpcmsg('createAccount', $params); |
78 | |
79 | /* replace here URL and credentials to access to the API */ |
80 | $cli = new xmlrpc_client('https://sip.your-company.com/xmlapi/xmlapi'); |
81 | $cli->setSSLVerifyPeer(false); |
82 | $cli->setCredentials('xmlapi', 'secret', CURLAUTH_DIGEST); |
83 | |
84 | $r = $cli->send($msg, 20); /* 20 seconds timeout */ |
85 | |
86 | if ($r->faultCode()) { |
87 | error_log("Fault. Code: " . $r->faultCode() . ", Reason: " . $r->faultString()); |
88 | return false; |
89 | } |
90 | |
91 | return $r->value(); |
92 | } |
93 | |
94 | function sendEMail($a) { |
95 | $body = " Welcome to Flysip! |
96 | |
97 | Please keep this email for your records. Your account information is as follows: |
98 | |
99 | SIP Login: ${a['authname']} |
100 | SIP Password: ${a['voip_password']} |
101 | Web Login: ${a['username']} |
102 | Web Password: ${a['web_password']} |
103 | SIP Proxy: sip.your-company.com |
104 | |
105 | Please do not forget your password as it has been encrypted in our database and |
106 | we cannot retrieve it for you. However, should you forget your password you can |
107 | request a password reset and a new one will be sent to you. |
108 | |
109 | To login to your account area please visit http://www.your-company.com/your-account.html |
110 | |
111 | When you login for the first time, the system will request a web login password change, |
112 | please make sure you change your password. |
113 | |
114 | To make Toll calls you will need to make on-line payments. |
115 | |
116 | Thank you for registering! |
117 | |
118 | Flysip Team."; |
119 | |
120 | $params = array(new xmlrpcval(array("from" => new xmlrpcval('[email protected]', "string"), |
121 | "to" => new xmlrpcval(get_par('email'), "string"), |
122 | "cc" => new xmlrpcval('', "string"), |
123 | "bcc" => new xmlrpcval('', "string"), |
124 | "subject" => new xmlrpcval('Signup confirmation', "string"), |
125 | "body" => new xmlrpcval($body, "string") |
126 | ), 'struct')); |
127 | $msg = new xmlrpcmsg('sendEMail', $params); |
128 | |
129 | /* replace here URL and credentials to access to the API */ |
130 | $cli = new xmlrpc_client('https://sip.your-company.com/xmlapi/xmlapi'); |
131 | $cli->setSSLVerifyPeer(false); |
132 | $cli->setCredentials('xmlapi', 'secret', CURLAUTH_DIGEST); |
133 | |
134 | $r = $cli->send($msg, 20); /* 20 seconds timeout */ |
135 | |
136 | if ($r->faultCode()) { |
137 | error_log("Fault. Code: " . $r->faultCode() . ", Reason: " . $r->faultString()); |
138 | } |
139 | } |
140 | |
141 | $ok = true; |
142 | if (isset_par('task')) { |
143 | if (!get_par('first_name') || !get_par('last_name') || |
144 | !get_par('street_addr') || !get_par('state') || |
145 | !get_par('postal_code') || !get_par('city') || |
146 | !get_par('country') || !get_par('phone') || |
147 | !get_par('email') || !get_par('payment_currency') || |
148 | !get_par('i_time_zone')) { |
149 | $ok = false; |
150 | } |
151 | if ($ok) { |
152 | $r = createAccount(); |
153 | if ($r) { |
154 | $a = Array(); |
155 | |
156 | $v = $r->structmem('username'); |
157 | $a['username'] = $v->scalarval(); |
158 | |
159 | $v = $r->structmem('web_password'); |
160 | $a['web_password'] = $v->scalarval(); |
161 | |
162 | $v = $r->structmem('authname'); |
163 | $a['authname'] = $v->scalarval(); |
164 | |
165 | $v = $r->structmem('voip_password'); |
166 | $a['voip_password'] = $v->scalarval(); |
167 | |
168 | $v = $r->structmem('vm_password'); |
169 | $a['vm_password'] = $v->scalarval(); |
170 | |
171 | sendEMail($a); |
172 | } else { |
173 | $ok = false; |
174 | } |
175 | } |
176 | } else { |
177 | $par['i_time_zone'] = 140; /* Europe/London */ |
178 | $par['payment_currency'] = 'USD'; |
179 | } |
180 | ?> |
181 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
182 | <html> |
183 | <head> |
184 | <meta http-equiv="content-type" content="text/html" /> |
185 | <title>Sign Up</title> |
186 | <style type="text/css"> |
187 | body { |
188 | margin: 0px; |
189 | padding: 0px; |
190 | border: 0px; |
191 | background-color: white; |
192 | } |
193 | form { |
194 | margin: 0px; |
195 | padding: 0px; |
196 | border: 0px; |
197 | } |
198 | .page { |
199 | margin-left: auto; |
200 | margin-right: auto; |
201 | margin-top: 10px; |
202 | margin-bottom: 10px; |
203 | padding: 5px; |
204 | width:80%; |
205 | background-color: #FFFFDD; |
206 | text-align: left; |
207 | font-family: Verdana, Arial, Helvetica, sans-serif; |
208 | font-size: 11px; |
209 | border: 1px solid #DDDDBB; |
210 | } |
211 | td { |
212 | font-size: 11px; |
213 | color: #000000; |
214 | text-decoration: none; |
215 | line-height: 14px; |
216 | } |
217 | input, select { |
218 | border: 1px solid #41884C; |
219 | background-color: #fff; |
220 | padding: 2px; |
221 | } |
222 | .int_h1 { |
223 | font-family: verdana; |
224 | font-size: 18px; |
225 | font-weight: bold; |
226 | padding: 3px 0 8px 5px; |
227 | } |
228 | .notice { |
229 | font-family: verdana; |
230 | font-size: 14px; |
231 | color: 000; |
232 | padding: 3px 0 8px 5px; |
233 | } |
234 | .error { |
235 | font-family: verdana; |
236 | font-size: 14px; |
237 | color: red; |
238 | padding: 3px 0 8px 5px; |
239 | } |
240 | .section_colour_bar{ |
241 | height: 2px; |
242 | background-color:#41884C; |
243 | } |
244 | .ctr { |
245 | text-align: center; |
246 | } |
247 | </style> |
248 | </head> |
249 | <body> |
250 | <div class="ctr" align="center"> |
251 | <div class="page" align="center"> |
252 | <div style="background-color:#fff"> |
253 | <div class="int_h1">Sign Up</div> |
254 | </div> |
255 | <div class="section_colour_bar"></div> |
256 | <?php if (!$ok) { ?> |
257 | <div style="background-color:#fff"> |
258 | <div class="error">Please fill in all required fields.</div> |
259 | </div> |
260 | <div class="section_colour_bar"></div> |
261 | <?php } ?> |
262 | <?php if (isset_par('task') && $ok) { ?> |
263 | <div style="background-color:#fff"> |
264 | <div class="notice">Thank you for registering with Flysip! All your account credentials have been emailed to you on <?php echo get_par('email'); ?>.</div> |
265 | </div> |
266 | <div class="section_colour_bar"></div> |
267 | <?php } else { ?> |
268 | <form method="post"> |
269 | <table> |
270 | <tr> |
271 | <td>Company Name</td> |
272 | <td> |
273 | <input name="company_name" type="text" size="50" value="<?php echo get_par('company_name'); ?>" /> |
274 | </td> |
275 | </tr> |
276 | <tr> |
277 | <td>Mr./Ms...</td> |
278 | <td> |
279 | <input name="salutation" type="text" size="50" value="<?php echo get_par('salutation'); ?>" /> |
280 | </td> |
281 | </tr> |
282 | <tr> |
283 | <td><b>First Name</b></td> |
284 | <td> |
285 | <input name="first_name" type="text" size="50" value="<?php echo get_par('first_name'); ?>" /> |
286 | </td> |
287 | </tr> |
288 | <tr> |
289 | <td><b>Last Name</b></td> |
290 | <td> |
291 | <input name="last_name" type="text" size="50" value="<?php echo get_par('last_name'); ?>" /> |
292 | </td> |
293 | </tr> |
294 | <tr> |
295 | <td><b>Address</b></td> |
296 | <td> |
297 | <input name="street_addr" type="text" size="50" value="<?php echo get_par('street_addr'); ?>" /> |
298 | </td> |
299 | </tr> |
300 | <tr> |
301 | <td><b>State</b></td> |
302 | <td> |
303 | <input name="state" type="text" size="50" value="<?php echo get_par('state'); ?>" /> |
304 | </td> |
305 | </tr> |
306 | <tr> |
307 | <td><b>Postal Code</b></td> |
308 | <td> |
309 | <input name="postal_code" type="text" size="50" value="<?php echo get_par('postal_code'); ?>" /> |
310 | </td> |
311 | </tr> |
312 | <tr> |
313 | <td><b>City</b></td> |
314 | <td> |
315 | <input name="city" type="text" size="50" value="<?php echo get_par('city'); ?>" /> |
316 | </td> |
317 | </tr> |
318 | <tr> |
319 | <td><b>Country</b></td> |
320 | <td> |
321 | <input name="country" type="text" size="50" value="<?php echo get_par('country'); ?>" /> |
322 | </td> |
323 | </tr> |
324 | <tr> |
325 | <td><b>Phone</b></td> |
326 | <td> |
327 | <input name="phone" type="text" size="50" value="<?php echo get_par('phone'); ?>" /> |
328 | </td> |
329 | </tr> |
330 | <tr> |
331 | <td>Fax</td> |
332 | <td> |
333 | <input name="fax" type="text" size="50" value="<?php echo get_par('fax'); ?>" /> |
334 | </td> |
335 | </tr> |
336 | <tr> |
337 | <td>Alt. Phone</td> |
338 | <td> |
339 | <input name="alt_phone" type="text" size="50" value="<?php echo get_par('alt_phone'); ?>" /> |
340 | </td> |
341 | </tr> |
342 | <tr> |
343 | <td><b>Email</b></td> |
344 | <td> |
345 | <input name="email" type="text" size="50" value="<?php echo get_par('email'); ?>" /> |
346 | </td> |
347 | </tr> |
348 | <tr> |
349 | <td>CC</td> |
350 | <td> |
351 | <input name="cc" type="text" size="50" value="<?php echo get_par('cc'); ?>" /> |
352 | </td> |
353 | </tr> |
354 | <tr> |
355 | <td>BCC</td> |
356 | <td> |
357 | <input name="bcc" type="text" size="50" value="<?php echo get_par('bcc'); ?>" /> |
358 | </td> |
359 | </tr> |
360 | <tr> |
361 | <td>E-mail Forwarding</td> |
362 | <td> |
363 | <input name="vm_forward_emails" type="text" size="50" value="<?php echo get_par('vm_forward_emails'); ?>" /> |
364 | </td> |
365 | </tr> |
366 | <tr> |
367 | <td>E-mail Notification</td> |
368 | <td> |
369 | <input name="vm_notify_emails" type="text" size="50" value="<?php echo get_par('vm_notify_emails'); ?>" /> |
370 | </td> |
371 | </tr> |
372 | <tr> |
373 | <td><b>Currency</b></td> |
374 | <td> |
375 | <select name="payment_currency"> |
376 | <?php |
377 | foreach ($currencies as $k => $v) { |
378 | $selected = (get_par('payment_currency') == $k) ? ' selected' : ''; |
379 | print "<option value=\"$k\" label=\"$v\"$selected>$v</option>\n"; |
380 | } |
381 | ?> |
382 | </select> |
383 | </td> |
384 | </tr> |
385 | <tr> |
386 | <td><b>Time Zone</b></td> |
387 | <td> |
388 | <select name="i_time_zone"> |
389 | <?php |
390 | foreach ($tzs as $k => $v) { |
391 | $selected = (get_par('i_time_zone') == $k) ? ' selected' : ''; |
392 | print "<option value=\"$k\" label=\"$v\"$selected>$v</option>\n"; |
393 | } |
394 | ?> |
395 | </select> |
396 | </td> |
397 | </tr> |
398 | <tr> |
399 | <td> </td> |
400 | <td> |
401 | <input id="enableSignUp" name="enableSignUp" type="submit" value="I have read and agreed to Flysip`s Terms & Conditions" onClick="this.disabled = true; b = document.getElementById('task'); b.disabled = false; return false;"/> |
402 | </td> |
403 | </tr> |
404 | <tr> |
405 | <td> </td> |
406 | <td> |
407 | <input id="task" name="task" type="submit" disabled value="Sign Up" /> |
408 | </td> |
409 | </tr> |
410 | </table> |
411 | </form> |
412 | <?php } ?> |
413 | </div> |
414 | </div> |
415 | </body> |
416 | </html> |
Эту страницу не перевели на русский. Можете выбрать другой язык: