Exemplo n.º 1
0
 function getInstallFTPList()
 {
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $this->pwd = $ftp_info->ftp_root_path;
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = "127.0.0.1";
     }
     if ($ftp_info->sftp == 'Y') {
         return $this->getSFTPList();
     }
     if (function_exists(ftp_connect)) {
         $connection = ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
         if (!$connection) {
             return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host));
         }
         $login_result = @ftp_login($connection, $ftp_info->ftp_user, $ftp_info->ftp_password);
         if (!$login_result) {
             ftp_close($connection);
             return new Object(-1, 'msg_ftp_invalid_auth_info');
         }
         if ($ftp_info->ftp_pasv != "N") {
             ftp_pasv($connection, true);
         }
         $_list = ftp_rawlist($connection, $this->pwd);
         ftp_close($connection);
     } else {
         require_once _XE_PATH_ . 'libs/ftp.class.php';
         $oFtp = new ftp();
         if ($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
             if ($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
                 $_list = $oFtp->ftp_rawlist($this->pwd);
                 $oFtp->ftp_quit();
             } else {
                 $oFtp->ftp_quit();
                 return new Object(-1, 'msg_ftp_invalid_auth_info');
             }
         }
     }
     $list = array();
     if ($_list) {
         foreach ($_list as $k => $v) {
             $src = null;
             $src->data = $v;
             $res = Context::convertEncoding($src);
             $v = $res->data;
             if (strpos($v, 'd') === 0 || strpos($v, '<DIR>')) {
                 $list[] = substr(strrchr($v, ' '), 1) . '/';
             }
         }
     }
     $this->add('list', $list);
 }
Exemplo n.º 2
0
 /**
  * Add file list to Object after ftp connect
  * @return void|Object
  */
 function getAdminFTPList()
 {
     Context::loadLang('./modules/autoinstall/lang');
     set_time_limit(5);
     require_once _XE_PATH_ . 'libs/ftp.class.php';
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $this->pwd = $ftp_info->ftp_root_path;
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = "127.0.0.1";
     }
     if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) {
         $ftp_info->ftp_port = "21";
     }
     if ($ftp_info->sftp == 'Y') {
         if (!function_exists(ssh2_sftp)) {
             return new Object(-1, 'disable_sftp_support');
         }
         return $this->getSFTPList();
     }
     $oFtp = new ftp();
     if ($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
         if ($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
             $_list = $oFtp->ftp_rawlist($this->pwd);
             $oFtp->ftp_quit();
         } else {
             return new Object(-1, 'msg_ftp_invalid_auth_info');
         }
     }
     $list = array();
     if ($_list) {
         foreach ($_list as $k => $v) {
             $src = null;
             $src->data = $v;
             $res = Context::convertEncoding($src);
             $v = $res->data;
             if (strpos($v, 'd') === 0 || strpos($v, '<DIR>')) {
                 $list[] = substr(strrchr($v, ' '), 1) . '/';
             }
         }
     } else {
         return new Object(-1, 'msg_ftp_no_directory');
     }
     $this->add('list', $list);
 }
Exemplo n.º 3
0
 function procInstallCheckFtp()
 {
     $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port');
     $ftp_info->ftp_port = (int) $ftp_info->ftp_port;
     if (!$ftp_info->ftp_port) {
         $ftp_info->ftp_port = 21;
     }
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(-1, 'msg_safe_mode_ftp_needed');
     }
     require_once _XE_PATH_ . 'libs/ftp.class.php';
     $oFtp = new ftp();
     if (!$oFtp->ftp_connect('localhost', $ftp_info->ftp_port)) {
         return new Object(-1, 'msg_ftp_not_connected');
     }
     if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
         $oFtp->ftp_quit();
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $oFtp->ftp_quit();
     $this->setMessage('msg_ftp_connect_success');
 }
Exemplo n.º 4
0
 function procInstallCheckFtp()
 {
     $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp');
     $ftp_info->ftp_port = (int) $ftp_info->ftp_port;
     if (!$ftp_info->ftp_port) {
         $ftp_info->ftp_port = 21;
     }
     if (!$ftp_info->sftp) {
         $ftp_info->sftp = 'N';
     }
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(-1, 'msg_safe_mode_ftp_needed');
     }
     if ($ftp_info->sftp == 'Y') {
         $connection = ssh2_connect('localhost', $ftp_info->ftp_port);
         if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) {
             return new Object(-1, 'msg_ftp_invalid_auth_info');
         }
     } else {
         require_once _XE_PATH_ . 'libs/ftp.class.php';
         $oFtp = new ftp();
         if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) {
             return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost'));
         }
         if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
             $oFtp->ftp_quit();
             return new Object(-1, 'msg_ftp_invalid_auth_info');
         }
         $oFtp->ftp_quit();
     }
     $this->setMessage('msg_ftp_connect_success');
 }
Exemplo n.º 5
0
 /**
  * @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);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
0
	public function _home() {
		global $config, $user, $cache;

		$ftp = new ftp();

		if (!$ftp->ftp_connect($config['broadcast_host'])) {
			_pre('Can not connect', true);
		}

		if (!$ftp->ftp_login($config['broadcast_username'], $config['broadcast_password'])) {
			$ftp->ftp_quit();
			_pre('Can not login', true);
		}

		$cds_file = ROOT . 'interfase/cds/schedule_playlist.txt';

		// Submit
		if (_button()) {
			$hours = request_var('hours', array('' => ''));

			$build = '';
			foreach ($hours as $hour => $play) {
				$build .= ((!empty($build)) ? nr(1) : '') . trim($hour) . ':' . trim($play);
			}

			if ($fp = @fopen($cds_file, 'w')) {
				@flock($fp, LOCK_EX);
				fputs($fp, $build);
				@flock($fp, LOCK_UN);
				fclose($fp);

				_chmod($cds_file, $config['mask']);

				if ($ftp->ftp_put('/Schedule/schedule_playlist.txt', $cds_file)) {
					echo '<h1>El archivo fue procesado correctamente.</h1>';
				} else {
					echo '<h1>Error al procesar, intenta nuevamente.</h1>';
				}
			} else {
				echo 'Error de escritura en archivo local.';
			}

			echo '<br />';
		}

		if (!@file_exists($cds_file)) {
			fatal_error();
		}

		$cds = @file($cds_file);

		$filelist = $ftp->ftp_nlist('/Schedule');
		echo '<pre>';
		print_r($filelist);
		echo '</pre>';

		foreach ($cds as $item)
		{
			$e_item = array_map('trim', explode(':', $item));
			if (!empty($e_item[0]))
			{
				echo sumhour($e_item[0]) . ' <input type="text" name="hours[' . $e_item[0] . ']" value="' . $e_item[1] . '" size="100"' . ((oclock($e_item[0])) ? 'class="highlight"' : '') . ' /><br />' . nr();
			}
		}

		$ftp->ftp_quit();

		return true;
	}