function procInstallAdminSaveFTPInfo()
 {
     $ftp_info = Context::getFTPInfo();
     $ftp_info->ftp_user = Context::get('ftp_user');
     $ftp_info->ftp_port = Context::get('ftp_port');
     $ftp_info->ftp_host = Context::get('ftp_host');
     $ftp_info->ftp_pasv = Context::get('ftp_pasv');
     if (!$ftp_info->ftp_pasv) {
         $ftp_info->ftp_pasv = "N";
     }
     $ftp_info->sftp = Context::get('sftp');
     $ftp_root_path = Context::get('ftp_root_path');
     if (substr($ftp_root_path, strlen($ftp_root_path) - 1) == "/") {
         $ftp_info->ftp_root_path = $ftp_root_path;
     } else {
         $ftp_info->ftp_root_path = $ftp_root_path . '/';
     }
     if (ini_get('safe_mode')) {
         $ftp_info->ftp_password = Context::get('ftp_password');
     }
     $buff = '<?php if(!defined("__XE__")) exit();' . "\n\$ftp_info = new stdClass;\n";
     foreach ($ftp_info as $key => $val) {
         if (!$val) {
             continue;
         }
         if (preg_match('/(<\\?|<\\?php|\\?>|fputs|fopen|fwrite|fgets|fread|file_get_contents|file_put_contents|exec|proc_open|popen|passthru|show_source|phpinfo|system|\\/\\*|\\*\\/|chr\\()/xsm', preg_replace('/\\s/', '', $val))) {
             continue;
         }
         $buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val));
     }
     $buff .= "?>";
     $config_file = Context::getFTPConfigFile();
     FileHandler::WriteFile($config_file, $buff);
     if ($_SESSION['ftp_password']) {
         unset($_SESSION['ftp_password']);
     }
     $this->setMessage('success_updated');
     $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigFtp');
     $this->setRedirectUrl($returnUrl);
 }
示例#2
0
 /**
  * Get remove url by path
  *
  * @param string $path Path to get url
  * @return string
  */
 function getRemoveUrlByPath($path)
 {
     if (!$path) {
         return;
     }
     $ftp_info = Context::getFTPInfo();
     if (!$ftp_info->ftp_root_path) {
         return;
     }
     $packageSrl = $this->getPackageSrlByPath($path);
     if (!$packageSrl) {
         return;
     }
     return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminUninstall', 'package_srl', $packageSrl);
 }
 function procInstallAdminSaveFTPInfo()
 {
     $ftp_info = Context::getFTPInfo();
     $ftp_info->ftp_user = Context::get('ftp_user');
     $ftp_info->ftp_port = Context::get('ftp_port');
     $ftp_info->ftp_host = Context::get('ftp_host');
     $ftp_info->ftp_pasv = Context::get('ftp_pasv');
     if (!$ftp_info->ftp_pasv) {
         $ftp_info->ftp_pasv = "N";
     }
     $ftp_info->sftp = Context::get('sftp');
     $ftp_root_path = Context::get('ftp_root_path');
     if (substr($ftp_root_path, strlen($ftp_root_path) - 1) == "/") {
         $ftp_info->ftp_root_path = $ftp_root_path;
     } else {
         $ftp_info->ftp_root_path = $ftp_root_path . '/';
     }
     if (ini_get('safe_mode')) {
         $ftp_info->ftp_password = Context::get('ftp_password');
     }
     $buff = '<?php if(!defined("__ZBXE__")) exit();' . "\n";
     foreach ($ftp_info as $key => $val) {
         if (!$val) {
             continue;
         }
         if (preg_match('/(<\\?|<\\?php|\\?>)/xsm', preg_replace('/\\s/', '', $val))) {
             continue;
         }
         $buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val));
     }
     $buff .= "?>";
     $config_file = Context::getFTPConfigFile();
     FileHandler::WriteFile($config_file, $buff);
     if ($_SESSION['ftp_password']) {
         unset($_SESSION['ftp_password']);
     }
     $this->setMessage('success_updated');
     $this->setRedirectUrl(Context::get('error_return_url'));
 }
示例#4
0
 /**
  * Constructor
  *
  * @param object $package Package information
  */
 function FTPModuleInstaller(&$package)
 {
     $this->package =& $package;
     $this->ftp_info = Context::getFTPInfo();
 }
