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}hCøðæ¾ 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 -/** -* {[hj [JeS[NX -*/ -class BrdMenuCate -{ - // {{{ properties - - public $name; // JeS[̼O - public $menuitas; // NXBrdMenuItaÌIuWFNgði[·ézñ - public $num; // i[³ê½BrdMenuItaIuWFNgÌ - public $is_open; // JÂóÔ(bool) - public $ita_match_num; // õÉqbgµ½ÂÌ - - // }}} - // {{{ constructor - - /** - * RXgN^ - */ - public function __construct($name) - { - $this->num = 0; - $this->menuitas = array(); - $this->ita_match_num = 0; - - $this->name = $name; - } - - // }}} - // {{{ addBrdMenuIta() - - /** - * ÂðÇÁ·é - */ - public function addBrdMenuIta(BrdMenuIta $aBrdMenuIta) - { - $this->menuitas[] = $aBrdMenuIta; - $this->num++; - } - - // }}} -} - -// }}} -// {{{ BrdMenuIta - -/** -* {[hj [ÂNX -*/ -class BrdMenuIta -{ - // {{{ properties - - public $host; - public $bbs; - public $itaj; // ¼ - public $itaj_en; // ¼ðGR[hµ½àÌ - public $itaj_ht; // HTMLÅoÍ·é¼itB^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 + +/** +* {[hj [JeS[NX +*/ +class BrdMenuCate +{ + // {{{ properties + + public $name; // JeS[̼O + public $menuitas; // NXBrdMenuItaÌIuWFNgði[·ézñ + public $num; // i[³ê½BrdMenuItaIuWFNgÌ + public $is_open; // JÂóÔ(bool) + public $ita_match_num; // õÉqbgµ½ÂÌ + + // }}} + // {{{ constructor + + /** + * RXgN^ + */ + public function __construct($name) + { + $this->num = 0; + $this->menuitas = array(); + $this->ita_match_num = 0; + + $this->name = $name; + } + + // }}} + // {{{ addBrdMenuIta() + + /** + * ÂðÇÁ·é + */ + 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 + +/** +* {[hj [ÂNX +*/ +class BrdMenuIta +{ + // {{{ properties + + public $host; + public $bbs; + public $itaj; // ¼ + public $itaj_en; // ¼ðGR[hµ½àÌ + public $itaj_ht; // HTMLÅoÍ·é¼itB^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); +/** + * _~[NX + */ +class P2HttpExt +{ + // {{{ constants + const DEBUG = 0; + + // }}} + // {{{ activate() + + /** + * ±Ìt@CÉÜÜêéNXð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ÌÄpbN + */ + +// {{{ P2Lock + +/** + * ÈÕbNNX + */ +class P2Lock +{ + // {{{ properties + + /** + * bNt@CÌpX + * + * @var string + */ + protected $_filename; + + /** + * bNt@CÌnh + * + * @var resource + */ + protected $_fh; + + /** + * bNt@Cð©®Åí·é©Ç¤© + * + * @var bool + */ + protected $_remove; + + // }}} + // {{{ constructor + + /** + * RXgN^ + * + * @param string $name bN¼iàr¼µ½¢t@C¼j + * @param bool $remove bNt@Cð©®Åí·é©Ç¤© + * @param string $suffix bNt@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 + + /** + * fXgN^ + */ + 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ÉbNðJú·é + */ + public function free() + { + $this->__destruct(); + } + + // }}} + // {{{ remove() + + /** + * ¾¦IÉbNðJúµAbNt@Cð§í·é + * + * unlink()Ístat()ÌLbV ð©®IÉNA·éÌÅ + * clearstatcache()·éKvÍÈ¢ + */ + 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 + +/** + * XLÌNX + */ +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 - -/** - * XLÌNX - */ -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ÜÆßÄvtFb` 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']);