/**
  * ハブサーバーに通知する
  */
 public function publish()
 {
     if (empty($this->hubs) || empty($this->urls)) {
         return;
     }
     $params = $this->params();
     $http = new Http();
     foreach ($this->hubs() as $hub) {
         $http->raw(implode('&', $params));
         $http->do_post($hub);
         if ($http->status() != 204) {
             throw new Exception(sprintf('[%d] %s', $http->status(), $http->body()));
         }
     }
 }
Exemple #2
0
 /**
  * 短縮urlから復元する
  * @param $url
  * @return string
  */
 public static function lookup($url)
 {
     if (strpos($url, "http://tinyurl.com/") !== 0) {
         $url = "http://tinyurl.com/" . $url;
     }
     $http = new Http();
     $http->status_redirect(false);
     $http->do_get($url);
     if ($http->status() === 301 && preg_match("/Location:[ ](.*)/i", $http->head(), $redirect_url)) {
         return trim($redirect_url[1]);
     }
     return $url;
     /***
     			eq("http://rhaco.org",Tinyurl::lookup("http://tinyurl.com/6bkavu"));
     			eq("http://rhaco.org",Tinyurl::lookup("6bkavu"));			
     		 */
 }
Exemple #3
0
 /**
  * tar.gz(tgz)を解凍してファイル書き出しを行う
  * @param string $inpath 解凍するファイルパス
  * @param string $outpath 解凍先のファイルパス
  * @param integer $permission フォルダを作成する際のアクセス権限、8進数(0755)で入力する
  */
 public static function untgz($inpath, $outpath, $permission = null)
 {
     $tmp = false;
     if (strpos($inpath, "://") !== false && (bool) ini_get("allow_url_fopen")) {
         $tmpname = self::absolute($outpath, self::temp_path($outpath));
         $http = new Http();
         try {
             $http->do_download($inpath, $tmpname);
             if ($http->status() !== 200) {
                 throw new InvalidArgumentException($inpath . ' not found');
             }
         } catch (ErrorException $e) {
             throw new InvalidArgumentException(sprintf("permission denied[%s]", $tmpname));
         }
         $inpath = $tmpname;
         $tmp = true;
     }
     self::untar(self::gzread($inpath), $outpath, $permission);
     if ($tmp) {
         self::rm($inpath);
     }
 }