forked from ivywe/geeklog-formmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
staticpages_formmail_bootstrap_en.php
1055 lines (953 loc) · 39.9 KB
/
staticpages_formmail_bootstrap_en.php
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// +---------------------------------------------------------------------------+
// | FormMail Static Page for Geeklog 1.8 higher Bootstrap class added, English|
// +---------------------------------------------------------------------------+
// | staticpages_formmail_bootstrap_en.php |
// | |
// | Version: 2.1.9 UIkit en |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2008-2015 by the following authors: |
// | Translated: kobab - geeklog.crimsonj.net |
// | Translated: Alleman Chie and Geeklog Japanese |
// +---------------------------------------------------------------------------+
// | This program was originally made for Japanese users. Several |
// | parts are therefore for Japanese users only and commented-out for |
// | this English version. |
// | For the purpose of future upgrade for both of Japanese & English |
// | verions, those commented-out parts are remained. Wish English |
// | users understand this and ignore those parts when you use. |
// +---------------------------------------------------------------------------+
global $_CONF,$_USER,$_PLUGINS,$_SCRIPTS,$page; // Geeklog variables
global $_fmtokenttl; // FormMail variables
if (!defined('XHTML')) define('XHTML', ' /');
// --[[ Default Setting ]]------------------------------------------------------
# receipient set
# If 2 or more receipient, each email should be commmaed. no space allowed.
# ex) 'info@abcd.com,admin@wxyz.com'
# Set email for a certain colum data. If colum 1 is AAA, receipient is info@geeksite. If colum 1 is BBB, receipient becomes to admin@geeksite
# You MUST set $owner_email_item_name if you use this feature.
# ex) 'AAA=info@abcd.com,BBB=admin@wxyz.com'
$owner_email=$_CONF['site_mail'];
# Set colum name of receipient
// *Remember to remove * to uncomment after setting colum name.
#$owner_email_item_name = 'q_mail_to';
# email of auto-reply message sender
$email_from = $_CONF['site_mail'];
#'noreply_mail' can be used if your Geeklog version is 1.5 or later.
#$email_from = $_CONF['noreply_mail'];
# inquirer email's item name
$email_input_name = 'q_mail';
# email double check
# no space allowed.
# ex) 'email=reemail'
$essential_email = 'q_mail=q_mail_re';
# email check
# check if input string is proper email address
# value of name attrubute with commas. no space is allowed.
# ex) 'email,reemail'
$propriety_email = 'q_mail,q_mail_re';
# CSRF Token (sec)
$_fmtokenttl = 1800;
# Referer check (CSRF) no check:0 check:1
$_spreferercheck = 1;
# Referer error message
$_spreferererrormsg = '<p class="text-danger">Access denied.</p>';
# use Geeklog's userset if logged-in
# use username, full name & email of login users
#
$username = ''; $user_email = '';
if (!COM_isAnonUser()) {
$username = isset($_USER['fullname']) ? $_USER['fullname'] : $_USER['username'];
$user_email = $_USER['email'];
}
# save as CSV file
# not save: 0, save with commas: 1, save with tabs: 2
$save_csv = 1;
# path for CSV file to be saved. / is mandatory at the end of URL If you specify# bare # path.
$save_csv_path = $_CONF['path_data'];
# CSV file name
$save_csv_name = 'formmail.csv';
# character code at saving CSV file
# If no code conversion is necesasry, make it blank, ie '' to disable this
# feature. If garbled, make this disabled and use another tool.
# Remember to use a code which mb_convert_encoding is covering
# ex) UTF-8, SJIS, EUC-JP, JIS, ASCII
$save_csv_lang = 'UTF-8';
# For Japanese language only.
# Set colums that auto-convert from zenkaku to hankaku neccessary.
# Specify name attribute's values one by one with commas. no space allowed.
$zentohan_itemname = 'q_phone,q_code1_1,q_code2_1,q_code3_1,q_code1_2,q_code2_2,q_code3_2,q_code1_3,q_code2_3,q_code3_3';
# For Japanese language only.
# Set colums that auto-convert from hankaku to zenkaku neccessary.
# Specify name attribute's values one by one with commas. no space allowed.
$kana_hantozen_itemname = 'q_kana_1,q_kana_2';
# For Japanese language only.
# Set colums that auto-convert from hiragana to katakana necessary.
# Specify name attribute's values one by one with commas. no space allowed.
$kana_hiratokana_itemname = 'q_kana_1,q_kana_2';
# item names at screen transition
$seni_items = array('input' => 'Input', 'confirm' => 'Confirm', 'finish' => 'Complete');
# string for mondatory item
$required_string = '<span class="text-danger">*</span>';
# === CAPTCHA === {
# error message after formmail used with CAPTCHA.
# *if blaked, error message of CAPTCHA plugin is used
# *if you speciy message here, it will be used
$msg_spformmail_notinstall_captcha = 'CAPTCHA plugin is not installed';
# CAPTCHA error message. If not set, CAPTCA plugin message is used.
$msg_spformmail_valid_captcha = '';
#
# ※ CAPTCHA templates
# private/plugins/captcha/templates/captcha_contact.thtml
# } === CAPTCHA ===
# ==About date and time { ==
# The date on the following JavaScript calendar.
# php date format. ref: http://www.php.net/manual/en/function.date.php
# "d, D, j, l, N, w, S, F, m, M, n, Y, y" can be assigned.
# change layout/theme/vendor/uikit/js/components/datepicker.js
# The receipt date and time indicated in an email.
# Any php date format can be used here. (ref: http://www.php.net/manual/en/function.date.php)
$date_mail = 'M j Y H:i';
# When the csv is outputted, the date and time are written to the first row of the csv.
# Any php date format can be used here. (ref: http://www.php.net/manual/en/function.date.php)
$date_csv = 'M j Y H:i';
# } ==About date and time { ==
#####
# display message
#####
$lang = array(
// { complete & email message
'receipt_admin' =>'Dear admins,'.LB.LB.$_CONF['site_name'].' site received a inquiry.'.LB.LB.'========== Inquiry =========='.LB.'receipt at:'.date($date_mail),
'receipt_user' =>'*This email is sent from '.$_CONF['site_name'].' site automatically.'.LB.'This email address is used for transmission only and not repliable.'.LB.'============================='.LB.'Thank you very much for your inquiry.'.LB.LB.'========== Inquiry =========='.LB.'Receipt at:'.date($date_mail),
'subject_admin'=> '['.$_CONF['site_name'].']Inquiry',
'subject_user'=> '['.$_CONF['site_name'].']Thanks for your inquiry',
'sign_admin' => '-----------------------------------------'.LB.$_CONF['site_name'].LB.$_CONF['site_url'].LB.'-----------------------------------------',
'sign_user' => '-----------------------------------------'.LB.$_CONF['site_name'].LB.'URL:' . $_CONF['site_url'].LB.'-----------------------------------------',
// } complete & email message
// { system error message
'ownertransmiterror'=>'An error has occurred at several email addresses during processing owner email, but process continued and completed.',
'transmiterror'=>'An error has occurred during processing.',
// } system error message
);
#####
# table's item names
#####
$form_items = array(
## table {
array('title'=>'Personal Information', 'table'=>array(
// table 1 row {
array('header'=>'Organization',
'data'=>array(
array( 'type'=>'text', 'name'=>'q_organization', 'size'=>'40', 'maxlength'=>'60', 'class'=>'form-control ime_on', 'placeholder' => 'Type your organization.' ),
),
),
// } table 1 row
// table 1 row {
array('header'=>'Name',
'valid_require'=>$required_string, 'error_require'=>'Please type your name.',
'data'=>array(
array( 'type'=>'text', 'name'=>'q_name', 'size'=>'40', 'maxlength'=>'40', 'class'=>'form-control ime_on', 'value'=>$username, 'placeholder' => 'Please type your name.' ),
),
),
// } table 1 row
// table 1 row {
array('header'=>'Email',
'valid_require' => $required_string, 'error_require' => 'Please type your email address.',
'valid_equal' => $essential_email, 'error_equal' => 'Email address not match.',
'valid_email' => $propriety_email, 'error_email' => 'Please type out proper email address.',
'data'=>array(
array( 'type'=>'text', 'name'=>'q_mail', 'size'=>'40', 'maxlength'=>'240', 'class'=>'form-control ime_off', 'value'=>$user_email,'placeholder' => 'Enter your e-mail address.' ),
array( 'type'=>'text', 'name'=>'q_mail_re', 'size'=>'40', 'maxlength'=>'240', 'class'=>'form-control email ime_off mt10', 'not_confirm'=>'true', 'not_csv'=>'true', 'value'=>$user_email, 'placeholder' => 'Please enter your e-mail address again to confirm.' ),
),
),
// } table 1 row
// table 1 row {
array('header'=>'Inquiry Method',
'data'=>array(
array( 'string'=>'<br'.XHTML.'>' ), // for Bootstrap
array( 'type'=>'radio', 'name'=>'q_answer_means', 'value'=>'Email', 'checked'=>'checked' ),
array( 'input'=>'Email ' ),
array( 'type'=>'radio', 'name'=>'q_answer_means', 'value'=>'Phone' ),
array( 'input'=>'Phone ' ),
array( 'string'=>'<br'.XHTML.'>' ),
array( 'input'=>'We may call you in the event e-mail inquiry fails.' ),
),
),
// } table 1 row
// table 1 row {
array('header'=>'Phone',
'valid_require'=>$required_string, 'error_require'=>'Please type your phone number.',
'valid_phone'=>'q_phone', 'error_phone'=>'Please input your phone number correctly. Only numbers, plus, minus, and space characters are allowed as input.',
'valid_minlen'=>'q_phone=6', 'error_minlen'=>'Phone number shouold be longer than 6 digit.',
'valid_maxlen'=>'q_phone=13', 'error_maxlen'=>'Phone number should not exceed 17 digit.',
'help'=>'phone number: number, +, -, space',
'data'=>array(
array( 'type'=>'text', 'name'=>'q_phone', 'size'=>'20', 'style'=>'width: 20em;', 'maxlength'=>'13', 'class'=>'form-control ime_off', 'placeholder' => 'e.g. +81311112222.' ),
array( 'type'=>'radio', 'name'=>'q_phone_kind', 'value'=>'Home', 'checked'=>'checked' ),
array( 'input'=>'Home ' ),
array( 'type'=>'radio', 'name'=>'q_phone_kind', 'value'=>'Office' ),
array( 'input'=>'Office ' ),
array( 'type'=>'radio', 'name'=>'q_phone_kind', 'value'=>'Mobile' ),
array( 'input'=>'Mobile' ),
),
),
// } table 1 row
// table 1 row {
array('header'=>'Inquiry Date',
'data'=>array(
array( 'type'=>'text', 'name'=>'q_date1', 'size'=>'20', 'class'=>'form-control', 'style'=>'width: 20em;', 'data-uk-datepicker'=>"{format:'YYYY.MM.DD'}"),
),
),
// } table 1 row
// table 1 row {
array('header' => 'Inquiry Time',
'data'=>array(
array( 'type'=>'select', 'name'=>'q_access_time', 'style'=>'width: 15em;', 'class'=>'', 'options' => array('selected' => 'Not Specified', 'values' => 'Not Specified,AM,Early PM, Late PM'), ),
array('input' => '<br'.XHTML.'>*Please indicate a time we may call you if telephone inquiry is preferred.'),
),
),
// } table 1 row
),),
## } table
## table {
array('title'=>'Preferences', 'table'=>array(
// table 1 row {
array('header'=>'Apply',
'data'=>array(
array( 'input'=>'<br'.XHTML.'>' ), // for Bootstrap
array( 'type'=>'checkbox', 'name'=>'q_order_1', 'value'=>'Seminar1' ),
array( 'input'=>' ' ),
array( 'type'=>'checkbox', 'name'=>'q_order_2', 'value'=>'Seminar2' ),
array( 'input'=>' ' ),
array( 'type'=>'checkbox', 'name'=>'q_order_3', 'value'=>'Seminar3' ),
),
),
// } table 1 row
// table 1 row {
array('header'=>'Comments',
'valid_maxlen'=>'q_other=500', 'error_maxlen'=>'Please complete within 500 characters.',
'help'=>'Please complete within 500 characters.',
'data'=>array(
array( 'type'=>'textarea', 'name'=>'q_other', 'class'=>'', 'style'=>'width: 95%; height: 100px;', 'onKeyup'=>"var n=500-this.value.length;var s=document.getElementById('tasp1');s.innerHTML='('+n+')';", 'placeholder' => 'Please complete within 500 characters.' ),
array( 'input'=>"<strong><span id='tasp1'></span></strong>" ),
),
),
// } table 1 row
),),
## } table
## table CAPTCHA {
array('title_captcha' => '', 'table_captcha' => array(
// { table 1 row CAPTCHA
array('header_captcha' => 'CAPTCHA',
'valid_captcha' => $required_string,
'error_captcha' => $msg_spformmail_valid_captcha,
'error_notcaptcha' => $msg_spformmail_notinstall_captcha,
'data' => array()
),
// } table 1 row CAPTCHA
),),
## } table CAPTCHA
## submit input {
array('action'=>'input',
'data'=>array(
array( 'string'=>'<div class="text-center">' ),
array( 'type'=>'submit', 'name'=>'submit', 'class'=>'uk-button', 'value'=>'Confirm' ),
array( 'string'=>'</div>' ),
),
),
## } submit input
## submit confirm {
array('action'=>'confirm',
'data'=>array(
array( 'string'=>'<div class="text-center">' ),
array( 'type'=>'submit', 'name'=>'goback', 'class'=>'uk-button', 'value'=>'Return to the previous page' ),
array( 'string'=>' ' ),
array( 'type'=>'submit', 'name'=>'submit', 'class'=>'uk-button', 'value'=>'Submit' ),
array( 'string'=>'</div>' ),
),
),
## } submit confirm
);
// --[[ Functions ]]---------------------------------------------------------------
if(!function_exists('_fmGetAction')){
function _fmGetAction ($err) {
$buf = '';
$action = COM_applyFilter($_POST['action']);
if (!empty($action) && empty($err) && $action == 'input') { $buf = 'confirm'; }
elseif (!empty($action) && empty($err) && $action == 'confirm') { $buf = empty($_POST['goback']) ? 'finish' : 'input'; }
else { $buf = 'input'; }
return $buf;
}
function _fmMkSeni ($items, $action) {
$buf = '<ul class="list-inline">'.LB;
foreach ($items as $key => $value) {
if ($action == $key) {
$buf .= ' <li><h4><span class="label label-default label-info">'.$value.'</span></li>'.LB;
} else {
$buf .= ' <li><h4><span class="label label-default label-default">'.$value.'</span></li>'.LB;
}
}
$buf .= '</ul>'.LB;
return $buf;
}
function _fmPutiFilter($s) {
$se = array('%','(',')',chr(92),chr(13).chr(10),chr(13),chr(10));
$re = array('%','(',')','\','','','');
return str_replace($se, $re, htmlspecialchars($s,ENT_QUOTES));
}
function _fmChkUseCAPTCHA_HTML () {
global $_CP_CONF, $_USER;
if ( ($_CP_CONF['anonymous_only'] && $_USER['uid'] < 2) || $_CP_CONF['anonymous_only'] == 0 || ($_CP_CONF['remoteusers'] == 1 && SEC_inGroup("Remote Users") ) ) {
return true;
}
return false;
}
function _fmVldCAPTCHA ($type, $errmsg) {
$msg = '';
if (!function_exists('CAPTCHA_sid')) { return $msg; }
if ( _fmChkUseCAPTCHA_HTML() ) {
$str = COM_applyFilter($_POST['captcha']);
list( $rc, $msg ) = CAPTCHA_checkInput( $type, $str );
}
if ( !empty($msg) && !empty($errmsg) ) { $msg = $errmsg; }
return $msg;
}
function _fmVld_isPhone($s) { return (preg_match('/^(?:[0-9'.chr(92).'+'.chr(92).'-'.chr(92).'s])+$/D',$s)) ? TRUE : FALSE; }
function _fmVld_isHankaku($s) { return (preg_match('/^(?:'.chr(92).'xEF'.chr(92).'xBD['.chr(92).'xA1-'.chr(92).'xBF]|'.chr(92).'xEF'.chr(92).'xBE['.chr(92).'x80-'.chr(92).'x9F]|['.chr(92).'x20-'.chr(92).'x7E])+$/D',$s)) ? TRUE : FALSE; }
function _fmVld_isZenkaku($s) { return (preg_match('/(?:'.chr(92).'xEF'.chr(92).'xBD['.chr(92).'xA1-'.chr(92).'xBF]|'.chr(92).'xEF'.chr(92).'xBE['.chr(92).'x80-'.chr(92).'x9F]|['.chr(92).'x20-'.chr(92).'x7E])+/D',$s)) ? FALSE : TRUE; }
function _fmVld_isEisuHan($s) { return (preg_match('/^(?:[0-9A-Za-z])+$/D',$s)) ? TRUE : FALSE; }
function _fmVld_isKanaZen($s) { return (preg_match('/^(?:'.chr(92).'xE3'.chr(92).'x82['.chr(92).'xA1-'.chr(92).'xBF]|'.chr(92).'xE3'.chr(92).'x83['.chr(92).'x80-'.chr(92).'xB6])+$/D',$s)) ? TRUE : FALSE; }
function _fmVld_isHiraZen($s) { return (preg_match('/^(?:'.chr(92).'xE3'.chr(92).'x81['.chr(92).'x81-'.chr(92).'xBF]|'.chr(92).'xE3'.chr(92).'x82['.chr(92).'x80-'.chr(92).'x93])+$/D',$s)) ? TRUE : FALSE; }
function _fmVld_isNotKanaHan($s) { return (preg_match('/(?:'.chr(92).'xEF'.chr(92).'xBD['.chr(92).'xA1-'.chr(92).'xBF]|'.chr(92).'xEF'.chr(92).'xBE['.chr(92).'x80-'.chr(92).'x9F])+/D',$s)) ? TRUE : FALSE; }
function _fmChkValidate ($mode, $datas, $errmsg, $attributes = '') {
$msg = '';
foreach ($datas as $data) {
if (isset($data['type'])) {
$name = $data['name'];
//<Input check>
switch ($mode) {
// check required item
case 'require':
if (empty($data['notrequire']) && empty($_POST[$name]) && $_POST[$name] != "0") { $msg = $errmsg; }
break;
// check matching
case 'equal':
if (!empty($attributes)) {
$es_emails = explode(',', $attributes);
foreach ($es_emails as $es_email) {
list($eq1,$eq2) = explode('=', $es_email);
// initial key ANT it exist
if ($name == $eq1 && !empty($_POST[$eq2])) {
if ($_POST[$eq1] != $_POST[$eq2]) {
$msg = $errmsg;
}
}
}
}
break;
// email check
case 'email':
if (!empty($attributes)) {
$pr_emails = explode(',', $attributes);
foreach ($pr_emails as $pr_email) {
if ($name == $pr_email) {
if (!COM_isemail($_POST[$name])) {
$msg = $errmsg;
}
}
}
}
break;
// num check - sum is more than 0
case 'notzero':
if (!empty($attributes)) {
$values_key = explode(',', $attributes);
foreach ($values_key as $val_key) {
// 最初のキーのときにチェック
if ($name == $val_key) {
$sum_val = 0;
foreach ($values_key as $chk_key) {
if (!empty($_POST[$chk_key])) {
$sum_val += $_POST[$chk_key];
}
}
if ($sum_val <= 0) {
$msg = $errmsg;
break;
}
}
}
}
break;
// check if numeric
case 'numeric':
if ((!empty($_POST[$name]) || $_POST[$name] == "0") && in_array($name,explode(',',$attributes)) && !ctype_digit($_POST[$name])) { $msg = $errmsg; }
break;
// check if phone
case 'phone':
if ((!empty($_POST[$name]) || $_POST[$name] == "0") && in_array($name,explode(',',$attributes)) && !_fmVld_isPhone($_POST[$name])) { $msg = $errmsg; }
break;
// (For Japanese language only) Check byte
case 'hankaku':
if ((!empty($_POST[$name]) || $_POST[$name] == "0") && in_array($name,explode(',',$attributes)) && !_fmVld_isHankaku($_POST[$name])) { $msg = $errmsg; }
break;
// (For Japanese language only) Check em
case 'zenkaku':
if (!empty($_POST[$name]) && in_array($name,explode(',',$attributes)) && !_fmVld_isZenkaku($_POST[$name])) { $msg = $errmsg; }
break;
// (For Japanese language only) Alphanumeric check
case 'eisuhan':
if ((!empty($_POST[$name]) || $_POST[$name] == "0") && in_array($name,explode(',',$attributes)) && !_fmVld_isEisuHan($_POST[$name])) { $msg = $errmsg; }
break;
// (For Japanese language only) Check em kana
case 'kanazen':
if (!empty($_POST[$name]) && in_array($name,explode(',',$attributes)) && !_fmVld_isKanaZen($_POST[$name])) { $msg = $errmsg; }
break;
// (For Japanese language only) Check em hiragana
case 'hirazen':
if (!empty($_POST[$name]) && in_array($name,explode(',',$attributes)) && !_fmVld_isHiraZen($_POST[$name])) { $msg = $errmsg; }
break;
// (For Japanese language only) Check for non-katakana
case 'notkanahan':
if ((!empty($_POST[$name]) || $_POST[$name] == "0") && in_array($name,explode(',',$attributes)) && _fmVld_isNotKanaHan($_POST[$name])) { $msg = $errmsg; }
break;
// check max length
case 'maxlen':
if ((!empty($_POST[$name]) || $_POST[$name] == "0")) {
foreach (explode(',', $attributes) as $attr1) {
list($name2,$max2) = explode('=',$attr1);
if ($name === $name2) {
if ($max2 < mb_strlen($_POST[$name], 'UTF-8')) { $msg = $errmsg; }
}
}
}
break;
// check min length
case 'minlen':
if ((!empty($_POST[$name]) || $_POST[$name] == "0")) {
foreach (explode(',', $attributes) as $attr1) {
list($name2,$min2) = explode('=',$attr1);
if ($name === $name2) {
if ($min2 > mb_strlen($_POST[$name], 'UTF-8')) { $msg = $errmsg; }
}
}
}
break;
}
//</Input check>
}
}
// check CAPTCHA
if ( $mode == 'captcha' ) { $msg = _fmVldCAPTCHA('contact', $errmsg); }
return $msg;
}
function _fmValidateLines ($lines) {
$errmsg;
foreach (array('require','equal','email','notzero','numeric','phone','hankaku','zenkaku','eisuhan','kanazen','hirazen','notkanahan','captcha','maxlen','minlen') as $chk) {
// check require,match,email,CAPTCH,error
if (isset($lines['valid_'.$chk])) {
$errmsg = _fmChkValidate($chk, $lines['data'], $lines['error_'.$chk], $lines['valid_'.$chk]);
// arrays if error found
if ($errmsg) {
break;
}
}
}
return $errmsg;
}
function _fmValidateItems ($items) {
$errs;
foreach ($items as $item) {
// eah table
foreach ($item as $key => $value) {
// 1 table
if ($key == 'table' || $key == 'table_captcha') {
$action = _fmGetAction('');
if ($key == 'table_captcha' && $action == 'finish') { continue; }
foreach ($value as $key2 => $value2) {
// table 1 row
$errmsg = _fmValidateLines($value2);
if ($errmsg) { $errs[] = $errmsg; }
}
}
}
}
return $errs;
}
function _fmValidate ($items) {
$buf = '';
$errs = _fmValidateItems($items);
if (!empty($errs)) {
$errmsg = '';
foreach ($errs as $err) {
$errmsg .= ' <li>'.$err.'</li>'.LB;
}
$buf = <<<END
<div class="alert alert-warning" role="alert">
<p style="margin-top:10px">Some error found. Please check below and correct your input.</p>
<ol>
$errmsg
</ol>
</div>
END;
}
return $buf;
}
function _fmMkTitle ($title) {
return <<<END
<h3>$title</h3>
END;
}
function _fmMkForm_Value ($name, $value) {
return (empty($_POST[$name]) && $_POST[$name] != "0") ? $value : _fmPutiFilter($_POST[$name]);
}
function _fmMkForm_Radio_Checked (&$attributes) {
$name = $attributes['name'];
if ((!empty($_POST[$name]) || $_POST[$name] == "0")) {
if (isset($attributes['checked'])) unset($attributes['checked']);
if ($_POST[$name] == $attributes['value']) {
$attributes['checked'] = 'checked';
}
}
}
function _fmMkForm_Input ($attributes, $hidden = false) {
if ($hidden) {
if ($attributes['type'] == 'radio' || $attributes['type'] == 'checkbox') {
if ($attributes['value'] != $_POST[$attributes['name']]) return '';
}
$attributes['type'] = 'hidden';
}
if ($attributes['type'] == 'radio' || $attributes['type'] == 'checkbox') {
_fmMkForm_Radio_Checked($attributes);
} else {
if ($attributes['type'] != 'submit') $attributes['value'] = _fmMkForm_Value($attributes['name'], $attributes['value']);
}
$buf = '<input';
foreach ($attributes as $key => $value) {
if ($key != 'not_confirm') { $buf .= ' '.$key.'="'.$value.'"'; }
}
$buf .= XHTML.'>';
if ($hidden || $attributes['type'] == 'checkbox') {
if ( !isset($attributes['not_confirm']) || ! $attributes['not_confirm'] ) { $buf .= ' ' . $attributes['value']; }
}
return $buf;
}
function _fmMkForm_Select_Options ($name, $attributes) {
$buf = '';
$selected = _fmMkForm_Value($name, $attributes['selected']);
$values = explode(',', $attributes['values']);
foreach ($values as $value) {
list($k,$v) = explode('=',$value);
if (empty($v)) $v = $k;
if ($selected == $k) {
$buf .= '<option selected="selected" value="'.$v.'">'.$k.'</option>';
} else {
$buf .= '<option value="'.$v.'">'.$k.'</option>';
}
}
return $buf;
}
function _fmMkForm_Select ($attributes) {
$buf = '<select';
foreach ($attributes as $key => $value) {
if ($key != 'options') {
$buf .= ' '.$key.'="'.$value.'"';
}
}
$buf .= '>';
$buf .= _fmMkForm_Select_Options($attributes['name'], $attributes['options']);
$buf .= '</select>';
return $buf;
}
function _fmMkForm_Textarea ($attributes) {
$attributes['value'] = _fmMkForm_Value($attributes['name'], $attributes['value']);
$buf = '<textarea';
foreach ($attributes as $key => $value) {
if ($key != 'value') $buf .= ' '.$key.'="'.$value.'"';
}
$buf .= '>'.$attributes['value'].'</textarea>';
return $buf;
}
function _fmMkForm_Item ($items, $action) {
$buf = '';
if ($action != 'input' && $items['type'] != 'submit' && $items['type'] != 'hidden') {
$buf .= _fmMkForm_Input($items, true);
} else {
switch ($items['type']) {
case 'text': $buf .= _fmMkForm_Input($items); break;
case 'password': $buf .= _fmMkForm_Input($items); break;
case 'hidden': $buf .= _fmMkForm_Input($items); break;
case 'radio': $buf .= _fmMkForm_Input($items); break;
case 'checkbox': $buf .= _fmMkForm_Input($items); break;
case 'select': $buf .= _fmMkForm_Select($items); break;
case 'textarea': $buf .= _fmMkForm_Textarea($items); break;
case 'submit': $buf .= _fmMkForm_Input($items); break;
case 'reset': $buf .= _fmMkForm_Input($items); break;
case 'button': $buf .= _fmMkForm_Input($items); break;
}
}
return $buf;
}
function _fmMkTable_Data ($datas, $action) {
$buf = '';
foreach ($datas as $data) {
// 1 data
if (!empty($data['type'])) {
// form
$buf .= _fmMkForm_Item($data, $action);
}
else {
// string
foreach ($data as $key => $value) {
if ($key == 'string') {
$buf .= $value;
} elseif ($key == $action) {
$buf .= $value;
}
}
}
}
return $buf;
}
function _fmMkCAPTCHA_HTML($name, $msg_notcaptcha) {
global $_CP_CONF, $_USER, $_TABLES;
$captcha = '';
if (!function_exists('CAPTCHA_sid')) { return $msg_notcaptcha; }
if ( _fmChkUseCAPTCHA_HTML() ) {
$csid = 0;
// housekeeping, delete old captcha sessions
$oldSessions = time() - ($_CP_CONF['expire']+900);
DB_query("DELETE FROM {$_TABLES['cp_sessions']} WHERE cptime < " . $oldSessions,1);
// OK, we need to insert the CAPTCHA, so now we need to setup the session_id:
// check to see if a failed entry happened...
if ( isset($_POST['csid']) ) {
$csid = COM_applyFilter($_POST['csid']);
} else {
$csid = CAPTCHA_sid();
}
$time = time();
$counter = 0;
$validation = ''; // this will be filled in by the CAPTCHA
DB_save($_TABLES['cp_sessions'],"session_id,cptime,validation,counter","'$csid','$time','','0'");
$captcha = CAPTCHA_getHTML($csid,$name);
}
return $captcha;
}
function _fmMkTable ($tables, $action) {
global $_fmhelppageurl;
$buf = '';
foreach ($tables as $lines) {
$flg_valid_captcha=false;
$errflg = '';
$tdclass='';
// Error check
if (!empty($_POST)) { $errflg = _fmValidateLines($lines); }
if ($errflg) { $div_errorclass=' has-error has-feedback'; $label_errorclass =' bg-danger'; } else { $tdclass=''; }
$buf .= LB .' ' . LB;
$buf .= '<div class="form-group'.$div_errorclass.'"><label class="control-label'.$label_errorclass.'">';
if (isset($lines['header'])) { $buf .= $lines['header'] ; }
if (isset($lines['header_captcha'])) { $buf .= $lines['header_captcha']; }
if (isset($lines['valid_require'])) { $buf .= $lines['valid_require']; }
if (isset($lines['valid_captcha'])) { $buf .= $lines['valid_captcha']; $flg_valid_captcha=true; }
$buf .= '</label>'.LB;
if (isset($lines['data'])) {
if ($flg_valid_captcha) {
$buf .= _fmMkCAPTCHA_HTML('contact',$lines['error_notcaptcha']);
} else {
$buf .= _fmMkTable_Data($lines['data'], $action);
}
}
if ($errflg) {
$buf .= '<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span><span id="inputError2Status" class="sr-only">(error)</span>';
} else {
$tdclass='';
}
$buf .= '</div>'.LB;
}
return $buf;
}
function _fmMkForm ($items, $action) {
global $_fmtokenttl;
$ttl = (isset($_fmtokenttl) && $_fmtokenttl > 1) ? $_fmtokenttl : 1800;
$buf = '';
foreach ($items as $item) {
// table
if (!empty($item['table'])) {
foreach ($item as $key => $value) {
// 1 table
switch ($key) {
case 'title': $buf .= _fmMkTitle($value); break;
case 'table': $buf .= _fmMkTable($value, $action); break;
}
}
$buf .= <<<END
END;
} elseif (!empty($item['table_captcha'])) { // CAPTCHA
if ((!empty($action) && $action == 'input') && _fmChkUseCAPTCHA_HTML()) {
foreach ($item as $key => $value) {
// 1 table
switch ($key) {
case 'title_captcha': $buf .= _fmMkTitle($value); break;
case 'table_captcha': $buf .= _fmMkTable($value, $action); break;
}
}
$buf .= <<<END
END;
}
} elseif (!empty($item['action'])) { // Submit button
if ($item['action'] == $action) {
$buf .= LB . ' <input type="hidden" name="action" value="' . $action . '"' . XHTML . '>';
$buf .= LB . _fmMkTable_Data($item['data'], $action);
}
}
}
if (!empty($buf) && ($action=='input' || $action=='confirm')) { $buf.=LB.' <input type="hidden" name="_glsectoken" value="'.SEC_createToken($ttl).'"'.XHTML.'>'; }
return $buf;
}
function _fmMkCsv ($items, $level=0, $dupcheck=array()) {
$ret = array();
if ($level > 5) { return; } $level++;
if (!empty($items['type']) && strtolower($items['type']) != 'submit' ) {
if((!empty($items['not_csv']) && $items['not_csv']) || empty($items['name'])) { return; }
if(strtolower($items['type']) == 'radio' && in_array($items['name'], $dupcheck)) { return; }
return $items['name'];
} else {
if (!is_array($items)) { return; }
foreach ($items as $i) {
$name = _fmMkCsv($i,$level, $ret);
if (!empty($name)) {
if(is_array($name)) { $ret = array_merge($ret,$name); } else { $ret[] = $name; }
}
}
}
return $ret;
}
function _fmChkReferer ($pu,$err) {
global $_CONF; $msg = ''; $action = COM_applyFilter($_POST['action']);
if (!isset($_SERVER['HTTP_REFERER'])) {
if (!empty($_POST)) { $msg = '<p class="text-danger">REFERER check required. But REFERER is not set on your server. Please contact your server-administrator.</p>'; }
} elseif (!empty($action) && ($action=='input' || $action=='confirm')) {
if (strpos($_SERVER['HTTP_REFERER'],$pu)===FALSE) {
$msg = $err;
}
} elseif (strpos($_SERVER['HTTP_REFERER'],$_CONF['site_url'])===FALSE) {
$msg = $err;
}
return $msg;
}
}
// +---------------------------------------------------------------------------+
// | initial process |
// +---------------------------------------------------------------------------+
//# For Japanese language only.
//# Direct convert of POST data, ie. from em-size to normal-width and from
//# the katakana normal-width to the katakana. This is for Japanese user only.
//# This program was originally made for Japanese users. Several parts are
//# therefore for Japanese users only. We commented those parts
//# out for this English version.
//# For the convenience of authors of future upgrade for both of Japanese
//# & English versions, those parts for Japanese users are remained in php
//# files. Wish English users understand this and ignore those parts when
//# you use this php.
//if (!empty($zentohan_itemname)) { foreach (explode(',',$zentohan_itemname) as $k) { if (!empty($_POST[$k])) $_POST[$k] = mb_convert_kana($_POST[$k], 'askh'); } }
//if (!empty($kana_hantozen_itemname)) { foreach (explode(',',$kana_hantozen_itemname) as $k) { if (!empty($_POST[$k])) $_POST[$k] = mb_convert_kana($_POST[$k], 'K'); } }
//if (!empty($kana_hiratokana_itemname)) { foreach (explode(',',$kana_hiratokana_itemname) as $k) { if (!empty($_POST[$k])) $_POST[$k] = mb_convert_kana($_POST[$k], 'C'); } }
# process data for saving
foreach ($_POST as $k => $v) {
$fld_list[$k] = preg_replace('/,/', ',', $_POST[$k]);
$fld_list[$k] = preg_replace('/"/', '”', $fld_list[$k]);
$fld_list[$k] = preg_replace("/'/", "’", $fld_list[$k]);
$fld_list[$k] = preg_replace('/`/', '‘', $fld_list[$k]);
$fld_list[$k] = preg_replace('/;/', ';', $fld_list[$k]);
$fld_list[$k] = preg_replace(preg_quote('#'.chr(92).'#'), '¥', $fld_list[$k]);
$fld_list[$k] = COM_applyFilter($fld_list[$k]);
}
# full path of CSV file
$save_csv_file = $save_csv_path . $save_csv_name;
# create pageurl from pageid
if (!empty($page)) { $pageurl = COM_buildUrl($_CONF['site_url'].'/staticpages/index.php?page='.$page); }
if (empty($_fmhelppageurl) && !empty($helppageid)) { $_fmhelppageurl = COM_buildUrl($_CONF['site_url'].'/staticpages/index.php?page='.$helppageid); }
# CSRF
if (!empty($_POST) && !SECINT_checkToken()) { $m=isset($_POST[$email_input_name]) ? 'email='.$_POST[$email_input_name].' ' : ''; COM_accessLog("tried {$m}to staticpage({$pageid}) failed CSRF checks."); header('Location: '.$pageurl); exit; }
// Referer check
if (!empty($_spreferercheck) && $_spreferercheck = 1) {
$valid = _fmChkReferer($pageurl,$_spreferererrormsg);
}
// Error check
if (empty($valid) && !empty($_POST) && !empty($_POST['action'])) {
$valid = _fmValidate($form_items);
}
$action = _fmGetAction($valid);
// --[[ Step 1 : Form (Input & Confirm) ]]-------------------------------
if ($action == 'input' || $action == 'confirm') {
/**
* Form HTML {
*/
// transition
$seni = _fmMkSeni($seni_items, $action);
// input form
$form = _fmMkForm($form_items, $action);
$retval = <<<END
<div data-uk-button-checkbox>
$seni
</div>
<div id="formmail">
$valid
<form name="subForm" class="form-block" method="post" action="{$pageurl}">
$form
</form>
</div>
END;
/**
* } Form HTML
*/
// --[[ Step 2 : Notice User Process & email submission ]]-----------------------------------
} elseif ($action == 'finish') {
/**
* COMPLETE MESSAGE HTML {
*/
// transition
$seni = _fmMkSeni($seni_items, $action);
$out_html = <<<END
<div>
$seni
</div>
<div>
<p><strong>We've received your inquiry.</strong></p>
<p>A confirmation e-mail has been sent to you.<br />
If you do not receive it, please re-submit your inquiry with this form.</p>
</div>
END;
/**
* } COMPLETE MESSAGE HTML
*/
# convert <br /> to LB
foreach ($fld_list as $k => $v) { $fld_list[$k] = ereg_replace("<br />", LB, $fld_list[$k]); }
$lang['sign_admin'] = ereg_replace("<br />", LB, $lang['sign_admin']);
$lang['sign_user'] = ereg_replace("<br />", LB, $lang['sign_user']);
// input content
$input4mail=<<<END
Organization: {$fld_list['q_organizaiton']}
Name: {$fld_list['q_first_name']} {$fld_list['q_last_name']}
Email: {$fld_list['q_mail']}
Inquiry Method: {$fld_list['q_answer_means']}
Phone: {$fld_list['q_phone']} ({$fld_list['q_phone_kind']})
Inquiry Date: {$fld_list['q_date1']}
Inquiry Time: {$fld_list['q_access_time']}
Apply: {$fld_list['q_order_1']} {$fld_list['q_order_2']} {$fld_list['q_order_3']}
Comments: {$fld_list['q_other']}
END;
/**
* mail to admin {
*/
$out_mail_admin = <<<END
{$lang['receipt_admin']}
$input4mail
{$lang['sign_admin']}
END;
/**
* } mail to admin
*/
/**
* mail to sender {
*/
$out_mail_user = <<<END
{$lang['receipt_user']}
$input4mail
{$lang['sign_user']}
END;
/**
* } mail to sender
*/
# send email
$ownererr = false;
$ownersend = false;
$om_array = explode(',', $owner_email);
$owner_mails = array_unique($om_array); # delete email double checked
if (!empty($owner_email_item_name)) {
$selmail;
foreach ($owner_mails as $v) {
list($key, $mail) = explode('=', $v);
if ($_POST[$owner_email_item_name] == $key) {
$selmail = explode('|', $mail);
break;
}
}
$owner_mails = $selmail;
}
$owner_subject = $lang['subject_admin'];
foreach ($owner_mails as $v) {
$email1 = COM_mail( $v, "$owner_subject", $out_mail_admin, $email_from, false); # mail to admin
if (!$email1) { $ownererr = true; } else { $ownersend = true; } # set flag of transmit error
}
# if error at admin email transmission
if ($ownererr) {
# if transmission succed for some of admins
if ($ownersend) {
# logs error. no error display for user since some of admin
COM_errorLog($lang['ownertransmiterror'], 1);
$email1 = true;
# if transmission failed to all admins
} elseif (!$ownersend) {
# makes it a process error. no email to user.
$email1 = false;
}
}
if ($email1) {
$usr_subject = $lang['subject_user'];
$email2 = COM_mail( $fld_list[$email_input_name], "$usr_subject", $out_mail_user, $email_from, false); # email to user
}