Move all auth stuff into functions.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5cb036d571
commit
340804aa79
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('../wp-config.php');
|
require_once('../wp-config.php');
|
||||||
require_once(ABSPATH . 'wp-includes/wp-l10n.php');
|
require_once(ABSPATH . 'wp-includes/wp-l10n.php');
|
||||||
|
require_once(ABSPATH . 'wp-admin/admin-functions.php');
|
||||||
|
auth_redirect();
|
||||||
|
|
||||||
require_once(ABSPATH . 'wp-admin/auth.php');
|
|
||||||
require(ABSPATH . 'wp-admin/admin-functions.php');
|
|
||||||
|
|
||||||
$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories");
|
$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories");
|
||||||
foreach ($dogs as $catt) {
|
foreach ($dogs as $catt) {
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<?php
|
|
||||||
require_once(ABSPATH . '/wp-config.php');
|
|
||||||
|
|
||||||
if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true))
|
|
||||||
|| (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
|
|
||||||
header('Expires: Wed, 5 Jun 1979 23:41:00 GMT'); // Michel's birthday
|
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
||||||
header('Cache-Control: no-cache, must-revalidate');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
|
|
||||||
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../wp-config.php');
|
require('../wp-config.php');
|
||||||
require_once('auth.php');
|
auth_redirect();
|
||||||
|
|
||||||
get_currentuserinfo();
|
get_currentuserinfo();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('../wp-config.php');
|
require_once('../wp-config.php');
|
||||||
require_once('auth.php');
|
auth_redirect();
|
||||||
switch($action) {
|
switch($action) {
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
|
|
|
@ -1954,6 +1954,7 @@ function wp_mail($to, $subject, $message, $headers = '', $more = '') {
|
||||||
return mail($to, $subject, $message, $headers, $more);
|
return mail($to, $subject, $message, $headers, $more);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !function_exists('wp_login') ) :
|
||||||
function wp_login($username, $password, $already_md5 = false) {
|
function wp_login($username, $password, $already_md5 = false) {
|
||||||
global $wpdb, $error;
|
global $wpdb, $error;
|
||||||
|
|
||||||
|
@ -1982,6 +1983,24 @@ function wp_login($username, $password, $already_md5 = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( !function_exists('auth_redirect') ) :
|
||||||
|
function auth_redirect() {
|
||||||
|
// Checks if a user is logged in, if not redirects them to the login page
|
||||||
|
if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&
|
||||||
|
!wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
|
||||||
|
(empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
|
||||||
|
header('Expires: Wed, 5 Jun 1979 23:41:00 GMT'); // Michel's birthday
|
||||||
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||||
|
header('Cache-Control: no-cache, must-revalidate');
|
||||||
|
header('Pragma: no-cache');
|
||||||
|
|
||||||
|
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endif;
|
||||||
|
|
||||||
function is_plugin_page() {
|
function is_plugin_page() {
|
||||||
global $plugin_page;
|
global $plugin_page;
|
||||||
|
|
Loading…
Reference in New Issue