Your request could not be understood by the server due to malformed syntax.
self::REMOTE_GET_TIMEOUT, 'httpversion' => '1.0' ) );
if ( is_wp_error($response) ) {
return false;
}
if ( isset($response['headers']['content-type'])
&& preg_match(self::IGNORE_CONTENT_REGEX, implode(' ', (array) $response['headers']['content-type'])) ) {
return false;
}
$response = wp_remote_get($url, array( 'timeout' => self::REMOTE_GET_TIMEOUT, 'httpversion' => '1.0' ) );
if ( is_wp_error($response) ) {
return false;
}
$contents = $response['body'];
if ( !preg_match_all('#]*?)media=([\'"])handheld\\2([^>]*)/?>#is', $contents, $links, PREG_SET_ORDER) ) {
return false;
}
$mobile_url = false;
foreach ($links as $l) {
$attr = $l[1] . $l[3];
if ( !preg_match('/rel=([\'"])alternate\\1/i', $attr) || !preg_match('/href=([\'"])(.*?)\\1/is', $attr, $href) ) {
continue;
}
if ( !preg_match('!^(https?:/)?/!', $href[2]) ) { // relarive URL
$href[2] = $url . $href[2];
}
$mobile_url = sanitize_url($href[2]); // available after WP 2.3
if ($mobile_url) {
break;
}
}
return $mobile_url;
}
// ==================================================
private function compare_host() {
$pc = parse_url($this->full_url);
$mobile = parse_url($this->mobile_url);
$this->same_host =
($pc['scheme'] === $mobile['scheme']
&& $pc['host'] === $mobile['host']
&& $pc['port'] === $mobile['port']);
return $this->same_host;
}
// ==================================================
public function use_template($template) {
require dirname(__FILE__) . '/template-tags.php';
add_filter('ktai_raw_content', array($this->base->ktai, 'shrink_pre_encode'), 9);
add_filter('ktai_encoding_converted', array($this->base->ktai, 'shrink_pre_split'), 5);
add_filter('ktai_encoding_converted', array($this->base->ktai, 'replace_smiley'), 7);
add_filter('ktai_encoding_converted', array($this->base->ktai, 'convert_pict'), 9);
add_filter('ktai_encoding_converted', array($this->base->ktai, 'shrink_post_split'), 15);
$buffer = $this->base->ktai->get('preamble');
$buffer .= ($buffer ? "\n" : '');
ob_start();
include $template;
$buffer .= ob_get_contents();
ob_end_clean();
$buffer = apply_filters('ktai_raw_content', $buffer);
$buffer = apply_filters('raw_content/ktai_style.php', $buffer);
$buffer = $this->base->encode_for_ktai($buffer);
$buffer = apply_filters('ktai_encoding_converted', $buffer);
$buffer = apply_filters('encoding_converted/ktai_style.php', $buffer);
$mime_type = apply_filters('ktai_mime_type', $this->base->ktai->get('mime_type'));
$iana_charset = apply_filters('ktai_iana_charset', $this->base->ktai->get('iana_charset'));
if (defined('KTAI_USE_400') && KTAI_USE_400 && is_null($this->full_url)) {
header("HTTP/1.0 400 Bad Request");
}
if (function_exists('mb_http_output')) {
mb_http_output('pass');
}
header ("Content-Type: $mime_type; charset=$iana_charset");
echo $buffer;
}
// ==================================================
public function output() {
$charset = $this->base->ktai->get('charset');
$title = __('Confirm connecting to external sites', 'ktai_style');
$html = '
';
if (! $this->mobile_url) {
$html .= __('You are about to visit a website for PC:', 'ktai_style')
. ' ' . esc_url($this->full_url) . '';
} else {
if ($this->mobile_url === $this->full_url) {
$html .= __('A mobile view is provided with the same URL at the visiting site:', 'ktai_style');
} else {
$html .= '
' . __('A mobile site found for the visiting site:', 'ktai_style');
}
$html .= ' ' . esc_url($this->mobile_url) . '';
if (! $this->same_host) {
$html .= ' ' . __('The host is diffrent from the origial. Make sure the valid mobile site.', 'ktai_style') . '';
}
if ($this->mobile_url != $this->full_url) {
$html .= '
' . __('The original URL of the site:', 'ktai_style')
. ' ' . esc_url($this->full_url) . '';
}
}
if (is_ktai() == 'KDDI' && is_ktai('type') == 'WAP2.0') {
$html .= ' '. sprintf(__('(View the site by PC Site Viewer.)', 'ktai_style'), ' href="device:pcsiteviewer?url=' . esc_url($this->full_url) . '"');
} elseif (is_ktai() == 'DoCoMo' && is_ktai('type') == 'FOMA') {
$html .= ' '. sprintf(__('(View the site by Full Browser.)', 'ktai_style'), 'href="' . esc_url($this->url) . '" ifb="' . esc_url($this->full_url) . '"');
}
$html .= "
\n
" . __("If you are sure, follow above link. If not, go to the previous page with browser's back button.", 'ktai_style') . '
';
$html .='';
$this->base->ks_die($html, $title, false);
}
// ==================================================
public function nonce_error() {
$charset = $this->base->ktai->get('charset');
$title = __('Error linking to external sites', 'ktai_style');
$html = '
' . __("A certain time has elapsed since you viewed the page, the link to exteral sites has became invalid. \nGo back the previous page and reload it. After that, retry clicking the link.", 'ktai_style') . '
';
if (defined('KTAI_USE_400') && KTAI_USE_400) {
header("HTTP/1.0 400 Bad Request");
}
$this->base->ks_die(apply_filters('ktai_redir_error', $html), $title, false);
}
// ===== End of class ====================
}
/* ==================================================
* @param string $key
* @return boolean $isset
* @since 1.81
*/
function ks_redir_has($key) {
global $Ktai_Style;
return is_object($Ktai_Style->redir) && $Ktai_Style->redir->has($key);
}
/* ==================================================
* @param string $key
* @return mix $value
* @since 1.81
*/
function ks_redir_get($key) {
global $Ktai_Style;
return is_object($Ktai_Style->redir) ? $Ktai_Style->redir->get($key) : NULL;
}
/* ==================================================
* @param none
* @return boolean $is_same_host
* @since 1.81
*/
function ks_redir_same_host() {
global $Ktai_Style;
return is_object($Ktai_Style->redir) && $Ktai_Style->redir->get('same_host');
}
// ==================================================
global $Ktai_Style;
if ( !isset($Ktai_Style) || !$Ktai_Style->is_ktai() ) {
KtaiStyle_Redir::show_error();
// exit;
}
$Ktai_Style->redir = new KtaiStyle_Redir($Ktai_Style);
$template = $Ktai_Style->theme->get('template_dir') . 'redir.php';
if ( false !== strpos($template, '/') && file_exists($template)) {
$Ktai_Style->redir->use_template($template);
} elseif ($Ktai_Style->redir->has('full_url')) {
$Ktai_Style->redir->output();
} else {
$Ktai_Style->redir->nonce_error();
}
exit();
?>