// Created : Sun Sep 5 13:34:02 JST 2004 // Updated : Sun Sep 5 13:34:02 JST 2004 // Description : mt-comments.cgi をラップするための関数群 // Version : 0.1 // $Id:$ // ////////////////////////////////////////////////////////////// // // (C) Copyright 2004 MIZUBAYASHI Kosuke // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License version 2 for more details. // // You can read GNU General Public License version 2 from the URI below. // http://mt.mizba.net/files/GPL.txt // or // http://www.gnu.org/licenses/gpl.txt // // // 本プログラムはフリーソフトウェアです.GNU General Public License // version 2 の定める条件を満たす限りにおいて,再頒布,改変することが // 可能です. // // 本プログラムは有用であることを願って頒布しますが,一切の保証はありません. // 商用として成り立ちうる可能性,特定目的への適合性は,非明示的なものを含めて // 一切存在しません. // 詳しくは GNU General Public License version 2 をご覧下さい. // // GNU General Public License version 2 全文は以下の URI で読むことができます. // http://mt.mizba.net/files/GPL.txt // or // http://www.gnu.org/licenses/gpl.txt // // ////////////////////////////////////////////////////////////// // ChangeLog: // 2004-09-05 13:34 MIZUBAYASHI Kosuke // created. // ////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////// // BEGIN: include_once ( "lib/CGIWrapper.php" ); class mt_comments_wrapper extends CGIWrapper { var $_host = ""; var $_path = ""; var $_result = null; /** * constructor */ function mt_comments_wrapper ( $p_host , $p_path ) { $this->_host = $p_host; $this->_path = $p_path . "/mt-comments.cgi"; } /** * mt-comments.cgi へ渡るモードが "preview" であるか否か. */ function isPreview () { return array_key_exists ( "preview" , $_REQUEST ) || array_key_exists ( "preview_x" , $_REQUEST ); } /** * mt-comments.cgi へ渡るモードが "post" であるか否か. */ function isPost () { return array_key_exists ( "post" , $_REQUEST ) || array_key_exists ( "post_x" , $_REQUEST ); } /** */ function go () { if ( $this->isPost () || $this->isPreview () ) { // POST メソッドを発行 $this->_result = $this->doPost ( $this->_host , $this->_path ); // リダイレクトが指定された場合はそちら優先 if ( preg_match ( "/302 Moved/" , $this->_result [0][0] ) ) { for ( $i = 0 ; $i < count ( $this->_result [0] ) ; ++ $i ) { // HTTP ヘッダを全て出力 header ( trim ( $this->_result [0][$i] ) ); } exit (); } } } /** * 本文を出力する関数. */ function showBody () { if ( $this->_result == null ) { return false; } else { echo $this->_result [1]; return true; } } /** * 本文を実行する関数. */ function execBody () { if ( $this->_result == null ) { return false; } else { echo $this->evalAsPHP ( $this->_result [1] ); return true; } } } // END: // ////////////////////////////////////////////////////////////// ?>