Ejemplo n.º 1
0
 /**
  * みみずん対応板を読み込む
  */
 public function load($type)
 {
     global $_conf;
     // 対応板の取得
     switch ($type) {
         case 0:
             $url = 'http://mimizun.com/search/2chlive.html';
             $path = $_conf['cache_dir'] . '/search.mimizun.com/2chlive.html';
             $match = '{<input type="checkbox" name="idxname" value="_(.+?)">}';
             break;
         case 1:
             $url = 'http://mimizun.com/search/2ch.html';
             $path = $_conf['cache_dir'] . '/search.mimizun.com/2ch.html';
             $match = '{<input type="checkbox" name="idxname" value="(.+?)">}';
             break;
     }
     // キャッシュ用ディレクトリが無ければ作成
     FileCtl::mkdir_for($path);
     // メニューのキャッシュ時間の10倍キャッシュ
     P2UtilWiki::cacheDownload($url, $path, $_conf['menu_dl_interval'] * 36000);
     $file = @file_get_contents($path);
     preg_match_all($match, $file, $boards);
     return $boards[1];
 }
Ejemplo n.º 2
0
 /**
  * コンストラクタ
  *
  * @param string $url
  * @param string $destination
  * @param array $options
  * @param P2HttpCallback $onSuccess
  * @param P2HttpCallback $onFailure
  */
 public function __construct($url, $destination, array $options = null, P2HttpCallback $onSuccess = null, P2HttpCallback $onFailure = null)
 {
     global $_conf;
     if ($options === null) {
         $options = array();
     }
     if (!isset($options['connecttimeout'])) {
         $options['connecttimeout'] = $_conf['fsockopen_time_limit'];
     }
     if (!isset($options['timeout'])) {
         $options['timeout'] = $_conf['fsockopen_time_limit'] * 2;
     }
     if (!isset($options['compress'])) {
         $options['compress'] = true;
     }
     if (!isset($options['useragent'])) {
         $options['useragent'] = P2Util::getP2UA($withMonazilla = true);
     }
     if ($_conf['proxy_use'] && !isset($options['proxyhost']) && !empty($_conf['proxy_host'])) {
         $options['proxyhost'] = $_conf['proxy_host'];
         if (!empty($_conf['proxy_port']) && is_numeric($_conf['proxy_port'])) {
             $options['proxyport'] = (int) $_conf['proxy_port'];
         } elseif (strpos($_conf['proxy_host'], ':') === false) {
             $options['proxyport'] = 80;
         }
         /*
         $options['proxytype'] = HTTP_PROXY_HTTP;
         if (isset($_conf['proxy_type'])) {
             switch ($_conf['proxy_type']) {
             case 'http':   $options['proxytype'] = HTTP_PROXY_HTTP;   break;
             case 'socks4': $options['proxytype'] = HTTP_PROXY_SOCKS4; break;
             case 'socks5': $options['proxytype'] = HTTP_PROXY_SOCKS5; break;
             default:
                 if (is_numeric($options['proxytype'])) {
                     $options['proxytype'] = (int)$_conf['proxy_type'];
                 }
             }
         }
         
         if (!empty($_conf['proxy_auth'])) {
             $options['proxy_auth'] = $_conf['proxy_auth'];
             $options['proxyauthtype'] = HTTP_AUTH_BASIC;
             if (isset($_conf['proxy_auth_type'])) {
                 switch ($_conf['proxy_auth_type']) {
                 case 'basic':  $options['proxyauthtype'] = HTTP_AUTH_BASIC;  break;
                 case 'digest': $options['proxyauthtype'] = HTTP_AUTH_DIGEST; break;
                 case 'ntlm':   $options['proxyauthtype'] = HTTP_AUTH_NTLM;   break;
                 case 'gssneg': $options['proxyauthtype'] = HTTP_AUTH_GSSNEG; break;
                 case 'any':    $options['proxyauthtype'] = HTTP_AUTH_ANY;    break;
                 default:
                     if (is_numeric($options['proxytype'])) {
                         $options['proxyauthtype'] = (int)$_conf['proxy_auth_type'];
                     }
                 }
             }
         }
         */
     }
     if (!isset($options['lastmodified']) && file_exists($destination)) {
         $options['lastmodified'] = filemtime($destination);
     } else {
         FileCtl::mkdir_for($destination);
     }
     $this->_destination = $destination;
     $this->_permission = !empty($_conf['dl_perm']) ? $_conf['dl_perm'] : 0666;
     $this->_errorCode = self::E_NONE;
     $this->_errorInfo = '';
     $this->_onSuccess = $onSuccess;
     $this->_onFailure = $onFailure;
     $this->_next = null;
     parent::__construct($url, HttpRequest::METH_GET, $options);
 }