is_ktai() || @$_COOKIE[KTAI_COOKIE_PCVIEW] ) { wp_redirect(get_bloginfo('wpurl') . '/wp-login.php'); exit(); } elseif ( ! class_exists('KtaiStyle_Admin') ) { wp_die(__('Mobile admin feature is not available.', 'ktai_style')); } nocache_headers(); /* ================================================== * KtaiStyle_Login class ================================================== */ class KtaiStyle_Login { private $base; private $mime_type; private $charset; private $iana_charset; private $warp_end; private $style_input; private $errors; // ================================================== public function __construct($base) { $this->base = $base; $this->base->admin = new KtaiStyle_Admin; $this->errors = array( 'oldsession' => __('ERROR: Your login session has been expired. Please login again.', 'ktai_style') ); switch ($_REQUEST['action']) { case 'logout': $this->logout(); break; default: $this->login(); break; } } // ================================================== private function logout() { if (function_exists('wp_logout_url')) { check_admin_referer('log-out'); } $this->base->admin->logout(); $redirect_to = KtaiStyle::LOGIN_PAGE . '?loggedout=true'; if (isset($_POST['redirect_to']) || isset($_GET['redirect_to'])) { $redirect_to = isset($_POST['redirect_to']) ? $_POST['redirect_to'] : $_GET['redirect_to']; $redirect_to = $this->base->admin->shrink_redirect_to($redirect_to); } $this->base->admin->safe_redirect($redirect_to); } // ================================================== private function login_header($title = 'Log in', $message = '', $wp_error = '') { setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); if ( SITECOOKIEPATH != COOKIEPATH ) { setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); } $body_color = 'bgcolor="#fbfbfb" text="#333333" link="#777777" vlink="#777777"'; $error_color = 'color="red"'; $message_color = 'color="#ff5566"'; $logo_file = $this->base->strip_host($this->base->get('plugin_url')) . KtaiStyle::INCLUDES_DIR . '/wplogo'; $this->mime_type = 'text/html'; $this->charset = $this->base->get('charset'); $this->iana_charset = $this->base->get('iana_charset'); $this->base->ktai->set('mime_type', $mime_type); // don't use 'application/xhtml+xml' switch ($this->base->is_ktai()) { case 'DoCoMo': $logo_ext = '.gif'; $wrap_start = ''; $this->wrap_end = ''; $this->style_input = ''; break; case 'Unknown': $logo_ext = '.png'; $style_body = ' style="text-align:center;"'; $wrap_start = '
" . apply_filters('login_errors', $errors) . '
'; } if (! empty($messages)) { echo "" . apply_filters('login_messages', $messages) . '
'; } } } // ================================================== private function login_footer() { ?>wrap_end; ?> charset, get_bloginfo('charset')); } $buffer = $this->base->ktai->convert_pict($buffer); $buffer = $this->base->ktai->shrink_pre_split($buffer); $buffer = $this->base->ktai->shrink_post_split($buffer); header ("Content-Type: {$this->mime_type}; charset={$this->iana_charset}"); echo $buffer; } // ================================================== private function login() { if ( isset($_REQUEST['redirect_to']) ) { $redirect_to = $_REQUEST['redirect_to']; $redirect_to = $this->base->admin->shrink_redirect_to($redirect_to); } else { $redirect_to = ''; } $user = $this->base->admin->signon(); $recirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user); if ( !is_wp_error($user) ) { // success if (! $user->has_cap('edit_posts') && (empty($redirect_to) || $redirect_to == KtaiStyle::ADMIN_DIR . '/')) { $redirect_to = KtaiStyle::ADMIN_DIR . '/profile.php'; } elseif ( empty($redirect_to) ) { $redirect_to = KtaiStyle::ADMIN_DIR . '/'; } if ( !$this->base->get('cookie_available') ) { $redirect_to = add_query_arg(KtaiStyle_Admin::SESSION_NAME, $this->base->admin->get('sid'), $redirect_to); } $this->base->admin->safe_redirect($redirect_to); exit(); } $errors = $user; if ( !empty($_GET['loggedout']) ) { // Clear error $errors = new WP_Error('loggedout', __('You are now logged out.', 'ktai_style'), 'message'); } elseif ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) ) { $errors->add('test_cookie', __("ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.")); } if (preg_match('!^' . KtaiStyle::ADMIN_DIR . '/$!', $redirect_to)) { $redirect_to = ''; } if ($_GET['error'] && isset($this->errors[$_GET['error']])) { $errors->add('session', $this->errors[$_GET['error']]); } $this->login_header(__('Log in'), '', $errors); ?>
base->get('pcview_enabled')) {
echo '
' . __('Go to PC login form.', 'ktai_style') . '';
}
$this->login_footer();
}
// ===== End of class ====================
}
global $Ktai_Login;
$Ktai_Login = new KtaiStyle_Login($Ktai_Style);
exit();
?>