4 require_once(
_XE_PATH_ .
'libs/ftp.class.php');
69 $this->base_url =
$url;
80 $type = $oModel->getTypeFromPath($this->package->path);
119 if($this->package->path ==
".")
121 $this->download_file = $this->temp_dir .
"xe.tar";
122 $this->target_path =
"";
127 $subpath = trim(substr($this->package->path, 2),
'/');
128 $this->download_file = $this->temp_dir . $subpath .
".tar";
129 $subpatharr = explode(
"/", $subpath);
130 array_pop($subpatharr);
131 $this->download_path = $this->temp_dir . implode(
"/", $subpatharr);
132 $this->target_path = implode(
"/", $subpatharr);
136 $postdata[
"path"] = $this->package->path;
137 $postdata[
"module"] =
"resourceapi";
138 $postdata[
"act"] =
"procResourceapiDownload";
152 $path_array = explode(
"/", $this->package->path);
153 $target_name = array_pop($path_array);
154 $oModule =
getModule($target_name,
"class");
157 return new BaseObject(-1,
'msg_invalid_request');
159 if(!method_exists($oModule,
"moduleUninstall"))
161 return new BaseObject(-1,
'msg_invalid_request');
164 $output = $oModule->moduleUninstall();
170 $schema_dir = sprintf(
'%s/schemas/', $this->package->path);
173 if(is_array($schema_files))
175 foreach($schema_files as $file)
177 $filename_arr = explode(
".", $file);
178 $filename = array_shift($filename_arr);
179 $oDB->dropTable($filename);
194 $path = $this->package->path;
197 $path_array = explode(
"/", $path);
198 $target_name = array_pop($path_array);
199 $type = substr(array_pop($path_array), 0, -1);
202 if($type ==
"module")
209 $oInstallController->installModule($target_name, $module_path);
213 $oModule =
getModule($target_name,
'class');
214 if(method_exists($oModule,
'moduleUpdate'))
216 $oModule->moduleUpdate();
233 $output = $this->_copyDir($file_list);
252 require_once(
_XE_PATH_ .
'libs/tar.class.php');
255 $oTar->openTAR($this->download_file);
257 $_files = $oTar->files;
258 $file_list = array();
259 if(is_array($_files))
261 foreach($_files as $key => $info)
264 $file_list[] = $info[
'name'];
281 while($file = $oDir->read())
283 if($file ==
"." || $file ==
"..")
290 foreach($files as $file)
292 $file_path = $path .
"/" . $file;
303 $output = $this->_removeFile($file_path);
310 $output = $this->_removeDir_real($path);
349 $this->
package = &$package;
360 if(!function_exists(
'ssh2_connect'))
362 return new BaseObject(-1,
'msg_sftp_not_supported');
365 if(!$this->ftp_info->ftp_user || !$this->ftp_info->sftp || $this->ftp_info->sftp !=
'Y')
367 return new BaseObject(-1,
'msg_ftp_invalid_auth_info');
370 if($this->ftp_info->ftp_host)
372 $ftp_host = $this->ftp_info->ftp_host;
376 $ftp_host =
"127.0.0.1";
378 $this->connection = ssh2_connect($ftp_host, $this->ftp_info->ftp_port);
379 if(!@ssh2_auth_password($this->connection, $this->ftp_info->ftp_user, $this->ftp_password))
381 return new BaseObject(-1,
'msg_ftp_invalid_auth_info');
384 $this->sftp = ssh2_sftp($this->connection);
406 if(substr($path, 0, 2) ==
"./")
408 $path = substr($path, 2);
427 if(substr($path, 0, 2) ==
"./")
429 $path = substr($path, 2);
448 if(!$this->ftp_password)
450 return new BaseObject(-1,
'msg_ftp_password_input');
461 if(is_array($file_list))
463 foreach($file_list as $k => $file)
466 if($this->package->path ==
".")
468 $file = substr($file, 3);
471 $pathname = dirname($target_dir .
"/" . $file);
475 ssh2_sftp_mkdir($this->sftp, $pathname, 0755, TRUE);
478 ssh2_scp_send($this->connection,
FileHandler::getRealPath($this->download_path .
"/" . $org_file), $target_dir .
"/" . $file);
518 $this->
package = &$package;
529 if($this->ftp_info->ftp_host)
531 $ftp_host = $this->ftp_info->ftp_host;
535 $ftp_host =
"127.0.0.1";
538 $this->connection = ftp_connect($ftp_host, $this->ftp_info->ftp_port);
539 if(!$this->connection)
544 $login_result = @ftp_login($this->connection, $this->ftp_info->ftp_user, $this->ftp_password);
548 return new BaseObject(-1,
'msg_ftp_invalid_auth_info');
552 if($this->ftp_info->ftp_pasv !=
"N")
554 ftp_pasv($this->connection, TRUE);
567 if(substr($path, 0, 2) ==
"./")
569 $path = substr($path, 2);
575 return new BaseObject(-1,
"failed to delete file " . $path);
588 if(substr($path, 0, 2) ==
"./")
590 $path = substr($path, 2);
596 return new BaseObject(-1,
"failed to delete directory " . $path);
608 ftp_close($this->connection);
619 if(!$this->ftp_password)
621 return new BaseObject(-1,
'msg_ftp_password_input');
630 if(!$this->target_path)
632 $this->target_path =
'.';
634 if(substr($this->download_path, -1) ==
'/')
636 $this->download_path = substr($this->download_path, 0, -1);
641 if(is_array($file_list))
643 foreach($file_list as $k => $file)
650 if($this->package->path ==
".")
652 $file = substr($file, 3);
655 $path_list = explode(
'/', dirname($this->target_path .
"/" . $file));
658 $ftp_path = $this->ftp_info->ftp_root_path;
660 for($i = 0; $i < count($path_list); $i++)
666 $real_path .= $path_list[$i] .
"/";
667 $ftp_path .= $path_list[$i] .
"/";
670 if(!@ftp_mkdir($this->connection, $ftp_path))
672 return new BaseObject(-1,
"msg_make_directory_failed");
675 if(strtoupper(substr(PHP_OS, 0, 3)) !==
'WIN')
677 if(function_exists(
'ftp_chmod'))
679 if(!ftp_chmod($this->connection, 0755, $ftp_path))
681 return new BaseObject(-1,
"msg_permission_adjust_failed");
686 if(!ftp_site($this->connection,
"CHMOD 755 " . $ftp_path))
688 return new BaseObject(-1,
"msg_permission_adjust_failed");
694 if(!ftp_put($this->connection, $target_dir .
'/' . $file,
FileHandler::getRealPath($this->download_path .
"/" . $org_file), FTP_BINARY))
696 return new BaseObject(-1,
"msg_ftp_upload_failed");
737 $this->
package = &$package;
748 if($this->ftp_info->ftp_host)
750 $ftp_host = $this->ftp_info->ftp_host;
754 $ftp_host =
"127.0.0.1";
757 $this->oFtp =
new ftp();
758 if(!$this->oFtp->ftp_connect($ftp_host, $this->ftp_info->ftp_port))
762 if(!$this->oFtp->ftp_login($this->ftp_info->ftp_user, $this->ftp_password))
765 return new BaseObject(-1,
'msg_ftp_invalid_auth_info');
779 if(substr($path, 0, 2) ==
"./")
781 $path = substr($path, 2);
799 if(substr($path, 0, 2) ==
"./")
801 $path = substr($path, 2);
819 $this->oFtp->ftp_quit();
830 if(!$this->ftp_password)
832 return new BaseObject(-1,
'msg_ftp_password_input');
841 $oFtp = &$this->oFtp;
846 if(is_array($file_list))
848 foreach($file_list as $k => $file)
851 if($this->package->path ==
".")
853 $file = substr($file, 3);
856 $path_list = explode(
'/', dirname($this->target_path .
"/" . $file));
859 $ftp_path = $this->ftp_info->ftp_root_path;
861 for($i = 0; $i < count($path_list); $i++)
867 $real_path .= $path_list[$i] .
"/";
868 $ftp_path .= $path_list[$i] .
"/";
871 $oFtp->ftp_mkdir($ftp_path);
872 $oFtp->ftp_site(
"CHMOD 755 " . $ftp_path);
903 $this->
package = &$package;
924 if(substr($path, 0, 2) ==
"./")
926 $path = substr($path, 2);
944 if(substr($path, 0, 2) ==
"./")
946 $path = substr($path, 2);
980 if(is_array($file_list))
982 foreach($file_list as $k => $file)
985 if($this->package->path ==
".")
987 $file = substr($file, 3);
990 $path_list = explode(
'/', dirname($this->target_path .
"/" . $file));
993 for($i = 0; $i < count($path_list); $i++)
999 $real_path .= $path_list[$i] .
"/";
getController($module_name)
writeFile($filename, $buff, $mode="w")
static invalidateOpcache($target, $force=true)
getRemoteResource($url, $body=null, $timeout=3, $method= 'GET', $content_type=null, $headers=array(), $cookies=array(), $post_data=array(), $request_config=array())
getInstance($db_type=NULL)
copyFile($source, $target, $force= 'Y')
readDir($path, $filter= '', $to_lower=FALSE, $concat_prefix=FALSE)
static clearStatCache($target, $include=false)
getModule($module_name, $type= 'view', $kind= '')
setPassword($ftp_password)