示例#1
0
 function getCurl()
 {
     static $curl;
     if (!isset($curl)) {
         $base = new Base();
         $curl = $base->getCurl();
         $dir = APP_PATH . '/cache/curl';
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         $curl->cache['dir'] = $dir;
     }
     return $curl;
 }
示例#2
0
 /**
  *
  * @param CurlMulti_Core $curlmulti
  * @param string $url
  * @param string $dir
  */
 function __construct($url, $dir)
 {
     parent::__construct();
     $this->startTime = time() - 1;
     if (is_array($url)) {
         $urlNew = array();
         foreach ($url as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $k1 => $v1) {
                     $path = '';
                     if ('/' != $v1) {
                         $path = '/' . ltrim($k1, '/');
                     }
                     $urlNew[rtrim($k, '/') . $path] = $v1;
                 }
             } elseif (is_string($v)) {
                 $urlNew[] = $v;
             } else {
                 user_error('url is invalid', E_USER_ERROR);
             }
         }
         $url = $urlNew;
     } else {
         user_error('url is invalid', E_USER_ERROR);
     }
     foreach ($url as $k => $v) {
         if (!$this->isUrl($k)) {
             user_error('url is invalid, url=' . $k, E_USER_ERROR);
         }
     }
     if (!is_dir($dir)) {
         user_error('dir not found, dir=' . $dir, E_USER_ERROR);
     }
     $this->url = $url;
     $this->dir = $dir;
 }