/**
  * Return content URL
  *
  * @param string $hash file hash
  * @param array $options options
  * @return array
  * @author Naoki Sawada
  **/
 public function getContentUrl($hash, $options = array())
 {
     if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) {
         $path = $this->decode($hash);
         $cache = $this->getDBdat($path);
         $url = '';
         if (isset($cache['share'])) {
             $res = $this->getHttpResponseHeader($cache['share']);
             if (preg_match("/^HTTP\\/[01\\.]+ ([0-9]{3})/", $res, $match)) {
                 if (preg_match('/^location:\\s*(http[^\\s]+)/im', $res, $match)) {
                     $url = $match[1];
                 } else {
                     if ($match[1] >= 400) {
                         $url = '';
                     }
                 }
             } else {
                 $url = '';
             }
         }
         if (!$url) {
             try {
                 $res = $this->dropbox->share($path);
                 $res = $this->getHttpResponseHeader($res['url']);
                 if (preg_match('/^location:\\s*(http[^\\s]+)/im', $res, $match)) {
                     $url = $match[1] . '?dl=1';
                 }
                 if ($url) {
                     if (!isset($cache['share']) || $cache['share'] !== $url) {
                         $cache['share'] = $url;
                         $this->updateDBdat($path, $cache);
                     }
                     $res = $this->getHttpResponseHeader($url);
                     if (preg_match('/^location:\\s*(http[^\\s?]+)/im', $res, $match)) {
                         $url = $match[1];
                     }
                 }
             } catch (Dropbox_Exception $e) {
                 return false;
             }
         }
         if ($url) {
             list($url) = explode('?', $url);
         }
         return $url;
     }
     return $file['url'];
 }
 /**
 * Return content URL
 *
 * @param string $hash file hash
 * @param array $options options
 * @return array
 * @author Naoki Sawada
 **/
 public function getContentUrl($hash, $options = array())
 {
     if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) {
         $path = $this->decode($hash);
         $cache =& $this->metaCacheArr['data'][strtolower($path)];
         $url = '';
         if (isset($cache['share'])) {
             $res = $this->getHttpResponseHeader($cache['share']);
             if (preg_match("/^HTTP\\/[01\\.]+ ([0-9]{3})/", $res, $match)) {
                 if (preg_match('/^location:\\s*(http[^\\s]+)/im', $res, $match)) {
                     $url = $match[1];
                 } else {
                     if ($match[1] >= 400) {
                         $url = '';
                     }
                 }
             } else {
                 $url = '';
             }
         }
         if (!$url) {
             try {
                 $res = $this->dropbox->share($path);
                 $res = $this->getHttpResponseHeader($res['url']);
                 if (preg_match('/^location:\\s*(http[^\\s]+)/im', $res, $match)) {
                     $url = $match[1] . '?dl=1';
                 }
                 if ($url) {
                     $cache['share'] = $url;
                     $this->mataCacheSave();
                     $res = $this->getHttpResponseHeader($url);
                     if (preg_match('/^location:\\s*(http[^\\s]+)/im', $res, $match)) {
                         $url = $match[1];
                     }
                 }
             } catch (Dropbox_Exception $e) {
                 return false;
             }
         }
         return $url;
     }
     return $file['url'];
 }
 /**
  * Return content URL
  *
  * @param string  $hash  file hash
  * @param array $options options
  * @return array
  * @author Naoki Sawada
  **/
 public function getContentUrl($hash, $options = array())
 {
     if (($file = $this->file($hash)) == false || !$file['url'] || $file['url'] == 1) {
         $path = $this->decode($hash);
         $cache = $this->getDBdat($path);
         $url = '';
         if (isset($cache['share']) && strpos($cache['share'], $this->dropbox_dlhost) !== false) {
             $res = $this->getHttpResponseHeader($cache['share']);
             if (preg_match("/^HTTP\\/[01\\.]+ ([0-9]{3})/", $res, $match)) {
                 if ($match[1] < 400) {
                     $url = $cache['share'];
                 }
             }
         }
         if (!$url) {
             try {
                 $res = $this->dropbox->share($path, null, false);
                 $url = $res['url'];
                 if (strpos($url, 'www.dropbox.com') === false) {
                     $res = $this->getHttpResponseHeader($url);
                     if (preg_match('/^location:\\s*(http[^\\s]+)/im', $res, $match)) {
                         $url = $match[1];
                     }
                 }
                 list($url) = explode('?', $url);
                 $url = str_replace('www.dropbox.com', $this->dropbox_dlhost, $url);
                 if (!isset($cache['share']) || $cache['share'] !== $url) {
                     $cache['share'] = $url;
                     $this->updateDBdat($path, $cache);
                 }
             } catch (Dropbox_Exception $e) {
                 return false;
             }
         }
         return $url;
     }
     return $file['url'];
 }
 public function share($path)
 {
     return $this->dropbox->share($path);
 }