-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
1303 lines (1117 loc) · 57.3 KB
/
plugin.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
<?php
/**
This is the Filmmakers for Future plugin.
This file contains the plugin class of the Filmmakers for Future plugin.
@package filmmakers4future\fm4fplugin
@version 0.1a0
@author Yahe <[email protected]>
@since 0.1a0
*/
// ===== DO NOT EDIT HERE =====
// prevent script from getting called directly
if (!defined("URLAUBE")) { die(""); }
class FM4FPlugin implements Plugin {
// CONSTANTS
const FM4FCONTACT = "[fm4fcontact]";
const FM4FNEWSLETTER = "[fm4fnewsletter]";
const FM4FREGISTER = "[fm4fregister]";
const FM4FSEND = "[fm4fsend]";
const FM4FSIGNATURES = "[fm4fsignatures]";
const FM4FSIGNATURESCOUNT = "[fm4fsignaturescount]";
const FM4FSIGNATURESDATE = "[fm4fsignaturesdate]";
const FM4FVERIFY = "[fm4fverify]";
const FM4FVIDEOS = "~\[fm4fvideos (?P<videos>[0-9A-Za-z\_\-]+)\]~";
const VIDEOS = "videos";
// FIELDS
protected static $subscribed = null;
protected static $subscribed_error = null;
protected static $verified = null;
protected static $verified_error = null;
// HELPER FUNCTIONS
protected static function configure() {
// this is mail address where administrative mails will be sent to
Plugins::preset("ADMIN_MAIL", "root@localhost");
// this is the base URL expected in REFERER headers sent by browsers when submitting a form,
// this value is used to check the actual REFERER header during a form submission,
// the check is used to prevent cross-site request forgery attempts
Plugins::preset("BASE_URL", absoluteurl(value(Main::class, "/")));
// this is the MailGun configuration needed to send mails
Plugins::preset("MAILGUN_AUTH", "api:key-0123456789abcdefghijklmnopqrstuvwxyz");
Plugins::preset("MAILGUN_ENDPOINT", "https://api.eu.mailgun.net/v3/localhost/messages");
Plugins::preset("MAILGUN_FROM", "Filmmakers for Future <root@localhost>");
// this is the newsletter submission password, it has to be set in the CRYPT password format,
// the value can be generated via:
// php -r 'print(str_replace("\$", "\\\$", password_hash(readline("Password: "), PASSWORD_DEFAULT)."\n"));'
Plugins::preset("NEWSLETTER_SEND_PASSWORD", null);
// this is the database configuration
Plugins::preset("DB_HOST", "localhost");
Plugins::preset("DB_PORT", 3306);
Plugins::preset("DB_NAME", null);
Plugins::preset("DB_USER", null);
Plugins::preset("DB_PASS", null);
// defines the recipients and mail subjects of messages sent through the contact form
Plugins::preset("CONTACT_SUBJECTS", [[MAIL_MAIL => Plugins::get("ADMIN_MAIL"),
MAIL_SUBJECT => "Message about example.com"],
[MAIL_MAIL => Plugins::get("ADMIN_MAIL"),
MAIL_SUBJECT => "Message about example.net"]]);
// defines the contents of the mail that is sent to the admin DURING verification
Plugins::preset("ADMIN_VERIFY_MAIL_BODY", file_get_contents(USER_CONFIG_PATH."templates/admin_verify.txt"));
Plugins::preset("ADMIN_VERIFY_MAIL_SUBJECT", "Verify signature - {%NAME}");
// defines the contents of the mail that is sent to the admin when the contact form is used
Plugins::preset("CONTACT_MAIL_BODY", file_get_contents(USER_CONFIG_PATH."templates/contact.txt"));
Plugins::preset("CONTACT_MAIL_SUBJECT", "Filmmakers for Future: {%SUBJECT}");
// defines the default contents of the newsletter submission form
Plugins::preset("NEWSLETTER_MAIL_BODY", file_get_contents(USER_CONFIG_PATH."templates/newsletter.txt"));
Plugins::preset("NEWSLETTER_MAIL_SUBJECT", "");
// defines the contents of the mail that is sent to the user when requesting a newsletter management link
Plugins::preset("USER_NEWSLETTER_MAIL_BODY", file_get_contents(USER_CONFIG_PATH."templates/user_newsletter.txt"));
Plugins::preset("USER_NEWSLETTER_MAIL_SUBJECT", "Newsletter subscription management link");
// defines the contents of the mail that is sent to the user AFTER verification
Plugins::preset("USER_VERIFIED_MAIL_BODY", file_get_contents(USER_CONFIG_PATH."templates/user_verified.txt"));
Plugins::preset("USER_VERIFIED_MAIL_SUBJECT", "Your registration has been verified!");
// defines the contents of the mail that is sent to the user DURING verification
Plugins::preset("USER_VERIFY_MAIL_BODY", file_get_contents(USER_CONFIG_PATH."templates/user_verify.txt"));
Plugins::preset("USER_VERIFY_MAIL_SUBJECT", "Please verify your registration!");
// defines the error handling
Plugins::preset("ERRORS_ENABLED", true);
Plugins::preset("ERRORS_FOLDER", USER_CONFIG_PATH."errors/");
Plugins::preset("ERRORS_NEWSLETTER", "Your signature has not yet been verified.");
Plugins::preset("ERRORS_REGISTER", "Your email address has already been used to sign our statement.");
Plugins::preset("ERRORS_VERIFY", "Your signature does not need to be verified.");
// defines the list of videos
Plugins::preset("VIDEOS", null);
// set fff-signup sourcecode uses standard defines so we have to convert them
static::define("ADMIN_MAIL");
static::define("BASE_URL");
static::define("MAILGUN_AUTH");
static::define("MAILGUN_ENDPOINT");
static::define("MAILGUN_FROM");
static::define("NEWSLETTER_SEND_PASSWORD");
static::define("DB_HOST");
static::define("DB_PORT");
static::define("DB_NAME");
static::define("DB_USER");
static::define("DB_PASS");
static::define("CONTACT_SUBJECTS");
static::define("ADMIN_VERIFY_MAIL_BODY");
static::define("ADMIN_VERIFY_MAIL_SUBJECT");
static::define("CONTACT_MAIL_BODY");
static::define("CONTACT_MAIL_SUBJECT");
#static::define("NEWSLETTER_MAIL_BODY");
#static::define("NEWSLETTER_MAIL_SUBJECT");
static::define("USER_NEWSLETTER_MAIL_BODY");
static::define("USER_NEWSLETTER_MAIL_SUBJECT");
static::define("USER_VERIFIED_MAIL_BODY");
static::define("USER_VERIFIED_MAIL_SUBJECT");
static::define("USER_VERIFY_MAIL_BODY");
static::define("USER_VERIFY_MAIL_SUBJECT");
static::define("ERRORS_ENABLED");
static::define("ERRORS_FOLDER");
static::define("ERRORS_NEWSLETTER");
static::define("ERRORS_REGISTER");
static::define("ERRORS_VERIFY");
}
protected static function define($name) {
try_define($name, Plugins::get($name));
}
protected static function get_subscribed(&$error = null) {
$result = null;
if ((null === static::$subscribed) && (null === static::$subscribed_error)) {
// retrieve result
$result = get_subscribed($error);
// store for later usage
static::$subscribed = $result;
static::$subscribed_error = $error;
} else {
// return cached result
$result = static::$suscribed;
$error = static::$subscribed_error;
}
return $result;
}
protected static function get_verified(&$error = null) {
$result = null;
if ((null === static::$verified) && (null === static::$verified_error)) {
// retrieve result
$result = get_verified($error);
// store for later usage
static::$verified = $result;
static::$verified_error = $error;
} else {
// return cached result
$result = static::$verified;
$error = static::$verified_error;
}
return $result;
}
protected static function contact_get($content) {
$result = $content;
if (is_string($result)) {
// generate HTML source code
$html = tfhtml("<form class=\"text-center\" id=\"contact_form\" action=\"%s\" method=\"post\">".NL.
" <!-- Subject -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <select name=\"subject\" class=\"browser-default custom-select mb-4\" required>".NL.
" <option value=\"\" disabled selected>%s</option>".NL,
FM4FPlugin::class,
value(Main::class, URI),
"Please select a subject for your message:",
"Choose option...");
$contact_subjects = value(Plugins::class, "CONTACT_SUBJECTS");
if (is_array($contact_subjects)) {
for ($i = 0; $i < count($contact_subjects); $i++) {
$html .= tfhtml(" <option value=\"%d\">%s</option>".NL,
FM4FPlugin::class,
$i,
$contact_subjects[$i][MAIL_SUBJECT]);
}
}
$html .= tfhtml(" </select>".NL.
" <!-- Name -->".NL.
" <input type=\"text\" name=\"name\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Email -->".NL.
" <input type=\"email\" name=\"mail\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Message -->".NL.
" <div class=\"form-group\">".NL.
" <textarea name=\"message\" rows=\"5\" placeholder=\"%s\" class=\"form-control mb-4\" required></textarea>".NL.
" </div>".NL.
" <!-- Captcha -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <div class=\"form-group\">".NL.
" <input type=\"number\" name=\"captcha\" min=\"0\" max=\"20\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" </div>".NL.
// Hidden field (if filled out = spamm)
// Captcha Part 2
" <p style=\"display:none;\"><textarea name=\"mail_message\" maxlength=\"2000\" rows=\"3\" tabindex=\"-1\" autocomplete=\"off\"></textarea></p>".NL.
" <!-- Privacy -->".NL.
" <div class=\"custom-control custom-checkbox mb-4\">".NL.
" <input type=\"checkbox\" class=\"custom-control-input\" id=\"privacy\" required>".NL.
" <label class=\"custom-control-label\" for=\"privacy\">%s <a href=\"%s\" target=\"_blank\" rel=\"noopener noreferrer\">%s</a>.</label>".NL.
" </div>".NL.
" <!-- Send button -->".NL.
" <button class=\"btn btn-info btn-block mb-1\" id=\"contact_button\" type=\"submit\">%s</button>".NL.
"</form>",
FM4FPlugin::class,
"Full name or organisation name*",
"Email address*",
"Message*",
get_captcha(),
"Captcha answer",
"I have read and agree to the",
"/privacy/",
"privacy policy",
"Send message");
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FCONTACT, $html, $result);
}
return $result;
}
protected static function contact_post($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = contact($_POST, $error);
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL,
FM4FPlugin::class);
if ($output) {
$html .= tfhtml(" <b>%s</b><br>".NL.
" %s".NL,
FM4FPlugin::class,
"Thank you for contacting us.",
"We will come back to you as soon as possible.");
} else {
// generate HTML source code
$html .= tfhtml(" <b>%s%s</b><br>".NL,
FM4FPlugin::class,
"Unfortunately, an error has occured",
(array_key_exists(ERROR_OUTPUT, $error)) ? ":" : ".");
if (array_key_exists(ERROR_OUTPUT, $error)) {
$html .= tfhtml(" %s<br>".NL,
FM4FPlugin::class,
$error[ERROR_OUTPUT]);
}
$html .= tfhtml(" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
}
$html .= tfhtml(" </p>".NL.
"</div>".NL.
"<script src=\"%s\"></script>",
FM4FPlugin::class,
path2uri(__DIR__."/js/norepost.js"));
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FCONTACT, $html, $result);
}
return $result;
}
protected static function newsletter_get($content) {
$result = $content;
if (is_string($result)) {
// check if a link was used
if (array_key_exists("uid", $_GET) && array_key_exists("user", $_GET)) {
$error = []; // has to be defined as an array
$output = preview_newsletter($_GET, $error);
if ($output) {
// generate HTML source code
$html = tfhtml("<form class=\"text-center p-5\" id=\"newsletter_form\" action=\"%s\" method=\"post\">".NL.
" <p class=\"text-white-85 mb-4\">%s</p>".NL.
" <label class=\"mb-3\">%s</label>".NL.
" <select id=\"newsletter\" name=\"newsletter\" class=\"browser-default custom-select mb-4\" required>".NL.
" <option value=\"\" disabled>%s</option>".NL.
" <option value=\"0\" %s>%s</option>".NL.
" <option value=\"1\" %s>%s</option>".NL.
" </select>".NL.
" <!-- Send button -->".NL.
" <button class=\"btn btn-info btn-block mb-0\" id=\"verify_button\" type=\"submit\">%s</button>".NL.
"</form>",
FM4FPlugin::class,
value(Main::class, URI).querystring(),
"Below you can see your current subscription status. Feel free to adjust it, you can always request a new link if you change your mind.",
"Do you want to stay in touch?",
"Choose option...",
($output[MAIL_NEWSLETTER]) ? "" : "selected",
"No updates please.",
($output[MAIL_NEWSLETTER]) ? "selected" : "",
"Please keep me updated.",
"Update newsletter subscription");
} else {
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL.
" <b>%s</b><br>".NL.
" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"The newsletter management link you used is invalid.",
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
$html .= fhtml(" </p>".NL.
"</div>");
}
} else {
// generate HTML source code
$html = tfhtml("<p class=\"text-white-85 mb-4\">%s</p>".NL.
"<form class=\"text-center\" id=\"newsletter_form\" action=\"%s\" method=\"post\">".NL.
" <input class=\"form-control mb-4\" type=\"email\" name=\"newmail\" required maxlength=\"256\" placeholder=\"%s\">".NL.
" <button class=\"btn btn-info btn-block mb-3\" id=\"newsletter_button\" type=\"submit\">%s</button>".NL.
" <p class=\"text-white-85 mb-0 font-weight-light\"><b>%s</b> %s</p>".NL.
"</form>",
FM4FPlugin::class,
"Request a new newsletter management link:",
value(Main::class, URI),
"Email address*",
"Request a new link",
"Please note:",
"You can only manage your newsletter subscription if you have signed our statement and have finished the verification process. We do not offer a general newsletters.");
}
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FNEWSLETTER, $html, $result);
}
return $result;
}
protected static function newsletter_post($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = newsletter(array_merge($_GET, $_POST), $error);
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL,
FM4FPlugin::class);
if ($output) {
// check if a link was used
if (array_key_exists("uid", $_GET) && array_key_exists("user", $_GET)) {
$html .= tfhtml(" <b>%s</b><br>".NL.
" %s".NL,
FM4FPlugin::class,
"Thank you for updating your newsletter subscription.",
"At the moment there is nothing more to do for you.");
} else {
$html .= tfhtml(" <b>%s</b><br>".NL.
" %s<br>".NL.
" %s".NL,
FM4FPlugin::class,
"Thank you for updating your newsletter subscription.",
"We will send you an e-mail with further instructions.",
"Please check your spam folder, just in case.");
}
} else {
// generate HTML source code
$html .= tfhtml(" <b>%s%s</b><br>".NL,
FM4FPlugin::class,
"Unfortunately, an error has occured",
(array_key_exists(ERROR_OUTPUT, $error)) ? ":" : ".");
if (array_key_exists(ERROR_OUTPUT, $error)) {
$html .= tfhtml(" %s<br>".NL,
FM4FPlugin::class,
$error[ERROR_OUTPUT]);
}
$html .= tfhtml(" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
}
$html .= tfhtml(" </p>".NL.
"</div>".NL.
"<script src=\"%s\"></script>",
FM4FPlugin::class,
path2uri(__DIR__."/js/norepost.js"));
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FNEWSLETTER, $html, $result);
}
return $result;
}
protected static function register_get($content) {
$result = $content;
if (is_string($result)) {
// generate HTML source code
$html = tfhtml("<form class=\"text-center border border-light p-5\" id=\"register_form\" action=\"%s\" method=\"post\">".NL.
" <!-- Name -->".NL.
" <input type=\"text\" name=\"name\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Email -->".NL.
" <input type=\"email\" name=\"mail\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Job -->".NL.
" <input type=\"text\" name=\"job\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Website -->".NL.
" <input type=\"link\" name=\"website\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\">".NL.
" <!-- Country -->".NL.
" <input type=\"text\" name=\"country\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- City -->".NL.
" <input type=\"text\" name=\"city\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\">".NL.
" <!-- Individual or Company -->".NL.
" <select name=\"iscompany\" class=\"browser-default custom-select mb-4\" required>".NL.
" <option value=\"\" disabled selected>%s</option>".NL.
" <option value=\"0\">%s</option>".NL.
" <option value=\"1\">%s</option>".NL.
" </select>".NL.
" <!-- Reference -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <div class=\"form-group\">".NL.
" <textarea name=\"verify_hints\" maxlength=\"1000\" rows=\"3\" placeholder=\"%s\" class=\"form-control mb-4\"></textarea>".NL.
" </div>".NL.
" <!-- Newsletter -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <select name=\"newsletter\" class=\"browser-default custom-select mb-4\" required>".NL.
" <option value=\"\" disabled selected>%s</option>".NL.
" <option value=\"0\">%s</option>".NL.
" <option value=\"1\">%s</option>".NL.
" </select>".NL.
" <!-- Captcha -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <div class=\"form-group\">".NL.
" <input type=\"number\" name=\"captcha\" min=\"0\" max=\"20\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" </div>".NL.
// Hidden field (if filled out = spamm)
// Captcha Part 2
" <p style=\"display:none;\"><textarea name=\"mail_message\" maxlength=\"2000\" rows=\"3\" tabindex=\"-1\" autocomplete=\"off\"></textarea></p>".NL.
" <!-- Privacy -->".NL.
" <div class=\"custom-control custom-checkbox mb-4\">".NL.
" <input type=\"checkbox\" class=\"custom-control-input\" id=\"privacy\" required>".NL.
" <label class=\"custom-control-label\" for=\"privacy\">%s <a href=\"%s\" target=\"_blank\" rel=\"noopener noreferrer\">%s</a>.</label>".NL.
" </div>".NL.
" <!-- Send button -->".NL.
" <button class=\"btn btn-info btn-block mb-1\" id=\"register_button\" type=\"submit\">%s</button>".NL.
"</form>",
FM4FPlugin::class,
value(Main::class, URI)."#sign",
"Full name or company name*",
"Email address*",
"Job title or company field*",
"Website | Filmography",
"Country*",
"City",
"Individual or organisation?",
"Individual",
"Organisation / Company",
"Help us verify your signature",
"If the submitted information does not already show it, please give us some hints on your connection to the film and television industry (e.g. more detailed job description or films you have worked on).",
"Do you want to stay in touch?",
"Choose option...",
"No updates please.",
"Please keep me updated.",
get_captcha(),
"Captcha answer",
"I have read and agree to the",
"/privacy/",
"privacy policy",
"Publicly sign statement");
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FREGISTER, $html, $result);
}
return $result;
}
protected static function register_post($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = register($_POST, $error);
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL,
FM4FPlugin::class);
if ($output) {
$html .= tfhtml(" <b>%s</b><br>".NL.
" %s<br>".NL.
" %s".NL,
FM4FPlugin::class,
"Thank you for signing the statement.",
"We will send you an e-mail with further instructions.",
"Please check your spam folder, just in case.");
} else {
// generate HTML source code
$html .= tfhtml(" <b>%s%s</b><br>".NL,
FM4FPlugin::class,
"Unfortunately, an error has occured",
(array_key_exists(ERROR_OUTPUT, $error)) ? ":" : ".");
if (array_key_exists(ERROR_OUTPUT, $error)) {
$html .= tfhtml(" %s<br>".NL,
FM4FPlugin::class,
$error[ERROR_OUTPUT]);
}
$html .= tfhtml(" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
}
$html .= tfhtml(" </p>".NL.
"</div>".NL.
"<script src=\"%s\"></script>",
FM4FPlugin::class,
path2uri(__DIR__."/js/norepost.js"));
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FREGISTER, $html, $result);
}
return $result;
}
protected static function send_get($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = static::get_subscribed($error);
if ($output) {
$countries = [];
if (is_array($output)) {
foreach ($output as $output_item) {
if (!array_key_exists(strtolower(trim($output_item[MAIL_COUNTRY])), $countries)) {
$countries[strtolower(trim($output_item[MAIL_COUNTRY]))] = trim($output_item[MAIL_COUNTRY]);
}
}
ksort($countries);
}
if (0 < count($countries)) {
// generate HTML source code
$html = tfhtml("<form class=\"text-center\" id=\"send_form\" action=\"%s\" method=\"post\">".NL.
" <!-- Subject -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <select name=\"country\" class=\"browser-default custom-select mb-4\" required>".NL.
" <option value=\"\" disabled selected>%s</option>".NL.
" <option value=\"\">%s</option>".NL,
FM4FPlugin::class,
value(Main::class, URI),
"Please select a subscriber country:",
"Choose option...",
"ALL COUNTRIES");
foreach ($countries as $key => $value) {
$html .= tfhtml(" <option value=\"%s\">%s</option>".NL,
FM4FPlugin::class,
$key,
$value);
}
$html .= tfhtml(" </select>".NL.
" <!-- Subject -->".NL.
" <input type=\"text\" name=\"subject\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Message -->".NL.
" <div class=\"form-group\">".NL.
" <textarea name=\"message\" rows=\"5\" placeholder=\"%s\" class=\"form-control mb-4\" required>%s</textarea>".NL.
" </div>".NL.
" <!-- Password -->".NL.
" <input type=\"password\" name=\"password\" maxlength=\"256\" placeholder=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Send button -->".NL.
" <button class=\"btn btn-info btn-block mb-1\" id=\"send_button\" type=\"submit\">%s</button>".NL.
"</form>",
FM4FPlugin::class,
"Subject*",
value(Plugins::class, "NEWSLETTER_MAIL_SUBJECT"),
"Message*",
value(Plugins::class, "NEWSLETTER_MAIL_BODY"),
"Password*",
"Send newsletter");
} else {
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>%s</p>".NL.
"</div>",
FM4FPlugin::class,
"There are currently no verified subscribers of the newsletter.");
}
} else {
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL.
" <b>%s%s</b><br>".NL,
FM4FPlugin::class,
"Unfortunately, an error has occured",
(array_key_exists(ERROR_OUTPUT, $error)) ? ":" : ".");
if (array_key_exists(ERROR_OUTPUT, $error)) {
$html .= tfhtml(" %s<br>".NL,
FM4FPlugin::class,
$error[ERROR_OUTPUT]);
}
$html .= tfhtml(" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
$html .= tfhtml(" </p>".NL.
"</div>",
FM4FPlugin::class);
}
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FSEND, $html, $result);
}
return $result;
}
protected static function send_post($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = send_newsletter($_POST, $error);
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL,
FM4FPlugin::class);
if ($output) {
$html .= tfhtml(" <b>%s</b><br>".NL.
" %s".NL,
FM4FPlugin::class,
"The newsletter has been sent.",
"At the moment there is nothing more to do for you.");
} else {
// generate HTML source code
$html .= tfhtml(" <b>%s%s</b><br>".NL,
FM4FPlugin::class,
"Unfortunately, an error has occured",
(array_key_exists(ERROR_OUTPUT, $error)) ? ":" : ".");
if (array_key_exists(ERROR_OUTPUT, $error)) {
$html .= tfhtml(" %s<br>".NL,
FM4FPlugin::class,
$error[ERROR_OUTPUT]);
}
$html .= tfhtml(" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
}
$html .= tfhtml(" </p>".NL.
"</div>".NL.
"<script src=\"%s\"></script>",
FM4FPlugin::class,
path2uri(__DIR__."/js/norepost.js"));
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FSEND, $html, $result);
}
return $result;
}
protected static function signatures($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = static::get_verified($error);
$html = "";
if ($output) {
if (is_array($output)) {
$countries = [];
foreach ($output as $output_item) {
if (!array_key_exists($output_item[MAIL_COUNTRY], $countries)) {
$countries[$output_item[MAIL_COUNTRY]] = [];
}
$countries[$output_item[MAIL_COUNTRY]][] = $output_item;
}
ksort($countries);
$iseven = false;
foreach ($countries as $country => $signatures) {
$iseven = (!$iseven);
$html .= tfhtml("<section class=\"page-section %s\">".NL.
" <div class=\"container\">".NL.
" <h2 class=\"text-white-50\">%s</h2>".NL.
" <p class=\"text-body\">".NL,
FM4FPlugin::class,
($iseven) ? "bg-dark text-left" : "bg-primary text-right",
$country);
foreach ($signatures as $signature) {
if ($signature[MAIL_ISCOMPANY]) {
$html .= tfhtml(" <span class=\"text-white-75 fa fa-briefcase\"></span> ",
FM4FPlugin::class);
}
if (empty($signature[MAIL_WEBSITE])) {
$html .= tfhtml("<span class=\"text-white\">%s</span> ",
FM4FPlugin::class,
$signature[MAIL_NAME]);
} else {
$html .= tfhtml("<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"%s\" class=\"text-white\">%s</a> ",
FM4FPlugin::class,
$signature[MAIL_WEBSITE],
$signature[MAIL_NAME]);
}
$html .= tfhtml("<span class=\"text-white-50\" >(%s)</span> · ".NL,
FM4FPlugin::class,
$signature[MAIL_JOB]);
}
$html .= tfhtml(" </p>".NL.
" </div>".NL.
"</section>".NL,
FM4FPlugin::class);
}
}
}
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FSIGNATURES, $html, $result);
}
return $result;
}
protected static function signaturescount($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = static::get_verified($error);
$count = 0;
if ($output) {
if (is_array($output)) {
$count = count($output);
}
}
$count = strval($count);
// replace shortcode with generated count
$result = str_ireplace(static::FM4FSIGNATURESCOUNT, $count, $result);
}
return $result;
}
protected static function signaturesdate($content) {
$result = $content;
if (is_string($result)) {
$error = []; // has to be defined as an array
$output = static::get_verified($error);
$date = "none";
if ($output) {
if (is_array($output)) {
$date = date("j F Y", hexdec(substr(end($output)[MAIL_UID], 0, 8)));
}
}
// replace shortcode with generated date
$result = str_ireplace(static::FM4FSIGNATURESDATE, $date, $result);
}
return $result;
}
protected static function verify_get($content) {
$result = $content;
if (is_string($result)) {
// check if a link was used
if (array_key_exists("uid", $_GET) && (array_key_exists("admin", $_GET) || array_key_exists("user", $_GET))) {
$error = []; // has to be defined as an array
$output = preview_verify($_GET, $error);
if ($output) {
// check if this is an admin verify or user verify link
$isadmin = (array_key_exists("uid", $_GET) && array_key_exists("admin", $_GET) && !array_key_exists("user", $_GET));
// generate HTML source code
$html = tfhtml("<p class=\"text-white-85 mb-4\">%s</p>".NL.
"<form class=\"text-center\" id=\"verify_form\" action=\"%s\" method=\"post\">".NL.
" <!-- Name -->".NL.
" <input type=\"text\" name=\"name\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Email -->".NL.
" <input type=\"email\" name=\"mail\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\" required %s>".NL.
" <!-- Job -->".NL.
" <input type=\"text\" name=\"job\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- Country -->".NL.
" <input type=\"text\" name=\"country\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\" required>".NL.
" <!-- City -->".NL.
" <input type=\"text\" name=\"city\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\">".NL.
" <!-- Website -->".NL.
" <input type=\"link\" name=\"website\" maxlength=\"256\" placeholder=\"%s\" value=\"%s\" class=\"form-control mb-4\">".NL.
" <!-- individual or a company -->".NL.
" <select name=\"iscompany\" class=\"browser-default custom-select mb-4\" required>".NL.
" <option value=\"0\" %s>%s</option>".NL.
" <option value=\"1\" %s>%s</option>".NL.
" </select>".NL.
" <!-- Reference -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <div class=\"form-group\">".NL.
" <textarea name=\"verify_hints\" maxlength=\"1000\" rows=\"3\" placeholder=\"%s\" class=\"form-control mb-4\" %s>%s</textarea>".NL.
" </div>".NL.
" <!-- Newsletter -->".NL.
" <label class=\"mb-1\">%s</label>".NL.
" <select name=\"newsletter\" class=\"browser-default custom-select mb-4\" required %s>".NL.
" <option value=\"0\" %s>%s</option>".NL.
" <option value=\"1\" %s>%s</option>".NL.
" </select>".NL.
" <!-- Send button -->".NL.
" <button class=\"btn btn-info btn-block mb-1\" id=\"verify_button\" type=\"submit\">%s</button>".NL.
"</form>",
FM4FPlugin::class,
($isadmin) ? "Please verify the following signature:" : "You entered the following data to sign our statement:",
value(Main::class, URI).querystring(),
"Full name or company name*",
$output[MAIL_NAME],
"Email address*",
$output[MAIL_MAIL],
($isadmin) ? "" : "disabled readonly",
"Job title or company field*",
$output[MAIL_JOB],
"Country*",
$output[MAIL_COUNTRY],
"City (not entered)",
$output[MAIL_CITY],
"Website | Filmography (not entered)",
$output[MAIL_WEBSITE],
($output[MAIL_ISCOMPANY]) ? "" : "selected",
"Individual",
($output[MAIL_ISCOMPANY]) ? "selected" : "",
"Company",
"Help us verify your signature",
"If the submitted information does not already show it, please give us some hints on your connection to the film and television industry (e.g. more detailed job description or films you have worked on).",
($isadmin) ? "disabled readonly" : "",
$output[MAIL_VERIFY_HINTS],
"Do you want to stay in touch?",
($isadmin) ? "disabled readonly" : "",
($output[MAIL_NEWSLETTER]) ? "" : "selected",
"No updates please.",
($output[MAIL_NEWSLETTER]) ? "selected" : "",
"Please keep me updated.",
($isadmin) ? "Authorize signature" : "Verify your signature");
} else {
// generate HTML source code
$html = tfhtml("<div class=\"text-center border border-light p-5\">".NL.
" <p>".NL.
" <b>%s</b><br>".NL.
" %s <a href=\"%s\">%s</a>.".NL,
FM4FPlugin::class,
"The verification link you used is invalid.",
"Please try again later or",
"/contact/",
"contact us");
if (array_key_exists(ERROR_ID, $error)) {
$html .= tfhtml(" <br>%s <span style=\"overflow-wrap: break-word;\">%s</span>".NL,
FM4FPlugin::class,
"Please provide the following error id when contacting us about this issue:",
$error[ERROR_ID]);
}
$html .= fhtml(" </p>".NL.
"</div>");
}
} else {
// generate HTML source code
$html = tfhtml("<p class=\"text-white-85 mb-4\">%s</p>".NL.
"<form class=\"text-center\" id=\"verify_form\" action=\"%s\" method=\"post\">".NL.
" <input class=\"form-control mb-4\" type=\"email\" name=\"newmail\" required maxlength=\"256\" placeholder=\"%s\">".NL.
" <button class=\"btn btn-info btn-block mb-3\" id=\"verify_button\" type=\"submit\">%s</button>".NL.
" <p class=\"text-white-85 mb-0 font-weight-light\"><b>%s</b> %s</p>".NL.
"</form>",
FM4FPlugin::class,
"Request a new verification link:",
value(Main::class, URI),
"Email address*",
"Request a new link",
"Please note:",
"You can only verify your signature if you have signed our statement and have not yet finished the verification process.");
}
// replace shortcode with generated HTML
$result = str_ireplace(static::FM4FVERIFY, $html, $result);
}
return $result;
}
protected static function verify_post($content) {