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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 16日 (土) 04:27:58 JST


Revision: 782
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=782
Author:   rsk
Date:     2010-01-16 04:27:58 +0900 (Sat, 16 Jan 2010)

Log Message:
-----------
expack:
- ResArticleクラスをlib/ResHist.phpからlib/ResArticle.phpに分離。
- BrdMenuCateクラスをlib/BrdMenu.phpからlib/BrdMenuCate.phpに分離。
- BrdMenuItaクラスをlib/BrdMenu.phpからlib/BrdMenuIta.phpに分離。
- 追加し忘れていたlib/P2Lock.phpを追加。

Modified Paths:
--------------
    p2ex/trunk/cli/fetch-subject-txt.php
    p2ex/trunk/lib/BrdMenu.php
    p2ex/trunk/lib/P2HttpExt.php
    p2ex/trunk/lib/ResHist.php
    p2ex/trunk/lib/ShowBrdMenuPc.php
    p2ex/trunk/lib/ThreadList.php
    p2ex/trunk/lib/menu.inc.php
    p2ex/trunk/lib/setup.funcs.php
    p2ex/trunk/subject.php

Added Paths:
-----------
    p2ex/trunk/lib/BrdMenuCate.php
    p2ex/trunk/lib/BrdMenuIta.php
    p2ex/trunk/lib/P2Lock.php
    p2ex/trunk/lib/ResArticle.php


-------------- next part --------------
Modified: p2ex/trunk/cli/fetch-subject-txt.php
===================================================================
--- p2ex/trunk/cli/fetch-subject-txt.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/cli/fetch-subject-txt.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -21,6 +21,8 @@
 require dirname(__FILE__) . '/../conf/conf.inc.php';
 require_once 'Console/Getopt.php';
 
+P2HttpExt::activate();
+
 // }}}
 // {{{ ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ˆø”‚ðŽæ“¾
 

Modified: p2ex/trunk/lib/BrdMenu.php
===================================================================
--- p2ex/trunk/lib/BrdMenu.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/BrdMenu.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -206,82 +206,7 @@
 }
 
 // }}}
-// {{{ BrdMenuCate
 
