1
+ <?php
2
+
3
+ /**
4
+ * Handle credits, license, privacy policy, cookie policy, registration agreement / TOS, contact
5
+ * staff (optional), sitemap (mod?), etc.
6
+ *
7
+ * @name ElkArte Forum
8
+ * @copyright ElkArte Forum contributors
9
+ * @license BSD http://opensource.org/licenses/BSD-3-Clause
10
+ *
11
+ * This software is a derived product, based on:
12
+ *
13
+ * Simple Machines Forum (SMF)
14
+ * copyright: 2011 Simple Machines (http://www.simplemachines.org)
15
+ * license: BSD, See included LICENSE.TXT for terms and conditions.
16
+ *
17
+ * @version 1.1 dev
18
+ *
19
+ */
20
+
21
+ if (!defined ('ELK ' ))
22
+ die ('No access... ' );
23
+
24
+ /**
25
+ * About Controller
26
+ */
27
+ class About_Controller extends Action_Controller
28
+ {
29
+ /**
30
+ * Default action of this class.
31
+ * Accessed with ?action=about
32
+ */
33
+ public function action_index ()
34
+ {
35
+ // Add an subaction array to act accordingly
36
+ $ subActions = array (
37
+ 'credits ' => array ($ this , 'action_credits ' ),
38
+ 'contact ' => array ($ this , 'action_contact ' ),
39
+ 'coppa ' => array ($ this , 'action_coppa ' ),
40
+ );
41
+
42
+ // Setup the action handler
43
+ $ action = new Action ();
44
+ $ subAction = $ action ->initialize ($ subActions , 'credits ' );
45
+
46
+ // Call the action
47
+ $ action ->dispatch ($ subAction );
48
+ }
49
+
50
+ /**
51
+ * Shows the contact form for the user to fill out
52
+ *
53
+ * - Functionality needs to be enabled in the ACP for this to be used
54
+ */
55
+ public function action_contact ()
56
+ {
57
+ global $ context , $ txt , $ user_info , $ modSettings ;
58
+
59
+ // Disabled, you cannot enter.
60
+ if (empty ($ modSettings ['enable_contactform ' ]) || $ modSettings ['enable_contactform ' ] === 'disabled ' )
61
+ redirectexit ();
62
+
63
+ loadLanguage ('Login ' );
64
+ loadTemplate ('Register ' );
65
+
66
+ // Submitted the contact form?
67
+ if (isset ($ this ->_req ->post ->send ))
68
+ {
69
+ checkSession ('post ' );
70
+ validateToken ('contact ' );
71
+
72
+ // Can't send a lot of these in a row, no sir!
73
+ spamProtection ('contact ' );
74
+
75
+ // No errors, yet.
76
+ $ context ['errors ' ] = array ();
77
+ loadLanguage ('Errors ' );
78
+
79
+ // Could they get the right send topic verification code?
80
+ require_once (SUBSDIR . '/VerificationControls.class.php ' );
81
+ require_once (SUBSDIR . '/Members.subs.php ' );
82
+
83
+ // Form validation
84
+ $ validator = new Data_Validator ();
85
+ $ validator ->sanitation_rules (array (
86
+ 'emailaddress ' => 'trim ' ,
87
+ 'contactmessage ' => 'trim '
88
+ ));
89
+ $ validator ->validation_rules (array (
90
+ 'emailaddress ' => 'required|valid_email ' ,
91
+ 'contactmessage ' => 'required '
92
+ ));
93
+ $ validator ->text_replacements (array (
94
+ 'emailaddress ' => $ txt ['error_email ' ],
95
+ 'contactmessage ' => $ txt ['error_message ' ]
96
+ ));
97
+
98
+ // Any form errors
99
+ if (!$ validator ->validate ($ this ->_req ->post ))
100
+ $ context ['errors ' ] = $ validator ->validation_errors ();
101
+
102
+ // Get the clean data
103
+ $ this ->_req ->post = new ArrayObject ($ validator ->validation_data (), ArrayObject::ARRAY_AS_PROPS );
104
+
105
+ // Trigger the verify contact event for captcha checks
106
+ $ this ->_events ->trigger ('verify_contact ' , array ());
107
+
108
+ // No errors, then send the PM to the admins
109
+ if (empty ($ context ['errors ' ]))
110
+ {
111
+ $ admins = admins ();
112
+ if (!empty ($ admins ))
113
+ {
114
+ require_once (SUBSDIR . '/PersonalMessage.subs.php ' );
115
+ sendpm (array ('to ' => array_keys ($ admins ), 'bcc ' => array ()), $ txt ['contact_subject ' ], $ this ->_req ->post ->contactmessage , false , array ('id ' => 0 , 'name ' => $ this ->_req ->post ->emailaddress , 'username ' => $ this ->_req ->post ->emailaddress ));
116
+ }
117
+
118
+ // Send the PM
119
+ redirectexit ('action=about;sa=contact;done ' );
120
+ }
121
+ else
122
+ {
123
+ $ context ['emailaddress ' ] = $ this ->_req ->post ->emailaddress ;
124
+ $ context ['contactmessage ' ] = $ this ->_req ->post ->contactmessage ;
125
+ }
126
+ }
127
+
128
+ // Show the contact done form or the form itself
129
+ if (isset ($ this ->_req ->query ->done ))
130
+ $ context ['sub_template ' ] = 'contact_form_done ' ;
131
+ else
132
+ {
133
+ $ context ['sub_template ' ] = 'contact_form ' ;
134
+ $ context ['page_title ' ] = $ txt ['admin_contact_form ' ];
135
+
136
+ // Setup any contract form events, like validation
137
+ $ this ->_events ->trigger ('setup_contact ' , array ());
138
+ }
139
+
140
+ createToken ('contact ' );
141
+ }
142
+
143
+ /**
144
+ * It prepares credit and copyright information for the credits page or the admin page.
145
+ *
146
+ * - Accessed by ?action=about;sa=credits
147
+ *
148
+ * @uses About language file
149
+ * @uses template_credits() sub template in About.template.php,
150
+ */
151
+ public function action_credits ()
152
+ {
153
+ global $ context , $ txt ;
154
+
155
+ require_once (SUBSDIR . '/About.subs.php ' );
156
+ loadLanguage ('About ' );
157
+
158
+ $ context += prepareCreditsData ();
159
+
160
+ loadTemplate ('About ' );
161
+ $ context ['sub_template ' ] = 'credits ' ;
162
+ $ context ['robot_no_index ' ] = true ;
163
+ $ context ['page_title ' ] = $ txt ['credits ' ];
164
+ }
165
+ }
0 commit comments