示例#5
0
 /**
  * Display FTP Configuration(settings) page
  * @return void
  */
 function dispAdminConfigFtp()
 {
     Context::loadLang('modules/install/lang');
     $ftp_info = Context::getFTPInfo();
     Context::set('ftp_info', $ftp_info);
     Context::set('sftp_support', function_exists(ssh2_sftp));
     $this->setTemplateFile('config_ftp');
     //$security = new Security();
     //$security->encodeHTML('ftp_info..');
 }
 /**
  * @brief 디렉토리 생성
  *
  * 주어진 경로를 단계별로 접근하여 recursive하게 디렉토리 생성
  **/
 function makeDir($path_string)
 {
     static $oFtp = null;
     // safe_mode 일 경우 ftp 정보를 이용해서 디렉토리 생성
     if (ini_get('safe_mode') && $oFtp == null) {
         if (!Context::isFTPRegisted()) {
             return;
         }
         require_once _XE_PATH_ . 'libs/ftp.class.php';
         $ftp_info = Context::getFTPInfo();
         $oFtp = new ftp();
         if (!$oFtp->ftp_connect('localhost')) {
             return;
         }
         if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
             $oFtp->ftp_quit();
             return;
         }
     }
     $path_string = str_replace(_XE_PATH_, '', $path_string);
     $path_list = explode('/', $path_string);
     $path = _XE_PATH_;
     for ($i = 0; $i < count($path_list); $i++) {
         if (!$path_list[$i]) {
             continue;
         }
         $path .= $path_list[$i] . '/';
         if (!is_dir($path)) {
             if (ini_get('safe_mode')) {
                 $oFtp->ftp_mkdir($path);
                 $oFtp->ftp_site("CHMOD 777 " . $path);
             } else {
                 @mkdir($path, 0755);
                 @chmod($path, 0755);
             }
         }
     }
     return is_dir($path_string);
 }
示例#7
0
 /**
  * Constructor
  *
  * @param object $package Package information
  */
 function __construct(&$package)
 {
     $this->package =& $package;
     $this->ftp_info = Context::getFTPInfo();
 }
