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
This commit is contained in:
saxmatt 2004-10-04 08:03:52 +00:00
parent ec34fb1d80
commit 551e52ff91
5 changed files with 45 additions and 75 deletions

View File

@ -1,42 +1,33 @@
<?php
function verify_login($user, $password) {
global $wpdb;
$user = $wpdb->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 = __('<strong>Error</strong>: 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 = __('<strong>Error</strong>: Wrong login.');
$pwd = '';
return false;
} else {
if ( $login->user_login == $username && $login->user_pass == $pwd ) {
return true;
else
} else {
$error = __('<strong>Error</strong>: 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();
}
}
}

View File

@ -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();

View File

@ -1,37 +1,6 @@
<?php
require('./wp-config.php');
function login($username, $password, $already_md5 = false) {
global $wpdb, $error;
if ( !$already_md5 )
$pwd = md5($password);
if ( !$username )
return false;
if ( !$password ) {
$error = __('<strong>Error</strong>: 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 = __('<strong>Error</strong>: Wrong login.');
$pwd = '';
return false;
} else {
if ( $login->user_login == $username && $login->user_pass == $pwd ) {
return true;
} else {
$error = __('<strong>Error</strong>: Incorrect password.');
$pwd = '';
return false;
}
}
}
if (!function_exists('add_magic_quotes')) {
function add_magic_quotes($array) {
foreach ($array as $k => $v) {

View File

@ -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');

View File

@ -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;