svnno****@sourc*****
svnno****@sourc*****
2009年 3月 27日 (金) 10:09:33 JST
Revision: 12 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=12 Author: m_nakashima Date: 2009-03-27 10:09:32 +0900 (Fri, 27 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/example/Hello.class.php current/DATA/lib/spider/Controller.class.php current/DATA/lib/spider/HttpOutput.class.php current/DATA/lib/spider/HttpRequest.class.php current/DATA/spider_main.inc.php current/README.txt Added Paths: ----------- current/DATA/lib/spider/Builder.class.php Removed Paths: ------------- current/DATA/lib/spider/ExecutableFileCreator.class.php -------------- next part -------------- Modified: current/DATA/lib/example/Hello.class.php =================================================================== --- current/DATA/lib/example/Hello.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/example/Hello.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -17,7 +17,7 @@ /** * execute method * you need override this method for your application! - * @param object HttpRequest + * @param object spider_HttpRequest * @see lib/spider/HttpRequest.class.php */ function execute( & $request ) { Added: current/DATA/lib/spider/Builder.class.php =================================================================== --- current/DATA/lib/spider/Builder.class.php (rev 0) +++ current/DATA/lib/spider/Builder.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -0,0 +1,330 @@ +<?php +/** + * 実行ファイルを作成します。 + * + * @package spider spiderのコアパッケージ + * @version 1.0.01 + * @copyright Copyright © 2008, Multimedia Digital Contents Systems.Co.,Ltd.<info****@md-sy*****> http://www.md-systems.net/ + * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima <m_nakas****@md-sy*****> + * @since PHP 4.3 + */ +class spider_Builder { + + /** 元の本文文字列 */ + var $org_body_strings; + /** 出力する本文文字列 */ + var $out_body_strings; + + /** + * コンストラクタ + */ + function spider_Builder() { + } + /** + * HTMLボディを生成する + */ + function convertBody( & $build_information_object ) { + $action_lines = file( $build_information_object->execute_file_path ); + $this->out_body_strings = implode( "", $action_lines ); + $this->org_body_strings = $this->out_body_strings; + + // 改行コード統一と連続改行の削除 + $this->out_body_strings = str_replace( "\r\n", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\r", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\n\n\n", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); + + // cms.phpインクルード行を削除 + preg_match_all( '/include_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + preg_match_all( '/require_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + // spider.inc.phpインクルード行を削除 + preg_match_all( '/include_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + preg_match_all( '/require_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + + // 空PHP部分を削除 + $this->out_body_strings = preg_replace('/<\\?php[\\s]+\\?>/','',$this->out_body_strings); + + // フォルダデフォルトファイルの適用 + $folder_default_path = null; + $folder_path = dirname($build_information_object->execute_file_path); + while( strlen($folder_path) > strlen(APPLICATION_BASE_PATH) ) { + $folder_default_path = $folder_path.DIRECTORY_SEPARATOR.'.default'; + if( file_exists( $folder_default_path ) ) { + break; + } else { + $folder_default_path = null; + } + $folder_path = dirname($folder_path); + } + if( !is_null( $folder_default_path ) && file_exists($folder_default_path) ) { + $str = trim(file_get_contents($folder_default_path)); + $this->out_body_strings = $str.$this->out_body_strings; + } + + // 変換タグの読み込みと変換 + $tag_object_array = array(); + $dir_path_tags = dirname(__FILE__).DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR; + if ( is_dir($dir_path_tags) ) { + if ( $dh = opendir( $dir_path_tags ) ) { + while ( ( $file_name = readdir($dh) ) !== false ) { + if( $file_name != "." && $file_name != ".." + && preg_match('/^[0-9a-zA-Z]+?\\.class\\.php$/',$file_name)) { + require_once( dirname(__FILE__).DIRECTORY_SEPARATOR + ."tags".DIRECTORY_SEPARATOR.$file_name ); + $tag_class_name = "spider_tags_".substr($file_name,0,strpos($file_name,".")); + $tag_class_obj = new $tag_class_name; + if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { + $tag_object_array[$tag_class_obj->priority] = array(); + } + array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); + } + } + closedir($dh); + } else { + } + } else { + } + // 外部変換タグの読み込みと変換 + $external_tags_conf_file = dirname(__FILE__) + .DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR."externals.conf"; + if( file_exists( $external_tags_conf_file ) ) { + $lines = file( $external_tags_conf_file ); + foreach( $lines as $line ) { + $line = trim($line); + $tag_class_name = $line; + $tag_class_file = DIR_PATH_LIB.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$line).'.class.php'; + if( file_exists($tag_class_file) ) { + require_once( $tag_class_file ); + $tag_class_obj = new $tag_class_name; + if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { + $tag_object_array[$tag_class_obj->priority] = array(); + } + array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); + } + } + } + // 優先順にタグのコンバートメソッドを実行 + ksort($tag_object_array); + foreach( $tag_object_array as $key => $tag_array ) { + foreach($tag_array as $tag_obj ) { + $tag_obj->convert( $this->out_body_strings, $build_information_object ); + } + } + } + /** + * 実行ファイル実体を書き出す + * @param $bin_file_path 実行ファイルの出力パス + */ + function createBinFile( & $build_information_object ) { + + $bin_file_path = $build_information_object->getAgentPageBuildFilePath(); + + // 実行ファイルを解析 + $this->convertBody($build_information_object); + + // 表示前実行部分作成 + $string = "<?php\n"; + + // 表示前実行コードを記述 + foreach( $build_information_object->preview_process_hash as $code_array ) { + foreach( $code_array as $code ) { + $string .= $code."\n"; + } + } + + // モジュール実行のスクリプト追加 + foreach( $build_information_object->module_exec_info_hash as $key => $info_hash ) { + $module_name = $info_hash['module_name']; + $force = 'false'; + if( $info_hash['force'] ) { + $force = 'true'; + } + $attribute_prefix = $info_hash['attribute_prefix']; + $attribute_prefix = str_replace('"','\\"',$attribute_prefix); + $post_contents = $info_hash['post']; + $post_contents = str_replace('"','\\"',$post_contents); + $get_contents = $info_hash['get']; + $get_contents = str_replace('"','\\"',$get_contents); + $string .= '$controller->loadModule( "' . $module_name . '", '.$force.',"'.$attribute_prefix + .'","'.$get_contents.'", "'.$post_contents.'" );'."\n"; + } + + // モジュール実行結果による分岐処理を記述 + $string .= 'if ( $request_object->isError() ) {'."\n"; + $string .= '$is_error = true;'."\n"; + $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; + $string .= '$tmp_array = $request_object->errors;'."\n"; + $string .= '$request_object->setAttribute("errors", $tmp_array );'."\n"; + $string .= '} else {'."\n"; + $string .= '$is_error = false;'."\n"; + $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; + $string .= '}'."\n"; + + // リクエスト属性をグローバル変数に格納する + $string .= 'foreach( $request_object->attribute_array as $key => $value ) { '; + $string .= ' $GLOBALS[$key] = $value; '; + $string .= ' }'."\n"; + + // ファイルアウトプット機能の追加 + // リクエストオブジェクトに乗せられたヘッダ + $string .= 'if( count( $request_object->headers ) > 0 ) {'."\n"; + $string .= 'foreach( $request_object->headers as $hkey => $hval ) {'."\n"; + $string .= 'header("$hkey: $hval");'."\n"; + $string .= '}'."\n"; + $string .= '}'."\n"; + // 下位互換:http_outputに乗せられたヘッダ + $string .= 'if( count( $this->headers ) > 0 ) {'."\n"; + $string .= 'foreach( $this->headers as $hkey => $hval ) {'."\n"; + $string .= 'header("$hkey: $hval");'."\n"; + $string .= '}'."\n"; + $string .= '}'."\n"; + + // リダイレクトの場合 + $string .= 'if( !is_null( $request_object->redirect_url ) && strlen($request_object->redirect_url)> 0 ) {'."\n"; + $string .= 'header("Location: ".$request_object->redirect_url);'."\n"; + $string .= "die;\n"; + $string .= '}'; + // レスポンスファイルが指定されている場合 + $string .= 'else if( !is_null( $request_object->response_file_path ) && strlen( $request_object->response_file_path ) > 0 && file_exists( $request_object->response_file_path ) ){'."\n"; + $string .= 'readfile($request_object->response_file_path);'."\n"; + // レスポンスボディが指定されている場合 + $string .= '} else if( !is_null( $request_object->response_body ) && strlen( $request_object->response_body ) > 0 ) {'."\n"; + $string .= 'echo $request_object->response_body;'."\n"; + $string .= '}'; + // 下位互換:http_outputにレスポンスファイル + $string .= 'else if( !is_null( $this->response_file_path ) && strlen( $this->response_file_path ) > 0 && file_exists( $this->response_file_path ) ){'."\n"; + $string .= 'readfile($this->response_file_path);'."\n"; + // 下位互換:http_outputにレスポンスボディ + $string .= '} else if( !is_null( $this->response_body ) && strlen( $this->response_body ) > 0 ) {'."\n"; + $string .= 'echo $this->response_body;'; + // レスポンスが何も指定されていないなら継続処理 + $string .= "} else { \n\n?>"; + + // テキスト出力があるなら出力 + $string .= $this->out_body_strings; + + // 出力を文字列に取得する + $string .= "<?php\n"; + $string .= '$outstr = ob_get_clean();'."\n"; + + // 表示文字列に対する処理実行コードを記述 + foreach( $build_information_object->convert_view_process_hash as $code_array ) { + foreach( $code_array as $code ) { + $string .= $code."\n"; + } + } + + // 最終的にできた表示文字列をフラッシュする + $string .= "ob_start('".$build_information_object->output_handler."');\n"; + $string .= "ob_implicit_flush( false );\n"; + $string .= "mb_language('".$build_information_object->output_language."');\n"; + $string .= 'echo $outstr;'."\n"; + $string .= "mb_http_output('".$build_information_object->output_charset."');\n\n"; + $string .= 'ob_flush();'."\n"; + $string .= "}\n"; + + // 表示後実行コードを記述 + foreach( $build_information_object->postview_process_hash as $code_array ) { + foreach( $code_array as $code ) { + $string .= $code."\n"; + } + } + + // フラッシュ後にモジュール後処理の実行 + $string .= '$controller->post_process_all(); '; + $string .= "?>\n"; + + $fp = @fopen( $bin_file_path, "w" ); + if( $fp ) { + if (@flock($fp, LOCK_EX)) { + fwrite( $fp, $string ); + flock($fp, LOCK_UN); + @fclose( $fp ); + @chmod( $bin_file_path, 0666 ); + } else { + @fclose( $fp ); + @chmod( $bin_file_path, 0666 ); + die('Core Error: Can\'t create execute file!!'); + } + } else { + die('Core Error: Can\'t create execute file!!'); + } + + // ビルドタイムスタンプファイル作成 + $build_file_path = $bin_file_path.".build.php"; + $bin_file_path = str_replace('\\','\\\\',$bin_file_path ); + $string = "<?php\n"; + $string .= '$build=false;'."\n"; + $target_file_path = $build_information_object->execute_file_path; + $target_file_path = str_replace('\\','\\\\',$target_file_path ); + $string .= 'if( file_exists("'.$target_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$target_file_path.'") ) { $build=true; }}'."\n"; + // 比較ファイルとのタイムスタンプ比較 + foreach( $build_information_object->compare_time_file_array as $compare_file_path ) { + $compare_file_path = str_replace('\\','\\\\',$compare_file_path); + $compare_file_path = str_replace('"','\\"',$compare_file_path); + // ファイルが存在する場合、ビルドファイルより更新日が新しいなら再ビルド、ファイルがなくなっていても再ビルド + $string .= 'if( file_exists("'.$compare_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$compare_file_path.'") ) { $build=true; }} else { $build=true; }'."\n"; + } + // 存在確認ファイル確認 + foreach( $build_information_object->confirm_exists_file_array as $compare_file_path ) { + if( strlen($compare_file_path) > 0 ) { + $compare_file_path = str_replace('\\','\\\\',$compare_file_path); + $compare_file_path = str_replace('"','\\"',$compare_file_path); + // ファイルができていたら再ビルド + $string .= 'if( file_exists("'.$compare_file_path.'") ){ $build=true; }'."\n"; + } + } + + $string .= "?>\n"; + + $fp = @fopen( $build_file_path, "w" ); + if( $fp ) { + if (@flock($fp, LOCK_EX)) { + fwrite( $fp, $string ); + flock($fp, LOCK_UN); + @fclose( $fp ); + @chmod( $build_file_path, 0666 ); + } else { + @fclose( $fp ); + @chmod( $build_file_path, 0666 ); + die('Core Error: Can\'t create build file!!'); + } + } else { + die('Core Error: Can\'t create build file!!'); + } + } +} +?> \ No newline at end of file Modified: current/DATA/lib/spider/Controller.class.php =================================================================== --- current/DATA/lib/spider/Controller.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/Controller.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -10,7 +10,7 @@ * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima <m_nakas****@md-sy*****> * @since PHP 4.3 */ -class Controller { +class spider_Controller { /** 実行モジュールのモジュール名+実行パラメータ文字列配列(実行した順) */ var $executed_module_info_array = array(); @@ -25,7 +25,7 @@ /** * コンストラクタ */ - function Controller( & $request_object, & $http_output_obj ) { + function spider_Controller( & $request_object, & $http_output_obj ) { $this->executed_module_info_array = array(); $this->executed_module_object_array = array(); $this->post_hash = $_POST; Deleted: current/DATA/lib/spider/ExecutableFileCreator.class.php =================================================================== --- current/DATA/lib/spider/ExecutableFileCreator.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/ExecutableFileCreator.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -1,330 +0,0 @@ -<?php -/** - * 実行ファイルを作成します。 - * - * @package spider spiderのコアパッケージ - * @version 1.0.01 - * @copyright Copyright © 2008, Multimedia Digital Contents Systems.Co.,Ltd.<info****@md-sy*****> http://www.md-systems.net/ - * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima <m_nakas****@md-sy*****> - * @since PHP 4.3 - */ -class spider_ExecutableFileCreator { - - /** 元の本文文字列 */ - var $org_body_strings; - /** 出力する本文文字列 */ - var $out_body_strings; - - /** - * コンストラクタ - */ - function spider_ExecutableFileCreator() { - } - /** - * HTMLボディを生成する - */ - function convertBody( & $build_information_object ) { - $action_lines = file( $build_information_object->execute_file_path ); - $this->out_body_strings = implode( "", $action_lines ); - $this->org_body_strings = $this->out_body_strings; - - // 改行コード統一と連続改行の削除 - $this->out_body_strings = str_replace( "\r\n", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\r", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\n\n\n", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); - - // cms.phpインクルード行を削除 - preg_match_all( '/include_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - preg_match_all( '/require_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - // spider.inc.phpインクルード行を削除 - preg_match_all( '/include_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - preg_match_all( '/require_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - - // 空PHP部分を削除 - $this->out_body_strings = preg_replace('/<\\?php[\\s]+\\?>/','',$this->out_body_strings); - - // フォルダデフォルトファイルの適用 - $folder_default_path = null; - $folder_path = dirname($build_information_object->execute_file_path); - while( strlen($folder_path) > strlen(APPLICATION_BASE_PATH) ) { - $folder_default_path = $folder_path.DIRECTORY_SEPARATOR.'.default'; - if( file_exists( $folder_default_path ) ) { - break; - } else { - $folder_default_path = null; - } - $folder_path = dirname($folder_path); - } - if( !is_null( $folder_default_path ) && file_exists($folder_default_path) ) { - $str = trim(file_get_contents($folder_default_path)); - $this->out_body_strings = $str.$this->out_body_strings; - } - - // 変換タグの読み込みと変換 - $tag_object_array = array(); - $dir_path_tags = dirname(__FILE__).DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR; - if ( is_dir($dir_path_tags) ) { - if ( $dh = opendir( $dir_path_tags ) ) { - while ( ( $file_name = readdir($dh) ) !== false ) { - if( $file_name != "." && $file_name != ".." - && preg_match('/^[0-9a-zA-Z]+?\\.class\\.php$/',$file_name)) { - require_once( dirname(__FILE__).DIRECTORY_SEPARATOR - ."tags".DIRECTORY_SEPARATOR.$file_name ); - $tag_class_name = "spider_tags_".substr($file_name,0,strpos($file_name,".")); - $tag_class_obj = new $tag_class_name; - if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { - $tag_object_array[$tag_class_obj->priority] = array(); - } - array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); - } - } - closedir($dh); - } else { - } - } else { - } - // 外部変換タグの読み込みと変換 - $external_tags_conf_file = dirname(__FILE__) - .DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR."externals.conf"; - if( file_exists( $external_tags_conf_file ) ) { - $lines = file( $external_tags_conf_file ); - foreach( $lines as $line ) { - $line = trim($line); - $tag_class_name = $line; - $tag_class_file = DIR_PATH_LIB.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$line).'.class.php'; - if( file_exists($tag_class_file) ) { - require_once( $tag_class_file ); - $tag_class_obj = new $tag_class_name; - if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { - $tag_object_array[$tag_class_obj->priority] = array(); - } - array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); - } - } - } - // 優先順にタグのコンバートメソッドを実行 - ksort($tag_object_array); - foreach( $tag_object_array as $key => $tag_array ) { - foreach($tag_array as $tag_obj ) { - $tag_obj->convert( $this->out_body_strings, $build_information_object ); - } - } - } - /** - * 実行ファイル実体を書き出す - * @param $bin_file_path 実行ファイルの出力パス - */ - function createBinFile( & $build_information_object ) { - - $bin_file_path = $build_information_object->getAgentPageBuildFilePath(); - - // 実行ファイルを解析 - $this->convertBody($build_information_object); - - // 表示前実行部分作成 - $string = "<?php\n"; - - // 表示前実行コードを記述 - foreach( $build_information_object->preview_process_hash as $code_array ) { - foreach( $code_array as $code ) { - $string .= $code."\n"; - } - } - - // モジュール実行のスクリプト追加 - foreach( $build_information_object->module_exec_info_hash as $key => $info_hash ) { - $module_name = $info_hash['module_name']; - $force = 'false'; - if( $info_hash['force'] ) { - $force = 'true'; - } - $attribute_prefix = $info_hash['attribute_prefix']; - $attribute_prefix = str_replace('"','\\"',$attribute_prefix); - $post_contents = $info_hash['post']; - $post_contents = str_replace('"','\\"',$post_contents); - $get_contents = $info_hash['get']; - $get_contents = str_replace('"','\\"',$get_contents); - $string .= '$controller->loadModule( "' . $module_name . '", '.$force.',"'.$attribute_prefix - .'","'.$get_contents.'", "'.$post_contents.'" );'."\n"; - } - - // モジュール実行結果による分岐処理を記述 - $string .= 'if ( $request_object->isError() ) {'."\n"; - $string .= '$is_error = true;'."\n"; - $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; - $string .= '$tmp_array = $request_object->errors;'."\n"; - $string .= '$request_object->setAttribute("errors", $tmp_array );'."\n"; - $string .= '} else {'."\n"; - $string .= '$is_error = false;'."\n"; - $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; - $string .= '}'."\n"; - - // リクエスト属性をグローバル変数に格納する - $string .= 'foreach( $request_object->attribute_array as $key => $value ) { '; - $string .= ' $GLOBALS[$key] = $value; '; - $string .= ' }'."\n"; - - // ファイルアウトプット機能の追加 - // リクエストオブジェクトに乗せられたヘッダ - $string .= 'if( count( $request_object->headers ) > 0 ) {'."\n"; - $string .= 'foreach( $request_object->headers as $hkey => $hval ) {'."\n"; - $string .= 'header("$hkey: $hval");'."\n"; - $string .= '}'."\n"; - $string .= '}'."\n"; - // 下位互換:http_outputに乗せられたヘッダ - $string .= 'if( count( $this->headers ) > 0 ) {'."\n"; - $string .= 'foreach( $this->headers as $hkey => $hval ) {'."\n"; - $string .= 'header("$hkey: $hval");'."\n"; - $string .= '}'."\n"; - $string .= '}'."\n"; - - // リダイレクトの場合 - $string .= 'if( !is_null( $request_object->redirect_url ) && strlen($request_object->redirect_url)> 0 ) {'."\n"; - $string .= 'header("Location: ".$request_object->redirect_url);'."\n"; - $string .= "die;\n"; - $string .= '}'; - // レスポンスファイルが指定されている場合 - $string .= 'else if( !is_null( $request_object->response_file_path ) && strlen( $request_object->response_file_path ) > 0 && file_exists( $request_object->response_file_path ) ){'."\n"; - $string .= 'readfile($request_object->response_file_path);'."\n"; - // レスポンスボディが指定されている場合 - $string .= '} else if( !is_null( $request_object->response_body ) && strlen( $request_object->response_body ) > 0 ) {'."\n"; - $string .= 'echo $request_object->response_body;'."\n"; - $string .= '}'; - // 下位互換:http_outputにレスポンスファイル - $string .= 'else if( !is_null( $this->response_file_path ) && strlen( $this->response_file_path ) > 0 && file_exists( $this->response_file_path ) ){'."\n"; - $string .= 'readfile($this->response_file_path);'."\n"; - // 下位互換:http_outputにレスポンスボディ - $string .= '} else if( !is_null( $this->response_body ) && strlen( $this->response_body ) > 0 ) {'."\n"; - $string .= 'echo $this->response_body;'; - // レスポンスが何も指定されていないなら継続処理 - $string .= "} else { \n\n?>"; - - // テキスト出力があるなら出力 - $string .= $this->out_body_strings; - - // 出力を文字列に取得する - $string .= "<?php\n"; - $string .= '$outstr = ob_get_clean();'."\n"; - - // 表示文字列に対する処理実行コードを記述 - foreach( $build_information_object->convert_view_process_hash as $code_array ) { - foreach( $code_array as $code ) { - $string .= $code."\n"; - } - } - - // 最終的にできた表示文字列をフラッシュする - $string .= "ob_start('".$build_information_object->output_handler."');\n"; - $string .= "ob_implicit_flush( false );\n"; - $string .= "mb_language('".$build_information_object->output_language."');\n"; - $string .= 'echo $outstr;'."\n"; - $string .= "mb_http_output('".$build_information_object->output_charset."');\n\n"; - $string .= 'ob_flush();'."\n"; - $string .= "}\n"; - - // 表示後実行コードを記述 - foreach( $build_information_object->postview_process_hash as $code_array ) { - foreach( $code_array as $code ) { - $string .= $code."\n"; - } - } - - // フラッシュ後にモジュール後処理の実行 - $string .= '$controller->post_process_all(); '; - $string .= "?>\n"; - - $fp = @fopen( $bin_file_path, "w" ); - if( $fp ) { - if (@flock($fp, LOCK_EX)) { - fwrite( $fp, $string ); - flock($fp, LOCK_UN); - @fclose( $fp ); - @chmod( $bin_file_path, 0666 ); - } else { - @fclose( $fp ); - @chmod( $bin_file_path, 0666 ); - die('Core Error: Can\'t create execute file!!'); - } - } else { - die('Core Error: Can\'t create execute file!!'); - } - - // ビルドタイムスタンプファイル作成 - $build_file_path = $bin_file_path.".build.php"; - $bin_file_path = str_replace('\\','\\\\',$bin_file_path ); - $string = "<?php\n"; - $string .= '$build=false;'."\n"; - $target_file_path = $build_information_object->execute_file_path; - $target_file_path = str_replace('\\','\\\\',$target_file_path ); - $string .= 'if( file_exists("'.$target_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$target_file_path.'") ) { $build=true; }}'."\n"; - // 比較ファイルとのタイムスタンプ比較 - foreach( $build_information_object->compare_time_file_array as $compare_file_path ) { - $compare_file_path = str_replace('\\','\\\\',$compare_file_path); - $compare_file_path = str_replace('"','\\"',$compare_file_path); - // ファイルが存在する場合、ビルドファイルより更新日が新しいなら再ビルド、ファイルがなくなっていても再ビルド - $string .= 'if( file_exists("'.$compare_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$compare_file_path.'") ) { $build=true; }} else { $build=true; }'."\n"; - } - // 存在確認ファイル確認 - foreach( $build_information_object->confirm_exists_file_array as $compare_file_path ) { - if( strlen($compare_file_path) > 0 ) { - $compare_file_path = str_replace('\\','\\\\',$compare_file_path); - $compare_file_path = str_replace('"','\\"',$compare_file_path); - // ファイルができていたら再ビルド - $string .= 'if( file_exists("'.$compare_file_path.'") ){ $build=true; }'."\n"; - } - } - - $string .= "?>\n"; - - $fp = @fopen( $build_file_path, "w" ); - if( $fp ) { - if (@flock($fp, LOCK_EX)) { - fwrite( $fp, $string ); - flock($fp, LOCK_UN); - @fclose( $fp ); - @chmod( $build_file_path, 0666 ); - } else { - @fclose( $fp ); - @chmod( $build_file_path, 0666 ); - die('Core Error: Can\'t create build file!!'); - } - } else { - die('Core Error: Can\'t create build file!!'); - } - } -} -?> \ No newline at end of file Modified: current/DATA/lib/spider/HttpOutput.class.php =================================================================== --- current/DATA/lib/spider/HttpOutput.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/HttpOutput.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -1,7 +1,7 @@ <?php require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'functions.inc.php' ); require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'BuildInformation.class.php' ); -require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'ExecutableFileCreator.class.php'); +require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'Builder.class.php'); require_once(dirname(dirname( __FILE__ )).DIRECTORY_SEPARATOR.'util'.DIRECTORY_SEPARATOR.'LockProcess.class.php' ); /** * HTTP出力を行うクラスです。 @@ -12,18 +12,18 @@ * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima <m_nakas****@md-sy*****> * @since PHP 4.3 */ -class HttpOutput { +class spider_HttpOutput { /** * コンストラクタ * @param $template_foler_path テンプレートファイルのルートディレクトリ */ - function HttpOutput() { + function spider_HttpOutput() { } /** * リクエストの出力 - * @param $controller モジュールを実行するControllerオブジェクト - * @param $request_object HttpRequestオブジェクト + * @param $controller モジュールを実行するspider_Controllerオブジェクト + * @param $request_object spider_HttpRequestオブジェクト */ function output( $controller, & $request ) { @@ -93,10 +93,10 @@ } // 実行ファイル作成オブジェクト - $creater_object = new spider_ExecutableFileCreator(); + $builder_object = new spider_Builder(); // 実行ファイル作成 - $creater_object->createBinFile( $build_information_object ); + $builder_object->createBinFile( $build_information_object ); $lock_obj->release(); // 実行ファイル実行 Modified: current/DATA/lib/spider/HttpRequest.class.php =================================================================== --- current/DATA/lib/spider/HttpRequest.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/HttpRequest.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -11,7 +11,7 @@ * @since PHP 4.3 */ require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'util'.DIRECTORY_SEPARATOR.'CharUtility.class.php'); -class HttpRequest { +class spider_HttpRequest { /** Attributes */ var $attribute_array = array(); /** Errors */ @@ -32,7 +32,7 @@ /** * コンストラクタ */ - function HttpRequest() { + function spider_HttpRequest() { $this->attribute_array = array(); $this->errors = array(); } Modified: current/DATA/spider_main.inc.php =================================================================== --- current/DATA/spider_main.inc.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/spider_main.inc.php 2009-03-27 01:09:32 UTC (rev 12) @@ -28,13 +28,13 @@ require_once( DIR_PATH_LIB . DIRECTORY_SEPARATOR . "spider" . DIRECTORY_SEPARATOR . "HttpRequest.class.php" ); -$GLOBALS['request_object'] = new HttpRequest(); +$GLOBALS['request_object'] = new spider_HttpRequest(); /* 出力クラス */ require_once( DIR_PATH_LIB . DIRECTORY_SEPARATOR . "spider" . DIRECTORY_SEPARATOR . "HttpOutput.class.php" ); -$GLOBALS['output_object'] = new HttpOutput(); +$GLOBALS['output_object'] = new spider_HttpOutput(); /* コントローラークラス */ require_once( DIR_PATH_LIB @@ -84,7 +84,7 @@ $GLOBALS['request_object']->setAttribute( 'spider.base_path', $base_path ); // コントローラー -$GLOBALS['controller'] = new Controller( $GLOBALS['request_object'], $GLOBALS['output_object'] ); +$GLOBALS['controller'] = new spider_Controller( $GLOBALS['request_object'], $GLOBALS['output_object'] ); // 前処理スクリプトの指定があるなら読み込む if( is_array($GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']) && count($GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']) > 0 ) { Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-26 12:09:16 UTC (rev 11) +++ current/README.txt 2009-03-27 01:09:32 UTC (rev 12) @@ -3,6 +3,15 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-27 +1)この機会しかないと思ったのでクラス名の変更を行いました。 + ・ExecutableFileCreator.class.php -> Builder.class.php + ・Conttoller -> spider_Controller + ・HttpOutput -> spider_HttpOutput + ・HttpRequest -> spider_HttpRequest + + 内部的な変更なのでコアなプログラム変更を行っているユーザ以外には影響ありません。 + -- 2009-03-26 1) OutputHtmlタグで出力するファイルパスがWindowsで不具合を起こす問題の修正