示例#8
0
 /**
  * Display package list
  *
  * @return Object
  */
 function dispAutoinstallAdminIndex()
 {
     $oModuleModel =& getModel('module');
     $config = $oModuleModel->getModuleConfig('autoinstall');
     $ftp_info = Context::getFTPInfo();
     if (!$ftp_info->ftp_root_path) {
         Context::set('show_ftp_note', true);
     }
     $this->setTemplateFile('index');
     $params = array();
     $params["act"] = "getResourceapiLastupdate";
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     $xml_lUpdate = new XmlParser();
     $lUpdateDoc = $xml_lUpdate->parse($buff);
     $updateDate = $lUpdateDoc->response->updatedate->body;
     if (!$updateDate) {
         return $this->stop('msg_connection_fail');
     }
     $oModel =& getModel('autoinstall');
     $item = $oModel->getLatestPackage();
     if (!$item || $item->updatedate < $updateDate || count($this->categories) < 1) {
         $oController =& getAdminController('autoinstall');
         $oController->_updateinfo();
         if (!$_SESSION['__XE_EASYINSTALL_REDIRECT__']) {
             header('location: ' . getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminIndex'));
             $_SESSION['__XE_EASYINSTALL_REDIRECT__'] = true;
             return;
         }
     }
     unset($_SESSION['__XE_EASYINSTALL_REDIRECT__']);
     $page = Context::get('page');
     if (!$page) {
         $page = 1;
     }
     Context::set('page', $page);
     $order_type = Context::get('order_type');
     if (!in_array($order_type, array('asc', 'desc'))) {
         $order_type = 'desc';
     }
     Context::set('order_type', $order_type);
     $order_target = Context::get('order_target');
     if (!in_array($order_target, array('newest', 'download', 'popular'))) {
         $order_target = 'newest';
     }
     Context::set('order_target', $order_target);
     $search_keyword = Context::get('search_keyword');
     $childrenList = Context::get('childrenList');
     $category_srl = Context::get('category_srl');
     if ($childrenList) {
         $params["category_srl"] = $childrenList;
     } else {
         if ($category_srl) {
             $params["category_srl"] = $category_srl;
         }
     }
     $params["act"] = "getResourceapiPackagelist";
     $params["order_target"] = $order_target;
     $params["order_type"] = $order_type;
     $params["page"] = $page;
     if ($search_keyword) {
         $params["search_keyword"] = $search_keyword;
     }
     $xmlDoc = XmlGenerater::getXmlDoc($params);
     if ($xmlDoc && $xmlDoc->response->packagelist->item) {
         $item_list = $this->rearranges($xmlDoc->response->packagelist->item);
         Context::set('item_list', $item_list);
         $array = array('total_count', 'total_page', 'cur_page', 'page_count', 'first_page', 'last_page');
         $page_nav = $this->rearrange($xmlDoc->response->page_navigation, $array);
         $page_navigation = new PageHandler($page_nav->total_count, $page_nav->total_page, $page_nav->cur_page, 5);
         Context::set('page_navigation', $page_navigation);
     }
     $security = new Security();
     $security->encodeHTML('package.', 'package.depends..');
 }
示例#9
0
 /**
  * Creates a directory
  *
  * This function creates directories recursively, which means that if ancestors of the target directory does not exist, they will be created too.
  *
  * @param string $path_string Path of target directory
  * @return bool TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed.
  */
 public static function makeDir($path_string)
 {
     if (self::exists($path_string) !== FALSE) {
         return TRUE;
     }
     if (!ini_get('safe_mode')) {
         @mkdir($path_string, 0755, TRUE);
         @chmod($path_string, 0755);
     } else {
         static $oFtp = NULL;
         $ftp_info = Context::getFTPInfo();
         if ($oFtp == NULL) {
             if (!Context::isFTPRegisted()) {
                 return;
             }
             $oFtp = new ftp();
             if (!$ftp_info->ftp_host) {
                 $ftp_info->ftp_host = "127.0.0.1";
             }
             if (!$ftp_info->ftp_port) {
                 $ftp_info->ftp_port = 21;
             }
             if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
                 return;
             }
             if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
                 $oFtp->ftp_quit();
                 return;
             }
         }
         if (!($ftp_path = $ftp_info->ftp_root_path)) {
             $ftp_path = DIRECTORY_SEPARATOR;
         }
         $path_string = str_replace(_XE_PATH_, '', $path_string);
         $path_list = explode(DIRECTORY_SEPARATOR, $path_string);
         $path = _XE_PATH_;
         for ($i = 0, $c = count($path_list); $i < $c; $i++) {
             if (!$path_list[$i]) {
                 continue;
             }
             $path .= $path_list[$i] . DIRECTORY_SEPARATOR;
             $ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR;
             if (!is_dir($path)) {
                 $oFtp->ftp_mkdir($ftp_path);
                 $oFtp->ftp_site("CHMOD 777 " . $ftp_path);
             }
         }
     }
     return is_dir($path_string);
 }
 /**
  * Get is authed ftp
  */
 function getAutoinstallAdminIsAuthed()
 {
     $is_authed = 0;
     $ftp_info = Context::getFTPInfo();
     if (!$ftp_info->ftp_root_path) {
         $is_authed = -1;
     } else {
         $is_authed = (int) isset($_SESSION['ftp_password']);
     }
     $this->add('is_authed', $is_authed);
 }
 private function _uninstallPackage($package)
 {
     $path = $package->path;
     if (!$_SESSION['ftp_password']) {
         $ftp_password = Context::get('ftp_password');
     } else {
         $ftp_password = $_SESSION['ftp_password'];
     }
     $ftp_info = Context::getFTPInfo();
     $isSftpSupported = function_exists(ssh2_sftp);
     if ($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported) {
         $oModuleInstaller = new SFTPModuleInstaller($package);
     } else {
         if (function_exists('ftp_connect')) {
             $oModuleInstaller = new PHPFTPModuleInstaller($package);
         } else {
             $oModuleInstaller = new FTPModuleInstaller($package);
         }
     }
     $oModuleInstaller->setServerUrl(_XE_DOWNLOAD_SERVER_);
     $oModuleInstaller->setPassword($ftp_password);
     $output = $oModuleInstaller->uninstall();
     if (!$output->toBool()) {
         return $output;
     }
     $this->_updateinfo();
     $this->setMessage('success_deleted', 'update');
     return new Object();
 }
