registration.php
17.8 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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
<?php
/**
* Registration Step Controller.
*
* KnowledgeTree Community Edition
* Document Management Made Simple
* Copyright(C) 2008,2009 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software(Pty) Limited
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
* must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
*
* @copyright 2008-2009, KnowledgeTree Inc.
* @license GNU General Public License version 3
* @author KnowledgeTree Team
* @package Installer
* @version Version 0.1
*/
class registration extends Step
{
/**
* Flag to store class information in session
*
* @author KnowledgeTree Team
* @access public
* @var array
*/
public $storeInSession = true;
/**
* Controller function for determining the position within the step
*
* @author KnowledgeTree Team
* @access public
* @return string The step position
*/
public function doStep()
{
$this->temp_variables = array("step_name"=>"registration");
$this->setFormInfo();
$this->loadFromSession();
if(!$this->inStep("registration")) {
$this->loadFromSession();
return 'landing';
}
if($this->next()) {
if($this->doRun())
return 'confirm';
return 'error';
} else if($this->previous()) {
return 'previous';
}else if($this->confirm()) {
return 'next';
}
return 'landing';
}
public function loadFromSession() {
$reg = $this->getDataFromSession('registration');
$this->temp_variables['first_name'] = $this->getPostSafe($reg['first_name']);
$this->temp_variables['last_name'] = $this->getPostSafe($reg['last_name']);
$this->temp_variables['email_address'] = $this->getPostSafe($reg['email_address']);
$this->temp_variables['sel_country'] = $this->getPostSafe($reg['sel_country']);
$this->temp_variables['sel_industry'] = $this->getPostSafe($reg['sel_industry']);
$this->temp_variables['sel_organization_size'] = $this->getPostSafe($reg['sel_organization_size']);
}
/**
* Safer way to return post data
*
* @author KnowledgeTree Team
* @params SimpleXmlObject $simplexml
* @access public
* @return void
*/
public function getPostSafe($key) {
$value = isset($key) ? $key : "";
return $value;
}
public function setInSession() {
$this->temp_variables['first_name'] = $_POST['submitted']['first_name'];
$this->temp_variables['last_name'] = $_POST['submitted']['last_name'];
$this->temp_variables['email_address'] = $_POST['submitted']['email_address'];
$this->temp_variables['sel_country'] = $_POST['submitted']['country'];
$this->temp_variables['sel_industry'] = $_POST['submitted']['industry'];
$this->temp_variables['sel_organization_size'] = $_POST['submitted']['organization_size'];
}
/**
* Execute the step action to register the user. If the user has already registered then the step will return.
*
* @author KnowledgeTree Team
* @access public
* @return unknown
*/
public function doRun()
{
if(isset($_POST['registered']) && $_POST['registered'] == 'yes'){
return true;
}
$this->setInSession();
// Post the form using curl
$this->curlForm($_POST);
// Prevent the form being reposted.
$_POST['registered'] = 'yes';
return true;
}
/**
* Post the form data to the drupal form using curl
*
* @author KnowledgeTree Team
* @access private
* @param array $data The post data
*/
private function curlForm($data)
{
$url = 'http://www.knowledgetree.com/installerform';
$data = http_build_query($data);
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
}
/**
* Post the form data to the drupal form using streams
*
* @author KnowledgeTree Team
* @access private
* @param array $data The post data
* @param array $optional_headers Optional headers to be sent with the data
* @return unknown
*/
private function postForm($data, $optional_headers = null)
{
$url = 'http://www.knowledgetree.com/installerform';
$data = http_build_query($data);
$params = array(
'http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = fopen($url, 'r', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
fclose($fp);
throw new Exception("Problem reading data from $url, $php_errormsg");
}
fclose($fp);
return $response;
}
/**
* Post the form data to the drupal form using file sockets
*
* @author KnowledgeTree Team
* @access private
* @param array $data The post data
*/
private function sendToHost($data)
{
$host = 'www.knowledgetree.com';
$method = 'POST';
$path = '/installerform';
$data = http_build_query($data, null, '&');
$method = strtoupper($method);
$fp = fsockopen($host, 80);
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
// fputs($fp,"Content-type: multipart/form-data\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
return $buf;
}
/**
* Set the information for the form dropdowns
*
* @author KnowledgeTree Team
* @access private
*/
private function setFormInfo()
{
$sizes = array(
'noneselected' => 'Select Organization Size...',
'upto10' => '1-10',
'upto20' => '11-20',
'upto50' => '21-50',
'upto100' => '51-100',
'upto500' => '101-500',
'upto1000' => '501-1000',
'more1000' => 'More than 1000'
);
$industries = array(
'noneselected' => 'Select Industry...',
'apparel' => 'Apparel',
'banking' => 'Banking',
'biotechnology' => 'Biotechnology',
'chemicals' => 'Chemicals',
'communications' => 'Communications',
'construction' => 'Construction',
'consulting' => 'Consulting',
'education' => 'Education',
'electronics' => 'Electronics',
'energy' => 'Energy',
'engineering' => 'Engineering',
'entertainment' => 'Entertainment',
'environmental' => 'Environmental',
'finance' => 'Finance',
'government' => 'Government',
'healthcare' => 'Healthcare',
'hospitality' => 'Hospitality',
'insurance' => 'Insurance',
'machinery' => 'Machinery',
'manufacturing' => 'Manufacturing',
'media' => 'Media',
'nonprofit' => 'Non Profit',
'recreation' => 'Recreation',
'retail' => 'Retail',
'shipping' => 'Shipping',
'technology' => 'Technology',
'telecommunications' => 'Telecommunications',
'transportation' => 'Transportation',
'utilities' => 'Utilities',
'other' => 'Other',
'legal' => 'Legal',
'software' => 'Software'
);
$countries = array(
'AF' => 'AFGHANISTAN',
'AX' => 'ÅLAND ISLANDS',
'AL' => 'ALBANIA',
'DZ' => 'ALGERIA',
'AS' => 'AMERICAN SAMOA',
'AD' => 'ANDORRA',
'AO' => 'ANGOLA',
'AI' => 'ANGUILLA',
'AQ' => 'ANTARCTICA',
'AG' => 'ANTIGUA AND BARBUDA',
'AR' => 'ARGENTINA',
'AM' => 'ARMENIA',
'AW' => 'ARUBA',
'AU' => 'AUSTRALIA',
'AT' => 'AUSTRIA',
'AZ' => 'AZERBAIJAN',
'BS' => 'BAHAMAS',
'BH' => 'BAHRAIN',
'BD' => 'BANGLADESH',
'BB' => 'BARBADOS',
'BY' => 'BELARUS',
'BE' => 'BELGIUM',
'BZ' => 'BELIZE',
'BJ' => 'BENIN',
'BM' => 'BERMUDA',
'BT' => 'BHUTAN',
'BO' => 'BOLIVIA',
'BA' => 'BOSNIA AND HERZEGOVINA',
'BW' => 'BOTSWANA',
'BV' => 'BOUVET ISLAND',
'BR' => 'BRAZIL',
'IO' => 'BRITISH INDIAN OCEAN TERRITORY',
'BN' => 'BRUNEI DARUSSALAM',
'BG' => 'BULGARIA',
'BF' => 'BURKINA FASO',
'BI' => 'BURUNDI',
'KH' => 'CAMBODIA',
'CM' => 'CAMEROON',
'CA' => 'CANADA',
'CV' => 'CAPE VERDE',
'KY' => 'CAYMAN ISLANDS',
'CF' => 'CENTRAL AFRICAN REPUBLIC',
'TD' => 'CHAD',
'CL' => 'CHILE',
'CN' => 'CHINA',
'CX' => 'CHRISTMAS ISLAND',
'CC' => 'COCOS (KEELING) ISLANDS',
'CO' => 'COLOMBIA',
'KM' => 'COMOROS',
'CG' => 'CONGO',
'CD' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE',
'CK' => 'COOK ISLANDS',
'CR' => 'COSTA RICA',
'CI' => "CÔTE D'IVOIRE",
'HR' => 'CROATIA',
'CU' => 'CUBA',
'CY' => 'CYPRUS',
'CZ' => 'CZECH REPUBLIC',
'DK' => 'DENMARK',
'DJ' => 'DJIBOUTI',
'DM' => 'DOMINICA',
'DO' => 'DOMINICAN REPUBLIC',
'EC' => 'ECUADOR',
'EG' => 'EGYPT',
'SV' => 'EL SALVADOR',
'GQ' => 'EQUATORIAL GUINEA',
'ER' => 'ERITREA',
'EE' => 'ESTONIA',
'ET' => 'ETHIOPIA',
'FK' => 'FALKLAND ISLANDS (MALVINAS)',
'FO' => 'FAROE ISLANDS',
'FJ' => 'FIJI',
'FI' => 'FINLAND',
'FR' => 'FRANCE',
'GF' => 'FRENCH GUIANA',
'PF' => 'FRENCH POLYNESIA',
'TF' => 'FRENCH SOUTHERN TERRITORIES',
'GA' => 'GABON',
'GM' => 'GAMBIA',
'GE' => 'GEORGIA',
'DE' => 'GERMANY',
'GH' => 'GHANA',
'GI' => 'GIBRALTAR',
'GR' => 'GREECE',
'GL' => 'GREENLAND',
'GD' => 'GRENADA',
'GP' => 'GUADELOUPE',
'GU' => 'GUAM',
'GT' => 'GUATEMALA',
'GG' => 'GUERNSEY',
'GN' => 'GUINEA',
'GW' => 'GUINEA-BISSAU',
'GY' => 'GUYANA',
'HT' => 'HAITI',
'HM' => 'HEARD ISLAND AND MCDONALD ISLANDS',
'VA' => 'HOLY SEE (VATICAN CITY STATE)',
'HN' => 'HONDURAS',
'HK' => 'HONG KONG',
'HU' => 'HUNGARY',
'IS' => 'ICELAND',
'IN' => 'INDIA',
'ID' => 'INDONESIA',
'IR' => 'IRAN, ISLAMIC REPUBLIC OF',
'IQ' => 'IRAQ',
'IE' => 'IRELAND',
'IM' => 'ISLE OF MAN',
'IL' => 'ISRAEL',
'IT' => 'ITALY',
'JM' => 'JAMAICA',
'JP' => 'JAPAN',
'JE' => 'JERSEY',
'JO' => 'JORDAN',
'KZ' => 'KAZAKHSTAN',
'KE' => 'KENYA',
'KI' => 'KIRIBATI',
'KP' => 'KOREA, DEMOCRATIC PEOPLE\'S REPUBLIC OF',
'KR' => 'KOREA, REPUBLIC OF',
'KW' => 'KUWAIT',
'KG' => 'KYRGYZSTAN',
'LA' => 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC',
'LV' => 'LATVIA',
'LB' => 'LEBANON',
'LS' => 'LESOTHO',
'LR' => 'LIBERIA',
'LY' => 'LIBYAN ARAB JAMAHIRIYA',
'LI' => 'LIECHTENSTEIN',
'LT' => 'LITHUANIA',
'LU' => 'LUXEMBOURG',
'MO' => 'MACAO',
'MK' => 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF',
'MG' => 'MADAGASCAR',
'MW' => 'MALAWI',
'MY' => 'MALAYSIA',
'MV' => 'MALDIVES',
'ML' => 'MALI',
'MT' => 'MALTA',
'MH' => 'MARSHALL ISLANDS',
'MQ' => 'MARTINIQUE',
'MR' => 'MAURITANIA',
'MU' => 'MAURITIUS',
'YT' => 'MAYOTTE',
'MX' => 'MEXICO',
'FM' => 'MICRONESIA, FEDERATED STATES OF',
'MD' => 'MOLDOVA, REPUBLIC OF',
'MC' => 'MONACO',
'MN' => 'MONGOLIA',
'ME' => 'MONTENEGRO',
'MS' => 'MONTSERRAT',
'MA' => 'MOROCCO',
'MZ' => 'MOZAMBIQUE',
'MM' => 'MYANMAR',
'NA' => 'NAMIBIA',
'NR' => 'NAURU',
'NP' => 'NEPAL',
'NL' => 'NETHERLANDS',
'AN' => 'NETHERLANDS ANTILLES',
'NC' => 'NEW CALEDONIA',
'NZ' => 'NEW ZEALAND',
'NI' => 'NICARAGUA',
'NE' => 'NIGER',
'NG' => 'NIGERIA',
'NU' => 'NIUE',
'NF' => 'NORFOLK ISLAND',
'MP' => 'NORTHERN MARIANA ISLANDS',
'NO' => 'NORWAY',
'OM' => 'OMAN',
'PK' => 'PAKISTAN',
'PW' => 'PALAU',
'PS' => 'PALESTINIAN TERRITORY, OCCUPIED',
'PA' => 'PANAMA',
'PG' => 'PAPUA NEW GUINEA',
'PY' => 'PARAGUAY',
'PE' => 'PERU',
'PH' => 'PHILIPPINES',
'PN' => 'PITCAIRN',
'PL' => 'POLAND',
'PT' => 'PORTUGAL',
'PR' => 'PUERTO RICO',
'QA' => 'QATAR',
'RE' => 'REUNION',
'RO' => 'ROMANIA',
'RU' => 'RUSSIAN FEDERATION',
'RW' => 'RWANDA',
// TODO: Special Character for the e
'BL' => 'SAINT BARTHELEMY',
'SH' => 'SAINT HELENA',
'KN' => 'SAINT KITTS AND NEVIS',
'LC' => 'SAINT LUCIA',
'MF' => 'SAINT MARTIN',
'PM' => 'SAINT PIERRE AND MIQUELON',
'VC' => 'SAINT VINCENT AND THE GRENADINES',
'WS' => 'SAMOA',
'SM' => 'SAN MARINO',
'ST' => 'SAO TOME AND PRINCIPE',
'SA' => 'SAUDI ARABIA',
'SN' => 'SENEGAL',
'RS' => 'SERBIA',
'SC' => 'SEYCHELLES',
'SL' => 'SIERRA LEONE',
'SG' => 'SINGAPORE',
'SK' => 'SLOVAKIA',
'SI' => 'SLOVENIA',
'SB' => 'SOLOMON ISLANDS',
'SO' => 'SOMALIA',
'ZA' => 'SOUTH AFRICA',
'GS' => 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
'ES' => 'SPAIN',
'LK' => 'SRI LANKA',
'SD' => 'SUDAN',
'SR' => 'SURINAME',
'SJ' => 'SVALBARD AND JAN MAYEN',
'SZ' => 'SWAZILAND',
'SE' => 'SWEDEN',
'CH' => 'SWITZERLAND',
'SY' => 'SYRIAN ARAB REPUBLIC',
'TW' => 'TAIWAN, PROVINCE OF CHINA',
'TJ' => 'TAJIKISTAN',
'TZ' => 'TANZANIA, UNITED REPUBLIC OF',
'TH' => 'THAILAND',
'TL' => 'TIMOR-LESTE',
'TG' => 'TOGO',
'TK' => 'TOKELAU',
'TO' => 'TONGA',
'TT' => 'TRINIDAD AND TOBAGO',
'TN' => 'TUNISIA',
'TR' => 'TURKEY',
'TM' => 'TURKMENISTAN',
'TC' => 'TURKS AND CAICOS ISLANDS',
'TV' => 'TUVALU',
'UG' => 'UGANDA',
'UA' => 'UKRAINE',
'AE' => 'UNITED ARAB EMIRATES',
'GB' => 'UNITED KINGDOM',
'US' => 'UNITED STATES',
'UM' => 'UNITED STATES MINOR OUTLYING ISLANDS',
'UY' => 'URUGUAY',
'UZ' => 'UZBEKISTAN',
'VU' => 'VANUATU',
'VE' => 'VENEZUELA',
'VN' => 'VIET NAM',
'VG' => 'VIRGIN ISLANDS, BRITISH',
'VI' => 'VIRGIN ISLANDS, U.S.',
'WF' => 'WALLIS AND FUTUNA',
'EH' => 'WESTERN SAHARA',
'YE' => 'YEMEN',
'ZM' => 'ZAMBIA',
'ZW' => 'ZIMBABWE'
);
$this->temp_variables['countries'] = $countries;
$this->temp_variables['industries'] = $industries;
$this->temp_variables['org_size'] = $sizes;
}
/**
* Return whether or not to store a step information in session
*
* @author KnowledgeTree Team
* @param none
* @access public
* @return boolean
*/
public function storeInSession() {
return $this->storeInSession;
}
}
?>