From 551e52ff91f108f26c45d0bcd9d4f4746430df66 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Mon, 4 Oct 2004 08:03:52 +0000 Subject: [PATCH] Code cleanup and some fixes from the WP Japan folks. git-svn-id: http://svn.automattic.com/wordpress/trunk@1734 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-user.php | 59 ++++++++++++++-------------------- wp-includes/functions.php | 9 ------ wp-login.php | 31 ------------------ wp-settings.php | 9 +++++- wp-trackback.php | 12 +++++++ 5 files changed, 45 insertions(+), 75 deletions(-) diff --git a/wp-includes/functions-user.php b/wp-includes/functions-user.php index f8c5816ef4..3862e33ee0 100644 --- a/wp-includes/functions-user.php +++ b/wp-includes/functions-user.php @@ -1,42 +1,33 @@ escape($user); - $password = $password; +function login($username, $password, $already_md5 = false) { + global $wpdb, $error; + if ( !$already_md5 ) + $pwd = md5($password); - if ( $user = $wpdb->get_row("SELECT user_login, user_pass FROM $wpdb->users WHERE user_login = '$user'") ) { - if ( $user->user_pass = md5($password) ) + if ( !$username ) + return false; + + if ( !$password ) { + $error = __('Error: The password field is empty.'); + return false; + } + + $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); + + if (!$login) { + $error = __('Error: Wrong login.'); + $pwd = ''; + return false; + } else { + + if ( $login->user_login == $username && $login->user_pass == $pwd ) { return true; - else + } else { + $error = __('Error: Incorrect password.'); + $pwd = ''; return false; - } else { - return false; - } -} - -function verify_current() { - if (!empty($_COOKIE['wordpressuser_' . COOKIEHASH])) { - $user_login = $_COOKIE['wordpressuser_' . COOKIEHASH]; - $user_pass = $_COOKIE['wordpresspass_' . COOKIEHASH]; - } else { - return false; - } - - if ('' == $user_login) - return false; - if ('' == $user_pass) - return false; - - if ( verify_login($user_login, $user_pass) ) { - return true; - } else { - header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); - 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(); + } } } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1793a02bf3..09dfb4b89a 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -559,15 +559,6 @@ function gzip_compression() { // functions to count the page generation time (from phpBB2) // ( or just any time between timer_start() and timer_stop() ) -function timer_start() { - global $timestart; - $mtime = microtime(); - $mtime = explode(' ',$mtime); - $mtime = $mtime[1] + $mtime[0]; - $timestart = $mtime; - return true; -} - function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal global $timestart, $timeend; $mtime = microtime(); diff --git a/wp-login.php b/wp-login.php index 5c04850c5e..427a4d721a 100644 --- a/wp-login.php +++ b/wp-login.php @@ -1,37 +1,6 @@ Error: The password field is empty.'); - return false; - } - - $login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); - - if (!$login) { - $error = __('Error: Wrong login.'); - $pwd = ''; - return false; - } else { - - if ( $login->user_login == $username && $login->user_pass == $pwd ) { - return true; - } else { - $error = __('Error: Incorrect password.'); - $pwd = ''; - return false; - } - } -} - if (!function_exists('add_magic_quotes')) { function add_magic_quotes($array) { foreach ($array as $k => $v) { diff --git a/wp-settings.php b/wp-settings.php index 96a92d394a..0e8771103d 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -9,6 +9,14 @@ $_SERVER['REQUEST_URI'] = ( isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_U if ( !(phpversion() >= '4.1') ) die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' ); +function timer_start() { + global $timestart; + $mtime = explode(' ', microtime() ); + $mtime = $mtime[1] + $mtime[0]; + $timestart = $mtime; + return true; +} +timer_start(); // Change to E_ALL for development/debugging error_reporting(E_ALL ^ E_NOTICE); @@ -40,7 +48,6 @@ $tableoptions = $wpdb->options; $tablepostmeta = $wpdb->postmeta; require (ABSPATH . WPINC . '/functions.php'); -timer_start(); require (ABSPATH . WPINC . '/functions-formatting.php'); require (ABSPATH . WPINC . '/functions-user.php'); require (ABSPATH . WPINC . '/classes.php'); diff --git a/wp-trackback.php b/wp-trackback.php index b46ceca27b..d268a265f9 100644 --- a/wp-trackback.php +++ b/wp-trackback.php @@ -34,6 +34,18 @@ $tb_url = $_POST['url']; $title = $_POST['title']; $excerpt = $_POST['excerpt']; $blog_name = $_POST['blog_name']; +$charset = $_POST['charset']; + +if ($charset) + $charset = strtoupper( trim($charset) ); +else + $charset = 'auto'; + +if ( function_exists('mb_convert_encoding') ) { + $title = mb_convert_encoding($title, get_settings('blog_charset'), $charset); + $excerpt = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset); + $blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset); +} if ( is_single() ) $tb_id = $posts[0]->ID;