示例#12
0
 /**
  * Creates a directory
  *
  * This function creates directories recursively, which means that if ancestors of the target directory does not exist, they will be created too.
  *
  * @param string $path_string Path of target directory
  * @return bool true if success. It might return nothing when ftp is used and connection to the ftp address failed.
  **/
 function makeDir($path_string)
 {
     static $oFtp = null;
     // if safe_mode is on, use FTP
     if (ini_get('safe_mode')) {
         $ftp_info = Context::getFTPInfo();
         if ($oFtp == null) {
             if (!Context::isFTPRegisted()) {
                 return;
             }
             require_once _XE_PATH_ . 'libs/ftp.class.php';
             $oFtp = new ftp();
             if (!$ftp_info->ftp_host) {
                 $ftp_info->ftp_host = "127.0.0.1";
             }
             if (!$ftp_info->ftp_port) {
                 $ftp_info->ftp_port = 21;
             }
             if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
                 return;
             }
             if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
                 $oFtp->ftp_quit();
                 return;
             }
         }
         $ftp_path = $ftp_info->ftp_root_path;
         if (!$ftp_path) {
             $ftp_path = "/";
         }
     }
     $path_string = str_replace(_XE_PATH_, '', $path_string);
     $path_list = explode('/', $path_string);
     $path = _XE_PATH_;
     for ($i = 0; $i < count($path_list); $i++) {
         if (!$path_list[$i]) {
             continue;
         }
         $path .= $path_list[$i] . '/';
         $ftp_path .= $path_list[$i] . '/';
         if (!is_dir($path)) {
             if (ini_get('safe_mode')) {
                 $oFtp->ftp_mkdir($ftp_path);
                 $oFtp->ftp_site("CHMOD 777 " . $ftp_path);
             } else {
                 @mkdir($path, 0755);
                 @chmod($path, 0755);
             }
         }
     }
     return is_dir($path_string);
 }
 /**
  * Get is authed ftp
  */
 function getAutoinstallAdminIsAuthed()
 {
     $oAdminModel = getAdminModel('autoinstall');
     $package = $oAdminModel->getInstallInfo(Context::get('package_srl'));
     $is_authed = 0;
     $output = $oAdminModel->checkUseDirectModuleInstall($package);
     if ($output->toBool() == TRUE) {
         $is_authed = 1;
     } else {
         $ftp_info = Context::getFTPInfo();
         if (!$ftp_info->ftp_root_path) {
             $is_authed = -1;
         } else {
             $is_authed = (int) isset($_SESSION['ftp_password']);
         }
     }
     $this->add('is_authed', $is_authed);
 }
 /**
  * Uninstall package
  *
  * @return Object
  */
 function procAutoinstallAdminUninstallPackage()
 {
     $package_srl = Context::get('package_srl');
     $oModel =& getModel('autoinstall');
     $package = $oModel->getPackage($package_srl);
     $path = $package->path;
     if (!$_SESSION['ftp_password']) {
         $ftp_password = Context::get('ftp_password');
     } else {
         $ftp_password = $_SESSION['ftp_password'];
     }
     $ftp_info = Context::getFTPInfo();
     $isSftpSupported = function_exists(ssh2_sftp);
     if ($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported) {
         $oModuleInstaller = new SFTPModuleInstaller($package);
     } else {
         if (function_exists('ftp_connect')) {
             $oModuleInstaller = new PHPFTPModuleInstaller($package);
         } else {
             $oModuleInstaller = new FTPModuleInstaller($package);
         }
     }
     $oModuleInstaller->setServerUrl(_XE_DOWNLOAD_SERVER_);
     $oModuleInstaller->setPassword($ftp_password);
     $output = $oModuleInstaller->uninstall();
     if (!$output->toBool()) {
         return $output;
     }
     $this->_updateinfo();
     $this->setMessage('success_deleted', 'update');
     if (Context::get('return_url')) {
         $this->setRedirectUrl(Context::get('return_url'));
     } else {
         $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminInstalledPackages'));
     }
 }
示例#15
0
 /**
  * @brief 관리자 설정
  **/
 function dispAdminConfig()
 {
     $db_info = Context::getDBInfo();
     Context::set('selected_lang', $db_info->lang_type);
     Context::set('default_url', $db_info->default_url);
     Context::set('langs', Context::loadLangSupported());
     Context::set('lang_selected', Context::loadLangSelected());
     Context::set('ftp_info', Context::getFTPInfo());
     $site_args->site_srl = 0;
     $output = executeQuery('module.getSiteInfo', $site_args);
     Context::set('start_module', $output->data);
     Context::set('layout', 'none');
     $this->setTemplateFile('config');
 }