[P2-php-svn] [753] expack:

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 12月 31日 (木) 22:39:08 JST


Revision: 753
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=753
Author:   rsk
Date:     2009-12-31 22:39:08 +0900 (Thu, 31 Dec 2009)

Log Message:
-----------
expack:
- post.php の公式p2を使った書き込みを postIt2() 関数に集約。
- FileCtl::mkdir_r() メソッドを追加。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/edit_user_font.php
    p2ex/trunk/ic2.php
    p2ex/trunk/iv2.php
    p2ex/trunk/lib/FileCtl.php
    p2ex/trunk/post.php
    p2ex/trunk/tgrepc.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/conf/conf.inc.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -917,7 +917,7 @@
 
 if ($_conf['session_save'] == 'p2' and session_module_name() == 'files') {
     if (!is_dir($_conf['session_dir'])) {
-        FileCtl::mkdir_for($_conf['session_dir'] . '/dummy_filename');
+        FileCtl::mkdir_r($_conf['session_dir']);
     } elseif (!is_writable($_conf['session_dir'])) {
         p2die("ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ ({$_conf['session_dir']}) ‚ɏ‘‚«ž‚ÝŒ ŒÀ‚ª‚ ‚è‚Ü‚¹‚ñB");
     }

Modified: p2ex/trunk/edit_user_font.php
===================================================================
--- p2ex/trunk/edit_user_font.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/edit_user_font.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -87,7 +87,7 @@
 // }}}
 
 if (!is_dir($_conf['compile_dir'])) {
-    FileCtl::mkdir_for($_conf['compile_dir'] . '/__dummy__');
+    FileCtl::mkdir_r($_conf['compile_dir']);
 }
 
 // ƒeƒ“ƒvƒŒ[ƒg‚ðƒRƒ“ƒpƒCƒ‹

Modified: p2ex/trunk/ic2.php
===================================================================
--- p2ex/trunk/ic2.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/ic2.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -56,7 +56,7 @@
 }
 
 if (!is_dir($_conf['tmp_dir'])) {
-    FileCtl::mkdir_for($_conf['tmp_dir'] . '/__dummy__');
+    FileCtl::mkdir_r($_conf['tmp_dir']);
 }
 
 if (!empty($uri)) {

Modified: p2ex/trunk/iv2.php
===================================================================
--- p2ex/trunk/iv2.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/iv2.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -310,7 +310,7 @@
 );
 
 if (!is_dir($_conf['compile_dir'])) {
-    FileCtl::mkdir_for($_conf['compile_dir'] . '/__dummy__');
+    FileCtl::mkdir_r($_conf['compile_dir']);
 }
 
 $flexy = new HTML_Template_Flexy($_flexy_options);

Modified: p2ex/trunk/lib/FileCtl.php
===================================================================
--- p2ex/trunk/lib/FileCtl.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/lib/FileCtl.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -112,6 +112,21 @@
     }
 
     // }}}
