예제 #1
0
 /**
  * uploadUrl
  * 
  * @param string $url
  * @param string $name
  * @param mixed  $chmod
  * @param string $headers
  * @param mixed  $set_time_limit
  * @param bool   $ignore_user_abort
  * @return string
  */
 public function uploadUrl($url = '', $name = '', $chmod = 0644, $headers = '', $set_time_limit = false, $ignore_user_abort = false)
 {
     if ($set_time_limit !== false) {
         @set_time_limit($set_time_limit);
     }
     if ($ignore_user_abort) {
         ignore_user_abort(true);
     }
     $this->_setIniHeaders($headers);
     $tmp = array();
     $url = trim($url);
     $url = NetworkWrapper::set($url);
     if (mb_strpos($url, "\n") !== false) {
         foreach (explode("\n", $url) as $v) {
             $v = trim($v);
             $tmp[] = array($v, $name . Helper_System::basename($v));
         }
     } else {
         $last = mb_substr($name, -1);
         $temp = false;
         if ($last != '/' && self::$_instance->is_dir($name)) {
             $name .= '/';
             $temp = true;
         }
         if ($last != '/' && !$temp) {
             $name = dirname($name) . '/' . Helper_System::basename($name);
         } else {
             $name .= $this->_getUrlName($url);
         }
         $tmp[] = array($url, $name);
     }
     $out = '';
     foreach ($tmp as $v) {
         $dir = dirname($v[1]);
         if (!self::$_instance->is_dir($dir)) {
             self::$_instance->mkdir($dir, 0755, true);
         }
         if (Config::get('Gmanager', 'mode') == 'FTP') {
             if ($tmp) {
                 $r = self::$_instance->file_put_contents($v[1], $tmp['body']);
                 self::$_instance->chmod($v[1], $chmod);
             } else {
                 $r = false;
             }
         } else {
             $r = self::$_instance->copy($v[0], $v[1], $chmod);
         }
         if ($r) {
             $out .= Helper_View::message(Language::get('upload_true') . ' -> ' . htmlspecialchars($v[0] . ' -> ' . $v[1], ENT_NOQUOTES), Helper_View::MESSAGE_SUCCESS);
         } else {
             $out .= Helper_View::message(Language::get('upload_false') . ' -&gt; ' . htmlspecialchars($v[0] . ' x ' . $v[1], ENT_NOQUOTES) . '<br/>' . Errors::get(), Helper_View::MESSAGE_ERROR_EMAIL);
         }
     }
     return $out;
 }