function json_xencode($value, $options = 0, $unescapee_unicode = true) { $v = json_encode($value, $options); if ($unescapee_unicode) { $v = unicode_encode($v); $v = preg_replace('/\\\\\\//', '/', $v); } return $v; }
function getArticlePlayData($purl) { global $_root; $count = substr_count($purl, $_root); if (1 != $count) { $purl = str_replace($purl, $_root); $purl = $_root . $purl; } $html = getHtml($purl); preg_match('#<div id="player"><script language="javascript">(.+)</script>#Uis', $html, $match); $playjs = $match[1]; if (empty($playjs)) { die("\nPurl: {$purl} Get Play Data Empty!\n"); } $count = substr_count($playjs, 'pp_play.replace('); if ($count) { return array(); } preg_match('#var pp_play="([^"]+)";#Uis', $playjs, $match); $pinfo = $match[1]; if (!$pinfo) { die("\nPurl: {$purl} Get pp_play info empty!\n"); } $pinfo = urldecode($pinfo); $pinfo = explode('$$$', $pinfo); $return = array(); foreach ($pinfo as &$v) { if (false !== stripos($v, 'qvod://')) { $v = str_replace('++qvod', '$qvod', $v); $v = str_replace('+++', '$qvod+++', $v); $v .= '$qvod'; $v = unicode_encode($v); $v = explode('+++', $v); $return[] = array('qvod', $v); } elseif (false !== stripos($v, 'bdhd://')) { $v = str_replace('++bdhd', '$bdhd', $v); $v = str_replace('+++', '$bdhd+++', $v); $v .= '$bdhd'; $v = unicode_encode($v); $v = explode('+++', $v); $return[] = array('bdhd', $v); } } return $return; }
public static function format($row, $option) { global $_G; //JSON解码 $option['jsonde'] = $option['jsonde'] ? $option['jsonde'] : array(); //逗号分隔 $option['split'] = $option['split'] ? $option['split'] : array(); //空隔分隔 $option['space'] = $option['space'] ? $option['space'] : array(); //反序列化 $option['serialize'] = $option['serialize'] ? $option['serialize'] : array(); //HTML实体 $option['entity'] = $option['entity'] ? $option['entity'] : array(); //移除数字零 $option['zeroed'] = $option['zeroed'] ? $option['zeroed'] : array(); //Unicode $option['unicode'] = $option['unicode'] ? $option['unicode'] : array(); //修正地址 $option['attach'] = $option['attach'] ? $option['attach'] : array(); //转换换行 $option['nl2br'] = $option['nl2br'] ? $option['nl2br'] : array(); /////////////////////////////// foreach ($row as $key => &$val) { if ($val == '' && (in_array($key, $option['jsonde']) || in_array($key, $option['split']) || in_array($key, $option['space']) || in_array($key, $option['serialize']))) { $val = array(); } else { if (in_array($key, $option['jsonde'])) { //JSON解码 $val = fix_json($val); } elseif (in_array($key, $option['split'])) { //换行和双竖线分隔符 $val = preg_split("/(\n|,|(\\|\\|))/", $val); } elseif (in_array($key, $option['space'])) { //空格分隔符 $val = explode(' ', $val); } elseif (in_array($key, $option['serialize'])) { //反序列化 $val = unserialize($val); } elseif (in_array($key, $option['entity'])) { //HTML实体 $val = entity_encode($val, $_G['product']['charset']); } elseif (in_array($key, $option['zeroed'])) { //去除小数后多除的零 $val = $val + 0; } elseif (in_array($key, $option['unicode'])) { //Unicode $val = unicode_encode($val, $_G['product']['charset']); } elseif (in_array($key, $option['attach'])) { //修正地址 $val = fix_attach($val); } elseif (in_array($key, $option['nl2br'])) { //转换换行 $val = preg_replace("(\r\n|\r|\n)", '<br />', $val); } } } return $row; }
function getArticlePlayData($purl) { global $_root; $purl = $_root . $purl . '.js'; $html = getHtml($purl); //$html = iconv("GBK","UTF-8//TRANSLIT",$html) ; $html = mb_convert_encoding($html, "UTF-8", "GBK"); preg_match("#stringReplaceAll\\('(.+)','(.+)',(.+)\\)\\)\\)#Uis", $html, $match); if (!isset($match[1])) { return array(); } $match[1] = str_replace("'+'", '', $match[1]); $match[1] = str_replace("'", '', $match[1]); $match[2] = str_replace("'+'", '', $match[2]); $match[2] = str_replace("'", '', $match[2]); $match[3] = str_replace("unescape('", '', $match[3]); $match[3] = str_replace("')+", '', $match[3]); $match[3] = str_replace("'", '', $match[3]); $place = urldecode($match[3]); $from = $match[2]; $playjs = str_replace($from, $place, $match[1]); $playjs = urldecode($playjs); $playjs = str_replace('%u', '\\u', $playjs); $playjs = explode('$$$', $playjs); $return = array(); foreach ($playjs as &$v) { $player = ''; $v = mb_convert_encoding($v, "UTF-8", "UTF-8"); $v = trim($v, '#'); if (false !== stripos($v, 'qvod://')) { $v = str_replace('qvod$$', '', $v); $v = unicode_encode($v); $v = explode('#', $v); $player = 'qvod'; } elseif (false !== stripos($v, 'bdhd://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'bdhd'; } elseif (false != stripos($v, 'gbl.114s.com')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'xigua'; } elseif (false != stripos($v, 'jjhd://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'jjhd'; } elseif (false != stripos($v, '$youku')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'youku'; } else { echo "\n++ {$v} ++\n"; continue; } $v = str_replace('$$', '', $v); $return[] = array($player, $v); } return $return; }
function getArticlePlayData($purl) { global $_root; if ('http://' != substr($purl, 0, 7)) { $purl = $_root . $purl; } $html = getHtml($purl); //$html = iconv("GBK","UTF-8//TRANSLIT",$html) ; //$html = mb_convert_encoding($html,"UTF-8","GBK"); preg_match('#<script language="javascript">var ff_urls=\'([^\']+)\';</script>#Uis', $html, $match); $pinfo = array(); //var_dump($match);exit; $js = $match[1]; $json = json_decode($js, 1); $json = $json['Data']; foreach ($json as &$vv) { if (!in_array($vv['playname'], array('xigua', 'qvod', 'xfplay'))) { continue; } $vols = array(); foreach ($vv['playurls'] as &$v) { $vols[] = unicode_encode($v[0]) . '$' . unicode_encode($v[1]) . '$' . $vv['playname']; } $pinfo[] = array($vv['playname'], $vols); } return $pinfo; }
<?php header("Content-type: text/html; charset=utf-8"); $num = '_' . base_convert('http://inankai.com', 16, 10); $num2 = base_convert('http://in2732.om', 10, 16); $_2732 = unicode_decode("\\u6211\\u662f\\u7231"); $aac = unicode_decode("\\u7684"); echo unicode_encode($name); echo ${$num} . "inankai" . ${$num2}; function unicode_encode($name) { $name = iconv('UTF-8', 'UCS-2', $name); $len = strlen($name); $str = ''; for ($i = 0; $i < $len - 1; $i = $i + 2) { $c = $name[$i]; $c2 = $name[$i + 1]; if (ord($c) > 0) { // 两个字节的文字 $str .= '\\u' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16); } else { $str .= $c2; } } return $str; } function unicode_decode($name) { $pattern = '/([\\w]+)|(\\\\u([\\w]{4}))/i'; preg_match_all($pattern, $name, $matches); if (!empty($matches)) {
function getArticlePlayData($purl) { global $_root; if (!$purl) { return array(); } $purl = $_root . $purl; $html = getHtml($purl); //$html = iconv("GBK","UTF-8//TRANSLIT",$html) ; $html = mb_convert_encoding($html, "UTF-8", "UTF-8"); $st = strlen('var playdata='); $pjs = substr($html, $st, -1); #echo $pjs,"\n";exit; $place = json_decode($pjs, 1); //var_dump($place);exit; $playjs = array(); if (!is_array($place)) { return array(); } foreach ($place as $item) { $tmp = array(); foreach ($item['data'] as $it) { $url = str_replace('xigua=', '', $it[1]); $tmpurl = unicode_encode($it[0]) . '$' . unicode_encode($url); $tmpurl = mb_convert_encoding($tmpurl, "UTF-8", "UTF-8"); $tmp[] = $tmpurl; } $playjs[] = implode('#', $tmp); } # var_dump($playjs);exit; $return = array(); foreach ($playjs as &$v) { if (false !== stripos($v, 'qvod://')) { $v = explode('#', $v); $player = 'qvod'; } elseif (false !== stripos($v, 'bdhd://')) { $v = explode('#', $v); $player = 'bdhd'; } elseif (false != stripos($v, 'gbl.114s.com')) { $v = explode('#', $v); $player = 'xigua'; } elseif (false != stripos($v, '$youku')) { $v = explode('#', $v); $player = 'youku'; } else { echo "\n++ {$v} ++\n"; continue; } $return[] = array($player, $v); } return $return; }
function getQvodUrls($qpurl = array()) { global $_root; $return = array(); foreach ($qpurl as $v) { $purl = getRealUrl($v['url']); $html = getHtml($purl); $html = mb_convert_encoding($html, "UTF-8", "GBK"); preg_match('#Player\\.url = "(qvod://.+)";#Uis', $html, $match); $purl = isset($match[1]) ? $match[1] : ''; if (!$purl) { die("\nGet Qvod Play Url Data Error!\n"); } $title = unicode_encode($v['title']); $purl = unicode_encode($purl); $return[] = sprintf('%s$%s$qvod', $title, $purl); sleep(5); } return $return; }
function getArticlePlayData($purl) { global $_root; $purl = $_root . $purl; $html = getHtml($purl); //$html = iconv("GBK","UTF-8//TRANSLIT",$html) ; $html = mb_convert_encoding($html, "UTF-8", "GBK"); preg_match("#var VideoInfoList=unescape\\('(.+)'\\);#Uis", $html, $match); $vlist = isset($match[1]) ? $match[1] : ''; #var_dump($match);exit; if (!$vlist) { return array(); } $playjs = urldecode($vlist); #var_dump($playjs);exit; $playjs = str_replace(array('%u', 'www.77vcd.com'), array('\\u', 'www.emubt.com'), $playjs); $playjs = explode('$$$', $playjs); $return = array(); foreach ($playjs as &$v) { $player = ''; $v = mb_convert_encoding($v, "UTF-8", "UTF-8"); $v = str_replace('$$', '', $v); $v = trim($v, '#'); if (false !== stripos($v, 'qvod://')) { $v = str_replace('qvod$$', '', $v); $v = unicode_encode($v); $v = explode('#', $v); $player = 'qvod'; } elseif (false !== stripos($v, 'bdhd://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'bdhd'; } elseif (false != stripos($v, 'gbl.114s.com')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'xigua'; } else { echo "\n++ {$v} ++\n"; continue; } $return[] = array($player, $v); } return $return; }
/** * Codifica a string para uma codificação qualquer * @param $encoding * @return Str */ public function encode($encoding = 'ISO-8859-1') { $this->string = unicode_encode($this->string, $encoding); return $this; }
$Response = $HttpRequest->send(); //print_r($HttpRequest); $statusCode = $Response->getStatus(); if (200 == $statusCode) { echo 'status code: ' . $Response->getStatus() . PHP_EOL; foreach ($Response->getHeader() as $key => $value) { echo $key . ': ' . $value . PHP_EOL; } } else { echo 'Unexpected HTTP status: ' . $statusCode . ' ' . $Response->getReasonPhrase(); } echo 'cookies: '; foreach ($Response->getCookies() as $key => $child) { foreach ($child as $childkey => $childval) { echo $key . PATH_SEPARATOR . rawurldecode($childkey) . ' = ' . rawurldecode($childval) . PHP_EOL; } echo PHP_EOL; } echo PHP_EOL; $responseBody = $Response->getBody(); echo PHP_EOL; echo 'response length: ' . strlen($responseBody) . PHP_EOL; echo 'response body: ' . PHP_EOL; // XXX ホントはjson限定では無いのだけど echo unicode_encode($responseBody) . PHP_EOL; echo '※実際の出力結果はunicodeにdecodeされて出力されています!!' . PHP_EOL; } catch (HTTP_Request2_Exception $e) { die($e->getMessage()); } catch (Exception $e) { die($e->getMessage()); }
/** * Convert some data from one encoding to the internal encoding. * * @param string Data to convert. * @param ?string Charset to convert from (NULL: that read by the last http_download_file call). * @param ?string Charset to convert to (NULL: current encoding). * @return string Converted data. */ function convert_to_internal_encoding($data, $input_charset = NULL, $internal_charset = NULL) { global $VALID_ENCODING; convert_data_encodings(); // In case it hasn't run yet. We need $VALID_ENCODING to be set. if (is_null($input_charset)) { $input_charset = $GLOBALS['HTTP_CHARSET']; } if ($input_charset === '' || is_null($input_charset)) { return $data; } if (is_null($internal_charset)) { $internal_charset = get_charset(); } if ((version_compare(phpversion(), '4.3.0') >= 0 || strtolower($internal_charset) == 'iso-8859-1') && strtolower($input_charset) == 'utf-8' && will_be_unicode_neutered($data) && in_array(strtolower($internal_charset), array('iso-8859-1', 'iso-8859-15', 'koi8-r', 'big5', 'gb2312', 'big5-hkscs', 'shift_jis', 'euc-jp'))) { $test = entity_utf8_decode($data, $internal_charset); if ($test !== false) { $data = $test; } } elseif (function_exists('unicode_decode') && $internal_charset != 'utf-8' && $input_charset == 'utf-8' && $VALID_ENCODING) { $test = @unicode_decode($data, $input_charset); if ($test !== false) { $data = $test; } } elseif (function_exists('unicode_encode') && $internal_charset == 'utf-8' && $input_charset != 'utf-8' && $VALID_ENCODING) { $test = @unicode_encode($data, $input_charset); if ($test !== false) { $data = $test; } } elseif (function_exists('iconv') && $VALID_ENCODING && get_value('disable_iconv') !== '1') { $test = @iconv($input_charset, $internal_charset . '//TRANSLIT', $data); if ($test !== false) { $data = $test; } } elseif (function_exists('mb_convert_encoding') && $VALID_ENCODING && get_value('disable_mbstring') !== '1') { if (function_exists('mb_list_encodings')) { $good_encoding = in_array(strtolower($input_charset), array_map('strtolower', mb_list_encodings())); } else { $good_encoding = true; } if ($good_encoding) { $test = @mb_convert_encoding($data, $internal_charset, $input_charset); if ($test !== false) { $data = $test; } } } elseif (strtolower($input_charset) == 'utf-8' && strtolower(substr($internal_charset, 0, 3)) != 'utf') { $test = utf8_decode($data); // Imperfect as it assumes ISO-8859-1, but it's our last resort. if ($test !== false) { $data = $test; } } elseif (strtolower($internal_charset) == 'utf-8' && strtolower(substr($input_charset, 0, 3)) != 'utf') { $test = utf8_encode($data); // Imperfect as it assumes ISO-8859-1, but it's our last resort. if ($test !== false) { $data = $test; } } return $data; }
function getArticlePlayData($purl) { global $_root; $purl = $_root . $purl; $html = getHtml($purl); //$html = iconv("GBK","UTF-8//TRANSLIT",$html) ; # $html = mb_convert_encoding($html,"UTF-8","GBK"); preg_match('#<script>var VideoInfoList="(.+)"</script>#Uis', $html, $match); $playjs = explode('$$$', $match[1]); #var_dump($playjs);exit; $return = array(); foreach ($playjs as &$v) { $v = preg_replace('#.+\\$\\$#Uis', '', $v); $v = trim($v, '#'); if (false !== stripos($v, 'qvod://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'qvod'; } elseif (false !== stripos($v, 'bdhd://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'bdhd'; } elseif (false != stripos($v, 'gbl.114s.com')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'xigua'; } elseif (false != stripos($v, 'jjhd://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'jjhd'; } elseif (false != stripos($v, 'xfplay://')) { $v = unicode_encode($v); $v = explode('#', $v); $player = 'xfplay'; } $return[] = array($player, $v); } return $return; }
/** * WebインターフェースでのMVCのメイン処理 * * @param boolean DIコンテナで実行するかどうか * @throws Exception */ public static function webmain($argFlowXMLBasePath = '') { self::$flowXMLBasePath = $argFlowXMLBasePath; logging($_REQUEST, 'post'); logging($_COOKIE, 'cookie'); logging($_SERVER, 'server'); debug('requestParam=' . var_export($_REQUEST, TRUE)); debug('cookie=' . var_export($_COOKIE, TRUE)); $actionMethodName = 'execute'; if (isset($_GET['_a_']) && strlen($_GET['_a_']) > 0) { $actionMethodName = $_GET['_a_']; } // $_GET['_o_']がコントローラで消されてしまうかも知れないので一回取っておく // 正式なOutputType定義はコントローラ処理終了後 $outputType = 'html'; if (isset($_GET['_o_']) && strlen($_GET['_o_']) > 0) { $outputType = $_GET['_o_']; } // アプリケーション情報の取得 $serverUserAgent = $_SERVER['HTTP_USER_AGENT']; $appleReviewd = FALSE; $deviceType = 'PC'; if (false != strpos(strtolower($serverUserAgent), 'iphone')) { $deviceType = 'iPhone'; } elseif (false != strpos(strtolower($serverUserAgent), 'ipad')) { $deviceType = 'iPad'; } elseif (false != strpos(strtolower($serverUserAgent), 'ipod')) { $deviceType = 'iPod'; } elseif (false != strpos(strtolower($serverUserAgent), 'android')) { $deviceType = 'Android'; } debug('deviceType=' . $deviceType); // アプリの必須バージョンチェック if (isset($_GET['_v_'])) { if (TRUE === Configure::constant('MUST_IOSAPP_VERSION_FLAG_FILE') && ('iPhone' === $deviceType || 'iPad' === $deviceType || 'iPod' === $deviceType)) { if (TRUE === is_file(Configure::MUST_IOSAPP_VERSION_FLAG_FILE)) { debug(Configure::MUST_IOSAPP_VERSION_FLAG_FILE); $mustVirsionStr = @file_get_contents(Configure::MUST_IOSAPP_VERSION_FLAG_FILE); $matches = NULL; if (preg_match('/([0-9.]+)/', $mustVirsionStr, $matches)) { $mustVirsionNum = (int) str_replace('.', '', $matches[1]); debug('mustVirsionNum=' . $mustVirsionNum); debug('nowversion=' . (int) str_replace('.', '', $_GET['_v_'])); if ($mustVirsionNum > (int) str_replace('.', '', $_GET['_v_'])) { self::$mustAppVersioned = FALSE; } } } } else { if (TRUE === Configure::constant('MUST_ANDROIDAPP_VERSION_FLAG_FILE') && ('android' === $deviceType || 'Android' === $deviceType)) { if (TRUE === is_file(Configure::MUST_ANDROIDAPP_VERSION_FLAG_FILE)) { debug(Configure::MUST_ANDROIDAPP_VERSION_FLAG_FILE); $mustVirsionStr = @file_get_contents(Configure::MUST_ANDROIDAPP_VERSION_FLAG_FILE); $matches = null; if (preg_match('/([0-9.]+)/', $mustVirsionStr, $matches)) { $mustVirsionNum = (int) str_replace('.', '', $matches[1]); if ($mustVirsionNum > (int) str_replace('.', '', $_GET['_v_'])) { self::$mustAppVersioned = FALSE; } } } } } } // アップルレビューバージョンの存在チェック if ('iPhone' === $deviceType || 'iPad' === $deviceType || 'iPod' === $deviceType) { if (TRUE === Configure::constant('APPLE_REVIEW_FLAG_FILE') && isset($_GET['_v_'])) { if (TRUE === is_file(Configure::APPLE_REVIEW_FLAG_FILE . $_GET['_v_'])) { debug(Configure::APPLE_REVIEW_FLAG_FILE . $_GET['_v_']); $appleReviewd = TRUE; debug('isAppleReview'); } } } // アプリバージョン $version = NULL; if (isset($_GET['_v_']) && strlen($_GET['_v_']) > 0) { $version = $_GET['_v_']; debug('version=' . $version); } self::$appVersion = $version; self::$deviceType = $deviceType; self::$appleReviewd = $appleReviewd; $res = FALSE; // 実行 try { $httpStatus = 200; // コントロール対象を取得 $res = self::loadMVCModule(); if (FALSE === $res) { // フィルター処理 if (self::loadMVCFilter('StaticPrependFilter')) { $PrependFilter = new StaticPrependFilter(); $filtered = $PrependFilter->execute(); if (FALSE === $filtered) { // XXX フィルターエラー throw new Exception('access denied.'); } } // ただのhtml表示かも知れないのを調べる if (is_file($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'])) { // そのままスタティックファイルとして表示 $res = file_get_contents($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI']); } else { // エラー throw new Exception('controller class faild.'); } // フィルター処理 if (self::loadMVCFilter('StaticAppendFilter')) { $AppendFilter = new StaticAppendFilter(); $filtered = $AppendFilter->execute(); if (FALSE === $filtered) { // XXX フィルターエラー throw new Exception('access denied.'); } } } else { $controlerClassName = $res; // フィルター処理 $filres = self::loadMVCFilter('MVCPrependFilter'); debug($filres); if (self::loadMVCFilter('MVCPrependFilter')) { debug('s??'); $PrependFilter = new MVCPrependFilter(); $filtered = $PrependFilter->execute(); if (FALSE === $filtered) { // XXX フィルターエラー throw new Exception('access denied.'); } } self::$CurrentController = new $controlerClassName(); if (isset($_SERVER['REQUEST_METHOD'])) { self::$CurrentController->requestMethod = strtoupper($_SERVER['REQUEST_METHOD']); } self::$CurrentController->controlerClassName = $controlerClassName; self::$CurrentController->outputType = $outputType; self::$CurrentController->deviceType = self::$deviceType; self::$CurrentController->appVersion = self::$appVersion; self::$CurrentController->appleReviewd = self::$appleReviewd; self::$CurrentController->mustAppVersioned = self::$mustAppVersioned; $res = self::$CurrentController->{$actionMethodName}(); if (FALSE === $res) { throw new Exception($actionMethodName . ' executed faild.'); } // フィルター処理 if (self::loadMVCFilter('MVCAppendFilter')) { $AppendFilter = new MVCAppendFilter(); $filtered = $AppendFilter->execute(); if (FALSE === $filtered) { // XXX フィルターエラー throw new Exception('access denied.'); } } } } catch (Exception $Exception) { // リターンは強制的にFALSE $res = FALSE; // statusコードがアレバそれを使う if (isset(self::$CurrentController->httpStatus) && $httpStatus != self::$CurrentController->httpStatus) { $httpStatus = self::$CurrentController->httpStatus; } else { // インターナルサーバエラー $httpStatus = 500; } } // Output try { if (200 !== $httpStatus && 201 !== $httpStatus && 202 !== $httpStatus) { // 200版以外のステータスコードの場合の出力処理 header('HTTP', TRUE, $httpStatus); if (FALSE === $res && isset($Exception)) { $html = ''; if ('json' === $outputType) { // exceptionのログ出力 if (!class_exists('PHPUnit_Framework_TestCase', FALSE)) { logging($Exception->getMessage() . PATH_SEPARATOR . var_export(debug_backtrace(), TRUE), 'exception'); } // jsonでエラーメッセージを出力 header('Content-type: text/javascript; charset=UTF-8'); $res = json_encode(array('error' => $Exception->getMessage())); if (TRUE == self::$CurrentController->jsonUnescapedUnicode) { $res = unicode_encode($res); // スラッシュのエスケープをアンエスケープする $res = preg_replace('/\\\\\\//', '/', $res); } debug($res); exit($res); } elseif ('xml' === $outputType) { // exceptionのログ出力 if (!class_exists('PHPUnit_Framework_TestCase', FALSE)) { logging($Exception->getMessage() . PATH_SEPARATOR . var_export(debug_backtrace(), TRUE), 'exception'); } // XMLでエラーメッセージを出力 header('Content-type:Content- type: application/xml; charset=UTF-8'); exit('<?xml version="1.0" encoding="UTF-8" ?>' . convertObjectToXML(array('error' => $Exception->getMessage()))); } elseif ('html' === $outputType) { $Tpl = self::loadTemplate('error'); if (is_object($Tpl)) { $dispatch = false; $html = $Tpl->execute(); } } _systemError('Exception :' . $Exception->getMessage(), $httpStatus, $html); } } else { $isBinary = FALSE; if (isset(self::$CurrentController->outputType)) { $outputType = self::$CurrentController->outputType; } if ('html' === $outputType) { // htmlヘッダー出力 header('Content-type: text/html; charset=UTF-8'); if (is_array($res)) { // html出力なのに配列は出力テンプレートの自動判別を試みる } } elseif ('txt' === $outputType) { // textヘッダー出力 header('Content-type: text/plain; charset=UTF-8'); if (is_array($res)) { $res = var_export($res, TRUE); } } elseif ('json' === $outputType) { // jsonヘッダー出力 header('Content-type: text/javascript; charset=UTF-8'); if (is_array($res)) { $res = json_encode($res); } if (TRUE == self::$CurrentController->jsonUnescapedUnicode) { $res = unicode_encode($res); // スラッシュのエスケープをアンエスケープする $res = preg_replace('/\\\\\\//', '/', $res); } } elseif ('xml' === $outputType) { // jsonヘッダー出力 header('Content-type:Content- type: application/xml; charset=UTF-8'); if (is_array($res)) { $res = '<?xml version="1.0" encoding="UTF-8" ?>' . convertObjectToXML($res); } } elseif ('csv' === $outputType) { // csvヘッダー出力 header('Content-type: application/octet-stream; charset=SJIS'); if (is_array($res)) { // XXX csvといいつつtsvを吐き出す $res = mb_convert_encoding(convertObjectToCSV($res, PHP_TAB), 'SJIS', 'UTF-8'); } } elseif ('jpg' === $outputType || 'jpeg' === $outputType) { // jpgヘッダー出力 header('Content-type: image/jpeg'); $isBinary = TRUE; } elseif ('png' === $outputType) { // pngヘッダー出力 header('Content-type: image/png'); $isBinary = TRUE; } elseif ('gif' === strtolower($outputType)) { // gifヘッダー出力 header('Content-type: image/gif'); $isBinary = TRUE; } elseif ('bmp' === strtolower($outputType)) { // bmpヘッダー出力 header('Content-type: image/bmp'); $isBinary = TRUE; } // 描画処理 if (TRUE === $isBinary && is_string($res)) { header('Content-length: ' . strlen($res)); } debug('lastRES='); debug($res); echo $res; } } catch (Exception $Exception) { // かなりのイレギュラー! 普通はココを通らない!! _systemError('Exception :' . $Exception->getMessage()); } // 明示的終了 exit; }
function getArticlePlayData($html, $ourl) { global $_root; preg_match_all("#<ul class=\"compress\" id=\"Url\\d+\">(.+)</ul>#Uis", $html, $match); $playUrl = empty($match[1]) ? array() : $match[1]; //var_dump($match);exit; $pUrls = array(); foreach ($playUrl as &$pu) { preg_match_all('#<li><a .*href="(play_\\d+_\\d+\\.html)".*>(.+)</a></li>#Uis', $pu, $match); # var_dump($match);exit; $purlPool = $match[1]; $titlePool = $match[2]; $pjs = array(); foreach ($purlPool as $k => &$v) { $purl = $ourl . '/' . $v; $phtml = getHtml($purl); $phtml = mb_convert_encoding($phtml, "UTF-8", "GBK"); preg_match('#<script>view\\(\'([^\']+)\',\'[^\']+\'\\)</script>#Uis', $phtml, $match); //file_put_contents('phtml.html',$phtml);exit; # var_dump($match);exit; $pl = $match[1]; $pl = preg_replace('#\\w\\.\\w\\.[\\.\\w]+#Uis', '', $pl); $cmp = substr($pl, 0, 7); if ($cmp != 'qvod://' && $cmp != 'bdhd://') { echo $cmp, "\n"; break; } if ($cmp == 'qvod://') { $suf = 'qvod'; } else { $suf = 'bdhd'; } $pjs[] = unicode_encode($titlePool[$k]) . '$' . unicode_encode($pl) . '$' . $suf; sleep(10); } $pjs = implode('#', $pjs); $pUrls[] = $pjs; } $return = array(); foreach ($pUrls as &$v) { if (empty($v)) { continue; } if (false !== stripos($v, 'qvod://')) { $v = explode('#', $v); $player = 'qvod'; } elseif (false !== stripos($v, 'bdhd://')) { $v = explode('#', $v); $player = 'bdhd'; } elseif (false != stripos($v, 'gbl.114s.com')) { $v = explode('#', $v); $player = 'xigua'; } else { $player = ''; } $return[] = array($player, $v); } return $return; }