+    // {{{ mkdir_r()
+
+    /**
+     * ƒfƒBƒŒƒNƒgƒŠ‚ª‚È‚¯‚ê‚ΐ¶¬‚µ‚ăp[ƒ~ƒbƒVƒ‡ƒ“‚𒲐®‚·‚é
+     *
+     * @param string $apath
+     * @param int $perm
+     * @return bool
+     */
+    static public function mkdir_r($apath, $perm = null)
+    {
+        return self::mkdir_for($apath . DIRECTORY_SEPARATOR . '_', $perm);
+    }
+
+    // }}}
     // {{{ get_gzfile_contents()
 
     /**

Modified: p2ex/trunk/post.php
===================================================================
--- p2ex/trunk/post.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/post.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -60,7 +60,7 @@
     // ƒ^ƒu‚ðƒXƒy[ƒX‚É
     $MESSAGE = tab2space($MESSAGE);
     // “ÁŽê•¶Žš‚ðŽÀ‘ÌŽQÆ‚É
-    $MESSAGE = htmlspecialchars($MESSAGE, ENT_QUOTES);
+    $MESSAGE = htmlspecialchars($MESSAGE, ENT_QUOTES, 'Shift_JIS');
     // Ž©“®URLƒŠƒ“ƒN‰ñ”ð
     $MESSAGE = str_replace('tp://', 'tp://', $MESSAGE);
     // s“ª‚̃Xƒy[ƒX‚ðŽÀ‘ÌŽQÆ‚É
@@ -183,42 +183,17 @@
 
 // ƒ|ƒXƒgŽÀs
 if (!empty($_POST['p2res']) && empty($_POST['newthread'])) {
-    // ŒöŽ®p2‚Ń|ƒXƒg
-    if (!class_exists('P2Client', false)) {
-        include P2_LIB_DIR . '/P2Client.php';
-    }
-    if (!is_dir($_conf['cookie_dir'])) {
-        FileCtl::mkdir_for($_conf['cookie_dir'] . '/dummy_filename');
-    }
-    if (P2Util::isHostBe2chNet($host) || !empty($_REQUEST['beres'])) {
-        $beres = true;
-    } else {
-        $beres = false;
-    }
-
-    try {
-        $client = new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'], $_conf['cookie_dir']);
-        $posted = $client->post($host, $bbs, $key, $FROM, $mail, $MESSAGE, $beres, $response);
-    } catch (P2Exception $e) {
-        p2die('ŒöŽ®p2ƒ|ƒXƒgŽ¸”s', $e->getMessage());
-    }
-
-    if ($posted) {
-        $reload = empty($_POST['from_read_new']);
-        showPostMsg(true, '‘‚«‚±‚Ý‚ªI‚í‚è‚Ü‚µ‚½B', $reload);
-    } else {
-        $result_msg = 'ŒöŽ®p2ƒ|ƒXƒgŽ¸”s</p>'
-                    . '<pre>' . htmlspecialchars($response['body'], ENT_QUOTES, 'Shift_JIS') . '</pre>'
-                    . '<p>-';
-        showPostMsg(false, $result_msg, false);
-    }
+    // ŒöŽ®p2‚ŏ‘‚«ž‚Ý
+    $posted = postIt2($host, $bbs, $key, $FROM, $mail, $MESSAGE);
 } else {
-    // ’ʏíƒ|ƒXƒg
+    // ’¼Ú‘‚«ž‚Ý
     $posted = postIt($host, $bbs, $key, $post);
 
     // cookie •Û‘¶
     FileCtl::make_datafile($cookie_file, $_conf['p2_perm']); // ‚È‚¯‚ê‚ΐ¶¬
-    if ($p2cookies) {$cookie_cont = serialize($p2cookies);}
+    if ($p2cookies) {
+        $cookie_cont = serialize($p2cookies);
+    }
     if ($cookie_cont) {
         if (FileCtl::file_write_contents($cookie_file, $cookie_cont) === false) {
             p2die('cannot write file.');
@@ -552,6 +527,51 @@
 }
 
 // }}}
+// {{{ postIt2()
+
+/**
+ * ŒöŽ®p2‚ŃŒƒX‚ð‘‚«ž‚Þ
+ *
+ * @return boolean ‘‚«ž‚ݐ¬Œ÷‚È‚ç trueAŽ¸”s‚È‚ç false
+ */
+function postIt2($host, $bbs, $key, $FROM, $mail, $MESSAGE)
+{
+    global $_conf;
+
+    if (!class_exists('P2Client', false)) {
+        include P2_LIB_DIR . '/P2Client.php';
+    }
+    if (!is_dir($_conf['cookie_dir'])) {
+        FileCtl::mkdir_r($_conf['cookie_dir']);
+    }
+
+    if (P2Util::isHostBe2chNet($host) || !empty($_REQUEST['beres'])) {
+        $beRes = true;
+    } else {
+        $beRes = false;
+    }
+
+    try {
+        $client = new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'], $_conf['cookie_dir']);
+        $posted = $client->post($host, $bbs, $key, $FROM, $mail, $MESSAGE, $beRes, $response);
+    } catch (P2Exception $e) {
+        p2die('ŒöŽ®p2ƒ|ƒXƒgŽ¸”s', $e->getMessage());
+    }
+
+    if ($posted) {
+        $reload = empty($_POST['from_read_new']);
+        showPostMsg(true, '‘‚«‚±‚Ý‚ªI‚í‚è‚Ü‚µ‚½B', $reload);
+    } else {
+        $result_msg = 'ŒöŽ®p2ƒ|ƒXƒgŽ¸”s</p>'
+                    . '<pre>' . htmlspecialchars($response['body'], ENT_QUOTES, 'Shift_JIS') . '</pre>'
+                    . '<p>-';
+        showPostMsg(false, $result_msg, false);
+    }
+
+    return $posted;
+}
+
+// }}}
 // {{{ showPostMsg()
 
 /**

Modified: p2ex/trunk/tgrepc.php
===================================================================
--- p2ex/trunk/tgrepc.php	2009-12-31 10:03:05 UTC (rev 752)
+++ p2ex/trunk/tgrepc.php	2009-12-31 13:39:08 UTC (rev 753)
@@ -67,7 +67,7 @@
         'automaticSerialization' => true,
     );
     if (!is_dir($cache_options['cacheDir'])) {
-        FileCtl::mkdir_for($cache_options['cacheDir'] . '__dummy__');
+        FileCtl::mkdir_r($cache_options['cacheDir']);
     }
     $cache = new Cache_Lite($cache_options);
     $cache_id_result = md5($query);



P2-php-svn メーリングリストの案内
Back to archive index