From svnnotify @ sourceforge.jp Thu Jun 3 16:17:45 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Thu, 03 Jun 2010 16:17:45 +0900 Subject: [Frameworkspider-svn] spider-commit [105] Message-ID: <1275549465.490786.8135.nullmailer@users.sourceforge.jp> Revision: 105 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=105 Author: m_nakashima Date: 2010-06-03 16:17:45 +0900 (Thu, 03 Jun 2010) Log Message: ----------- Modified Paths: -------------- current/README.txt current/spider/lib/spider/tags/SetAttribute.class.php current/spider/lib/spider/tags/TagBase.class.php current/spider/lib/util/GetHTTPResponse.class.php -------------- next part -------------- Modified: current/README.txt =================================================================== --- current/README.txt 2010-05-10 07:21:40 UTC (rev 104) +++ current/README.txt 2010-06-03 07:17:45 UTC (rev 105) @@ -3,6 +3,14 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2010-06-03 +1) setタグクラスの修正をおこないました。第二引数全体が''で囲まれていた場合、文字列判断はPHPプログラム + と同等の記述で動作するようになりました。 +2) util_HttpRequestクラスを追加しました。JavaScriptのHTTPオブジェクトと同様の感覚で使えるHTTP + 通信用クラスです。fsockopenがSSLに対応していればHTTPS通信も可能です。 + これに伴い、util_GetHTTPResponseクラスは非推奨クラスとなります。次回アップデートから削除しますので + ご利用中の方は気を付けてください。 + -- 2010-05-10 1) ドライブ文字判断の正規表現に誤りがあり一部Windowsにて正常に動作しない現象の修正 Modified: current/spider/lib/spider/tags/SetAttribute.class.php =================================================================== --- current/spider/lib/spider/tags/SetAttribute.class.php 2010-05-10 07:21:40 UTC (rev 104) +++ current/spider/lib/spider/tags/SetAttribute.class.php 2010-06-03 07:17:45 UTC (rev 105) @@ -49,7 +49,11 @@ $attributeName = trim(array_shift($optionArray)); // 属性値 $attibuteValue = trim(array_shift($optionArray)); - if( preg_match('/\\:\\:/',$attibuteValue) > 0 ) { + if( preg_match('/^\'/',$attibuteValue) > 0 && preg_match('/\'$/',$attibuteValue) > 0 ) { + // シングルクォートで全体が囲まれているなら + $repCode = ''; + $result_strings = str_replace( $tagStrings, $repCode, $result_strings ); + } else if( preg_match('/\\:\\:/',$attibuteValue) > 0 ) { // コロン連続を含むなら下位互換 $repCode = $this->cnvOldCode( $attributeName, $attibuteValue ); $result_strings = str_replace( $tagStrings, $repCode, $result_strings ); Modified: current/spider/lib/spider/tags/TagBase.class.php =================================================================== --- current/spider/lib/spider/tags/TagBase.class.php 2010-05-10 07:21:40 UTC (rev 104) +++ current/spider/lib/spider/tags/TagBase.class.php 2010-06-03 07:17:45 UTC (rev 105) @@ -114,13 +114,9 @@ foreach( $column_array as $column ) { $data .= $column; if( preg_match('/^\\\'/',$data) > 0 && substr_count( $data, "'" ) % 2 == 1 ) { - // 'から始まって'の数が偶数個なら次のカラムとつなげる + // 'から始まって'の数が奇数個なら次のカラムとつなげる $data .= ' '; continue; - } else if( preg_match('/^\\\"/',$data) > 0 && substr_count( $data, '"' ) % 2 == 1 ) { - // "から始まって"の数が偶数個なら次のカラムとつなげる - $data .= ' '; - continue; } else { // そうでない場合はカラムがデータとして完結しているので配列に追加 array_push( $option_array, $data ); @@ -128,6 +124,10 @@ $data = ''; } } + if( strlen($data) > 0 ) { + array_push( $option_array, $data ); + $data = ''; + } } else { array_push( $option_array, $string ); } Modified: current/spider/lib/util/GetHTTPResponse.class.php =================================================================== --- current/spider/lib/util/GetHTTPResponse.class.php 2010-05-10 07:21:40 UTC (rev 104) +++ current/spider/lib/util/GetHTTPResponse.class.php 2010-06-03 07:17:45 UTC (rev 105) @@ -7,6 +7,7 @@ * @copyright Copyright © 2008, Multimedia Digital Contents Systems.Co.,Ltd. http://www.md-systems.net/ * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima * @since PHP 4.3 + * @deprecated */ class util_GetHTTPResponse { var $protocol = ""; From svnnotify @ sourceforge.jp Thu Jun 3 16:18:22 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Thu, 03 Jun 2010 16:18:22 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B106=5D_1=29__set?= =?utf-8?b?44K/44Kw44Kv44Op44K544Gu5L+u5q2j44KS44GK44GT44Gq44GE44G+44GX?= =?utf-8?b?44Gf44CC56ys5LqM5byV5pWw5YWo5L2T44GMICcnIOOBp+WbsuOBvuOCjA==?= =?utf-8?b?44Gm44GE44Gf5aC05ZCI44CB5paH5a2X5YiX5Yik5pat44GvUEhQ44OX44Ot?= =?utf-8?b?44Kw44Op44Og?= Message-ID: <1275549502.029728.9448.nullmailer@users.sourceforge.jp> Revision: 106 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=106 Author: m_nakashima Date: 2010-06-03 16:18:21 +0900 (Thu, 03 Jun 2010) Log Message: ----------- 1) setタグクラスの修正をおこないました。第二引数全体が''で囲まれていた場合、文字列判断はPHPプログラム と同等の記述で動作するようになりました。 2) util_HttpRequestクラスを追加しました。JavaScriptのHTTPオブジェクトと同様の感覚で使えるHTTP 通信用クラスです。fsockopenがSSLに対応していればHTTPS通信も可能です。 これに伴い、util_GetHTTPResponseクラスは非推奨クラスとなります。次回アップデートから削除しますので ご利用中の方は気を付けてください。 Added Paths: ----------- current/spider/lib/util/HttpRequest.class.php -------------- next part -------------- Added: current/spider/lib/util/HttpRequest.class.php =================================================================== --- current/spider/lib/util/HttpRequest.class.php (rev 0) +++ current/spider/lib/util/HttpRequest.class.php 2010-06-03 07:18:21 UTC (rev 106) @@ -0,0 +1,205 @@ + http://www.md-systems.net/ + * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima + * @since PHP 4.3 + */ +class util_HttpRequest { + /** リクエスト対象URL */ + var $requestUrl; + /** リクエストプロトコル */ + var $requestProtocol = 'http'; + /** リクエストホスト名 */ + var $requestHostName; + /** リクエストポート番号 */ + var $requestPort = 80; + /** リクエストURI */ + var $requestUri = '/'; + /** リクエストメソッド */ + var $requestMethod = 'get'; + /** リクエストヘッダハッシュ */ + var $requestHeaders = array(); + + /** レスポンスステータスコード */ + var $statusCode = 0; + /** レスポンスステータスメッセージ */ + var $statusMessage = ''; + /** レスポンスプロトコル */ + var $responseProtocol = ""; + + /** エラー番号 */ + var $errorNumber; + /** エラーメッセージ */ + var $errorMessage; + + /** レスポンスヘッダハッシュ */ + var $responseHeaders = array(); + /** レスポンスボディ */ + var $responseBody = null; + + /** + * コンストラクタ + */ + function util_HttpRequest( $url = null, $method='get', $headerParms=array() ){ + $this->requestHeaders = array(); + $this->open( $url, $method, $headerParms ); + } + /** + * 指定URLへの接続を作成準備します + */ + function open( $url = null, $method='get', $headerParms=null ) { + // メソッドの設定 + if( 'post' == strtolower($method) ) { + $this->requestMethod = 'post'; + } else { + $this->requestMethod = 'get'; + } + // URLの設定 + $this->requestUrl = $url; + // リクエストヘッダの設定 + if( is_array($headerParms) ) { + $this->requestHeaders = array(); + foreach($headerParms as $key=>$val ) { + if( strlen($key)>0 && strlen($val) > 0 ) { + $this->requestHeaders[$key] = $val; + } + } + } + } + /** + * リクエストを送信して結果を取得します + */ + function send( $contents=null, $timeout=10 ) { + // URLの分割 + $urlElementArray = explode('/',$this->requestUrl ); + if( count($urlElementArray) == 0 ) { + $this->errorMessage = 'Target URL is invalid!'; + return false; + } + if( strtolower($urlElementArray[0]) != 'http:' + && strtolower($urlElementArray[0]) != 'https:' ) { + // httpまたはhttpsから始まらないならデフォルトでhttpを追加する + array_unshift($urlElementArray,''); + array_unshift($urlElementArray,'http:'); + } + $this->requestProtocol = str_replace(':','',trim(array_shift($urlElementArray))); + array_shift($urlElementArray); + $fqdn = array_shift($urlElementArray); + $this->requestUri = '/'.implode('/',$urlElementArray); + $this->requestHostName = $fqdn; + $this->requestPort = 80; + $connectTarget = $this->requestHostName; + // ホスト名整理 + if( strpos( $this->requestHostName, ':' ) !== false ) { + list( $this->requestHostName, $this->requestPort ) = explode(':',$this->requestHostName); + } else if( strtolower($this->requestProtocol) == 'https' ) { + $this->requestPort = 443; + $connectTarget = 'ssl://'.$this->requestHostName; + } + // ホスト存在確認 + $address = gethostbyname($this->requestHostName); + if( preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/',$address) == 0 ) { + $this->errorMessage = 'Target Host is not found!'; + return false; + } + // リクエスト文字列作成 + $requestStrings = $this->_createRequestStrings( $contents ); + // ソケット通信 + if( $socket = @fsockopen( $connectTarget, $this->requestPort, $this->errorNumber, $this->errorMessage, $timeout ) ){ + if( @socket_set_timeout( $socket, $timeout ) ) { + // リクエスト送信 + fwrite( $socket, $requestStrings ); + // レスポンス文字列受信 + $responseText = ''; + while (!feof($socket)) { + $responseText .= fgets($socket, 128); + } + $this->_convertResponse( $responseText ); + } else { + $this->errorMessage = 'Can\'t set connection timeout!'; + return false; + } + @fclose($socket); + } else { + return false; + } + return true; + } + /** + * リクエスト用文字列を作成して取得します + */ + function _createRequestStrings( $contents ) { + $method = 'GET'; + $requestStrings = ''; + if( 'post' == $this->requestMethod ) { + $method = 'POST'; + } + $hostName = $this->requestHostName; + $uri = $this->requestUri; + $requestStrings = "{$method} {$uri} HTTP/1.1\r\n" + ."Accept: */*\r\n" + ."Host: {$hostName}\r\n"; + foreach( $this->requestHeaders as $key => $value ) { + if( strlen(trim($key)) > 0 && strlen(trim($value)) > 0 ) { + $requestStrings .= $key . ": " . $value . "\r\n"; + } + } + $requestStrings .= "Connection: close\r\n\r\n"; + if( strlen($contents) > 0 ) { + $requestStrings .= $contents."\r\n\r\n"; + } + return $requestStrings; + } + /** + * レスポンス文字列をヘッダとボディに分割します + */ + function _convertResponse( $responseText ) { + // レスポンスヘッダ文字列(最初のCRLFCRLFまで)を取得 + $globalHeaderStr = substr( $responseText, 0, strpos($responseText,"\r\n\r\n")); + $globalHeaders = explode("\r\n",$globalHeaderStr); + // レスポンスステータスを確認 + $responseStatus = array_shift($globalHeaders); + $responseStatusElms = explode(" ",$responseStatus); + $this->responseProtocol = array_shift($responseStatusElms); + $this->statusCode = array_shift($responseStatusElms); + $this->statusMessage = implode(' ',$responseStatusElms); + // ヘッダをハッシュに格納 + foreach($globalHeaders as $line){ + if( strlen($line) > 0 ) { + $headers = explode(":",$line); + if( count($headers) > 0 ) { + $key = array_shift($headers); + $val = implode(':',$headers); + $this->responseHeaders[trim($key)] = trim($val); + } + } + } + // ボディの解析 + if( $this->responseHeaders['Transfer-Encoding'] == 'chunked' ) { + $hexHeaderStr = bin2hex($globalHeaderStr."\r\n\r\n"); + $hexSeparator = bin2hex("\r\n"); + $bodyStartPos = strlen($hexHeaderStr); + $hexBodyStr = bin2hex($responseText); + $hexBodyStr = substr($hexBodyStr,$bodyStartPos); + $bodyChunkArray = explode($hexSeparator,$hexBodyStr); + // 0,2,4,..偶数はチャンクサイズなので削除してつなげ直す + $i = 0; + $hexBodyStr = ''; + foreach( $bodyChunkArray as $val ) { + if( $i%2 != 0 ) { $hexBodyStr .= $val; } + $i++; + } + $this->responseBody = pack("H*",$hexBodyStr); + } else { + $lines = explode("\r\n\r\n",$responseText); + $globalHeaderStr = array_shift($lines); + $responseBody = implode("\r\n\r\n",$lines); + $this->responseBody = $responseBody; + } + } +} +?> \ No newline at end of file From svnnotify @ sourceforge.jp Tue Jun 22 11:09:58 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 22 Jun 2010 11:09:58 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B107=5D__RewriteD?= =?utf-8?b?b2N1bWVudFJvb3Tjgr/jgrDjga7kv67mraPjgII=?= Message-ID: <1277172598.606462.8431.nullmailer@users.sourceforge.jp> Revision: 107 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=107 Author: m_nakashima Date: 2010-06-22 11:09:58 +0900 (Tue, 22 Jun 2010) Log Message: ----------- RewriteDocumentRootタグの修正。 同じ名称のフォルダが階層内にあった場合にリンク変換が正しく行われない問題の修正をおこないました。 Modified Paths: -------------- current/README.txt current/spider/lib/spider/tags/RewriteDocumentRoot.class.php current/spider/lib/util/HttpRequest.class.php current/spider/spider_main.inc.php Removed Paths: ------------- current/spider/lib/util/GetHTTPResponse.class.php -------------- next part -------------- Modified: current/README.txt =================================================================== --- current/README.txt 2010-06-03 07:18:21 UTC (rev 106) +++ current/README.txt 2010-06-22 02:09:58 UTC (rev 107) @@ -3,6 +3,8 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2010-06-22 +1) RewriteDocumentRootタグの修正。同じ名称のフォルダが階層内にあった場合にリンク変換が正しく行われない問題の修正をおこないました。 -- 2010-06-03 1) setタグクラスの修正をおこないました。第二引数全体が''で囲まれていた場合、文字列判断はPHPプログラム と同等の記述で動作するようになりました。 Modified: current/spider/lib/spider/tags/RewriteDocumentRoot.class.php =================================================================== --- current/spider/lib/spider/tags/RewriteDocumentRoot.class.php 2010-06-03 07:18:21 UTC (rev 106) +++ current/spider/lib/spider/tags/RewriteDocumentRoot.class.php 2010-06-22 02:09:58 UTC (rev 107) @@ -16,7 +16,8 @@ * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima * @since PHP 4.3 */ -require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."TagBase.class.php"); +require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'TagBase.class.php'); +require_once(dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'util'.DIRECTORY_SEPARATOR.'CharUtility.class.php'); class spider_tags_RewriteDocumentRoot extends spider_tags_TagBase { /** @@ -39,9 +40,10 @@ // 明示的に否定していないなら暗黙的に書き換える $result_strings = preg_replace( '/\\{rewrite\\-document\\-root\\:[^\\}]*?\\}/' , "", $result_strings ); - $replace_uri = APPLICATION_BASE_URI; - if( preg_match('/\\/$/', APPLICATION_BASE_URI) > 0 ) { - $replace_uri = preg_replace('/\\/$/','',$replace_uri); + $regxUri = str_replace('\\','\\\\',util_CharUtility::escapeRegxStr(APPLICATION_BASE_URI)); + $replaceUri = APPLICATION_BASE_URI; + if( preg_match('/\\/$/', $replaceUri) > 0 ) { + $replaceUri = preg_replace('/\\/$/','',$replaceUri); } // src書き換え $process_code = 'if( preg_match_all( \'/[sS][rR][cC]\\\\=([\\\'"])(\\/([^\\\'"\\/][^\\\'"]*|))([\\\'"])/\''; @@ -50,8 +52,8 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/\'.str_replace("/","\\/",\''.$replace_uri.'\').\'/\', $target ) == 0 ) { '."\n"; - $process_code .= '$repstr = preg_replace(\'/[sS][rR][cC]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'src=${1}'.$replace_uri.'${2}${3}\',$target); '."\n"; + $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= '$repstr = preg_replace(\'/[sS][rR][cC]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'src=${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; $process_code .= '}}}'; @@ -63,8 +65,8 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/\'.str_replace("/","\\/",\''.$replace_uri.'\').\'/\', $target ) == 0 ) { '."\n"; - $process_code .= '$repstr = preg_replace(\'/[hH][rR][eE][fF]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'href=${1}'.$replace_uri.'${2}${3}\',$target); '."\n"; + $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= '$repstr = preg_replace(\'/[hH][rR][eE][fF]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'href=${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; $process_code .= '}}}'; @@ -76,8 +78,8 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/\'.str_replace("/","\\/",\''.$replace_uri.'\').\'/\', $target ) == 0 ) { '."\n"; - $process_code .= '$repstr = preg_replace(\'/[aA][cC][tT][iI][oO][nN]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'action=${1}'.$replace_uri.'${2}${3}\',$target); '."\n"; + $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= '$repstr = preg_replace(\'/[aA][cC][tT][iI][oO][nN]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'action=${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; $process_code .= '}}}'; @@ -89,8 +91,8 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/\'.str_replace("/","\\/",\''.$replace_uri.'\').\'/\', $target ) == 0 ) { '."\n"; - $process_code .= '$repstr = preg_replace(\'/window\\\\.open\\\\(([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'window.open(${1}'.$replace_uri.'${2}${3}\',$target); '."\n"; + $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= '$repstr = preg_replace(\'/window\\\\.open\\\\(([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'window.open(${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; $process_code .= '}}}'; @@ -102,8 +104,8 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/\'.str_replace("/","\\/",\''.$replace_uri.'\').\'/\', $target ) == 0 ) { '."\n"; - $process_code .= '$repstr = preg_replace(\'/url\\\\(([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'url(${1}'.$replace_uri.'${2}${3}\',$target); '."\n"; + $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= '$repstr = preg_replace(\'/url\\\\(([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'url(${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; $process_code .= '}}}'; Deleted: current/spider/lib/util/GetHTTPResponse.class.php =================================================================== --- current/spider/lib/util/GetHTTPResponse.class.php 2010-06-03 07:18:21 UTC (rev 106) +++ current/spider/lib/util/GetHTTPResponse.class.php 2010-06-22 02:09:58 UTC (rev 107) @@ -1,208 +0,0 @@ - http://www.md-systems.net/ - * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima - * @since PHP 4.3 - * @deprecated - */ -class util_GetHTTPResponse { - var $protocol = ""; - var $status_code = ""; - var $status_string = ""; - var $response_headers = array(); - var $response_body = null; - function util_GetHTTPResponse(){ - } - function get($url,$header_params=array()){ - list( $pr, $blank, $domain ) = explode('/',$url ); - $uri = substr($url,strpos($url,$domain)); - $uri = str_replace($domain,"",$uri); - if( strlen($uri) == 0 ) { - $uri = '/'; - } - if( preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/',gethostbyname($domain)) == 0 ) { - return false; - } - return $this->get_response($domain,$uri,$header_params); - } - function get_response($host,$uri,$header_params=array()){ - $request = "GET {$uri} HTTP/1.1\r\n" - ."Accept: */*\r\n" - ."Host: {$host}\r\n" - ; - foreach( $header_params as $key => $value ) { - if( strlen(trim($key)) > 0 && strlen(trim($value)) > 0 ) { - $request .= $key . ": " . $value . "\r\n"; - } - } - $request .= "Connection: close\r\n\r\n"; - if( $fp = @fsockopen( gethostbyname($host), 80, $rv->en, $rv->es, 20 ) ){ - if( socket_set_timeout( $fp, 30 ) ) { - fwrite( $fp, $request ); - $response = ''; - while (!feof($fp)) { - $response .= fgets($fp, 128); - } - // responseの解析 - $header_string = ''; - $response_body = null; - - // レスポンスヘッダ文字列を取得 - $header_string = substr( $response, 0, strpos($response,"\r\n\r\n")); - $headerpear_array = explode("\r\n",$header_string); - // レスポンスステータスを確認 - $status_str = array_shift($headerpear_array); - list($this->protocol,$this->status_code,$this->status_string) - = explode(" ",$status_str); - // その他のヘッダを取得 - foreach($headerpear_array as $line){ - if( strlen($line) > 0 ) { - $headers = explode(":",$line); - if( count($headers) > 0 ) { - $key = array_shift($headers); - $val = implode(':',$headers); - $this->response_headers[trim($key)] = trim($val); - } - } - } - // レスポンスボディの取得 - if( $this->response_headers['Transfer-Encoding'] == 'chunked' ) { - $header_hex_string = bin2hex($header_string."\r\n\r\n"); - $separator_hex_string = bin2hex("\r\n"); - $body_start_pos = strlen($header_hex_string); - $body_hex_string = bin2hex($response); - $body_hex_string = substr($body_hex_string,$body_start_pos); - $body_chunk_array = explode($separator_hex_string,$body_hex_string); - // 0,2,4,..偶数はチャンクサイズなので削除してつなげ直す - $i = 0; - $body_hex_string = ''; - foreach( $body_chunk_array as $val ) { - if( $i%2 != 0 ) { $body_hex_string .= $val; } - $i++; - } - $this->response_body = pack("H*",$body_hex_string); - } else { - $lines = explode("\r\n\r\n",$response); - $header_string = array_shift($lines); - $response_body = implode("\r\n\r\n",$lines); - $this->response_body = $response_body; - $headerpear_array = explode("\r\n",$header_string); - $status_str = array_shift($headerpear_array); - list($this->protocol,$this->status_code,$this->status_string) - = explode(" ",$status_str); - } - return true; - } - return false; - } else { - return false; - } - } - function post($url,$header_params=array(),$requestBody){ - list( $pr, $blank, $domain ) = explode('/',$url ); - $uri = substr($url,strpos($url,$domain)); - $uri = str_replace($domain,"",$uri); - if( strlen($uri) == 0 ) { - $uri = '/'; - } - if( preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/',gethostbyname($domain)) == 0 ) { - return false; - } - return $this->post_response($domain,$uri,$header_params,$requestBody); - } - function post_response($host,$uri,$header_params=array(),$requestBody){ - $request = "POST {$uri} HTTP/1.1\r\n" - ."Accept: */*\r\n" - ."Host: {$host}\r\n" - ; - foreach( $header_params as $key => $value ) { - if( strlen(trim($key)) > 0 && strlen(trim($value)) > 0 ) { - $request .= $key . ": " . $value . "\r\n"; - } - } - $request .= "Connection: close\r\n\r\n"; - $request .= "Content-Type: application/x-www-form-urlencoded;charset=UTF-8\r\n"; - $request .= "Content-Length: ".strlen($requestBody)."\r\n\r\n"; - $request .= $requestBody; - if( $fp = @fsockopen( $host, 80, $rv->en, $rv->es, 20 ) ){ - if( socket_set_timeout( $fp, 30 ) ) { - fwrite( $fp, $request ); - $response = ''; - while (!feof($fp)) { - $response .= fgets($fp, 128); - } - // responseの解析 - $header_string = ''; - $response_body = null; - - // レスポンスヘッダ文字列を取得 - $header_string = substr( $response, 0, strpos($response,"\r\n\r\n")); - $headerpear_array = explode("\r\n",$header_string); - // レスポンスステータスを確認 - $status_str = array_shift($headerpear_array); - list($this->protocol,$this->status_code,$this->status_string) - = explode(" ",$status_str); - // その他のヘッダを取得 - foreach($headerpear_array as $line){ - if( strlen($line) > 0 ) { - $headers = explode(":",$line); - if( count($headers) > 0 ) { - $key = array_shift($headers); - $val = implode(':',$headers); - $this->response_headers[trim($key)] = trim($val); - } - } - } - // レスポンスボディの取得 - if( $this->response_headers['Transfer-Encoding'] == 'chunked' ) { - $header_hex_string = bin2hex($header_string."\r\n\r\n"); - $separator_hex_string = bin2hex("\r\n"); - $body_start_pos = strlen($header_hex_string); - $body_hex_string = bin2hex($response); - $body_hex_string = substr($body_hex_string,$body_start_pos); - $body_chunk_array = explode($separator_hex_string,$body_hex_string); - // 0,2,4,..偶数はチャンクサイズなので削除してつなげ直す - $i = 0; - $body_hex_string = ''; - foreach( $body_chunk_array as $val ) { - if( $i%2 != 0 ) { $body_hex_string .= $val; } - $i++; - } - $this->response_body = pack("H*",$body_hex_string); - } else { - $lines = explode("\r\n\r\n",$response); - $header_string = array_shift($lines); - $response_body = implode("\r\n\r\n",$lines); - $this->response_body = $response_body; - $headerpear_array = explode("\r\n",$header_string); - $status_str = array_shift($headerpear_array); - list($this->protocol,$this->status_code,$this->status_string) - = explode(" ",$status_str); - } - return true; - } - return false; - } else { - return false; - } - } -} -//$obj = new util_GetHTTPResponse(); -//if( $obj->get('http://www.md-systems.net/') ){ -//// foreach( $obj->response_headers as $key => $value ) { -//// header($key.': '.$value); -//// } -//// print $obj->response_body; -//// -// header('Content-type: text/plain;charset=UTF-8'); -//print_r($obj); -//} else { -// header('Content-type: text/plain;charset=UTF-8'); -// echo "通信に失敗"; -//} -// -?> \ No newline at end of file Modified: current/spider/lib/util/HttpRequest.class.php =================================================================== --- current/spider/lib/util/HttpRequest.class.php 2010-06-03 07:18:21 UTC (rev 106) +++ current/spider/lib/util/HttpRequest.class.php 2010-06-22 02:09:58 UTC (rev 107) @@ -109,7 +109,7 @@ // リクエスト文字列作成 $requestStrings = $this->_createRequestStrings( $contents ); // ソケット通信 - if( $socket = @fsockopen( $connectTarget, $this->requestPort, $this->errorNumber, $this->errorMessage, $timeout ) ){ + if( $socket = @fsockopen( $address, $this->requestPort, $this->errorNumber, $this->errorMessage, $timeout ) ){ if( @socket_set_timeout( $socket, $timeout ) ) { // リクエスト送信 fwrite( $socket, $requestStrings ); @@ -148,9 +148,13 @@ $requestStrings .= $key . ": " . $value . "\r\n"; } } - $requestStrings .= "Connection: close\r\n\r\n"; + $requestStrings .= "Connection: close\r\n"; if( strlen($contents) > 0 ) { + $requestStrings .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $requestStrings .= "Content-Length: ".strlen($contents)."\r\n\r\n"; $requestStrings .= $contents."\r\n\r\n"; + } else { + $requestStrings .= "\r\n"; } return $requestStrings; } Modified: current/spider/spider_main.inc.php =================================================================== --- current/spider/spider_main.inc.php 2010-06-03 07:18:21 UTC (rev 106) +++ current/spider/spider_main.inc.php 2010-06-22 02:09:58 UTC (rev 107) @@ -3,7 +3,7 @@ * framework-spider: Webページ利用用共通メイン実行ファイル */ // Framework Version -define( 'SPIDER_VERSION', '1.0.01' ); +define( 'SPIDER_VERSION', '1.0.04' ); /* 設定ファイルの読み込み */ require_once( dirname(__FILE__).DIRECTORY_SEPARATOR.'define.inc.php' ); From svnnotify @ sourceforge.jp Tue Jun 22 11:13:29 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 22 Jun 2010 11:13:29 +0900 Subject: [Frameworkspider-svn] spider-commit [108] Message-ID: <1277172809.559758.13986.nullmailer@users.sourceforge.jp> Revision: 108 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=108 Author: m_nakashima Date: 2010-06-22 11:13:29 +0900 (Tue, 22 Jun 2010) Log Message: ----------- Modified Paths: -------------- current/spider/lib/spider/BuildInformation.class.php current/spider/lib/util/HttpRequest.class.php -------------- next part -------------- Modified: current/spider/lib/spider/BuildInformation.class.php =================================================================== --- current/spider/lib/spider/BuildInformation.class.php 2010-06-22 02:09:58 UTC (rev 107) +++ current/spider/lib/spider/BuildInformation.class.php 2010-06-22 02:13:29 UTC (rev 108) @@ -97,9 +97,10 @@ $virtual_root = APPLICATION_BASE_PATH; if( preg_match('/^[a-zA-Z]\\:/', APPLICATION_BASE_PATH, $regmatch_array ) ) { // Windows対策ドライブをディレクトリとして変換 - $drive_name = substr($regmatch_array[0],0,1); - $virtual_root = preg_replace('/^[a-zA-Z]\\:/' - ,$drive_name.DIRECTORY_SEPARATOR,$virtual_root ); + $driveName = substr($regmatch_array[0],0,1); + $virtual_root = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR,preg_replace('/^[a-zA-Z]\\:/' + ,$driveName.DIRECTORY_SEPARATOR,$virtual_root )); } else { $virtual_root = substr($virtual_root,1); } @@ -109,8 +110,9 @@ if( preg_match('/^[a-zA-Z]\\:/', APPLICATION_BASE_PATH, $regmatch_array ) > 0 ) { // Windows対策ドライブをディレクトリとして変換 $driveName = substr($regmatch_array[0],0,1); - $cutPath = preg_replace('/^[a-zA-Z]\\:/' - ,$driveName.DIRECTORY_SEPARATOR, $cutPath ); + $cutPath = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, + DIRECTORY_SEPARATOR,preg_replace('/^[a-zA-Z]\\:/' + ,$driveName.DIRECTORY_SEPARATOR, $cutPath )); } $virtual_root = preg_replace('/^'.util_CharUtility::escapeRegxStr($cutPath).'/','',$virtual_root); } Modified: current/spider/lib/util/HttpRequest.class.php =================================================================== --- current/spider/lib/util/HttpRequest.class.php 2010-06-22 02:09:58 UTC (rev 107) +++ current/spider/lib/util/HttpRequest.class.php 2010-06-22 02:13:29 UTC (rev 108) @@ -23,7 +23,8 @@ var $requestMethod = 'get'; /** リクエストヘッダハッシュ */ var $requestHeaders = array(); - + /** POSTリクエストデータハッシュ */ + var $postDataHash = array(); /** レスポンスステータスコード */ var $statusCode = 0; /** レスポンスステータスメッセージ */ @@ -69,6 +70,8 @@ } } } + // POST情報をクリア + $this->clearPostData(); } /** * リクエストを送信して結果を取得します @@ -92,13 +95,11 @@ $this->requestUri = '/'.implode('/',$urlElementArray); $this->requestHostName = $fqdn; $this->requestPort = 80; - $connectTarget = $this->requestHostName; // ホスト名整理 if( strpos( $this->requestHostName, ':' ) !== false ) { list( $this->requestHostName, $this->requestPort ) = explode(':',$this->requestHostName); } else if( strtolower($this->requestProtocol) == 'https' ) { $this->requestPort = 443; - $connectTarget = 'ssl://'.$this->requestHostName; } // ホスト存在確認 $address = gethostbyname($this->requestHostName); @@ -106,28 +107,96 @@ $this->errorMessage = 'Target Host is not found!'; return false; } - // リクエスト文字列作成 - $requestStrings = $this->_createRequestStrings( $contents ); - // ソケット通信 - if( $socket = @fsockopen( $address, $this->requestPort, $this->errorNumber, $this->errorMessage, $timeout ) ){ - if( @socket_set_timeout( $socket, $timeout ) ) { - // リクエスト送信 - fwrite( $socket, $requestStrings ); - // レスポンス文字列受信 - $responseText = ''; - while (!feof($socket)) { - $responseText .= fgets($socket, 128); + // 接続先の判断:IPアドレスで接続する + $connectTarget = $address; + if( strtolower($this->requestProtocol) == 'https' ) { + $connectTarget = 'ssl://'.$address; + } + + // PEAR HTTP_Requestの存在確認 + @include_once('HTTP/Request.php'); + if( class_exists('HTTP_Request') ){ + // PEARが存在するなら優先 + $httpRequestOptions = array( + // タイムアウトの秒数指定 + 'timeout' => $timeout, + //"allowRedirects" => true, // リダイレクトの許可設定(true/false) + //"maxRedirects" => 3, // リダイレクトの最大回数 + ); + // httpリクエストオブジェクト作成 + $httpRequest = new HTTP_Request($this->requestUrl, $httpRequestOptions ); + if( 'post' == strtolower($this->requestMethod) ) { + $httpRequest->setMethod(HTTP_REQUEST_METHOD_POST); + } else { + $httpRequest->setMethod(HTTP_REQUEST_METHOD_GET); + } + // headerパラメータ + if( is_array($this->requestHeaders) && count($this->requestHeaders) > 0 ) { + foreach( $this->requestHeaders as $key => $val ) { + $httpRequest->addHeader($key,$val); } - $this->_convertResponse( $responseText ); + } + // bodyコンテンツ + $contentArray = explode('&',$contents); + foreach( $contentArray as $content ) { + list( $key, $val ) = explode('=',$content); + $this->postDataHash[urldecode($key)] = urldecode($val); + } + if( is_array($this->postDataHash) && count($this->postDataHash) > 0 ) { + $httpRequest->addHeader('Content-Type','application/x-www-form-urlencoded'); + foreach( $this->postDataHash as $key => $val ) { + $httpRequest->addPostData($key, $val); + } + } + // リクエスト実行 + $httpResponse = $httpRequest->sendRequest(); + if (!PEAR::isError($httpResponse)) { + // 応答内容の解析 + $this->responseProtocol = $this->requestProtocol; + $this->statusCode = $httpRequest->getResponseCode(); + $this->statusMessage = $httpRequest->getResponseReason(); + $this->responseHeaders = $httpRequest->getResponseHeader(); + $this->responseBody = $httpRequest->getResponseBody(); + return true; } else { - $this->errorMessage = 'Can\'t set connection timeout!'; + // リクエストエラー + $this->errorMessage = $httpResponse->getMessage(); return false; } - @fclose($socket); } else { - return false; + // PEARが存在しない場合 + if( strtolower($this->requestProtocol) == 'https' ) { + // SSL接続の場合 + if( function_exists('get_loaded_extensions') && in_array('openssl', get_loaded_extensions())) { + } else { + // openssl拡張モジュールがないならエラー + $this->errorMessage = 'Requre PEAR:HTTP_Request or openssl extension!'; + return false; + } + } + // リクエスト文字列作成 + $requestStrings = $this->_createRequestStrings( $contents ); + // ソケット通信 + if( $socket = @fsockopen( $connectTarget, $this->requestPort, $this->errorNumber, $this->errorMessage, $timeout ) ){ + if( @socket_set_timeout( $socket, $timeout ) ) { + // リクエスト送信 + fwrite( $socket, $requestStrings ); + // レスポンス文字列受信 + $responseText = ''; + while (!feof($socket)) { + $responseText .= fgets($socket, 128); + } + $this->_convertResponse( $responseText ); + } else { + $this->errorMessage = 'Can\'t set connection timeout!'; + return false; + } + @fclose($socket); + } else { + return false; + } + return true; } - return true; } /** * リクエスト用文字列を作成して取得します @@ -149,6 +218,27 @@ } } $requestStrings .= "Connection: close\r\n"; + + // POSTリクエストデータがあるなら文字列に追加 + if( $this->requestMethod == 'post' && is_array($this->postDataHash) ) { + $addContentsArray = array(); + foreach( $this->postDataHash as $key => $value ) { + if( strlen($key) > 0 ) { + array_push($addContentsArray, urlencode($key).'='.urlencode($value) ); + } + } + if( count($addContentsArray) > 0 ) { + $str = implode('&',$addContentsArray); + if( strlen($contents) == 0 ) { + $contents = $str; + } else if( preg_match('/\\&$/',$contents) == 0 ) { + $contents .= '&'.$str; + } else { + $contents .= $str; + } + } + } + if( strlen($contents) > 0 ) { $requestStrings .= "Content-Type: application/x-www-form-urlencoded\r\n"; $requestStrings .= "Content-Length: ".strlen($contents)."\r\n\r\n"; @@ -156,6 +246,7 @@ } else { $requestStrings .= "\r\n"; } + $this->requestStrings = $requestStrings; return $requestStrings; } /** @@ -205,5 +296,32 @@ $this->responseBody = $responseBody; } } + /** + * POSTで送信するデータを追加・設定します。keyが同じ場合は値を上書きします + * @param $key POSTするキー文字列 + * @param $value POSTする値文字列 + */ + function addPostData( $key, $value ) { + if( strlen($key)>0 ) { + $this->postDataHash[$key] = $value; + } + } + /** + * 現在設定されるPOSTデータをキーを指定して取得します。 + * @param $key POSTするキー文字列 + */ + function getPostData( $key ) { + if( isset( $this->postDataHash[$key] ) ) { + return $this->postDataHash[$key]; + } else { + return null; + } + } + /** + * 現在設定されているPOSTデータをクリアします + */ + function clearPostData() { + $this->postDataHash = array(); + } } ?> \ No newline at end of file From svnnotify @ sourceforge.jp Tue Jun 22 13:02:17 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 22 Jun 2010 13:02:17 +0900 Subject: [Frameworkspider-svn] spider-commit [109] Message-ID: <1277179337.009423.3095.nullmailer@users.sourceforge.jp> Revision: 109 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=109 Author: m_nakashima Date: 2010-06-22 13:02:16 +0900 (Tue, 22 Jun 2010) Log Message: ----------- Modified Paths: -------------- current/spider/lib/spider/tags/Template.class.php -------------- next part -------------- Modified: current/spider/lib/spider/tags/Template.class.php =================================================================== (Binary files differ) From svnnotify @ sourceforge.jp Tue Jun 22 13:04:07 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 22 Jun 2010 13:04:07 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B110=5D__spider_T?= =?utf-8?b?ZW1wbGF0ZeOCv+OCsOOBruS/ruato+OAgiAuIGRlZmF1bHTjg5XjgqHjgqQ=?= =?utf-8?b?44Or44Gu44Oi44K444Ol44O844Or5ZG844Gz5Ye644GX44GM5aSW5YG044OG?= =?utf-8?b?44Oz44OX44Os44O844OI44KI44KK5YSq5YWI44GV44KM44Gm44GE44Gq44GL?= =?utf-8?b?44Gj44Gf5ZWP6aGM44KS5L+u5q2j44GX44G+44GX44Gf44CC?= Message-ID: <1277179447.452200.6244.nullmailer@users.sourceforge.jp> Revision: 110 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=110 Author: m_nakashima Date: 2010-06-22 13:04:07 +0900 (Tue, 22 Jun 2010) Log Message: ----------- spider Templateタグの修正。.defaultファイルのモジュール呼び出しが外側テンプレートより優先されていなかった問題を修正しました。 Modified Paths: -------------- current/README.txt -------------- next part -------------- Modified: current/README.txt =================================================================== --- current/README.txt 2010-06-22 04:02:16 UTC (rev 109) +++ current/README.txt 2010-06-22 04:04:07 UTC (rev 110) @@ -5,6 +5,7 @@ ** -- 2010-06-22 1) RewriteDocumentRootタグの修正。同じ名称のフォルダが階層内にあった場合にリンク変換が正しく行われない問題の修正をおこないました。 +2) Templateタグの修正。外側テンプレートに記述されたモジュールより優先されていなかった問題の修正 -- 2010-06-03 1) setタグクラスの修正をおこないました。第二引数全体が''で囲まれていた場合、文字列判断はPHPプログラム と同等の記述で動作するようになりました。 From svnnotify @ sourceforge.jp Wed Jun 23 20:10:08 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Wed, 23 Jun 2010 20:10:08 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B112=5D__CopyRigh?= =?utf-8?b?dOOBruS/ruatow==?= Message-ID: <1277291408.695133.18129.nullmailer@users.sourceforge.jp> Revision: 112 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=112 Author: m_nakashima Date: 2010-06-23 20:10:08 +0900 (Wed, 23 Jun 2010) Log Message: ----------- CopyRightの修正 Modified Paths: -------------- current/spider/lib/spider/functions.inc.php -------------- next part -------------- Modified: current/spider/lib/spider/functions.inc.php =================================================================== --- current/spider/lib/spider/functions.inc.php 2010-06-23 04:25:37 UTC (rev 111) +++ current/spider/lib/spider/functions.inc.php 2010-06-23 11:10:08 UTC (rev 112) @@ -13,11 +13,6 @@ * Modifier : Masanori Nakashima * Last Updated: 2010.06.23 * - * @version 1.0.00 - * @copyright Copyright © 2008, Framework-Spider Developer Team. http://sourceforge.jp/projects/frameworkspider/ - * @author Multimedia Digital Contents Systems.Co.,Ltd. Masanori Nakashima - * @since PHP 4.3 - * */ /** * spiderに必要なディレクトリとファイルのパーミッションを確認します From svnnotify @ sourceforge.jp Thu Jun 24 10:33:57 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Thu, 24 Jun 2010 10:33:57 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B113=5D__RewriteD?= =?utf-8?b?b2N1bWVudFJvb3Tjgr/jgrDjga7kv67mraPjgILlkIzjgZjlkI3np7Djga4=?= =?utf-8?b?44OV44Kp44Or44OA44GM6ZqO5bGk5YaF44Gr44GC44Gj44Gf5aC05ZCI44Gr?= =?utf-8?b?44Oq44Oz44Kv5aSJ5o+b44GM5q2j44GX44GP6KGM44KP44KM44Gq44GE5ZWP?= =?utf-8?b?6aGM44Gu5YaN5L+u5q2j?= Message-ID: <1277343237.435670.2688.nullmailer@users.sourceforge.jp> Revision: 113 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=113 Author: m_nakashima Date: 2010-06-24 10:33:57 +0900 (Thu, 24 Jun 2010) Log Message: ----------- RewriteDocumentRootタグの修正。同じ名称のフォルダが階層内にあった場合にリンク変換が正しく行われない問題の再修正 Modified Paths: -------------- current/spider/lib/spider/tags/Module.class.php current/spider/lib/spider/tags/RewriteDocumentRoot.class.php current/spider/lib/spider/tags/Write.class.php -------------- next part -------------- Modified: current/spider/lib/spider/tags/Module.class.php =================================================================== --- current/spider/lib/spider/tags/Module.class.php 2010-06-23 11:10:08 UTC (rev 112) +++ current/spider/lib/spider/tags/Module.class.php 2010-06-24 01:33:57 UTC (rev 113) @@ -1,7 +1,7 @@ 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= 'if( preg_match(\'/^[sS][rR][cC]\\\\=([\\\'"])'.$regxUri.'/\', $target ) == 0 ) { '."\n"; $process_code .= '$repstr = preg_replace(\'/[sS][rR][cC]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'src=${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; @@ -77,7 +77,7 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= 'if( preg_match(\'/^[hH][rR][eE][fF]\\\\=([\\\'"])'.$regxUri.'/\', $target ) == 0 ) { '."\n"; $process_code .= '$repstr = preg_replace(\'/[hH][rR][eE][fF]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'href=${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; @@ -90,7 +90,7 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= 'if( preg_match(\'/^[aA][cC][tT][iI][oO][nN]\\\\=([\\\'"])'.$regxUri.'/\', $target ) == 0 ) { '."\n"; $process_code .= '$repstr = preg_replace(\'/[aA][cC][tT][iI][oO][nN]\\\\=([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'action=${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; @@ -103,7 +103,7 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= 'if( preg_match(\'/^window\\\\.open\\\\(([\\\'"])'.$regxUri.'/\', $target ) == 0 ) { '."\n"; $process_code .= '$repstr = preg_replace(\'/window\\\\.open\\\\(([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'window.open(${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; @@ -116,7 +116,7 @@ $process_code .= ', PREG_PATTERN_ORDER ) > 0 ) { '; $process_code .= 'foreach ( $output_array as $output ) { '; $process_code .= 'foreach ( $output as $target ) { '; - $process_code .= 'if( preg_match(\'/^\'.\''.$regxUri.'\'.\'/\', $target ) == 0 ) { '."\n"; + $process_code .= 'if( preg_match(\'/^'.$regxUri.'/\', $target ) == 0 ) { '."\n"; $process_code .= '$repstr = preg_replace(\'/url\\\\(([\\\'"])(\\/[^\\\'"]*)([\\\'"])/\',\'url(${1}'.$replaceUri.'${2}${3}\',$target); '."\n"; $process_code .= '$outstr = str_replace( $target, $repstr, $outstr );'."\n"; $process_code .= ' }'."\n"; Modified: current/spider/lib/spider/tags/Write.class.php =================================================================== --- current/spider/lib/spider/tags/Write.class.php 2010-06-23 11:10:08 UTC (rev 112) +++ current/spider/lib/spider/tags/Write.class.php 2010-06-24 01:33:57 UTC (rev 113) @@ -1,7 +1,7 @@ Revision: 114 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=114 Author: m_nakashima Date: 2010-06-25 10:32:22 +0900 (Fri, 25 Jun 2010) Log Message: ----------- spiderのビルドファイル作成パスが一部のWindows環境でうまく動作しなかった問題の修正 Modified Paths: -------------- current/README.txt current/spider/lib/spider/BuildInformation.class.php -------------- next part -------------- Modified: current/README.txt =================================================================== --- current/README.txt 2010-06-24 01:33:57 UTC (rev 113) +++ current/README.txt 2010-06-25 01:32:22 UTC (rev 114) @@ -10,6 +10,8 @@ ** Modifier : Masanori Nakashima ** Last Updated: 2010.06.23 ** +-- 2010-06-25 +1)spiderのビルドファイル作成パスが一部のWindows環境でうまく動作しなかった問題の修正 -- 2010-06-22 1) RewriteDocumentRootタグの修正。同じ名称のフォルダが階層内にあった場合にリンク変換が正しく行われない問題の修正をおこないました。 2) Templateタグの修正。外側テンプレートに記述されたモジュールより優先されていなかった問題の修正 Modified: current/spider/lib/spider/BuildInformation.class.php =================================================================== --- current/spider/lib/spider/BuildInformation.class.php 2010-06-24 01:33:57 UTC (rev 113) +++ current/spider/lib/spider/BuildInformation.class.php 2010-06-25 01:32:22 UTC (rev 114) @@ -109,36 +109,35 @@ * 実行ビルドファイルパスを取得します */ function getAgentPageBuildFilePath() { - $virtual_root = APPLICATION_BASE_PATH; - if( preg_match('/^[a-zA-Z]\\:/', APPLICATION_BASE_PATH, $regmatch_array ) ) { - // Windows対策ドライブをディレクトリとして変換 - $driveName = substr($regmatch_array[0],0,1); - $virtual_root = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR,preg_replace('/^[a-zA-Z]\\:/' - ,$driveName.DIRECTORY_SEPARATOR,$virtual_root )); - } else { - $virtual_root = substr($virtual_root,1); - } - // 2009-12-16 実行ファイル作成パスをspiderの上層ディレクトリ起点とする + // 実行フォルダパスの変換を簡易にする + $vartualRoot = str_replace(DIRECTORY_SEPARATOR,'/',APPLICATION_BASE_PATH); + $appBaseUri = str_replace(DIRECTORY_SEPARATOR,'/',APPLICATION_BASE_URI); if( !defined('SPIDER_USE_ABSOLUTE_BIN_PATH') || SPIDER_USE_ABSOLUTE_BIN_PATH === false ) { - $cutPath = dirname(DIR_PATH_SPIDER_DATA); - if( preg_match('/^[a-zA-Z]\\:/', APPLICATION_BASE_PATH, $regmatch_array ) > 0 ) { - // Windows対策ドライブをディレクトリとして変換 - $driveName = substr($regmatch_array[0],0,1); - $cutPath = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR,preg_replace('/^[a-zA-Z]\\:/' - ,$driveName.DIRECTORY_SEPARATOR, $cutPath )); - } - $virtual_root = preg_replace('/^'.util_CharUtility::escapeRegxStr($cutPath).'/','',$virtual_root); + // 実行ファイルパスをspiderの上層ディレクトリにする + $cutPath = str_replace(DIRECTORY_SEPARATOR,'/',dirname(DIR_PATH_SPIDER_DATA)); + $vartualRoot = str_replace($cutPath,'',$vartualRoot); } - $bin_file_path = DIR_PATH_BIN - .DIRECTORY_SEPARATOR.$virtual_root - .DIRECTORY_SEPARATOR.str_replace('/','',str_replace(DIRECTORY_SEPARATOR,'',APPLICATION_BASE_URI)) - .DIRECTORY_SEPARATOR.$this->getAgentPageUri(); - $bin_file_path = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR,DIRECTORY_SEPARATOR,$bin_file_path); - if( !is_dir( dirname($bin_file_path) ) ) { + if( strpos($vartualRoot,':') !== false ) { + // windows対策に:を変換 + $vartualRoot = str_replace(':','_CMA',dirname($vartualRoot)); + } + if( strpos($vartualRoot,'/') === 0 ) { + // /から始まるなら頭の/を除去 + $vartualRoot = substr($vartualRoot,1); + } + $binFilePath = DIR_PATH_BIN.'/'.$vartualRoot + .'/'.str_replace('/','_',$appBaseUri) + .'/'.$this->getAgentPageUri(); + while( strpos($binFilePath,DIRECTORY_SEPARATOR) !== false ){ + $binFilePath = str_replace(DIRECTORY_SEPARATOR,'/',$binFilePath); + } + while( strpos($binFilePath,'//') !== false ){ + $binFilePath = str_replace('//','/',$binFilePath); + } + $binFilePath = str_replace('/',DIRECTORY_SEPARATOR,$binFilePath); + if( !is_dir( dirname($binFilePath) ) ) { // 上位ディレクトリがないならディレクトリ階層を作成する - $dirname_array = explode(DIRECTORY_SEPARATOR, dirname($bin_file_path) ); + $dirname_array = explode(DIRECTORY_SEPARATOR, dirname($binFilePath) ); $dir_path = ''; foreach( $dirname_array as $dir_name ) { if( strlen($dir_path) > 0 ) { @@ -160,7 +159,7 @@ } } } - return $bin_file_path; + return $binFilePath; } /** * プレモジュール取り出し From svnnotify @ sourceforge.jp Fri Jun 25 17:58:40 2010 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Fri, 25 Jun 2010 17:58:40 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B115=5D__spider?= =?utf-8?b?44Gu44OT44Or44OJ44OV44Kh44Kk44Or5L2c5oiQ44OR44K544GM5LiA6YOo?= =?utf-8?b?44GuV2luZG93c+eSsOWig+OBp+OBhuOBvuOBj+WLleS9nOOBl+OBquOBiw==?= =?utf-8?b?44Gj44Gf5ZWP6aGM44Gu5L+u5q2j?= Message-ID: <1277456320.276121.3091.nullmailer@users.sourceforge.jp> Revision: 115 http://sourceforge.jp/projects/frameworkspider/svn/view?view=rev&revision=115 Author: m_nakashima Date: 2010-06-25 17:58:40 +0900 (Fri, 25 Jun 2010) Log Message: ----------- spiderのビルドファイル作成パスが一部のWindows環境でうまく動作しなかった問題の修正 Modified Paths: -------------- current/spider/lib/spider/BuildInformation.class.php -------------- next part -------------- Modified: current/spider/lib/spider/BuildInformation.class.php =================================================================== --- current/spider/lib/spider/BuildInformation.class.php 2010-06-25 01:32:22 UTC (rev 114) +++ current/spider/lib/spider/BuildInformation.class.php 2010-06-25 08:58:40 UTC (rev 115) @@ -128,7 +128,7 @@ $binFilePath = DIR_PATH_BIN.'/'.$vartualRoot .'/'.str_replace('/','_',$appBaseUri) .'/'.$this->getAgentPageUri(); - while( strpos($binFilePath,DIRECTORY_SEPARATOR) !== false ){ + if( strpos($binFilePath,DIRECTORY_SEPARATOR) !== false ){ $binFilePath = str_replace(DIRECTORY_SEPARATOR,'/',$binFilePath); } while( strpos($binFilePath,'//') !== false ){