Example #1
0
 /**
  *
  * @param CurlMulti_Core $curlmulti
  * @param string $url
  * @param string $dir
  */
 function __construct($url, $dir)
 {
     parent::__construct();
     $this->url = $url;
     $this->dir = $dir;
     if (!$this->isUrl($url)) {
         throw new Exception('url is invalid, url=' . $url);
     }
     if (!is_dir($this->dir)) {
         throw new Exception('dir not found, dir=' . $this->dir);
     }
 }
 function __construct($curl)
 {
     parent::__construct($curl);
     $cacheDir = __DIR__ . '/cache';
     $this->imgDir = __DIR__ . '/image';
     if (!is_dir($cacheDir)) {
         mkdir($cacheDir);
     }
     if (!is_dir($this->imgDir)) {
         mkdir($this->imgDir);
     }
     $this->getCurl()->cache['dir'] = $cacheDir;
     $this->getCurl()->cache['enalbe'] = true;
     $this->getCurl()->maxThread = 12;
     $this->getCurl()->opt[CURLOPT_CONNECTTIMEOUT] = 10;
     $this->getCurl()->cbInfo = array($this, 'cbCurlInfo');
     $this->getCurl()->maxThreadType['img'] = 10;
 }
Example #3
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;
 }