@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | // Datatables numbers columns 0, 1, 2 |
152 | 152 | // MySQL numbers columns 1, 2, 3 |
153 | 153 | switch ($value['dir']) { |
154 | - case 'asc': |
|
155 | - $order_by .= (1 + $value['column']) . " ASC "; |
|
156 | - break; |
|
157 | - case 'desc': |
|
158 | - $order_by .= (1 + $value['column']) . " DESC "; |
|
159 | - break; |
|
154 | + case 'asc': |
|
155 | + $order_by .= (1 + $value['column']) . " ASC "; |
|
156 | + break; |
|
157 | + case 'desc': |
|
158 | + $order_by .= (1 + $value['column']) . " DESC "; |
|
159 | + break; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } else { |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | |
191 | 191 | foreach ($differences as $difference) { |
192 | 192 | switch ($difference[1]) { |
193 | - case MyersDiff::DELETE: |
|
194 | - $diff_lines[] = '<del>' . $difference[0] . '</del>'; |
|
195 | - break; |
|
196 | - case MyersDiff::INSERT: |
|
197 | - $diff_lines[] = '<ins>' . $difference[0] . '</ins>'; |
|
198 | - break; |
|
199 | - default: |
|
200 | - $diff_lines[] = $difference[0]; |
|
193 | + case MyersDiff::DELETE: |
|
194 | + $diff_lines[] = '<del>' . $difference[0] . '</del>'; |
|
195 | + break; |
|
196 | + case MyersDiff::INSERT: |
|
197 | + $diff_lines[] = '<ins>' . $difference[0] . '</ins>'; |
|
198 | + break; |
|
199 | + default: |
|
200 | + $diff_lines[] = $difference[0]; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 |
@@ -45,95 +45,95 @@ discard block |
||
45 | 45 | |
46 | 46 | // Form actions |
47 | 47 | switch (Filter::post('action')) { |
48 | -case 'save': |
|
49 | - if (Filter::checkCsrf()) { |
|
50 | - $user_id = Filter::postInteger('user_id'); |
|
51 | - $user = User::find($user_id); |
|
52 | - $username = Filter::post('username'); |
|
53 | - $real_name = Filter::post('real_name'); |
|
54 | - $email = Filter::postEmail('email'); |
|
55 | - $pass1 = Filter::post('pass1', WT_REGEX_PASSWORD); |
|
56 | - $pass2 = Filter::post('pass2', WT_REGEX_PASSWORD); |
|
57 | - $theme = Filter::post('theme', implode('|', array_keys(Theme::themeNames())), ''); |
|
58 | - $language = Filter::post('language'); |
|
59 | - $timezone = Filter::post('timezone'); |
|
60 | - $contact_method = Filter::post('contact_method'); |
|
61 | - $comment = Filter::post('comment'); |
|
62 | - $auto_accept = Filter::postBool('auto_accept'); |
|
63 | - $canadmin = Filter::postBool('canadmin'); |
|
64 | - $visible_online = Filter::postBool('visible_online'); |
|
65 | - $verified = Filter::postBool('verified'); |
|
66 | - $approved = Filter::postBool('approved'); |
|
67 | - |
|
68 | - if ($user_id === 0) { |
|
69 | - // Create a new user |
|
70 | - if (User::findByUserName($username)) { |
|
71 | - FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.')); |
|
72 | - } elseif (User::findByEmail($email)) { |
|
73 | - FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.')); |
|
74 | - } elseif ($pass1 !== $pass2) { |
|
75 | - FlashMessages::addMessage(I18N::translate('The passwords do not match.')); |
|
76 | - } else { |
|
77 | - $user = User::create($username, $real_name, $email, $pass1); |
|
78 | - $user->setPreference('reg_timestamp', date('U'))->setPreference('sessiontime', '0'); |
|
79 | - Log::addAuthenticationLog('User ->' . $username . '<- created'); |
|
80 | - } |
|
81 | - } else { |
|
82 | - $user = User::find($user_id); |
|
83 | - if ($user && $username && $real_name) { |
|
84 | - $user->setEmail($email); |
|
85 | - $user->setUserName($username); |
|
86 | - $user->setRealName($real_name); |
|
87 | - if ($pass1 !== null && $pass1 === $pass2) { |
|
88 | - $user->setPassword($pass1); |
|
89 | - } |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - if ($user) { |
|
94 | - // Approving for the first time? Send a confirmation email |
|
95 | - if ($approved && !$user->getPreference('verified_by_admin') && $user->getPreference('sessiontime') == 0) { |
|
96 | - I18N::init($user->getPreference('language')); |
|
97 | - Mail::systemMessage( |
|
98 | - $WT_TREE, |
|
99 | - $user, |
|
100 | - I18N::translate('Approval of account at %s', WT_BASE_URL), |
|
101 | - I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now sign in by accessing the following link: %s', WT_BASE_URL, WT_BASE_URL) |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - $user |
|
106 | - ->setPreference('theme', $theme) |
|
107 | - ->setPreference('language', $language) |
|
108 | - ->setPreference('TIMEZONE', $timezone) |
|
109 | - ->setPreference('contactmethod', $contact_method) |
|
110 | - ->setPreference('comment', $comment) |
|
111 | - ->setPreference('auto_accept', $auto_accept ? '1' : '0') |
|
112 | - ->setPreference('visibleonline', $visible_online ? '1' : '0') |
|
113 | - ->setPreference('verified', $verified ? '1' : '0') |
|
114 | - ->setPreference('verified_by_admin', $approved ? '1' : '0'); |
|
115 | - |
|
116 | - // We cannot change our own admin status. Another admin will need to do it. |
|
117 | - if ($user->getUserId() !== Auth::id()) { |
|
118 | - $user->setPreference('canadmin', $canadmin ? '1' : '0'); |
|
119 | - } |
|
120 | - |
|
121 | - foreach (Tree::getAll() as $tree) { |
|
122 | - $tree->setUserPreference($user, 'gedcomid', Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF)); |
|
123 | - $tree->setUserPreference($user, 'canedit', Filter::post('canedit' . $tree->getTreeId(), implode('|', array_keys($ALL_EDIT_OPTIONS)))); |
|
124 | - if (Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF)) { |
|
125 | - $tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', Filter::postInteger('RELATIONSHIP_PATH_LENGTH' . $tree->getTreeId(), 0, 10, 0)); |
|
126 | - } else { |
|
127 | - // Do not allow a path length to be set if the individual ID is not |
|
128 | - $tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', null); |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
135 | - |
|
136 | - return; |
|
48 | + case 'save': |
|
49 | + if (Filter::checkCsrf()) { |
|
50 | + $user_id = Filter::postInteger('user_id'); |
|
51 | + $user = User::find($user_id); |
|
52 | + $username = Filter::post('username'); |
|
53 | + $real_name = Filter::post('real_name'); |
|
54 | + $email = Filter::postEmail('email'); |
|
55 | + $pass1 = Filter::post('pass1', WT_REGEX_PASSWORD); |
|
56 | + $pass2 = Filter::post('pass2', WT_REGEX_PASSWORD); |
|
57 | + $theme = Filter::post('theme', implode('|', array_keys(Theme::themeNames())), ''); |
|
58 | + $language = Filter::post('language'); |
|
59 | + $timezone = Filter::post('timezone'); |
|
60 | + $contact_method = Filter::post('contact_method'); |
|
61 | + $comment = Filter::post('comment'); |
|
62 | + $auto_accept = Filter::postBool('auto_accept'); |
|
63 | + $canadmin = Filter::postBool('canadmin'); |
|
64 | + $visible_online = Filter::postBool('visible_online'); |
|
65 | + $verified = Filter::postBool('verified'); |
|
66 | + $approved = Filter::postBool('approved'); |
|
67 | + |
|
68 | + if ($user_id === 0) { |
|
69 | + // Create a new user |
|
70 | + if (User::findByUserName($username)) { |
|
71 | + FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.')); |
|
72 | + } elseif (User::findByEmail($email)) { |
|
73 | + FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.')); |
|
74 | + } elseif ($pass1 !== $pass2) { |
|
75 | + FlashMessages::addMessage(I18N::translate('The passwords do not match.')); |
|
76 | + } else { |
|
77 | + $user = User::create($username, $real_name, $email, $pass1); |
|
78 | + $user->setPreference('reg_timestamp', date('U'))->setPreference('sessiontime', '0'); |
|
79 | + Log::addAuthenticationLog('User ->' . $username . '<- created'); |
|
80 | + } |
|
81 | + } else { |
|
82 | + $user = User::find($user_id); |
|
83 | + if ($user && $username && $real_name) { |
|
84 | + $user->setEmail($email); |
|
85 | + $user->setUserName($username); |
|
86 | + $user->setRealName($real_name); |
|
87 | + if ($pass1 !== null && $pass1 === $pass2) { |
|
88 | + $user->setPassword($pass1); |
|
89 | + } |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + if ($user) { |
|
94 | + // Approving for the first time? Send a confirmation email |
|
95 | + if ($approved && !$user->getPreference('verified_by_admin') && $user->getPreference('sessiontime') == 0) { |
|
96 | + I18N::init($user->getPreference('language')); |
|
97 | + Mail::systemMessage( |
|
98 | + $WT_TREE, |
|
99 | + $user, |
|
100 | + I18N::translate('Approval of account at %s', WT_BASE_URL), |
|
101 | + I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now sign in by accessing the following link: %s', WT_BASE_URL, WT_BASE_URL) |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + $user |
|
106 | + ->setPreference('theme', $theme) |
|
107 | + ->setPreference('language', $language) |
|
108 | + ->setPreference('TIMEZONE', $timezone) |
|
109 | + ->setPreference('contactmethod', $contact_method) |
|
110 | + ->setPreference('comment', $comment) |
|
111 | + ->setPreference('auto_accept', $auto_accept ? '1' : '0') |
|
112 | + ->setPreference('visibleonline', $visible_online ? '1' : '0') |
|
113 | + ->setPreference('verified', $verified ? '1' : '0') |
|
114 | + ->setPreference('verified_by_admin', $approved ? '1' : '0'); |
|
115 | + |
|
116 | + // We cannot change our own admin status. Another admin will need to do it. |
|
117 | + if ($user->getUserId() !== Auth::id()) { |
|
118 | + $user->setPreference('canadmin', $canadmin ? '1' : '0'); |
|
119 | + } |
|
120 | + |
|
121 | + foreach (Tree::getAll() as $tree) { |
|
122 | + $tree->setUserPreference($user, 'gedcomid', Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF)); |
|
123 | + $tree->setUserPreference($user, 'canedit', Filter::post('canedit' . $tree->getTreeId(), implode('|', array_keys($ALL_EDIT_OPTIONS)))); |
|
124 | + if (Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF)) { |
|
125 | + $tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', Filter::postInteger('RELATIONSHIP_PATH_LENGTH' . $tree->getTreeId(), 0, 10, 0)); |
|
126 | + } else { |
|
127 | + // Do not allow a path length to be set if the individual ID is not |
|
128 | + $tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', null); |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
135 | + |
|
136 | + return; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | switch (Filter::get('action')) { |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | // Datatables numbers columns 0, 1, 2 |
174 | 174 | // MySQL numbers columns 1, 2, 3 |
175 | 175 | switch ($value['dir']) { |
176 | - case 'asc': |
|
177 | - $sql_select .= (1 + $value['column']) . " ASC "; |
|
178 | - break; |
|
179 | - case 'desc': |
|
180 | - $sql_select .= (1 + $value['column']) . " DESC "; |
|
181 | - break; |
|
176 | + case 'asc': |
|
177 | + $sql_select .= (1 + $value['column']) . " ASC "; |
|
178 | + break; |
|
179 | + case 'desc': |
|
180 | + $sql_select .= (1 + $value['column']) . " DESC "; |
|
181 | + break; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | } else { |
@@ -38,75 +38,75 @@ discard block |
||
38 | 38 | |
39 | 39 | // Form actions |
40 | 40 | switch (Filter::post('action')) { |
41 | -case 'save': |
|
42 | - if (Filter::checkCsrf()) { |
|
43 | - $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
44 | - $ip_address_start = Filter::post('ip_address_start', WT_REGEX_IPV4); |
|
45 | - $ip_address_end = Filter::post('ip_address_end', WT_REGEX_IPV4); |
|
46 | - $user_agent_pattern = Filter::post('user_agent_pattern'); |
|
47 | - $rule = Filter::post('rule', 'allow|deny|robot'); |
|
48 | - $comment = Filter::post('comment'); |
|
49 | - $user_agent_string = Filter::server('HTTP_USER_AGENT'); |
|
50 | - $ip_address = WT_CLIENT_IP; |
|
51 | - |
|
52 | - if ($ip_address_start !== null && $ip_address_end !== null && $user_agent_pattern !== null && $rule !== null) { |
|
53 | - // This doesn't work with named placeholders. The :user_agent_string parameter is not recognised. |
|
54 | - $oops = $rule !== 'allow' && Database::prepare( |
|
55 | - "SELECT INET_ATON(:ip_address) BETWEEN INET_ATON(:ip_address_start) AND INET_ATON(:ip_address_end)" . |
|
56 | - " AND :user_agent_string LIKE :user_agent_pattern" |
|
57 | - )->execute(array( |
|
58 | - 'ip_address' => $ip_address, |
|
59 | - 'ip_address_start' => $ip_address_start, |
|
60 | - 'ip_address_end' => $ip_address_end, |
|
61 | - 'user_agent_string' => $user_agent_string, |
|
62 | - 'user_agent_pattern' => $user_agent_pattern, |
|
63 | - ))->fetchOne(); |
|
64 | - |
|
65 | - if ($oops) { |
|
66 | - FlashMessages::addMessage(I18N::translate('You cannot create a rule which would prevent yourself from accessing the website.'), 'danger'); |
|
67 | - } elseif ($site_access_rule_id === null) { |
|
68 | - Database::prepare( |
|
69 | - "INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, rule, comment) VALUES (INET_ATON(:ip_address_start), INET_ATON(:ip_address_end), :user_agent_pattern, :rule, :comment)" |
|
70 | - )->execute(array( |
|
71 | - 'ip_address_start' => $ip_address_start, |
|
72 | - 'ip_address_end' => $ip_address_end, |
|
73 | - 'user_agent_pattern' => $user_agent_pattern, |
|
74 | - 'rule' => $rule, |
|
75 | - 'comment' => $comment, |
|
76 | - )); |
|
77 | - FlashMessages::addMessage(I18N::translate('The website access rule has been created.'), 'success'); |
|
78 | - } else { |
|
79 | - Database::prepare( |
|
80 | - "UPDATE `##site_access_rule` SET ip_address_start = INET_ATON(:ip_address_start), ip_address_end = INET_ATON(:ip_address_end), user_agent_pattern = :user_agent_pattern, rule = :rule, comment = :comment WHERE site_access_rule_id = :site_access_rule_id" |
|
81 | - )->execute(array( |
|
82 | - 'ip_address_start' => $ip_address_start, |
|
83 | - 'ip_address_end' => $ip_address_end, |
|
84 | - 'user_agent_pattern' => $user_agent_pattern, |
|
85 | - 'rule' => $rule, |
|
86 | - 'comment' => $comment, |
|
87 | - 'site_access_rule_id' => $site_access_rule_id, |
|
88 | - )); |
|
89 | - FlashMessages::addMessage(I18N::translate('The website access rule has been updated.'), 'success'); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
93 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
94 | - |
|
95 | - return; |
|
96 | - |
|
97 | -case 'delete': |
|
98 | - if (Filter::checkCsrf()) { |
|
99 | - $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
100 | - Database::prepare( |
|
101 | - "DELETE FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
102 | - )->execute(array( |
|
103 | - 'site_access_rule_id' => $site_access_rule_id, |
|
104 | - )); |
|
105 | - FlashMessages::addMessage(I18N::translate('The website access rule has been deleted.'), 'success'); |
|
106 | - } |
|
107 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | - |
|
109 | - return; |
|
41 | + case 'save': |
|
42 | + if (Filter::checkCsrf()) { |
|
43 | + $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
44 | + $ip_address_start = Filter::post('ip_address_start', WT_REGEX_IPV4); |
|
45 | + $ip_address_end = Filter::post('ip_address_end', WT_REGEX_IPV4); |
|
46 | + $user_agent_pattern = Filter::post('user_agent_pattern'); |
|
47 | + $rule = Filter::post('rule', 'allow|deny|robot'); |
|
48 | + $comment = Filter::post('comment'); |
|
49 | + $user_agent_string = Filter::server('HTTP_USER_AGENT'); |
|
50 | + $ip_address = WT_CLIENT_IP; |
|
51 | + |
|
52 | + if ($ip_address_start !== null && $ip_address_end !== null && $user_agent_pattern !== null && $rule !== null) { |
|
53 | + // This doesn't work with named placeholders. The :user_agent_string parameter is not recognised. |
|
54 | + $oops = $rule !== 'allow' && Database::prepare( |
|
55 | + "SELECT INET_ATON(:ip_address) BETWEEN INET_ATON(:ip_address_start) AND INET_ATON(:ip_address_end)" . |
|
56 | + " AND :user_agent_string LIKE :user_agent_pattern" |
|
57 | + )->execute(array( |
|
58 | + 'ip_address' => $ip_address, |
|
59 | + 'ip_address_start' => $ip_address_start, |
|
60 | + 'ip_address_end' => $ip_address_end, |
|
61 | + 'user_agent_string' => $user_agent_string, |
|
62 | + 'user_agent_pattern' => $user_agent_pattern, |
|
63 | + ))->fetchOne(); |
|
64 | + |
|
65 | + if ($oops) { |
|
66 | + FlashMessages::addMessage(I18N::translate('You cannot create a rule which would prevent yourself from accessing the website.'), 'danger'); |
|
67 | + } elseif ($site_access_rule_id === null) { |
|
68 | + Database::prepare( |
|
69 | + "INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, rule, comment) VALUES (INET_ATON(:ip_address_start), INET_ATON(:ip_address_end), :user_agent_pattern, :rule, :comment)" |
|
70 | + )->execute(array( |
|
71 | + 'ip_address_start' => $ip_address_start, |
|
72 | + 'ip_address_end' => $ip_address_end, |
|
73 | + 'user_agent_pattern' => $user_agent_pattern, |
|
74 | + 'rule' => $rule, |
|
75 | + 'comment' => $comment, |
|
76 | + )); |
|
77 | + FlashMessages::addMessage(I18N::translate('The website access rule has been created.'), 'success'); |
|
78 | + } else { |
|
79 | + Database::prepare( |
|
80 | + "UPDATE `##site_access_rule` SET ip_address_start = INET_ATON(:ip_address_start), ip_address_end = INET_ATON(:ip_address_end), user_agent_pattern = :user_agent_pattern, rule = :rule, comment = :comment WHERE site_access_rule_id = :site_access_rule_id" |
|
81 | + )->execute(array( |
|
82 | + 'ip_address_start' => $ip_address_start, |
|
83 | + 'ip_address_end' => $ip_address_end, |
|
84 | + 'user_agent_pattern' => $user_agent_pattern, |
|
85 | + 'rule' => $rule, |
|
86 | + 'comment' => $comment, |
|
87 | + 'site_access_rule_id' => $site_access_rule_id, |
|
88 | + )); |
|
89 | + FlashMessages::addMessage(I18N::translate('The website access rule has been updated.'), 'success'); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
94 | + |
|
95 | + return; |
|
96 | + |
|
97 | + case 'delete': |
|
98 | + if (Filter::checkCsrf()) { |
|
99 | + $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
100 | + Database::prepare( |
|
101 | + "DELETE FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
102 | + )->execute(array( |
|
103 | + 'site_access_rule_id' => $site_access_rule_id, |
|
104 | + )); |
|
105 | + FlashMessages::addMessage(I18N::translate('The website access rule has been deleted.'), 'success'); |
|
106 | + } |
|
107 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | + |
|
109 | + return; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Delete any "unknown" visitors that are now "known". |
@@ -128,50 +128,50 @@ discard block |
||
128 | 128 | |
129 | 129 | $action = Filter::get('action'); |
130 | 130 | switch ($action) { |
131 | -case 'load': |
|
132 | - // AJAX callback for datatables |
|
133 | - $search = Filter::get('search'); |
|
134 | - $search = $search['value']; |
|
135 | - $start = Filter::getInteger('start'); |
|
136 | - $length = Filter::getInteger('length'); |
|
137 | - |
|
138 | - $sql = |
|
139 | - "SELECT SQL_CALC_FOUND_ROWS" . |
|
140 | - " '', INET_NTOA(ip_address_start), ip_address_start, INET_NTOA(ip_address_end), ip_address_end, user_agent_pattern, rule, comment, site_access_rule_id" . |
|
141 | - " FROM `##site_access_rule`"; |
|
142 | - $args = array(); |
|
143 | - |
|
144 | - if ($search) { |
|
145 | - $sql .= |
|
146 | - " WHERE (INET_ATON(:search_1) BETWEEN ip_address_start AND ip_address_end" . |
|
147 | - " OR INET_NTOA(ip_address_start) LIKE CONCAT('%', :search_2, '%')" . |
|
148 | - " OR INET_NTOA(ip_address_end) LIKE CONCAT('%', :search_3, '%')" . |
|
149 | - " OR user_agent_pattern LIKE CONCAT('%', :search_4, '%')" . |
|
150 | - " OR comment LIKE CONCAT('%', :search_5, '%'))"; |
|
151 | - $args['search_1'] = Filter::escapeLike($search); |
|
152 | - $args['search_2'] = Filter::escapeLike($search); |
|
153 | - $args['search_3'] = Filter::escapeLike($search); |
|
154 | - $args['search_4'] = Filter::escapeLike($search); |
|
155 | - $args['search_5'] = Filter::escapeLike($search); |
|
156 | - } |
|
157 | - |
|
158 | - $order = Filter::getArray('order'); |
|
159 | - $sql .= ' ORDER BY'; |
|
160 | - if ($order) { |
|
161 | - foreach ($order as $key => $value) { |
|
162 | - if ($key > 0) { |
|
163 | - $sql .= ','; |
|
164 | - } |
|
165 | - // Datatables numbers columns 0, 1, 2 |
|
166 | - // MySQL numbers columns 1, 2, 3 |
|
167 | - switch ($value['dir']) { |
|
168 | - case 'asc': |
|
169 | - $sql .= " :col_" . $key . " ASC"; |
|
170 | - break; |
|
171 | - case 'desc': |
|
172 | - $sql .= " :col_" . $key . " DESC"; |
|
173 | - break; |
|
174 | - } |
|
131 | + case 'load': |
|
132 | + // AJAX callback for datatables |
|
133 | + $search = Filter::get('search'); |
|
134 | + $search = $search['value']; |
|
135 | + $start = Filter::getInteger('start'); |
|
136 | + $length = Filter::getInteger('length'); |
|
137 | + |
|
138 | + $sql = |
|
139 | + "SELECT SQL_CALC_FOUND_ROWS" . |
|
140 | + " '', INET_NTOA(ip_address_start), ip_address_start, INET_NTOA(ip_address_end), ip_address_end, user_agent_pattern, rule, comment, site_access_rule_id" . |
|
141 | + " FROM `##site_access_rule`"; |
|
142 | + $args = array(); |
|
143 | + |
|
144 | + if ($search) { |
|
145 | + $sql .= |
|
146 | + " WHERE (INET_ATON(:search_1) BETWEEN ip_address_start AND ip_address_end" . |
|
147 | + " OR INET_NTOA(ip_address_start) LIKE CONCAT('%', :search_2, '%')" . |
|
148 | + " OR INET_NTOA(ip_address_end) LIKE CONCAT('%', :search_3, '%')" . |
|
149 | + " OR user_agent_pattern LIKE CONCAT('%', :search_4, '%')" . |
|
150 | + " OR comment LIKE CONCAT('%', :search_5, '%'))"; |
|
151 | + $args['search_1'] = Filter::escapeLike($search); |
|
152 | + $args['search_2'] = Filter::escapeLike($search); |
|
153 | + $args['search_3'] = Filter::escapeLike($search); |
|
154 | + $args['search_4'] = Filter::escapeLike($search); |
|
155 | + $args['search_5'] = Filter::escapeLike($search); |
|
156 | + } |
|
157 | + |
|
158 | + $order = Filter::getArray('order'); |
|
159 | + $sql .= ' ORDER BY'; |
|
160 | + if ($order) { |
|
161 | + foreach ($order as $key => $value) { |
|
162 | + if ($key > 0) { |
|
163 | + $sql .= ','; |
|
164 | + } |
|
165 | + // Datatables numbers columns 0, 1, 2 |
|
166 | + // MySQL numbers columns 1, 2, 3 |
|
167 | + switch ($value['dir']) { |
|
168 | + case 'asc': |
|
169 | + $sql .= " :col_" . $key . " ASC"; |
|
170 | + break; |
|
171 | + case 'desc': |
|
172 | + $sql .= " :col_" . $key . " DESC"; |
|
173 | + break; |
|
174 | + } |
|
175 | 175 | $args['col_' . $key] = 1 + $value['column']; |
176 | 176 | } |
177 | 177 | } else { |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | )); |
211 | 211 | break; |
212 | 212 | |
213 | -case 'edit': |
|
214 | -case 'create': |
|
215 | - if (Filter::get('action') === 'edit') { |
|
216 | - $controller->setPageTitle(I18N::translate('Edit a website access rule')); |
|
217 | - } else { |
|
218 | - $controller->setPageTitle(I18N::translate('Create a website access rule')); |
|
219 | - } |
|
220 | - |
|
221 | - $controller->pageHeader(); |
|
222 | - |
|
223 | - $site_access_rule = Database::prepare( |
|
224 | - "SELECT site_access_rule_id, INET_NTOA(ip_address_start) AS ip_address_start, INET_NTOA(ip_address_end) AS ip_address_end, user_agent_pattern, rule, comment" . |
|
225 | - " FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
226 | - )->execute(array( |
|
227 | - 'site_access_rule_id' => Filter::getInteger('site_access_rule_id'), |
|
228 | - ))->fetchOneRow(); |
|
229 | - |
|
230 | - $site_access_rule_id = $site_access_rule ? $site_access_rule->site_access_rule_id : null; |
|
231 | - $ip_address_start = $site_access_rule ? $site_access_rule->ip_address_start : '0.0.0.0'; |
|
232 | - $ip_address_end = $site_access_rule ? $site_access_rule->ip_address_end : '255.255.255.255'; |
|
233 | - $user_agent_pattern = $site_access_rule ? $site_access_rule->user_agent_pattern : '%'; |
|
234 | - $rule = $site_access_rule ? $site_access_rule->rule : 'allow'; |
|
235 | - $comment = $site_access_rule ? $site_access_rule->comment : ''; |
|
236 | - |
|
237 | - ?> |
|
213 | + case 'edit': |
|
214 | + case 'create': |
|
215 | + if (Filter::get('action') === 'edit') { |
|
216 | + $controller->setPageTitle(I18N::translate('Edit a website access rule')); |
|
217 | + } else { |
|
218 | + $controller->setPageTitle(I18N::translate('Create a website access rule')); |
|
219 | + } |
|
220 | + |
|
221 | + $controller->pageHeader(); |
|
222 | + |
|
223 | + $site_access_rule = Database::prepare( |
|
224 | + "SELECT site_access_rule_id, INET_NTOA(ip_address_start) AS ip_address_start, INET_NTOA(ip_address_end) AS ip_address_end, user_agent_pattern, rule, comment" . |
|
225 | + " FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
226 | + )->execute(array( |
|
227 | + 'site_access_rule_id' => Filter::getInteger('site_access_rule_id'), |
|
228 | + ))->fetchOneRow(); |
|
229 | + |
|
230 | + $site_access_rule_id = $site_access_rule ? $site_access_rule->site_access_rule_id : null; |
|
231 | + $ip_address_start = $site_access_rule ? $site_access_rule->ip_address_start : '0.0.0.0'; |
|
232 | + $ip_address_end = $site_access_rule ? $site_access_rule->ip_address_end : '255.255.255.255'; |
|
233 | + $user_agent_pattern = $site_access_rule ? $site_access_rule->user_agent_pattern : '%'; |
|
234 | + $rule = $site_access_rule ? $site_access_rule->rule : 'allow'; |
|
235 | + $comment = $site_access_rule ? $site_access_rule->comment : ''; |
|
236 | + |
|
237 | + ?> |
|
238 | 238 | <ol class="breadcrumb small"> |
239 | 239 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
240 | 240 | <li><a href="admin_site_access.php"><?php echo I18N::translate('Website access rules'); ?></a></li> |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | </form> |
312 | 312 | |
313 | 313 | <?php |
314 | - break; |
|
314 | + break; |
|
315 | 315 | |
316 | -default: |
|
317 | - $controller |
|
318 | - ->pageHeader() |
|
319 | - ->addInlineJavascript(' |
|
316 | + default: |
|
317 | + $controller |
|
318 | + ->pageHeader() |
|
319 | + ->addInlineJavascript(' |
|
320 | 320 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
321 | 321 | jQuery.fn.dataTableExt.oSort["unicode-desc"]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
322 | 322 | jQuery(".table-site-access-rules").dataTable({ |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | }); |
341 | 341 | '); |
342 | 342 | |
343 | - ?> |
|
343 | + ?> |
|
344 | 344 | <ol class="breadcrumb small"> |
345 | 345 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
346 | 346 | <li class="active"><?php echo $controller->getPageTitle(); ?></li> |
@@ -381,5 +381,5 @@ discard block |
||
381 | 381 | } |
382 | 382 | </script> |
383 | 383 | <?php |
384 | - break; |
|
384 | + break; |
|
385 | 385 | } |
@@ -126,53 +126,53 @@ |
||
126 | 126 | |
127 | 127 | // vertical and horizontal position of the text |
128 | 128 | switch ($vpos) { |
129 | - default: |
|
130 | - case 'top': |
|
131 | - $taille = textlength($maxsize, $width, $text); |
|
132 | - $pos_y = $height * 0.15 + $taille; |
|
133 | - $pos_x = $width * 0.15; |
|
134 | - $rotation = 0; |
|
135 | - break; |
|
136 | - case 'middle': |
|
137 | - $taille = textlength($maxsize, $width, $text); |
|
138 | - $pos_y = ($height + $taille) / 2; |
|
139 | - $pos_x = $width * 0.15; |
|
140 | - $rotation = 0; |
|
141 | - break; |
|
142 | - case 'bottom': |
|
143 | - $taille = textlength($maxsize, $width, $text); |
|
144 | - $pos_y = ($height * .85 - $taille); |
|
145 | - $pos_x = $width * 0.15; |
|
146 | - $rotation = 0; |
|
147 | - break; |
|
148 | - case 'across': |
|
149 | - switch ($hpos) { |
|
150 | - default: |
|
151 | - case 'left': |
|
152 | - $taille = textlength($maxsize, $hypoth, $text); |
|
153 | - $pos_y = ($height * .85 - $taille); |
|
154 | - $pos_x = $width * 0.15; |
|
155 | - $rotation = $calc_angle; |
|
156 | - break; |
|
157 | - case 'right': |
|
158 | - $taille = textlength($maxsize, $hypoth, $text); |
|
159 | - $pos_y = ($height * .15 - $taille); |
|
160 | - $pos_x = $width * 0.85; |
|
161 | - $rotation = $calc_angle + 180; |
|
162 | - break; |
|
163 | - case 'top2bottom': |
|
164 | - $taille = textlength($maxsize, $height, $text); |
|
165 | - $pos_y = ($height * .15 - $taille); |
|
166 | - $pos_x = ($width * .90 - $taille); |
|
167 | - $rotation = -90; |
|
168 | - break; |
|
169 | - case 'bottom2top': |
|
170 | - $taille = textlength($maxsize, $height, $text); |
|
171 | - $pos_y = $height * 0.85; |
|
172 | - $pos_x = $width * 0.15; |
|
173 | - $rotation = 90; |
|
174 | - break; |
|
175 | - } |
|
129 | + default: |
|
130 | + case 'top': |
|
131 | + $taille = textlength($maxsize, $width, $text); |
|
132 | + $pos_y = $height * 0.15 + $taille; |
|
133 | + $pos_x = $width * 0.15; |
|
134 | + $rotation = 0; |
|
135 | + break; |
|
136 | + case 'middle': |
|
137 | + $taille = textlength($maxsize, $width, $text); |
|
138 | + $pos_y = ($height + $taille) / 2; |
|
139 | + $pos_x = $width * 0.15; |
|
140 | + $rotation = 0; |
|
141 | + break; |
|
142 | + case 'bottom': |
|
143 | + $taille = textlength($maxsize, $width, $text); |
|
144 | + $pos_y = ($height * .85 - $taille); |
|
145 | + $pos_x = $width * 0.15; |
|
146 | + $rotation = 0; |
|
147 | + break; |
|
148 | + case 'across': |
|
149 | + switch ($hpos) { |
|
150 | + default: |
|
151 | + case 'left': |
|
152 | + $taille = textlength($maxsize, $hypoth, $text); |
|
153 | + $pos_y = ($height * .85 - $taille); |
|
154 | + $pos_x = $width * 0.15; |
|
155 | + $rotation = $calc_angle; |
|
156 | + break; |
|
157 | + case 'right': |
|
158 | + $taille = textlength($maxsize, $hypoth, $text); |
|
159 | + $pos_y = ($height * .15 - $taille); |
|
160 | + $pos_x = $width * 0.85; |
|
161 | + $rotation = $calc_angle + 180; |
|
162 | + break; |
|
163 | + case 'top2bottom': |
|
164 | + $taille = textlength($maxsize, $height, $text); |
|
165 | + $pos_y = ($height * .15 - $taille); |
|
166 | + $pos_x = ($width * .90 - $taille); |
|
167 | + $rotation = -90; |
|
168 | + break; |
|
169 | + case 'bottom2top': |
|
170 | + $taille = textlength($maxsize, $height, $text); |
|
171 | + $pos_y = $height * 0.85; |
|
172 | + $pos_x = $width * 0.15; |
|
173 | + $rotation = 90; |
|
174 | + break; |
|
175 | + } |
|
176 | 176 | break; |
177 | 177 | } |
178 | 178 |
@@ -68,89 +68,89 @@ discard block |
||
68 | 68 | $message = ''; |
69 | 69 | |
70 | 70 | switch ($action) { |
71 | -case 'login': |
|
72 | - try { |
|
73 | - if (!$_COOKIE) { |
|
74 | - Log::addAuthenticationLog('Login failed (no session cookies): ' . $username); |
|
75 | - throw new \Exception(I18N::translate('You cannot sign in because your browser does not accept cookies.')); |
|
76 | - } |
|
77 | - |
|
78 | - $user = User::findByIdentifier($username); |
|
79 | - |
|
80 | - if (!$user) { |
|
81 | - Log::addAuthenticationLog('Login failed (no such user/email): ' . $username); |
|
82 | - throw new \Exception(I18N::translate('The username or password is incorrect.')); |
|
83 | - } |
|
84 | - |
|
85 | - if (!$user->checkPassword($password)) { |
|
86 | - Log::addAuthenticationLog('Login failed (incorrect password): ' . $username); |
|
87 | - throw new \Exception(I18N::translate('The username or password is incorrect.')); |
|
88 | - } |
|
89 | - |
|
90 | - if (!$user->getPreference('verified')) { |
|
91 | - Log::addAuthenticationLog('Login failed (not verified by user): ' . $username); |
|
92 | - throw new \Exception(I18N::translate('This account has not been verified. Please check your email for a verification message.')); |
|
93 | - } |
|
94 | - |
|
95 | - if (!$user->getPreference('verified_by_admin')) { |
|
96 | - Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username); |
|
97 | - throw new \Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.')); |
|
98 | - } |
|
99 | - |
|
100 | - Auth::login($user); |
|
101 | - Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName()); |
|
102 | - Auth::user()->setPreference('sessiontime', WT_TIMESTAMP); |
|
103 | - |
|
104 | - Session::put('locale', Auth::user()->getPreference('language')); |
|
105 | - Session::put('theme_id', Auth::user()->getPreference('theme')); |
|
106 | - I18N::init(Auth::user()->getPreference('language')); |
|
107 | - |
|
108 | - // We're logging in as an administrator |
|
109 | - if (Auth::isAdmin()) { |
|
110 | - // Check for updates |
|
111 | - $latest_version_txt = Functions::fetchLatestVersion(); |
|
112 | - if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
113 | - list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt); |
|
114 | - if (version_compare(WT_VERSION, $latest_version) < 0) { |
|
115 | - FlashMessages::addMessage( |
|
116 | - I18N::translate('A new version of webtrees is available.') . |
|
117 | - ' <a href="admin_site_upgrade.php"><b>' . |
|
118 | - I18N::translate('Upgrade to webtrees %s.', '<span dir="ltr">' . $latest_version . '</span>') . |
|
119 | - '</b></a>' |
|
120 | - ); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - // If we were on a "home page", redirect to "my page" |
|
126 | - if ($url === '' || strpos($url, 'index.php?ctype=gedcom') === 0) { |
|
127 | - $url = 'index.php?ctype=user'; |
|
128 | - // Switch to a tree where we have a genealogy record (or keep to the current/default). |
|
129 | - $tree = Database::prepare( |
|
130 | - "SELECT gedcom_name FROM `##gedcom` JOIN `##user_gedcom_setting` USING (gedcom_id)" . |
|
131 | - " WHERE setting_name = 'gedcomid' AND user_id = :user_id" . |
|
132 | - " ORDER BY gedcom_id = :tree_id DESC" |
|
133 | - )->execute(array( |
|
134 | - 'user_id' => Auth::user()->getUserId(), |
|
135 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
136 | - ))->fetchOne(); |
|
137 | - $url .= '&ged=' . Filter::escapeUrl($tree); |
|
138 | - } |
|
139 | - |
|
140 | - // Redirect to the target URL |
|
141 | - header('Location: ' . WT_BASE_URL . $url); |
|
142 | - |
|
143 | - return; |
|
144 | - } catch (\Exception $ex) { |
|
145 | - $message = $ex->getMessage(); |
|
146 | - } |
|
147 | - // No break; |
|
148 | - |
|
149 | -default: |
|
150 | - $controller |
|
151 | - ->setPageTitle(I18N::translate('Sign in')) |
|
152 | - ->pageHeader() |
|
153 | - ->addInlineJavascript(' |
|
71 | + case 'login': |
|
72 | + try { |
|
73 | + if (!$_COOKIE) { |
|
74 | + Log::addAuthenticationLog('Login failed (no session cookies): ' . $username); |
|
75 | + throw new \Exception(I18N::translate('You cannot sign in because your browser does not accept cookies.')); |
|
76 | + } |
|
77 | + |
|
78 | + $user = User::findByIdentifier($username); |
|
79 | + |
|
80 | + if (!$user) { |
|
81 | + Log::addAuthenticationLog('Login failed (no such user/email): ' . $username); |
|
82 | + throw new \Exception(I18N::translate('The username or password is incorrect.')); |
|
83 | + } |
|
84 | + |
|
85 | + if (!$user->checkPassword($password)) { |
|
86 | + Log::addAuthenticationLog('Login failed (incorrect password): ' . $username); |
|
87 | + throw new \Exception(I18N::translate('The username or password is incorrect.')); |
|
88 | + } |
|
89 | + |
|
90 | + if (!$user->getPreference('verified')) { |
|
91 | + Log::addAuthenticationLog('Login failed (not verified by user): ' . $username); |
|
92 | + throw new \Exception(I18N::translate('This account has not been verified. Please check your email for a verification message.')); |
|
93 | + } |
|
94 | + |
|
95 | + if (!$user->getPreference('verified_by_admin')) { |
|
96 | + Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username); |
|
97 | + throw new \Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.')); |
|
98 | + } |
|
99 | + |
|
100 | + Auth::login($user); |
|
101 | + Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName()); |
|
102 | + Auth::user()->setPreference('sessiontime', WT_TIMESTAMP); |
|
103 | + |
|
104 | + Session::put('locale', Auth::user()->getPreference('language')); |
|
105 | + Session::put('theme_id', Auth::user()->getPreference('theme')); |
|
106 | + I18N::init(Auth::user()->getPreference('language')); |
|
107 | + |
|
108 | + // We're logging in as an administrator |
|
109 | + if (Auth::isAdmin()) { |
|
110 | + // Check for updates |
|
111 | + $latest_version_txt = Functions::fetchLatestVersion(); |
|
112 | + if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
113 | + list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt); |
|
114 | + if (version_compare(WT_VERSION, $latest_version) < 0) { |
|
115 | + FlashMessages::addMessage( |
|
116 | + I18N::translate('A new version of webtrees is available.') . |
|
117 | + ' <a href="admin_site_upgrade.php"><b>' . |
|
118 | + I18N::translate('Upgrade to webtrees %s.', '<span dir="ltr">' . $latest_version . '</span>') . |
|
119 | + '</b></a>' |
|
120 | + ); |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + // If we were on a "home page", redirect to "my page" |
|
126 | + if ($url === '' || strpos($url, 'index.php?ctype=gedcom') === 0) { |
|
127 | + $url = 'index.php?ctype=user'; |
|
128 | + // Switch to a tree where we have a genealogy record (or keep to the current/default). |
|
129 | + $tree = Database::prepare( |
|
130 | + "SELECT gedcom_name FROM `##gedcom` JOIN `##user_gedcom_setting` USING (gedcom_id)" . |
|
131 | + " WHERE setting_name = 'gedcomid' AND user_id = :user_id" . |
|
132 | + " ORDER BY gedcom_id = :tree_id DESC" |
|
133 | + )->execute(array( |
|
134 | + 'user_id' => Auth::user()->getUserId(), |
|
135 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
136 | + ))->fetchOne(); |
|
137 | + $url .= '&ged=' . Filter::escapeUrl($tree); |
|
138 | + } |
|
139 | + |
|
140 | + // Redirect to the target URL |
|
141 | + header('Location: ' . WT_BASE_URL . $url); |
|
142 | + |
|
143 | + return; |
|
144 | + } catch (\Exception $ex) { |
|
145 | + $message = $ex->getMessage(); |
|
146 | + } |
|
147 | + // No break; |
|
148 | + |
|
149 | + default: |
|
150 | + $controller |
|
151 | + ->setPageTitle(I18N::translate('Sign in')) |
|
152 | + ->pageHeader() |
|
153 | + ->addInlineJavascript(' |
|
154 | 154 | jQuery("#new_passwd_form").hide(); |
155 | 155 | jQuery("#passwd_click").click(function() { |
156 | 156 | jQuery("#new_passwd_form").slideToggle(100, function() { |
@@ -160,25 +160,25 @@ discard block |
||
160 | 160 | }); |
161 | 161 | '); |
162 | 162 | |
163 | - echo '<div id="login-page">'; |
|
164 | - echo '<div id="login-text">'; |
|
165 | - |
|
166 | - echo '<p class="center"><strong>' . I18N::translate('Welcome to this genealogy website') . '</strong></p>'; |
|
167 | - |
|
168 | - switch (Site::getPreference('WELCOME_TEXT_AUTH_MODE')) { |
|
169 | - case 1: |
|
170 | - echo '<p>' . I18N::translate('Anyone with a user account can access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>'; |
|
171 | - break; |
|
172 | - case 2: |
|
173 | - echo '<p>' . I18N::translate('You need to be an authorized user to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>'; |
|
174 | - break; |
|
175 | - case 3: |
|
176 | - echo '<p>' . I18N::translate('You need to be a family member to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>'; |
|
177 | - break; |
|
178 | - case 4: |
|
179 | - echo '<p style="white-space: pre-wrap;">', Site::getPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE), '</p>'; |
|
180 | - break; |
|
181 | - } |
|
163 | + echo '<div id="login-page">'; |
|
164 | + echo '<div id="login-text">'; |
|
165 | + |
|
166 | + echo '<p class="center"><strong>' . I18N::translate('Welcome to this genealogy website') . '</strong></p>'; |
|
167 | + |
|
168 | + switch (Site::getPreference('WELCOME_TEXT_AUTH_MODE')) { |
|
169 | + case 1: |
|
170 | + echo '<p>' . I18N::translate('Anyone with a user account can access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>'; |
|
171 | + break; |
|
172 | + case 2: |
|
173 | + echo '<p>' . I18N::translate('You need to be an authorized user to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>'; |
|
174 | + break; |
|
175 | + case 3: |
|
176 | + echo '<p>' . I18N::translate('You need to be a family member to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>'; |
|
177 | + break; |
|
178 | + case 4: |
|
179 | + echo '<p style="white-space: pre-wrap;">', Site::getPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE), '</p>'; |
|
180 | + break; |
|
181 | + } |
|
182 | 182 | |
183 | 183 | echo '</div>'; |
184 | 184 | echo '<div id="login-box">'; |
@@ -233,181 +233,181 @@ discard block |
||
233 | 233 | echo '</div>'; |
234 | 234 | break; |
235 | 235 | |
236 | -case 'requestpw': |
|
237 | - $user_name = Filter::post('new_passwd_username'); |
|
238 | - $user = User::findByIdentifier($user_name); |
|
239 | - |
|
240 | - if ($user) { |
|
241 | - $passchars = 'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; |
|
242 | - $user_new_pw = ''; |
|
243 | - $max = strlen($passchars) - 1; |
|
244 | - for ($i = 0; $i < 8; $i++) { |
|
245 | - $index = rand(0, $max); |
|
246 | - $user_new_pw .= $passchars{$index}; |
|
247 | - } |
|
248 | - |
|
249 | - $user->setPassword($user_new_pw); |
|
250 | - Log::addAuthenticationLog('Password request was sent to user: ' . $user->getUserName()); |
|
251 | - |
|
252 | - Mail::systemMessage( |
|
253 | - $WT_TREE, |
|
254 | - $user, |
|
255 | - I18N::translate('Lost password request'), |
|
256 | - I18N::translate('Hello %s…', $user->getRealNameHtml()) . Mail::EOL . Mail::EOL . |
|
257 | - I18N::translate('A new password has been requested for your username.') . Mail::EOL . Mail::EOL . |
|
258 | - I18N::translate('Username') . ": " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . |
|
259 | - I18N::translate('Password') . ": " . $user_new_pw . Mail::EOL . Mail::EOL . |
|
260 | - I18N::translate('After you have signed in, select the “My account” link under the “My pages” menu and fill in the password fields to change your password.') . Mail::EOL . Mail::EOL . |
|
261 | - '<a href="' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '</a>' |
|
262 | - ); |
|
263 | - |
|
264 | - FlashMessages::addMessage(I18N::translate('A new password has been created and emailed to %s. You can change this password after you sign in.', Filter::escapeHtml($user_name)), 'success'); |
|
265 | - } else { |
|
266 | - FlashMessages::addMessage(I18N::translate('There is no account with the username or email “%s”.', Filter::escapeHtml($user_name)), 'danger'); |
|
267 | - } |
|
268 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
269 | - |
|
270 | - return; |
|
271 | - break; |
|
272 | - |
|
273 | -case 'register': |
|
274 | - if (!Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
275 | - header('Location: ' . WT_BASE_URL); |
|
276 | - |
|
277 | - return; |
|
278 | - } |
|
279 | - |
|
280 | - $controller->setPageTitle(I18N::translate('Request a new user account')); |
|
281 | - |
|
282 | - // The form parameters are mandatory, and the validation errors are shown in the client. |
|
283 | - if (Session::get('good_to_send') && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) { |
|
284 | - |
|
285 | - // These validation errors cannot be shown in the client. |
|
286 | - if (User::findByUserName($user_name)) { |
|
287 | - FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.')); |
|
288 | - } elseif (User::findByEmail($user_email)) { |
|
289 | - FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.')); |
|
290 | - } elseif (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\/\/)[a-zA-Z0-9.-]+)/', $user_comments, $match)) { |
|
291 | - FlashMessages::addMessage( |
|
292 | - I18N::translate('You are not allowed to send messages that contain external links.') . ' ' . |
|
293 | - I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1]) |
|
294 | - ); |
|
295 | - Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"'); |
|
296 | - } else { |
|
297 | - // Everything looks good - create the user |
|
298 | - $controller->pageHeader(); |
|
299 | - Log::addAuthenticationLog('User registration requested for: ' . $user_name); |
|
300 | - |
|
301 | - $user = User::create($user_name, $user_realname, $user_email, $user_password01); |
|
302 | - $user |
|
303 | - ->setPreference('language', WT_LOCALE) |
|
304 | - ->setPreference('verified', '0') |
|
305 | - ->setPreference('verified_by_admin', 0) |
|
306 | - ->setPreference('reg_timestamp', date('U')) |
|
307 | - ->setPreference('reg_hashcode', md5(Uuid::uuid4())) |
|
308 | - ->setPreference('contactmethod', 'messaging2') |
|
309 | - ->setPreference('comment', $user_comments) |
|
310 | - ->setPreference('visibleonline', '1') |
|
311 | - ->setPreference('auto_accept', '0') |
|
312 | - ->setPreference('canadmin', '0') |
|
313 | - ->setPreference('sessiontime', '0'); |
|
314 | - |
|
315 | - // Generate an email in the admin’s language |
|
316 | - $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')); |
|
317 | - I18N::init($webmaster->getPreference('language')); |
|
318 | - |
|
319 | - $mail1_body = |
|
320 | - I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . |
|
321 | - /* I18N: %s is a server name/URL */ |
|
322 | - I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL . |
|
323 | - I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL . |
|
324 | - I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL . |
|
325 | - I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL . |
|
326 | - I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL . |
|
327 | - I18N::translate('The user has been sent an email with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL . |
|
328 | - I18N::translate('You will be informed by email when this prospective user has confirmed the request. You can then complete the process by activating the username. The new user will not be able to sign in until you activate the account.'); |
|
329 | - |
|
330 | - $mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle()); |
|
331 | - I18N::init(WT_LOCALE); |
|
332 | - |
|
333 | - echo '<div id="login-register-page">'; |
|
334 | - |
|
335 | - // Generate an email in the user’s language |
|
336 | - $mail2_body = |
|
337 | - I18N::translate('Hello %s…', $user->getRealNameHtml()) . |
|
338 | - Mail::EOL . Mail::EOL . |
|
339 | - /* I18N: %1$s is the site URL and %2$s is an email address */ |
|
340 | - I18N::translate('You (or someone claiming to be you) has requested an account at %1$s using the email address %2$s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml(), $user->getEmail()) . |
|
341 | - Mail::EOL . Mail::EOL . |
|
342 | - I18N::translate('Follow this link to verify your email address.') . |
|
343 | - Mail::EOL . Mail::EOL . |
|
344 | - '<a href="' . WT_LOGIN_URL . '?user_name=' . Filter::escapeUrl($user->getUserName()) . '&user_hashcode=' . $user->getPreference('reg_hashcode') . '&action=userverify&ged=' . $WT_TREE->getNameUrl() . '">' . |
|
345 | - WT_LOGIN_URL . "?user_name=" . Filter::escapeHtml($user->getUserName()) . "&user_hashcode=" . urlencode($user->getPreference('reg_hashcode')) . '&action=userverify&ged=' . $WT_TREE->getNameHtml() . |
|
346 | - '</a>' . Mail::EOL . Mail::EOL . |
|
347 | - I18N::translate('Username') . " - " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . |
|
348 | - I18N::translate('Comments') . " - " . $user->getPreference('comment') . Mail::EOL . |
|
349 | - I18N::translate('If you didn’t request an account, you can just delete this message.') . Mail::EOL; |
|
350 | - $mail2_subject = /* I18N: %s is a server name/URL */ I18N::translate('Your registration at %s', WT_BASE_URL); |
|
351 | - $mail2_to = $user->getEmail(); |
|
352 | - $mail2_from = $WT_TREE->getPreference('WEBTREES_EMAIL'); |
|
353 | - |
|
354 | - // Send user message by email only |
|
355 | - Mail::send( |
|
356 | - // “From:” header |
|
357 | - $WT_TREE, |
|
358 | - // “To:” header |
|
359 | - $mail2_to, |
|
360 | - $mail2_to, |
|
361 | - // “Reply-To:” header |
|
362 | - $mail2_from, |
|
363 | - $mail2_from, |
|
364 | - // Message body |
|
365 | - $mail2_subject, |
|
366 | - $mail2_body |
|
367 | - ); |
|
368 | - |
|
369 | - // Send admin message by email and/or internal messaging |
|
370 | - Mail::send( |
|
371 | - // “From:” header |
|
372 | - $WT_TREE, |
|
373 | - // “To:” header |
|
374 | - $webmaster->getEmail(), |
|
375 | - $webmaster->getRealName(), |
|
376 | - // “Reply-To:” header |
|
377 | - $user->getEmail(), |
|
378 | - $user->getRealName(), |
|
379 | - // Message body |
|
380 | - $mail1_subject, |
|
381 | - $mail1_body |
|
382 | - ); |
|
383 | - $mail1_method = $webmaster->getPreference('contact_method'); |
|
384 | - if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') { |
|
385 | - Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)") |
|
386 | - ->execute(array($user->getEmail(), WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body))); |
|
387 | - } |
|
388 | - |
|
389 | - echo '<div class="confirm"><p>', I18N::translate('Hello %s…<br>Thank you for your registration.', $user->getRealNameHtml()), '</p>'; |
|
390 | - echo '<p>', I18N::translate('We will now send a confirmation email to the address <b>%s</b>. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.<br><br>After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.<br><br>To sign in to this website, you will need to know your username and password.', $user->getEmail()), '</p>'; |
|
391 | - echo '</div>'; |
|
392 | - echo '</div>'; |
|
393 | - |
|
394 | - return; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - Session::put('good_to_send', true); |
|
399 | - $controller |
|
400 | - ->pageHeader() |
|
401 | - ->addInlineJavascript('function regex_quote(str) {return str.replace(/[\\\\.?+*()[\](){}|]/g, "\\\\$&");}'); |
|
402 | - |
|
403 | - ?> |
|
236 | + case 'requestpw': |
|
237 | + $user_name = Filter::post('new_passwd_username'); |
|
238 | + $user = User::findByIdentifier($user_name); |
|
239 | + |
|
240 | + if ($user) { |
|
241 | + $passchars = 'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; |
|
242 | + $user_new_pw = ''; |
|
243 | + $max = strlen($passchars) - 1; |
|
244 | + for ($i = 0; $i < 8; $i++) { |
|
245 | + $index = rand(0, $max); |
|
246 | + $user_new_pw .= $passchars{$index}; |
|
247 | + } |
|
248 | + |
|
249 | + $user->setPassword($user_new_pw); |
|
250 | + Log::addAuthenticationLog('Password request was sent to user: ' . $user->getUserName()); |
|
251 | + |
|
252 | + Mail::systemMessage( |
|
253 | + $WT_TREE, |
|
254 | + $user, |
|
255 | + I18N::translate('Lost password request'), |
|
256 | + I18N::translate('Hello %s…', $user->getRealNameHtml()) . Mail::EOL . Mail::EOL . |
|
257 | + I18N::translate('A new password has been requested for your username.') . Mail::EOL . Mail::EOL . |
|
258 | + I18N::translate('Username') . ": " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . |
|
259 | + I18N::translate('Password') . ": " . $user_new_pw . Mail::EOL . Mail::EOL . |
|
260 | + I18N::translate('After you have signed in, select the “My account” link under the “My pages” menu and fill in the password fields to change your password.') . Mail::EOL . Mail::EOL . |
|
261 | + '<a href="' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '</a>' |
|
262 | + ); |
|
263 | + |
|
264 | + FlashMessages::addMessage(I18N::translate('A new password has been created and emailed to %s. You can change this password after you sign in.', Filter::escapeHtml($user_name)), 'success'); |
|
265 | + } else { |
|
266 | + FlashMessages::addMessage(I18N::translate('There is no account with the username or email “%s”.', Filter::escapeHtml($user_name)), 'danger'); |
|
267 | + } |
|
268 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
269 | + |
|
270 | + return; |
|
271 | + break; |
|
272 | + |
|
273 | + case 'register': |
|
274 | + if (!Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
275 | + header('Location: ' . WT_BASE_URL); |
|
276 | + |
|
277 | + return; |
|
278 | + } |
|
279 | + |
|
280 | + $controller->setPageTitle(I18N::translate('Request a new user account')); |
|
281 | + |
|
282 | + // The form parameters are mandatory, and the validation errors are shown in the client. |
|
283 | + if (Session::get('good_to_send') && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) { |
|
284 | + |
|
285 | + // These validation errors cannot be shown in the client. |
|
286 | + if (User::findByUserName($user_name)) { |
|
287 | + FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.')); |
|
288 | + } elseif (User::findByEmail($user_email)) { |
|
289 | + FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.')); |
|
290 | + } elseif (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\/\/)[a-zA-Z0-9.-]+)/', $user_comments, $match)) { |
|
291 | + FlashMessages::addMessage( |
|
292 | + I18N::translate('You are not allowed to send messages that contain external links.') . ' ' . |
|
293 | + I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1]) |
|
294 | + ); |
|
295 | + Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"'); |
|
296 | + } else { |
|
297 | + // Everything looks good - create the user |
|
298 | + $controller->pageHeader(); |
|
299 | + Log::addAuthenticationLog('User registration requested for: ' . $user_name); |
|
300 | + |
|
301 | + $user = User::create($user_name, $user_realname, $user_email, $user_password01); |
|
302 | + $user |
|
303 | + ->setPreference('language', WT_LOCALE) |
|
304 | + ->setPreference('verified', '0') |
|
305 | + ->setPreference('verified_by_admin', 0) |
|
306 | + ->setPreference('reg_timestamp', date('U')) |
|
307 | + ->setPreference('reg_hashcode', md5(Uuid::uuid4())) |
|
308 | + ->setPreference('contactmethod', 'messaging2') |
|
309 | + ->setPreference('comment', $user_comments) |
|
310 | + ->setPreference('visibleonline', '1') |
|
311 | + ->setPreference('auto_accept', '0') |
|
312 | + ->setPreference('canadmin', '0') |
|
313 | + ->setPreference('sessiontime', '0'); |
|
314 | + |
|
315 | + // Generate an email in the admin’s language |
|
316 | + $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')); |
|
317 | + I18N::init($webmaster->getPreference('language')); |
|
318 | + |
|
319 | + $mail1_body = |
|
320 | + I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . |
|
321 | + /* I18N: %s is a server name/URL */ |
|
322 | + I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL . |
|
323 | + I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL . |
|
324 | + I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL . |
|
325 | + I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL . |
|
326 | + I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL . |
|
327 | + I18N::translate('The user has been sent an email with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL . |
|
328 | + I18N::translate('You will be informed by email when this prospective user has confirmed the request. You can then complete the process by activating the username. The new user will not be able to sign in until you activate the account.'); |
|
329 | + |
|
330 | + $mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle()); |
|
331 | + I18N::init(WT_LOCALE); |
|
332 | + |
|
333 | + echo '<div id="login-register-page">'; |
|
334 | + |
|
335 | + // Generate an email in the user’s language |
|
336 | + $mail2_body = |
|
337 | + I18N::translate('Hello %s…', $user->getRealNameHtml()) . |
|
338 | + Mail::EOL . Mail::EOL . |
|
339 | + /* I18N: %1$s is the site URL and %2$s is an email address */ |
|
340 | + I18N::translate('You (or someone claiming to be you) has requested an account at %1$s using the email address %2$s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml(), $user->getEmail()) . |
|
341 | + Mail::EOL . Mail::EOL . |
|
342 | + I18N::translate('Follow this link to verify your email address.') . |
|
343 | + Mail::EOL . Mail::EOL . |
|
344 | + '<a href="' . WT_LOGIN_URL . '?user_name=' . Filter::escapeUrl($user->getUserName()) . '&user_hashcode=' . $user->getPreference('reg_hashcode') . '&action=userverify&ged=' . $WT_TREE->getNameUrl() . '">' . |
|
345 | + WT_LOGIN_URL . "?user_name=" . Filter::escapeHtml($user->getUserName()) . "&user_hashcode=" . urlencode($user->getPreference('reg_hashcode')) . '&action=userverify&ged=' . $WT_TREE->getNameHtml() . |
|
346 | + '</a>' . Mail::EOL . Mail::EOL . |
|
347 | + I18N::translate('Username') . " - " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . |
|
348 | + I18N::translate('Comments') . " - " . $user->getPreference('comment') . Mail::EOL . |
|
349 | + I18N::translate('If you didn’t request an account, you can just delete this message.') . Mail::EOL; |
|
350 | + $mail2_subject = /* I18N: %s is a server name/URL */ I18N::translate('Your registration at %s', WT_BASE_URL); |
|
351 | + $mail2_to = $user->getEmail(); |
|
352 | + $mail2_from = $WT_TREE->getPreference('WEBTREES_EMAIL'); |
|
353 | + |
|
354 | + // Send user message by email only |
|
355 | + Mail::send( |
|
356 | + // “From:” header |
|
357 | + $WT_TREE, |
|
358 | + // “To:” header |
|
359 | + $mail2_to, |
|
360 | + $mail2_to, |
|
361 | + // “Reply-To:” header |
|
362 | + $mail2_from, |
|
363 | + $mail2_from, |
|
364 | + // Message body |
|
365 | + $mail2_subject, |
|
366 | + $mail2_body |
|
367 | + ); |
|
368 | + |
|
369 | + // Send admin message by email and/or internal messaging |
|
370 | + Mail::send( |
|
371 | + // “From:” header |
|
372 | + $WT_TREE, |
|
373 | + // “To:” header |
|
374 | + $webmaster->getEmail(), |
|
375 | + $webmaster->getRealName(), |
|
376 | + // “Reply-To:” header |
|
377 | + $user->getEmail(), |
|
378 | + $user->getRealName(), |
|
379 | + // Message body |
|
380 | + $mail1_subject, |
|
381 | + $mail1_body |
|
382 | + ); |
|
383 | + $mail1_method = $webmaster->getPreference('contact_method'); |
|
384 | + if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') { |
|
385 | + Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)") |
|
386 | + ->execute(array($user->getEmail(), WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body))); |
|
387 | + } |
|
388 | + |
|
389 | + echo '<div class="confirm"><p>', I18N::translate('Hello %s…<br>Thank you for your registration.', $user->getRealNameHtml()), '</p>'; |
|
390 | + echo '<p>', I18N::translate('We will now send a confirmation email to the address <b>%s</b>. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.<br><br>After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.<br><br>To sign in to this website, you will need to know your username and password.', $user->getEmail()), '</p>'; |
|
391 | + echo '</div>'; |
|
392 | + echo '</div>'; |
|
393 | + |
|
394 | + return; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + Session::put('good_to_send', true); |
|
399 | + $controller |
|
400 | + ->pageHeader() |
|
401 | + ->addInlineJavascript('function regex_quote(str) {return str.replace(/[\\\\.?+*()[\](){}|]/g, "\\\\$&");}'); |
|
402 | + |
|
403 | + ?> |
|
404 | 404 | <div id="login-register-page"> |
405 | 405 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
406 | 406 | |
407 | 407 | <?php if (Site::getPreference('SHOW_REGISTER_CAUTION')): ?> |
408 | - <div id="register-text"> |
|
408 | + <div id="register-text"> |
|
409 | 409 | <?php echo I18N::translate('<div class="largeError">Notice:</div><div class="error">By completing and submitting this form, you agree:<ul><li>to protect the privacy of living individuals listed on our site;</li><li>and in the text box below, to explain to whom you are related, or to provide us with information on someone who should be listed on our website.</li></ul></div>'); ?> |
410 | - </div> |
|
410 | + </div> |
|
411 | 411 | <?php endif; ?> |
412 | 412 | <div id="register-box"> |
413 | 413 | <form id="register-form" name="register-form" method="post" onsubmit="return checkform(this);" autocomplete="off"> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | <div> |
419 | 419 | <label for="user_realname"> |
420 | 420 | <?php echo I18N::translate('Real name'); ?> |
421 | - <input type="text" id="user_realname" name="user_realname" required maxlength="64" value="<?php echo Filter::escapeHtml($user_realname); ?>" autofocus> |
|
421 | + <input type="text" id="user_realname" name="user_realname" required maxlength="64" value="<?php echo Filter::escapeHtml($user_realname); ?>" autofocus> |
|
422 | 422 | </label> |
423 | 423 | <p class="small text-muted"> |
424 | 424 | <?php echo I18N::translate('This is your real name, as you would like it displayed on screen.'); ?> |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | <div> |
429 | 429 | <label for="user_email"> |
430 | 430 | <?php echo I18N::translate('Email address'); ?> |
431 | - <input type="email" id="user_email" name="user_email" required maxlength="64" value="<?php echo Filter::escapeHtml($user_email); ?>"> |
|
431 | + <input type="email" id="user_email" name="user_email" required maxlength="64" value="<?php echo Filter::escapeHtml($user_email); ?>"> |
|
432 | 432 | </label> |
433 | 433 | <p class="small text-muted"> |
434 | 434 | <?php echo I18N::translate('This email address will be used to send password reminders, website notifications, and messages from other family members who are registered on the website.'); ?> |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | <div> |
439 | 439 | <label for="username"> |
440 | 440 | <?php echo I18N::translate('Username'); ?> |
441 | - <input type="text" id="username" name="user_name" required maxlength="32" value="<?php Filter::escapeHtml($user_name); ?>"> |
|
441 | + <input type="text" id="username" name="user_name" required maxlength="32" value="<?php Filter::escapeHtml($user_name); ?>"> |
|
442 | 442 | </label> |
443 | 443 | <p class="small text-muted"> |
444 | 444 | <?php echo I18N::translate('Usernames are case-insensitive and ignore accented letters, so that “chloe”, “chloë”, and “Chloe” are considered to be the same.'); ?> |
@@ -501,24 +501,24 @@ discard block |
||
501 | 501 | </div> |
502 | 502 | </div> |
503 | 503 | <?php |
504 | - break; |
|
504 | + break; |
|
505 | 505 | |
506 | -case 'userverify': |
|
507 | - if (!Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
508 | - header('Location: ' . WT_BASE_URL); |
|
506 | + case 'userverify': |
|
507 | + if (!Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
508 | + header('Location: ' . WT_BASE_URL); |
|
509 | 509 | |
510 | - return; |
|
511 | - } |
|
510 | + return; |
|
511 | + } |
|
512 | 512 | |
513 | - // Change to the new user’s language |
|
514 | - $user = User::findByUserName($user_name); |
|
513 | + // Change to the new user’s language |
|
514 | + $user = User::findByUserName($user_name); |
|
515 | 515 | |
516 | - I18N::init($user->getPreference('language')); |
|
516 | + I18N::init($user->getPreference('language')); |
|
517 | 517 | |
518 | - $controller->setPageTitle(I18N::translate('User verification')); |
|
519 | - $controller->pageHeader(); |
|
518 | + $controller->setPageTitle(I18N::translate('User verification')); |
|
519 | + $controller->pageHeader(); |
|
520 | 520 | |
521 | - echo '<div id="login-register-page"> |
|
521 | + echo '<div id="login-register-page"> |
|
522 | 522 | <form id="verify-form" name="verify-form" method="post" action="', WT_LOGIN_URL, '"> |
523 | 523 | <input type="hidden" name="action" value="verify_hash"> |
524 | 524 | <h4>', I18N::translate('User verification'), '</h4> |
@@ -539,87 +539,87 @@ discard block |
||
539 | 539 | </div> |
540 | 540 | </form> |
541 | 541 | </div>'; |
542 | - break; |
|
543 | - |
|
544 | -case 'verify_hash': |
|
545 | - if (!Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
546 | - header('Location: ' . WT_BASE_URL); |
|
547 | - |
|
548 | - return; |
|
549 | - } |
|
550 | - |
|
551 | - // switch language to webmaster settings |
|
552 | - $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')); |
|
553 | - I18N::init($webmaster->getPreference('language')); |
|
554 | - |
|
555 | - $user = User::findByUserName($user_name); |
|
556 | - $edit_user_url = WT_BASE_URL . "admin_users.php?action=edit&user_id=" . $user->getUserId(); |
|
557 | - $mail1_body = |
|
558 | - I18N::translate('Hello administrator…') . |
|
559 | - Mail::EOL . Mail::EOL . |
|
560 | - /* I18N: %1$s is a real-name, %2$s is a username, %3$s is an email address */ I18N::translate( |
|
561 | - 'A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', |
|
562 | - $user->getRealNameHtml(), |
|
563 | - Filter::escapeHtml($user->getUserName()), |
|
564 | - Filter::escapeHtml($user->getEmail()) |
|
565 | - ) . |
|
566 | - Mail::EOL . Mail::EOL . |
|
567 | - I18N::translate('You need to review the account details.') . |
|
568 | - Mail::EOL . Mail::EOL . |
|
569 | - '<a href="' . $edit_user_url . '">' . $edit_user_url . '</a>' . |
|
570 | - Mail::EOL . Mail::EOL . |
|
571 | - /* I18N: You need to: */ I18N::translate('Set the status to “approved”.') . |
|
572 | - Mail::EOL . |
|
573 | - /* I18N: You need to: */ I18N::translate('Set the access level for each tree.') . |
|
574 | - Mail::EOL . |
|
575 | - /* I18N: You need to: */ I18N::translate('Link the user account to an individual.'); |
|
576 | - |
|
577 | - $mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New user at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle()); |
|
578 | - |
|
579 | - // Change to the new user’s language |
|
580 | - I18N::init($user->getPreference('language')); |
|
581 | - |
|
582 | - $controller->setPageTitle(I18N::translate('User verification')); |
|
583 | - $controller->pageHeader(); |
|
584 | - |
|
585 | - echo '<div id="login-register-page">'; |
|
586 | - echo '<h2>' . I18N::translate('User verification') . '</h2>'; |
|
587 | - echo '<div id="user-verify">'; |
|
588 | - if ($user && $user->checkPassword($user_password) && $user->getPreference('reg_hashcode') === $user_hashcode) { |
|
589 | - Mail::send( |
|
590 | - // “From:” header |
|
591 | - $WT_TREE, |
|
592 | - // “To:” header |
|
593 | - $webmaster->getEmail(), |
|
594 | - $webmaster->getRealName(), |
|
595 | - // “Reply-To:” header |
|
596 | - $WT_TREE->getPreference('WEBTREES_EMAIL'), |
|
597 | - $WT_TREE->getPreference('WEBTREES_EMAIL'), |
|
598 | - // Message body |
|
599 | - $mail1_subject, |
|
600 | - $mail1_body |
|
601 | - ); |
|
602 | - $mail1_method = $webmaster->getPreference('CONTACT_METHOD'); |
|
603 | - if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') { |
|
604 | - Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)") |
|
605 | - ->execute(array($user_name, WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body))); |
|
606 | - } |
|
607 | - |
|
608 | - $user |
|
609 | - ->setPreference('verified', '1') |
|
610 | - ->setPreference('reg_timestamp', date('U')) |
|
611 | - ->deletePreference('reg_hashcode'); |
|
612 | - |
|
613 | - Log::addAuthenticationLog('User ' . $user_name . ' verified their email address'); |
|
614 | - |
|
615 | - echo '<p>', I18N::translate('You have confirmed your request to become a registered user.'), '</p>'; |
|
616 | - echo '<p>', I18N::translate('The administrator has been informed. As soon as they give you permission to sign in, you can sign in with your username and password.'), '</p>'; |
|
617 | - } else { |
|
618 | - echo '<p class="warning">'; |
|
619 | - echo I18N::translate('Could not verify the information you entered. Please try again or contact the site administrator for more information.'); |
|
620 | - echo '</p>'; |
|
621 | - } |
|
622 | - echo '</div>'; |
|
623 | - echo '</div>'; |
|
624 | - break; |
|
542 | + break; |
|
543 | + |
|
544 | + case 'verify_hash': |
|
545 | + if (!Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
546 | + header('Location: ' . WT_BASE_URL); |
|
547 | + |
|
548 | + return; |
|
549 | + } |
|
550 | + |
|
551 | + // switch language to webmaster settings |
|
552 | + $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID')); |
|
553 | + I18N::init($webmaster->getPreference('language')); |
|
554 | + |
|
555 | + $user = User::findByUserName($user_name); |
|
556 | + $edit_user_url = WT_BASE_URL . "admin_users.php?action=edit&user_id=" . $user->getUserId(); |
|
557 | + $mail1_body = |
|
558 | + I18N::translate('Hello administrator…') . |
|
559 | + Mail::EOL . Mail::EOL . |
|
560 | + /* I18N: %1$s is a real-name, %2$s is a username, %3$s is an email address */ I18N::translate( |
|
561 | + 'A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', |
|
562 | + $user->getRealNameHtml(), |
|
563 | + Filter::escapeHtml($user->getUserName()), |
|
564 | + Filter::escapeHtml($user->getEmail()) |
|
565 | + ) . |
|
566 | + Mail::EOL . Mail::EOL . |
|
567 | + I18N::translate('You need to review the account details.') . |
|
568 | + Mail::EOL . Mail::EOL . |
|
569 | + '<a href="' . $edit_user_url . '">' . $edit_user_url . '</a>' . |
|
570 | + Mail::EOL . Mail::EOL . |
|
571 | + /* I18N: You need to: */ I18N::translate('Set the status to “approved”.') . |
|
572 | + Mail::EOL . |
|
573 | + /* I18N: You need to: */ I18N::translate('Set the access level for each tree.') . |
|
574 | + Mail::EOL . |
|
575 | + /* I18N: You need to: */ I18N::translate('Link the user account to an individual.'); |
|
576 | + |
|
577 | + $mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New user at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle()); |
|
578 | + |
|
579 | + // Change to the new user’s language |
|
580 | + I18N::init($user->getPreference('language')); |
|
581 | + |
|
582 | + $controller->setPageTitle(I18N::translate('User verification')); |
|
583 | + $controller->pageHeader(); |
|
584 | + |
|
585 | + echo '<div id="login-register-page">'; |
|
586 | + echo '<h2>' . I18N::translate('User verification') . '</h2>'; |
|
587 | + echo '<div id="user-verify">'; |
|
588 | + if ($user && $user->checkPassword($user_password) && $user->getPreference('reg_hashcode') === $user_hashcode) { |
|
589 | + Mail::send( |
|
590 | + // “From:” header |
|
591 | + $WT_TREE, |
|
592 | + // “To:” header |
|
593 | + $webmaster->getEmail(), |
|
594 | + $webmaster->getRealName(), |
|
595 | + // “Reply-To:” header |
|
596 | + $WT_TREE->getPreference('WEBTREES_EMAIL'), |
|
597 | + $WT_TREE->getPreference('WEBTREES_EMAIL'), |
|
598 | + // Message body |
|
599 | + $mail1_subject, |
|
600 | + $mail1_body |
|
601 | + ); |
|
602 | + $mail1_method = $webmaster->getPreference('CONTACT_METHOD'); |
|
603 | + if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') { |
|
604 | + Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)") |
|
605 | + ->execute(array($user_name, WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body))); |
|
606 | + } |
|
607 | + |
|
608 | + $user |
|
609 | + ->setPreference('verified', '1') |
|
610 | + ->setPreference('reg_timestamp', date('U')) |
|
611 | + ->deletePreference('reg_hashcode'); |
|
612 | + |
|
613 | + Log::addAuthenticationLog('User ' . $user_name . ' verified their email address'); |
|
614 | + |
|
615 | + echo '<p>', I18N::translate('You have confirmed your request to become a registered user.'), '</p>'; |
|
616 | + echo '<p>', I18N::translate('The administrator has been informed. As soon as they give you permission to sign in, you can sign in with your username and password.'), '</p>'; |
|
617 | + } else { |
|
618 | + echo '<p class="warning">'; |
|
619 | + echo I18N::translate('Could not verify the information you entered. Please try again or contact the site administrator for more information.'); |
|
620 | + echo '</p>'; |
|
621 | + } |
|
622 | + echo '</div>'; |
|
623 | + echo '</div>'; |
|
624 | + break; |
|
625 | 625 | } |
@@ -43,38 +43,38 @@ |
||
43 | 43 | |
44 | 44 | foreach ($facts as $fact) { |
45 | 45 | switch ($fact->getTag()) { |
46 | - case 'ADDR': |
|
47 | - case 'ALIA': |
|
48 | - case 'ASSO': |
|
49 | - case 'CHAN': |
|
50 | - case 'CHIL': |
|
51 | - case 'EMAIL': |
|
52 | - case 'FAMC': |
|
53 | - case 'FAMS': |
|
54 | - case 'HUSB': |
|
55 | - case 'NAME': |
|
56 | - case 'NOTE': |
|
57 | - case 'OBJE': |
|
58 | - case 'PHON': |
|
59 | - case 'RESI': |
|
60 | - case 'RESN': |
|
61 | - case 'SEX': |
|
62 | - case 'SOUR': |
|
63 | - case 'SSN': |
|
64 | - case 'SUBM': |
|
65 | - case 'TITL': |
|
66 | - case 'URL': |
|
67 | - case 'WIFE': |
|
68 | - case 'WWW': |
|
69 | - case '_EMAIL': |
|
70 | - case '_TODO': |
|
71 | - case '_UID': |
|
72 | - case '_WT_OBJE_SORT': |
|
73 | - // Do not show these |
|
74 | - break; |
|
75 | - default: |
|
76 | - // Simple version of FunctionsPrintFacts::print_fact() |
|
77 | - echo $fact->summary(); |
|
78 | - break; |
|
46 | + case 'ADDR': |
|
47 | + case 'ALIA': |
|
48 | + case 'ASSO': |
|
49 | + case 'CHAN': |
|
50 | + case 'CHIL': |
|
51 | + case 'EMAIL': |
|
52 | + case 'FAMC': |
|
53 | + case 'FAMS': |
|
54 | + case 'HUSB': |
|
55 | + case 'NAME': |
|
56 | + case 'NOTE': |
|
57 | + case 'OBJE': |
|
58 | + case 'PHON': |
|
59 | + case 'RESI': |
|
60 | + case 'RESN': |
|
61 | + case 'SEX': |
|
62 | + case 'SOUR': |
|
63 | + case 'SSN': |
|
64 | + case 'SUBM': |
|
65 | + case 'TITL': |
|
66 | + case 'URL': |
|
67 | + case 'WIFE': |
|
68 | + case 'WWW': |
|
69 | + case '_EMAIL': |
|
70 | + case '_TODO': |
|
71 | + case '_UID': |
|
72 | + case '_WT_OBJE_SORT': |
|
73 | + // Do not show these |
|
74 | + break; |
|
75 | + default: |
|
76 | + // Simple version of FunctionsPrintFacts::print_fact() |
|
77 | + echo $fact->summary(); |
|
78 | + break; |
|
79 | 79 | } |
80 | 80 | } |
@@ -49,72 +49,72 @@ discard block |
||
49 | 49 | echo '<div id="pending"><h2>', I18N::translate('Pending changes'), '</h2>'; |
50 | 50 | |
51 | 51 | switch ($action) { |
52 | -case 'undo': |
|
53 | - $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
54 | - $xref = Database::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
55 | - // Undo a change, and subsequent changes to the same record |
|
56 | - Database::prepare( |
|
57 | - "UPDATE `##change`" . |
|
58 | - " SET status = 'rejected'" . |
|
59 | - " WHERE status = 'pending'" . |
|
60 | - " AND gedcom_id = ?" . |
|
61 | - " AND xref = ?" . |
|
62 | - " AND change_id >= ?" |
|
63 | - )->execute(array($gedcom_id, $xref, $change_id)); |
|
64 | - break; |
|
65 | -case 'accept': |
|
66 | - $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
67 | - $xref = Database::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
68 | - // Accept a change, and all previous changes to the same record |
|
69 | - $changes = Database::prepare( |
|
70 | - "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" . |
|
71 | - " FROM `##change` c" . |
|
72 | - " JOIN `##gedcom` g USING (gedcom_id)" . |
|
73 | - " WHERE c.status = 'pending'" . |
|
74 | - " AND gedcom_id = ?" . |
|
75 | - " AND xref = ?" . |
|
76 | - " AND change_id <= ?" . |
|
77 | - " ORDER BY change_id" |
|
78 | - )->execute(array($gedcom_id, $xref, $change_id))->fetchAll(); |
|
79 | - foreach ($changes as $change) { |
|
80 | - if (empty($change->new_gedcom)) { |
|
81 | - // delete |
|
82 | - FunctionsImport::updateRecord($change->old_gedcom, $gedcom_id, true); |
|
83 | - } else { |
|
84 | - // add/update |
|
85 | - FunctionsImport::updateRecord($change->new_gedcom, $gedcom_id, false); |
|
86 | - } |
|
87 | - Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); |
|
88 | - Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database"); |
|
89 | - } |
|
90 | - break; |
|
91 | -case 'undoall': |
|
92 | - Database::prepare( |
|
93 | - "UPDATE `##change`" . |
|
94 | - " SET status='rejected'" . |
|
95 | - " WHERE status='pending' AND gedcom_id=?" |
|
96 | - )->execute(array($WT_TREE->getTreeId())); |
|
97 | - break; |
|
98 | -case 'acceptall': |
|
99 | - $changes = Database::prepare( |
|
100 | - "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" . |
|
101 | - " FROM `##change` c" . |
|
102 | - " JOIN `##gedcom` g USING (gedcom_id)" . |
|
103 | - " WHERE c.status='pending' AND gedcom_id=?" . |
|
104 | - " ORDER BY change_id" |
|
105 | - )->execute(array($WT_TREE->getTreeId()))->fetchAll(); |
|
106 | - foreach ($changes as $change) { |
|
107 | - if (empty($change->new_gedcom)) { |
|
108 | - // delete |
|
109 | - FunctionsImport::updateRecord($change->old_gedcom, $change->gedcom_id, true); |
|
110 | - } else { |
|
111 | - // add/update |
|
112 | - FunctionsImport::updateRecord($change->new_gedcom, $change->gedcom_id, false); |
|
113 | - } |
|
114 | - Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); |
|
115 | - Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database"); |
|
116 | - } |
|
117 | - break; |
|
52 | + case 'undo': |
|
53 | + $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
54 | + $xref = Database::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
55 | + // Undo a change, and subsequent changes to the same record |
|
56 | + Database::prepare( |
|
57 | + "UPDATE `##change`" . |
|
58 | + " SET status = 'rejected'" . |
|
59 | + " WHERE status = 'pending'" . |
|
60 | + " AND gedcom_id = ?" . |
|
61 | + " AND xref = ?" . |
|
62 | + " AND change_id >= ?" |
|
63 | + )->execute(array($gedcom_id, $xref, $change_id)); |
|
64 | + break; |
|
65 | + case 'accept': |
|
66 | + $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
67 | + $xref = Database::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); |
|
68 | + // Accept a change, and all previous changes to the same record |
|
69 | + $changes = Database::prepare( |
|
70 | + "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" . |
|
71 | + " FROM `##change` c" . |
|
72 | + " JOIN `##gedcom` g USING (gedcom_id)" . |
|
73 | + " WHERE c.status = 'pending'" . |
|
74 | + " AND gedcom_id = ?" . |
|
75 | + " AND xref = ?" . |
|
76 | + " AND change_id <= ?" . |
|
77 | + " ORDER BY change_id" |
|
78 | + )->execute(array($gedcom_id, $xref, $change_id))->fetchAll(); |
|
79 | + foreach ($changes as $change) { |
|
80 | + if (empty($change->new_gedcom)) { |
|
81 | + // delete |
|
82 | + FunctionsImport::updateRecord($change->old_gedcom, $gedcom_id, true); |
|
83 | + } else { |
|
84 | + // add/update |
|
85 | + FunctionsImport::updateRecord($change->new_gedcom, $gedcom_id, false); |
|
86 | + } |
|
87 | + Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); |
|
88 | + Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database"); |
|
89 | + } |
|
90 | + break; |
|
91 | + case 'undoall': |
|
92 | + Database::prepare( |
|
93 | + "UPDATE `##change`" . |
|
94 | + " SET status='rejected'" . |
|
95 | + " WHERE status='pending' AND gedcom_id=?" |
|
96 | + )->execute(array($WT_TREE->getTreeId())); |
|
97 | + break; |
|
98 | + case 'acceptall': |
|
99 | + $changes = Database::prepare( |
|
100 | + "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" . |
|
101 | + " FROM `##change` c" . |
|
102 | + " JOIN `##gedcom` g USING (gedcom_id)" . |
|
103 | + " WHERE c.status='pending' AND gedcom_id=?" . |
|
104 | + " ORDER BY change_id" |
|
105 | + )->execute(array($WT_TREE->getTreeId()))->fetchAll(); |
|
106 | + foreach ($changes as $change) { |
|
107 | + if (empty($change->new_gedcom)) { |
|
108 | + // delete |
|
109 | + FunctionsImport::updateRecord($change->old_gedcom, $change->gedcom_id, true); |
|
110 | + } else { |
|
111 | + // add/update |
|
112 | + FunctionsImport::updateRecord($change->new_gedcom, $change->gedcom_id, false); |
|
113 | + } |
|
114 | + Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); |
|
115 | + Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database"); |
|
116 | + } |
|
117 | + break; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $changed_gedcoms = Database::prepare( |
@@ -146,27 +146,27 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 148 | switch ($match[1]) { |
149 | - case 'INDI': |
|
150 | - $record = new Individual($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
151 | - break; |
|
152 | - case 'FAM': |
|
153 | - $record = new Family($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
154 | - break; |
|
155 | - case 'SOUR': |
|
156 | - $record = new Source($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
157 | - break; |
|
158 | - case 'REPO': |
|
159 | - $record = new Repository($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
160 | - break; |
|
161 | - case 'OBJE': |
|
162 | - $record = new Media($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
163 | - break; |
|
164 | - case 'NOTE': |
|
165 | - $record = new Note($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
166 | - break; |
|
167 | - default: |
|
168 | - $record = new GedcomRecord($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
169 | - break; |
|
149 | + case 'INDI': |
|
150 | + $record = new Individual($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
151 | + break; |
|
152 | + case 'FAM': |
|
153 | + $record = new Family($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
154 | + break; |
|
155 | + case 'SOUR': |
|
156 | + $record = new Source($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
157 | + break; |
|
158 | + case 'REPO': |
|
159 | + $record = new Repository($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
160 | + break; |
|
161 | + case 'OBJE': |
|
162 | + $record = new Media($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
163 | + break; |
|
164 | + case 'NOTE': |
|
165 | + $record = new Note($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
166 | + break; |
|
167 | + default: |
|
168 | + $record = new GedcomRecord($change->xref, $change->old_gedcom, $change->new_gedcom, $tree); |
|
169 | + break; |
|
170 | 170 | } |
171 | 171 | if ($change->xref != $prev_xref || $change->gedcom_id != $prev_gedcom_id) { |
172 | 172 | if ($prev_xref) { |
@@ -137,12 +137,12 @@ |
||
137 | 137 | // Datatables numbers columns 0, 1, 2 |
138 | 138 | // MySQL numbers columns 1, 2, 3 |
139 | 139 | switch ($value['dir']) { |
140 | - case 'asc': |
|
141 | - $order_by .= (1 + $value['column']) . " ASC "; |
|
142 | - break; |
|
143 | - case 'desc': |
|
144 | - $order_by .= (1 + $value['column']) . " DESC "; |
|
145 | - break; |
|
140 | + case 'asc': |
|
141 | + $order_by .= (1 + $value['column']) . " ASC "; |
|
142 | + break; |
|
143 | + case 'desc': |
|
144 | + $order_by .= (1 + $value['column']) . " DESC "; |
|
145 | + break; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } else { |
@@ -278,40 +278,40 @@ discard block |
||
278 | 278 | |
279 | 279 | $level1type = $edit_fact->getTag(); |
280 | 280 | switch ($record::RECORD_TYPE) { |
281 | - case 'REPO': |
|
282 | - // REPO:NAME facts may take a NOTE (but the REPO record may not). |
|
283 | - if ($level1type === 'NAME') { |
|
284 | - FunctionsEdit::printAddLayer('NOTE'); |
|
285 | - FunctionsEdit::printAddLayer('SHARED_NOTE'); |
|
286 | - } |
|
287 | - break; |
|
288 | - case 'FAM': |
|
289 | - case 'INDI': |
|
290 | - // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc. |
|
291 | - if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') { |
|
292 | - if ($level1type !== 'SOUR') { |
|
293 | - FunctionsEdit::printAddLayer('SOUR'); |
|
294 | - } |
|
295 | - if ($level1type !== 'OBJE') { |
|
296 | - FunctionsEdit::printAddLayer('OBJE'); |
|
297 | - } |
|
298 | - FunctionsEdit::printAddLayer('NOTE'); |
|
299 | - FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type); |
|
300 | - if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') { |
|
301 | - FunctionsEdit::printAddLayer('ASSO'); |
|
302 | - } |
|
303 | - // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
304 | - if (in_array($level1type, Config::twoAssociates())) { |
|
305 | - FunctionsEdit::printAddLayer('ASSO2'); |
|
306 | - } |
|
307 | - if ($level1type !== 'SOUR') { |
|
308 | - FunctionsEdit::printAddLayer('RESN'); |
|
309 | - } |
|
310 | - } |
|
311 | - break; |
|
312 | - default: |
|
313 | - // Other types of record do not have these lower-level records |
|
314 | - break; |
|
281 | + case 'REPO': |
|
282 | + // REPO:NAME facts may take a NOTE (but the REPO record may not). |
|
283 | + if ($level1type === 'NAME') { |
|
284 | + FunctionsEdit::printAddLayer('NOTE'); |
|
285 | + FunctionsEdit::printAddLayer('SHARED_NOTE'); |
|
286 | + } |
|
287 | + break; |
|
288 | + case 'FAM': |
|
289 | + case 'INDI': |
|
290 | + // FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc. |
|
291 | + if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') { |
|
292 | + if ($level1type !== 'SOUR') { |
|
293 | + FunctionsEdit::printAddLayer('SOUR'); |
|
294 | + } |
|
295 | + if ($level1type !== 'OBJE') { |
|
296 | + FunctionsEdit::printAddLayer('OBJE'); |
|
297 | + } |
|
298 | + FunctionsEdit::printAddLayer('NOTE'); |
|
299 | + FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type); |
|
300 | + if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') { |
|
301 | + FunctionsEdit::printAddLayer('ASSO'); |
|
302 | + } |
|
303 | + // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
304 | + if (in_array($level1type, Config::twoAssociates())) { |
|
305 | + FunctionsEdit::printAddLayer('ASSO2'); |
|
306 | + } |
|
307 | + if ($level1type !== 'SOUR') { |
|
308 | + FunctionsEdit::printAddLayer('RESN'); |
|
309 | + } |
|
310 | + } |
|
311 | + break; |
|
312 | + default: |
|
313 | + // Other types of record do not have these lower-level records |
|
314 | + break; |
|
315 | 315 | } |
316 | 316 | if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) { |
317 | 317 | echo |
@@ -1905,9 +1905,9 @@ discard block |
||
1905 | 1905 | <b> |
1906 | 1906 | <?php |
1907 | 1907 | switch ($father->getSex()) { |
1908 | - case 'M': echo I18N::translate('husband'); break; |
|
1909 | - case 'F': echo I18N::translate('wife'); break; |
|
1910 | - default: echo I18N::translate('spouse'); break; |
|
1908 | + case 'M': echo I18N::translate('husband'); break; |
|
1909 | + case 'F': echo I18N::translate('wife'); break; |
|
1910 | + default: echo I18N::translate('spouse'); break; |
|
1911 | 1911 | } |
1912 | 1912 | ?> |
1913 | 1913 | </b> |
@@ -1940,9 +1940,9 @@ discard block |
||
1940 | 1940 | <b> |
1941 | 1941 | <?php |
1942 | 1942 | switch ($mother->getSex()) { |
1943 | - case 'M': echo I18N::translate('husband'); break; |
|
1944 | - case 'F': echo I18N::translate('wife'); break; |
|
1945 | - default: echo I18N::translate('spouse'); break; |
|
1943 | + case 'M': echo I18N::translate('husband'); break; |
|
1944 | + case 'F': echo I18N::translate('wife'); break; |
|
1945 | + default: echo I18N::translate('spouse'); break; |
|
1946 | 1946 | } |
1947 | 1947 | ?> |
1948 | 1948 | </b> |
@@ -1976,9 +1976,9 @@ discard block |
||
1976 | 1976 | <b> |
1977 | 1977 | <?php |
1978 | 1978 | switch ($child->getSex()) { |
1979 | - case 'M': echo I18N::translate('son'); break; |
|
1980 | - case 'F': echo I18N::translate('daughter'); break; |
|
1981 | - default: echo I18N::translate('child'); break; |
|
1979 | + case 'M': echo I18N::translate('son'); break; |
|
1980 | + case 'F': echo I18N::translate('daughter'); break; |
|
1981 | + default: echo I18N::translate('child'); break; |
|
1982 | 1982 | } |
1983 | 1983 | ?> |
1984 | 1984 | </b> |
@@ -2354,35 +2354,35 @@ discard block |
||
2354 | 2354 | } |
2355 | 2355 | |
2356 | 2356 | switch ($nextaction) { |
2357 | - case 'add_child_to_family_action': |
|
2358 | - $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender)); |
|
2359 | - break; |
|
2360 | - case 'add_child_to_individual_action': |
|
2361 | - if ($person->getSex() === 'F') { |
|
2362 | - $name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender)); |
|
2363 | - } else { |
|
2364 | - $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender)); |
|
2365 | - } |
|
2366 | - break; |
|
2367 | - case 'add_parent_to_individual_action': |
|
2368 | - $name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender)); |
|
2369 | - break; |
|
2370 | - case 'add_spouse_to_family_action': |
|
2371 | - if ($father) { |
|
2372 | - $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender)); |
|
2373 | - } else { |
|
2374 | - $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender)); |
|
2375 | - } |
|
2376 | - break; |
|
2377 | - case 'add_spouse_to_individual_action': |
|
2378 | - $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender)); |
|
2379 | - break; |
|
2380 | - case 'add_unlinked_indi_action': |
|
2381 | - case 'update': |
|
2382 | - if ($surname_tradition->hasSurnames()) { |
|
2383 | - $name_fields['NAME'] = '//'; |
|
2384 | - } |
|
2385 | - break; |
|
2357 | + case 'add_child_to_family_action': |
|
2358 | + $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender)); |
|
2359 | + break; |
|
2360 | + case 'add_child_to_individual_action': |
|
2361 | + if ($person->getSex() === 'F') { |
|
2362 | + $name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender)); |
|
2363 | + } else { |
|
2364 | + $name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender)); |
|
2365 | + } |
|
2366 | + break; |
|
2367 | + case 'add_parent_to_individual_action': |
|
2368 | + $name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender)); |
|
2369 | + break; |
|
2370 | + case 'add_spouse_to_family_action': |
|
2371 | + if ($father) { |
|
2372 | + $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender)); |
|
2373 | + } else { |
|
2374 | + $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender)); |
|
2375 | + } |
|
2376 | + break; |
|
2377 | + case 'add_spouse_to_individual_action': |
|
2378 | + $name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender)); |
|
2379 | + break; |
|
2380 | + case 'add_unlinked_indi_action': |
|
2381 | + case 'update': |
|
2382 | + if ($surname_tradition->hasSurnames()) { |
|
2383 | + $name_fields['NAME'] = '//'; |
|
2384 | + } |
|
2385 | + break; |
|
2386 | 2386 | } |
2387 | 2387 | } |
2388 | 2388 | |
@@ -2403,15 +2403,15 @@ discard block |
||
2403 | 2403 | echo '<table class="facts_table">'; |
2404 | 2404 | |
2405 | 2405 | switch ($nextaction) { |
2406 | - case 'add_child_to_family_action': |
|
2407 | - case 'add_child_to_individual_action': |
|
2408 | - // When adding a new child, specify the pedigree |
|
2409 | - FunctionsEdit::addSimpleTag('0 PEDI'); |
|
2410 | - break; |
|
2411 | - case 'update': |
|
2412 | - // When adding/editing a name, specify the type |
|
2413 | - FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person); |
|
2414 | - break; |
|
2406 | + case 'add_child_to_family_action': |
|
2407 | + case 'add_child_to_individual_action': |
|
2408 | + // When adding a new child, specify the pedigree |
|
2409 | + FunctionsEdit::addSimpleTag('0 PEDI'); |
|
2410 | + break; |
|
2411 | + case 'update': |
|
2412 | + // When adding/editing a name, specify the type |
|
2413 | + FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person); |
|
2414 | + break; |
|
2415 | 2415 | } |
2416 | 2416 | |
2417 | 2417 | // First - new/existing standard name fields |