-/**
-* ƒ{[ƒhƒƒjƒ…[ƒJƒeƒSƒŠ[ƒNƒ‰ƒX
-*/
-class BrdMenuCate
-{
-    // {{{ properties
-
-    public $name;          // ƒJƒeƒSƒŠ[‚Ì–¼‘O
-    public $menuitas;      // ƒNƒ‰ƒXBrdMenuIta‚̃IƒuƒWƒFƒNƒg‚ðŠi”[‚·‚é”z—ñ
-    public $num;           // Ši”[‚³‚ꂽBrdMenuItaƒIƒuƒWƒFƒNƒg‚̐”
-    public $is_open;       // ŠJ•Âó‘Ô(bool)
-    public $ita_match_num; // ŒŸõ‚Ƀqƒbƒg‚µ‚½”‚̐”
-
-    // }}}
-    // {{{ constructor
-
-    /**
-    * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
-    */
-    public function __construct($name)
-    {
-        $this->num = 0;
-        $this->menuitas = array();
-        $this->ita_match_num = 0;
-
-        $this->name = $name;
-    }
-
-    // }}}
-    // {{{ addBrdMenuIta()
-
-    /**
-     * ”‚ð’ljÁ‚·‚é
-     */
-    public function addBrdMenuIta(BrdMenuIta $aBrdMenuIta)
-    {
-        $this->menuitas[] = $aBrdMenuIta;
-        $this->num++;
-    }
-
-    // }}}
-}
-
-// }}}
-// {{{ BrdMenuIta
-
-/**
-* ƒ{[ƒhƒƒjƒ…[”ƒNƒ‰ƒX
-*/
-class BrdMenuIta
-{
-    // {{{ properties
-
-    public $host;
-    public $bbs;
-    public $itaj;    // ”–¼
-    public $itaj_en;    // ”–¼‚ðƒGƒ“ƒR[ƒh‚µ‚½‚à‚Ì
-    public $itaj_ht;    // HTML‚ŏo—Í‚·‚é”–¼iƒtƒBƒ‹ƒ^ƒŠƒ“ƒO‚µ‚½‚à‚́j
-
-    // }}}
-    // {{{ setItaj()
-
-    public function setItaj($itaj)
-    {
-        $this->itaj = $itaj;
-        $this->itaj_en = rawurlencode(base64_encode($this->itaj));
-        $this->itaj_ht = htmlspecialchars($this->itaj, ENT_QUOTES);
-    }
-
-    // }}}
-}
-
-// }}}
-
 /*
  * Local Variables:
  * mode: php

Added: p2ex/trunk/lib/BrdMenuCate.php
===================================================================
--- p2ex/trunk/lib/BrdMenuCate.php	                        (rev 0)
+++ p2ex/trunk/lib/BrdMenuCate.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -0,0 +1,59 @@
+<?php
+
+// {{{ BrdMenuCate
+
+/**
+* ƒ{[ƒhƒƒjƒ…[ƒJƒeƒSƒŠ[ƒNƒ‰ƒX
+*/
+class BrdMenuCate
+{
+    // {{{ properties
+
+    public $name;          // ƒJƒeƒSƒŠ[‚Ì–¼‘O
+    public $menuitas;      // ƒNƒ‰ƒXBrdMenuIta‚̃IƒuƒWƒFƒNƒg‚ðŠi”[‚·‚é”z—ñ
+    public $num;           // Ši”[‚³‚ꂽBrdMenuItaƒIƒuƒWƒFƒNƒg‚̐”
+    public $is_open;       // ŠJ•Âó‘Ô(bool)
+    public $ita_match_num; // ŒŸõ‚Ƀqƒbƒg‚µ‚½”‚̐”
+
+    // }}}
+    // {{{ constructor
+
+    /**
+    * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
+    */
+    public function __construct($name)
+    {
+        $this->num = 0;
+        $this->menuitas = array();
+        $this->ita_match_num = 0;
+
+        $this->name = $name;
+    }
+
+    // }}}
+    // {{{ addBrdMenuIta()
+
+    /**
+     * ”‚ð’ljÁ‚·‚é
+     */
+    public function addBrdMenuIta(BrdMenuIta $aBrdMenuIta)
+    {
+        $this->menuitas[] = $aBrdMenuIta;
+        $this->num++;
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Added: p2ex/trunk/lib/BrdMenuIta.php
===================================================================
--- p2ex/trunk/lib/BrdMenuIta.php	                        (rev 0)
+++ p2ex/trunk/lib/BrdMenuIta.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -0,0 +1,42 @@
+<?php
+
+// {{{ BrdMenuIta
+
+/**
+* ƒ{[ƒhƒƒjƒ…[”ƒNƒ‰ƒX
+*/
+class BrdMenuIta
+{
+    // {{{ properties
+
+    public $host;
+    public $bbs;
+    public $itaj;    // ”–¼
+    public $itaj_en;    // ”–¼‚ðƒGƒ“ƒR[ƒh‚µ‚½‚à‚Ì
+    public $itaj_ht;    // HTML‚ŏo—Í‚·‚é”–¼iƒtƒBƒ‹ƒ^ƒŠƒ“ƒO‚µ‚½‚à‚́j
+
+    // }}}
+    // {{{ setItaj()
+
+    public function setItaj($itaj)
+    {
+        $this->itaj = $itaj;
+        $this->itaj_en = rawurlencode(base64_encode($this->itaj));
+        $this->itaj_ht = htmlspecialchars($this->itaj, ENT_QUOTES);
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Modified: p2ex/trunk/lib/P2HttpExt.php
===================================================================
--- p2ex/trunk/lib/P2HttpExt.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/P2HttpExt.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -3,10 +3,36 @@
  * rep2expack feat. pecl_http
  */
 
-// {{{ CONSTANTS
+// {{{ P2HttpExt
 
-define('P2HTTPEXT_DEBUG', 0);
+/**
+ * ƒ_ƒ~[ƒNƒ‰ƒX
+ */
+class P2HttpExt
+{
+    // {{{ constants
 
+    const DEBUG = 0;
+
+    // }}}
+    // {{{ activate()
+
+    /**
+     * ‚±‚̃tƒ@ƒCƒ‹‚ÉŠÜ‚Ü‚ê‚éƒNƒ‰ƒX‚ð—˜—p‚·‚é‚Æ‚«‚Í
+     * ‚Ü‚¸ P2HttpExt::activate() ‚ðƒR[ƒ‹‚µ‚Ä
+     * ƒI[ƒgƒ[ƒ_[‚É‚æ‚肱‚̃tƒ@ƒCƒ‹‚ð“ǂݍž‚ށB
+     *
+     * @param void
+     * @return void
+     */
+    static public function activate()
+    {
+        // nothing to do
+    }
+
+    // }}}
+}
+
 // }}}
 // {{{ P2HttpCallback
 
@@ -363,7 +389,7 @@
                                     );
                 }
             }
-            if (P2HTTPEXT_DEBUG && !$this->hasError()) {
+            if (P2HttpExt::DEBUG && !$this->hasError()) {
                 $this->setError(sprintf('HTTP %d %s', $code, $this->getResponseStatus()),
                                 self::E_DEBUG
                                 );
@@ -832,7 +858,7 @@
             $GLOBALS['_info_msg_ht'] .= "<ul class=\"errors\">{$err}</ul>\n";
         }
 
-        if (P2HTTPEXT_DEBUG) {
+        if (P2HttpExt::DEBUG) {
             if ($ph = http_persistent_handles_count()) {
                 $ph_dump = str_replace('  ', ' ', print_r($ph, true));
                 $ph_dump = preg_replace('/[\\r\\n]+/', "\n", $ph_dump);

Added: p2ex/trunk/lib/P2Lock.php
===================================================================
--- p2ex/trunk/lib/P2Lock.php	                        (rev 0)
+++ p2ex/trunk/lib/P2Lock.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -0,0 +1,123 @@
+<?php
+/**
+ * rep2expack - flock() ƒx[ƒX‚̔ėpƒƒbƒN
+ */
+
+// {{{ P2Lock
+
+/**
+ * ŠÈˆÕƒƒbƒNƒNƒ‰ƒX
+ */
+class P2Lock
+{
+    // {{{ properties
+
+    /**
+     * ƒƒbƒNƒtƒ@ƒCƒ‹‚̃pƒX
+     *
+     * @var string
+     */
+    protected $_filename;
+
+    /**
+     * ƒƒbƒNƒtƒ@ƒCƒ‹‚̃nƒ“ƒhƒ‹
+     *
+     * @var resource
+     */
+    protected $_fh;
+
+    /**
+     * ƒƒbƒNƒtƒ@ƒCƒ‹‚ðŽ©“®‚ō폜‚·‚é‚©‚Ç‚¤‚©
+     *
+     * @var bool
+     */
+    protected $_remove;
+
+    // }}}
+    // {{{ constructor
+
+    /**
+     * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
+     *
+     * @param  string $name     ƒƒbƒN–¼ià”r‘¼ˆ—‚µ‚½‚¢ƒtƒ@ƒCƒ‹–¼j
+     * @param  bool   $remove   ƒƒbƒNƒtƒ@ƒCƒ‹‚ðŽ©“®‚ō폜‚·‚é‚©‚Ç‚¤‚©
+     * @param  string $suffix   ƒƒbƒNƒtƒ@ƒCƒ‹–¼‚̐ڔöŽ«
+     */
+    public function __construct($name, $remove = true, $suffix = '.lck')
+    {
+        $this->_filename = p2_realpath($name . $suffix);
+        $this->_remove = $remove;
+
+        FileCtl::mkdir_for($this->_filename);
+
+        $this->_fh = fopen($this->_filename, 'wb');
+        if (!$this->_fh) {
+            p2die("cannot create lockfile ({$this->_filename}).");
+        }
+        if (!flock($this->_fh, LOCK_EX)) {
+            p2die("cannot get lock ({$this->_filename}).");
+        }
+    }
+
+    // }}}
+    // {{{ destructor
+
+    /**
+     * ƒfƒXƒgƒ‰ƒNƒ^
+     */
+    public function __destruct()
+    {
+        if (is_resource($this->_fh)) {
+            flock($this->_fh, LOCK_UN);
+            fclose($this->_fh);
+            $this->_fh = null;
+        }
+
+        if ($this->_remove && file_exists($this->_filename)) {
+            unlink($this->_filename);
+        }
+    }
+
+    // }}}
+    // {{{ free()
+
+    /**
+     * –¾Ž¦“I‚ɃƒbƒN‚ðŠJ•ú‚·‚é
+     */
+    public function free()
+    {
+        $this->__destruct();
+    }
+
+    // }}}
+    // {{{ remove()
+
+    /**
+     * –¾Ž¦“I‚ɃƒbƒN‚ðŠJ•ú‚µAƒƒbƒNƒtƒ@ƒCƒ‹‚ð‹­§íœ‚·‚é
+     *
+     * unlink()‚Ístat()‚̃LƒƒƒbƒVƒ…‚ðŽ©“®“I‚ɃNƒŠƒA‚·‚é‚Ì‚Å
+     * clearstatcache()‚·‚é•K—v‚Í‚È‚¢
+     */
+    public function remove()
+    {
+        $this->__destruct();
+        if (file_exists($this->_filename)) {
+            unlink($this->_filename);
+        }
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Added: p2ex/trunk/lib/ResArticle.php
===================================================================
--- p2ex/trunk/lib/ResArticle.php	                        (rev 0)
+++ p2ex/trunk/lib/ResArticle.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -0,0 +1,34 @@
+<?php
+
+// {{{ ResArticle
+
+/**
+ * ƒŒƒX‹LŽ–‚̃Nƒ‰ƒX
+ */
+class ResArticle
+{
+    public $name;
+    public $mail;
+    public $daytime;
+    public $msg;
+    public $ttitle;
+    public $host;
+    public $bbs;
+    public $itaj;
+    public $key;
+    public $resnum;
+    public $order; // ‹LŽ–”ԍ†
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Modified: p2ex/trunk/lib/ResHist.php
===================================================================
--- p2ex/trunk/lib/ResHist.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/ResHist.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -5,27 +5,6 @@
 
 require_once 'Pager/Pager.php';
 
-// {{{ ResArticle
-
-/**
- * ƒŒƒX‹LŽ–‚̃Nƒ‰ƒX
- */
-class ResArticle
-{
-    public $name;
-    public $mail;
-    public $daytime;
-    public $msg;
-    public $ttitle;
-    public $host;
-    public $bbs;
-    public $itaj;
-    public $key;
-    public $resnum;
-    public $order; // ‹LŽ–”ԍ†
-}
-
-// }}}
 // {{{ ResHist
 
 /**

Modified: p2ex/trunk/lib/ShowBrdMenuPc.php
===================================================================
--- p2ex/trunk/lib/ShowBrdMenuPc.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/ShowBrdMenuPc.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -108,6 +108,7 @@
             // V’…”‚ð•\Ž¦‚·‚éê‡E‚܂Ƃ߂ăvƒŠƒtƒFƒbƒ`
             if ($_conf['enable_menu_new'] && !empty($_GET['new'])) {
                 if ($_conf['expack.use_pecl_http'] == 1) {
+                    P2HttpExt::activate();
                     P2HttpRequestPool::fetchSubjectTxt($favitas);
                     $GLOBALS['expack.subject.multi-threaded-download.done'] = true;
                 } elseif ($_conf['expack.use_pecl_http'] == 2) {

Modified: p2ex/trunk/lib/ThreadList.php
===================================================================
--- p2ex/trunk/lib/ThreadList.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/ThreadList.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -168,6 +168,7 @@
 
             if (empty($_REQUEST['norefresh']) && !(empty($_REQUEST['refresh']) && isset($_REQUEST['word']))) {
                 if ($_conf['expack.use_pecl_http'] == 1) {
+                    P2HttpExt::activate();
                     P2HttpRequestPool::fetchSubjectTxt($favitas);
                     $GLOBALS['expack.subject.multi-threaded-download.done'] = true;
                 } elseif ($_conf['expack.use_pecl_http'] == 2) {

Modified: p2ex/trunk/lib/menu.inc.php
===================================================================
--- p2ex/trunk/lib/menu.inc.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/menu.inc.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -248,6 +248,7 @@
 if ($_conf['enable_menu_new'] == 1 && $_GET['new']) {
     // •À—ñƒ_ƒEƒ“ƒ[ƒh‚̐ݒè
     if ($_conf['expack.use_pecl_http'] == 1) {
+        P2HttpExt::activate();
         $GLOBALS['expack.subject.multi-threaded-download.done'] = true;
     } elseif ($_conf['expack.use_pecl_http'] == 2) {
         $GLOBALS['expack.subject.multi-threaded-download.done'] = true;

Modified: p2ex/trunk/lib/setup.funcs.php
===================================================================
--- p2ex/trunk/lib/setup.funcs.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/lib/setup.funcs.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -176,14 +176,8 @@
             Wap[A-Z][A-Za-z]*
         )$/x', $name))
     {
-        if ($name == 'ResArticle') {
-            include P2_LIB_DIR . '/ResHist.php';
-        } elseif (strncmp($name, 'Wap', 3) === 0) {
+        if (strncmp($name, 'Wap', 3) === 0) {
             include P2_LIB_DIR . '/Wap.php';
-        } elseif (strncmp($name, 'P2Http', 6) === 0) {
-            include P2_LIB_DIR . '/P2HttpExt.php';
-        } elseif (strncmp($name, 'BrdMenu', 7) === 0) {
-            include P2_LIB_DIR . '/BrdMenu.php';
         } else {
             include P2_LIB_DIR . '/' . $name . '.php';
         }

Modified: p2ex/trunk/subject.php
===================================================================
--- p2ex/trunk/subject.php	2010-01-15 18:58:14 UTC (rev 781)
+++ p2ex/trunk/subject.php	2010-01-15 19:27:58 UTC (rev 782)
@@ -269,6 +269,7 @@
 
 if (empty($_REQUEST['norefresh']) && !(empty($_REQUEST['refresh']) && isset($_REQUEST['word']))) {
     if ($_conf['expack.use_pecl_http'] == 1) {
+        P2HttpExt::activate();
         switch ($spmode) {
         case 'fav':
             P2HttpRequestPool::fetchSubjectTxt($_conf['favlist_idx']);



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