1 | Index: wp-includes/pluggable-functions.php |
---|
2 | =================================================================== |
---|
3 | --- wp-includes/pluggable-functions.php (revision 2552) |
---|
4 | +++ wp-includes/pluggable-functions.php (working copy) |
---|
5 | @@ -1,269 +1,269 @@ |
---|
6 | -<?php |
---|
7 | - |
---|
8 | - /* These functions can be replaced via plugins. They are loaded after |
---|
9 | - plugins are loaded. */ |
---|
10 | - |
---|
11 | - |
---|
12 | -if ( !function_exists('get_currentuserinfo') ) : |
---|
13 | -function get_currentuserinfo() { |
---|
14 | - global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $user_identity; |
---|
15 | - // *** retrieving user's data from cookies and db - no spoofing |
---|
16 | - |
---|
17 | - if (isset($_COOKIE['wordpressuser_' . COOKIEHASH])) |
---|
18 | - $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH]; |
---|
19 | - $userdata = get_userdatabylogin($user_login); |
---|
20 | - $user_level = $userdata->user_level; |
---|
21 | - $user_ID = $userdata->ID; |
---|
22 | - $user_nickname = $userdata->user_nickname; |
---|
23 | - $user_email = $userdata->user_email; |
---|
24 | - $user_url = $userdata->user_url; |
---|
25 | - $user_pass_md5 = md5($userdata->user_pass); |
---|
26 | - |
---|
27 | - $idmode = $userdata->user_idmode; |
---|
28 | - if ($idmode == 'nickname') $user_identity = $userdata->user_nickname; |
---|
29 | - if ($idmode == 'login') $user_identity = $userdata->user_login; |
---|
30 | - if ($idmode == 'firstname') $user_identity = $userdata->user_firstname; |
---|
31 | - if ($idmode == 'lastname') $user_identity = $userdata->user_lastname; |
---|
32 | - if ($idmode == 'namefl') $user_identity = $userdata->user_firstname.' '.$userdata->user_lastname; |
---|
33 | - if ($idmode == 'namelf') $user_identity = $userdata->user_lastname.' '.$userdata->user_firstname; |
---|
34 | - if (!$idmode) $user_identity = $userdata->user_nickname; |
---|
35 | -} |
---|
36 | -endif; |
---|
37 | - |
---|
38 | -if ( !function_exists('get_userdata') ) : |
---|
39 | -function get_userdata($userid) { |
---|
40 | - global $wpdb, $cache_userdata; |
---|
41 | - $userid = (int) $userid; |
---|
42 | - if ( empty($cache_userdata[$userid]) && $userid != 0) { |
---|
43 | - $cache_userdata[$userid] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $userid"); |
---|
44 | - $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$userid]; |
---|
45 | - } |
---|
46 | - |
---|
47 | - return $cache_userdata[$userid]; |
---|
48 | -} |
---|
49 | -endif; |
---|
50 | - |
---|
51 | -if ( !function_exists('get_userdatabylogin') ) : |
---|
52 | -function get_userdatabylogin($user_login) { |
---|
53 | - global $cache_userdata, $wpdb; |
---|
54 | - if ( !empty($user_login) && empty($cache_userdata[$user_login]) ) { |
---|
55 | - $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'"); /* todo: get rid of this intermediate var */ |
---|
56 | - $cache_userdata[$user->ID] = $user; |
---|
57 | - $cache_userdata[$user_login] =& $cache_userdata[$user->ID]; |
---|
58 | - } else { |
---|
59 | - $user = $cache_userdata[$user_login]; |
---|
60 | - } |
---|
61 | - return $user; |
---|
62 | -} |
---|
63 | -endif; |
---|
64 | - |
---|
65 | -if ( !function_exists('wp_mail') ) : |
---|
66 | -function wp_mail($to, $subject, $message, $headers = '') { |
---|
67 | - if( $headers == '' ) { |
---|
68 | - $headers = "MIME-Version: 1.0\r\n" . |
---|
69 | - "From: " . get_settings('admin_email') . "\r\n" . |
---|
70 | - "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; |
---|
71 | - } |
---|
72 | - |
---|
73 | - return @mail($to, $subject, $message, $headers); |
---|
74 | -} |
---|
75 | -endif; |
---|
76 | - |
---|
77 | -if ( !function_exists('wp_login') ) : |
---|
78 | -function wp_login($username, $password, $already_md5 = false) { |
---|
79 | - global $wpdb, $error; |
---|
80 | - |
---|
81 | - if ( !$username ) |
---|
82 | - return false; |
---|
83 | - |
---|
84 | - if ( !$password ) { |
---|
85 | - $error = __('<strong>Error</strong>: The password field is empty.'); |
---|
86 | - return false; |
---|
87 | - } |
---|
88 | - |
---|
89 | - $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); |
---|
90 | - |
---|
91 | - if (!$login) { |
---|
92 | - $error = __('<strong>Error</strong>: Wrong username.'); |
---|
93 | - return false; |
---|
94 | - } else { |
---|
95 | - // If the password is already_md5, it has been double hashed. |
---|
96 | - // Otherwise, it is plain text. |
---|
97 | - if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { |
---|
98 | - return true; |
---|
99 | - } else { |
---|
100 | - $error = __('<strong>Error</strong>: Incorrect password.'); |
---|
101 | - $pwd = ''; |
---|
102 | - return false; |
---|
103 | - } |
---|
104 | - } |
---|
105 | -} |
---|
106 | -endif; |
---|
107 | - |
---|
108 | -if ( !function_exists('auth_redirect') ) : |
---|
109 | -function auth_redirect() { |
---|
110 | - // Checks if a user is logged in, if not redirects them to the login page |
---|
111 | - if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && |
---|
112 | - !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) || |
---|
113 | - (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) { |
---|
114 | - header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); |
---|
115 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
---|
116 | - header('Cache-Control: no-cache, must-revalidate, max-age=0'); |
---|
117 | - header('Pragma: no-cache'); |
---|
118 | - |
---|
119 | - header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); |
---|
120 | - exit(); |
---|
121 | - } |
---|
122 | -} |
---|
123 | -endif; |
---|
124 | - |
---|
125 | -// Cookie safe redirect. Works around IIS Set-Cookie bug. |
---|
126 | -// http://support.microsoft.com/kb/q176113/ |
---|
127 | -if ( !function_exists('wp_redirect') ) : |
---|
128 | -function wp_redirect($location) { |
---|
129 | - global $is_IIS; |
---|
130 | - |
---|
131 | - if ($is_IIS) |
---|
132 | - header("Refresh: 0;url=$location"); |
---|
133 | - else |
---|
134 | - header("Location: $location"); |
---|
135 | -} |
---|
136 | -endif; |
---|
137 | - |
---|
138 | -if ( !function_exists('wp_setcookie') ) : |
---|
139 | -function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') { |
---|
140 | - if ( !$already_md5 ) |
---|
141 | - $password = md5( md5($password) ); // Double hash the password in the cookie. |
---|
142 | - |
---|
143 | - if ( empty($home) ) |
---|
144 | - $cookiepath = COOKIEPATH; |
---|
145 | - else |
---|
146 | - $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); |
---|
147 | - |
---|
148 | - if ( empty($siteurl) ) { |
---|
149 | - $sitecookiepath = SITECOOKIEPATH; |
---|
150 | - $cookiehash = COOKIEHASH; |
---|
151 | - } else { |
---|
152 | - $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); |
---|
153 | - $cookiehash = md5($siteurl); |
---|
154 | - } |
---|
155 | - |
---|
156 | - setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath); |
---|
157 | - setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath); |
---|
158 | - |
---|
159 | - if ( $cookiepath != $sitecookiepath ) { |
---|
160 | - setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath); |
---|
161 | - setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath); |
---|
162 | - } |
---|
163 | -} |
---|
164 | -endif; |
---|
165 | - |
---|
166 | -if ( !function_exists('wp_clearcookie') ) : |
---|
167 | -function wp_clearcookie() { |
---|
168 | - setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); |
---|
169 | - setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); |
---|
170 | - setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); |
---|
171 | - setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); |
---|
172 | -} |
---|
173 | -endif; |
---|
174 | - |
---|
175 | -if ( ! function_exists('wp_notify_postauthor') ) : |
---|
176 | -function wp_notify_postauthor($comment_id, $comment_type='') { |
---|
177 | - global $wpdb; |
---|
178 | - |
---|
179 | - $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); |
---|
180 | - $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); |
---|
181 | - $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1"); |
---|
182 | - |
---|
183 | - if ('' == $user->user_email) return false; // If there's no email to send the comment to |
---|
184 | - |
---|
185 | - $comment_author_domain = gethostbyaddr($comment->comment_author_IP); |
---|
186 | - |
---|
187 | - $blogname = get_settings('blogname'); |
---|
188 | - |
---|
189 | - if ( empty( $comment_type ) ) $comment_type = 'comment'; |
---|
190 | - |
---|
191 | - if ('comment' == $comment_type) { |
---|
192 | - $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
---|
193 | - $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
194 | - $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; |
---|
195 | - $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
196 | - $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
---|
197 | - $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
---|
198 | - $notify_message .= __('You can see all comments on this post here: ') . "\r\n"; |
---|
199 | - $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title ); |
---|
200 | - } elseif ('trackback' == $comment_type) { |
---|
201 | - $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
---|
202 | - $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
203 | - $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
204 | - $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
---|
205 | - $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; |
---|
206 | - $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); |
---|
207 | - } elseif ('pingback' == $comment_type) { |
---|
208 | - $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
---|
209 | - $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
210 | - $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
211 | - $notify_message .= __('Excerpt: ') . "\r\n" . sprintf( __('[...] %s [...]'), $comment->comment_content ) . "\r\n\r\n"; |
---|
212 | - $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; |
---|
213 | - $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); |
---|
214 | - } |
---|
215 | - $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; |
---|
216 | - $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
---|
217 | - |
---|
218 | - if ('' == $comment->comment_author_email || '' == $comment->comment_author) { |
---|
219 | - $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>'; |
---|
220 | - } else { |
---|
221 | - $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>"; |
---|
222 | - } |
---|
223 | - |
---|
224 | - $message_headers = "MIME-Version: 1.0\r\n" |
---|
225 | - . "$from\r\n" |
---|
226 | - . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; |
---|
227 | - |
---|
228 | - @wp_mail($user->user_email, $subject, $notify_message, $message_headers); |
---|
229 | - |
---|
230 | - return true; |
---|
231 | -} |
---|
232 | -endif; |
---|
233 | - |
---|
234 | -/* wp_notify_moderator |
---|
235 | - notifies the moderator of the blog (usually the admin) |
---|
236 | - about a new comment that waits for approval |
---|
237 | - always returns true |
---|
238 | - */ |
---|
239 | -if ( !function_exists('wp_notify_moderator') ) : |
---|
240 | -function wp_notify_moderator($comment_id) { |
---|
241 | - global $wpdb; |
---|
242 | - |
---|
243 | - if( get_settings( "moderation_notify" ) == 0 ) |
---|
244 | - return true; |
---|
245 | - |
---|
246 | - $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); |
---|
247 | - $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); |
---|
248 | - $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1"); |
---|
249 | - |
---|
250 | - $comment_author_domain = gethostbyaddr($comment->comment_author_IP); |
---|
251 | - $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); |
---|
252 | - |
---|
253 | - $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; |
---|
254 | - $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; |
---|
255 | - $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
256 | - $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; |
---|
257 | - $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
258 | - $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
---|
259 | - $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
---|
260 | - $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
---|
261 | - $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
---|
262 | - $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n"; |
---|
263 | - $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n"; |
---|
264 | - |
---|
265 | - $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title ); |
---|
266 | - $admin_email = get_settings("admin_email"); |
---|
267 | - |
---|
268 | - @wp_mail($admin_email, $subject, $notify_message); |
---|
269 | - |
---|
270 | - return true; |
---|
271 | -} |
---|
272 | -endif; |
---|
273 | - |
---|
274 | -?> |
---|
275 | \ No newline at end of file |
---|
276 | +<?php |
---|
277 | + |
---|
278 | + /* These functions can be replaced via plugins. They are loaded after |
---|
279 | + plugins are loaded. */ |
---|
280 | + |
---|
281 | + |
---|
282 | +if ( !function_exists('get_currentuserinfo') ) : |
---|
283 | +function get_currentuserinfo() { |
---|
284 | + global $user_login, $userdata, $user_level, $user_ID, $user_nickname, $user_email, $user_url, $user_pass_md5, $user_identity; |
---|
285 | + // *** retrieving user's data from cookies and db - no spoofing |
---|
286 | + |
---|
287 | + if (isset($_COOKIE['wordpressuser_' . COOKIEHASH])) |
---|
288 | + $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH]; |
---|
289 | + $userdata = get_userdatabylogin($user_login); |
---|
290 | + $user_level = $userdata->user_level; |
---|
291 | + $user_ID = $userdata->ID; |
---|
292 | + $user_nickname = $userdata->user_nickname; |
---|
293 | + $user_email = $userdata->user_email; |
---|
294 | + $user_url = $userdata->user_url; |
---|
295 | + $user_pass_md5 = md5($userdata->user_pass); |
---|
296 | + |
---|
297 | + $idmode = $userdata->user_idmode; |
---|
298 | + if ($idmode == 'nickname') $user_identity = $userdata->user_nickname; |
---|
299 | + if ($idmode == 'login') $user_identity = $userdata->user_login; |
---|
300 | + if ($idmode == 'firstname') $user_identity = $userdata->user_firstname; |
---|
301 | + if ($idmode == 'lastname') $user_identity = $userdata->user_lastname; |
---|
302 | + if ($idmode == 'namefl') $user_identity = $userdata->user_firstname.' '.$userdata->user_lastname; |
---|
303 | + if ($idmode == 'namelf') $user_identity = $userdata->user_lastname.' '.$userdata->user_firstname; |
---|
304 | + if (!$idmode) $user_identity = $userdata->user_nickname; |
---|
305 | +} |
---|
306 | +endif; |
---|
307 | + |
---|
308 | +if ( !function_exists('get_userdata') ) : |
---|
309 | +function get_userdata($userid) { |
---|
310 | + global $wpdb, $cache_userdata; |
---|
311 | + $userid = (int) $userid; |
---|
312 | + if ( empty($cache_userdata[$userid]) && $userid != 0) { |
---|
313 | + $cache_userdata[$userid] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $userid"); |
---|
314 | + $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$userid]; |
---|
315 | + } |
---|
316 | + |
---|
317 | + return $cache_userdata[$userid]; |
---|
318 | +} |
---|
319 | +endif; |
---|
320 | + |
---|
321 | +if ( !function_exists('get_userdatabylogin') ) : |
---|
322 | +function get_userdatabylogin($user_login) { |
---|
323 | + global $cache_userdata, $wpdb; |
---|
324 | + if ( !empty($user_login) && empty($cache_userdata[$user_login]) ) { |
---|
325 | + $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'"); /* todo: get rid of this intermediate var */ |
---|
326 | + $cache_userdata[$user->ID] = $user; |
---|
327 | + $cache_userdata[$user_login] =& $cache_userdata[$user->ID]; |
---|
328 | + } else { |
---|
329 | + $user = $cache_userdata[$user_login]; |
---|
330 | + } |
---|
331 | + return $user; |
---|
332 | +} |
---|
333 | +endif; |
---|
334 | + |
---|
335 | +if ( !function_exists('wp_mail') ) : |
---|
336 | +function wp_mail($to, $subject, $message, $headers = '') { |
---|
337 | + if( $headers == '' ) { |
---|
338 | + $headers = "MIME-Version: 1.0\r\n" . |
---|
339 | + "From: " . get_settings('admin_email') . "\r\n" . |
---|
340 | + "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; |
---|
341 | + } |
---|
342 | + |
---|
343 | + return @mail($to, $subject, $message, $headers); |
---|
344 | +} |
---|
345 | +endif; |
---|
346 | + |
---|
347 | +if ( !function_exists('wp_login') ) : |
---|
348 | +function wp_login($username, $password, $already_md5 = false) { |
---|
349 | + global $wpdb, $error; |
---|
350 | + |
---|
351 | + if ( !$username ) |
---|
352 | + return false; |
---|
353 | + |
---|
354 | + if ( !$password ) { |
---|
355 | + $error = __('<strong>Error</strong>: The password field is empty.'); |
---|
356 | + return false; |
---|
357 | + } |
---|
358 | + |
---|
359 | + $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); |
---|
360 | + |
---|
361 | + if (!$login) { |
---|
362 | + $error = __('<strong>Error</strong>: Wrong username.'); |
---|
363 | + return false; |
---|
364 | + } else { |
---|
365 | + // If the password is already_md5, it has been double hashed. |
---|
366 | + // Otherwise, it is plain text. |
---|
367 | + if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { |
---|
368 | + return true; |
---|
369 | + } else { |
---|
370 | + $error = __('<strong>Error</strong>: Incorrect password.'); |
---|
371 | + $pwd = ''; |
---|
372 | + return false; |
---|
373 | + } |
---|
374 | + } |
---|
375 | +} |
---|
376 | +endif; |
---|
377 | + |
---|
378 | +if ( !function_exists('auth_redirect') ) : |
---|
379 | +function auth_redirect() { |
---|
380 | + // Checks if a user is logged in, if not redirects them to the login page |
---|
381 | + if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && |
---|
382 | + !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) || |
---|
383 | + (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) { |
---|
384 | + header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); |
---|
385 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
---|
386 | + header('Cache-Control: no-cache, must-revalidate, max-age=0'); |
---|
387 | + header('Pragma: no-cache'); |
---|
388 | + |
---|
389 | + header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); |
---|
390 | + exit(); |
---|
391 | + } |
---|
392 | +} |
---|
393 | +endif; |
---|
394 | + |
---|
395 | +// Cookie safe redirect. Works around IIS Set-Cookie bug. |
---|
396 | +// http://support.microsoft.com/kb/q176113/ |
---|
397 | +if ( !function_exists('wp_redirect') ) : |
---|
398 | +function wp_redirect($location) { |
---|
399 | + global $is_IIS; |
---|
400 | + |
---|
401 | + if ($is_IIS) |
---|
402 | + header("Refresh: 0;url=$location"); |
---|
403 | + else |
---|
404 | + header("Location: $location"); |
---|
405 | +} |
---|
406 | +endif; |
---|
407 | + |
---|
408 | +if ( !function_exists('wp_setcookie') ) : |
---|
409 | +function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') { |
---|
410 | + if ( !$already_md5 ) |
---|
411 | + $password = md5( md5($password) ); // Double hash the password in the cookie. |
---|
412 | + |
---|
413 | + if ( empty($home) ) |
---|
414 | + $cookiepath = COOKIEPATH; |
---|
415 | + else |
---|
416 | + $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); |
---|
417 | + |
---|
418 | + if ( empty($siteurl) ) { |
---|
419 | + $sitecookiepath = SITECOOKIEPATH; |
---|
420 | + $cookiehash = COOKIEHASH; |
---|
421 | + } else { |
---|
422 | + $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); |
---|
423 | + $cookiehash = md5($siteurl); |
---|
424 | + } |
---|
425 | + |
---|
426 | + setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath); |
---|
427 | + setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath); |
---|
428 | + |
---|
429 | + if ( $cookiepath != $sitecookiepath ) { |
---|
430 | + setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath); |
---|
431 | + setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath); |
---|
432 | + } |
---|
433 | +} |
---|
434 | +endif; |
---|
435 | + |
---|
436 | +if ( !function_exists('wp_clearcookie') ) : |
---|
437 | +function wp_clearcookie() { |
---|
438 | + setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); |
---|
439 | + setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); |
---|
440 | + setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); |
---|
441 | + setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); |
---|
442 | +} |
---|
443 | +endif; |
---|
444 | + |
---|
445 | +if ( ! function_exists('wp_notify_postauthor') ) : |
---|
446 | +function wp_notify_postauthor($comment_id, $comment_type='') { |
---|
447 | + global $wpdb; |
---|
448 | + |
---|
449 | + $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); |
---|
450 | + $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); |
---|
451 | + $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1"); |
---|
452 | + |
---|
453 | + if ('' == $user->user_email) return false; // If there's no email to send the comment to |
---|
454 | + |
---|
455 | + $comment_author_domain = gethostbyaddr($comment->comment_author_IP); |
---|
456 | + |
---|
457 | + $blogname = get_settings('blogname'); |
---|
458 | + |
---|
459 | + if ( empty( $comment_type ) ) $comment_type = 'comment'; |
---|
460 | + |
---|
461 | + if ('comment' == $comment_type) { |
---|
462 | + $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
---|
463 | + $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
464 | + $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; |
---|
465 | + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
466 | + $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
---|
467 | + $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
---|
468 | + $notify_message .= __('You can see all comments on this post here: ') . "\r\n"; |
---|
469 | + $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title ); |
---|
470 | + } elseif ('trackback' == $comment_type) { |
---|
471 | + $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
---|
472 | + $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
473 | + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
474 | + $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
---|
475 | + $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; |
---|
476 | + $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); |
---|
477 | + } elseif ('pingback' == $comment_type) { |
---|
478 | + $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; |
---|
479 | + $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
480 | + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
481 | + $notify_message .= __('Excerpt: ') . "\r\n" . sprintf( __('[...] %s [...]'), $comment->comment_content ) . "\r\n\r\n"; |
---|
482 | + $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; |
---|
483 | + $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); |
---|
484 | + } |
---|
485 | + $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; |
---|
486 | + $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
---|
487 | + |
---|
488 | + if ('' == $comment->comment_author_email || '' == $comment->comment_author) { |
---|
489 | + $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>'; |
---|
490 | + } else { |
---|
491 | + $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>"; |
---|
492 | + } |
---|
493 | + |
---|
494 | + $message_headers = "MIME-Version: 1.0\r\n" |
---|
495 | + . "$from\r\n" |
---|
496 | + . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n"; |
---|
497 | + |
---|
498 | + @wp_mail($user->user_email, $subject, $notify_message, $message_headers); |
---|
499 | + |
---|
500 | + return true; |
---|
501 | +} |
---|
502 | +endif; |
---|
503 | + |
---|
504 | +/* wp_notify_moderator |
---|
505 | + notifies the moderator of the blog (usually the admin) |
---|
506 | + about a new comment that waits for approval |
---|
507 | + always returns true |
---|
508 | + */ |
---|
509 | +if ( !function_exists('wp_notify_moderator') ) : |
---|
510 | +function wp_notify_moderator($comment_id) { |
---|
511 | + global $wpdb; |
---|
512 | + |
---|
513 | + if( get_settings( "moderation_notify" ) == 0 ) |
---|
514 | + return true; |
---|
515 | + |
---|
516 | + $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); |
---|
517 | + $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); |
---|
518 | + $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1"); |
---|
519 | + |
---|
520 | + $comment_author_domain = gethostbyaddr($comment->comment_author_IP); |
---|
521 | + $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); |
---|
522 | + |
---|
523 | + $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; |
---|
524 | + $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; |
---|
525 | + $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; |
---|
526 | + $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; |
---|
527 | + $notify_message .= sprintf( __('URI : %s'), $comment->comment_author_url ) . "\r\n"; |
---|
528 | + $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; |
---|
529 | + $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; |
---|
530 | + $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=mailapprovecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
---|
531 | + $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_settings('siteurl').'/wp-admin/post.php?action=confirmdeletecomment&p='.$comment->comment_post_ID."&comment=$comment_id" ) . "\r\n"; |
---|
532 | + $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n"; |
---|
533 | + $notify_message .= get_settings('siteurl') . "/wp-admin/moderation.php\r\n"; |
---|
534 | + |
---|
535 | + $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_settings('blogname'), $post->post_title ); |
---|
536 | + $admin_email = get_settings("admin_email"); |
---|
537 | + |
---|
538 | + @wp_mail($admin_email, $subject, $notify_message); |
---|
539 | + |
---|
540 | + return true; |
---|
541 | +} |
---|
542 | +endif; |
---|
543 | + |
---|
544 | +?> |
---|