本文整理汇总了PHP中FileHandler::WriteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHandler::WriteFile方法的具体用法?PHP FileHandler::WriteFile怎么用?PHP FileHandler::WriteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHandler
的用法示例。
在下文中一共展示了FileHandler::WriteFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: procInstallAdminSaveFTPInfo
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'));
}
示例2: procInstallFTP
/**
* @brief FTP 정보 등록
**/
function procInstallFTP()
{
if (Context::isInstalled()) {
return new Object(-1, 'msg_already_installed');
}
$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;
}
$buff = '<?php if(!defined("__ZBXE__")) exit();' . "\n";
foreach ($ftp_info as $key => $val) {
$buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val));
}
$buff .= "?>";
// safe_mode 일 경우
if (ini_get('safe_mode')) {
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');
}
if (!is_dir(_XE_PATH_ . 'files') && !$oFtp->ftp_mkdir(_XE_PATH_ . 'files')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_mkdir_fail');
}
if (!$oFtp->ftp_site("CHMOD 777 " . _XE_PATH_ . 'files')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_chmod_fail');
}
if (!is_dir(_XE_PATH_ . 'files/config') && !$oFtp->ftp_mkdir(_XE_PATH_ . 'files/config')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_mkdir_fail');
}
if (!$oFtp->ftp_site("CHMOD 777 " . _XE_PATH_ . 'files/config')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_chmod_fail');
}
$oFtp->ftp_quit();
}
$config_file = Context::getFTPConfigFile();
FileHandler::WriteFile($config_file, $buff);
}
示例3: procInstallAdminSaveFTPInfo
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);
}
示例4: procInstallFTP
/**
* @brief Set FTP Information
*/
function procInstallFTP()
{
if (Context::isInstalled()) {
return new Object(-1, 'msg_already_installed');
}
$ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path');
$ftp_info->ftp_port = (int) $ftp_info->ftp_port;
if (!$ftp_info->ftp_port) {
$ftp_info->ftp_port = 21;
}
if (!$ftp_info->ftp_host) {
$ftp_info->ftp_host = '127.0.0.1';
}
if (!$ftp_info->ftp_root_path) {
$ftp_info->ftp_root_path = '/';
}
$buff = array('<?php if(!defined("__XE__")) exit();');
$buff[] = "\$ftp_info = new stdClass();";
foreach ($ftp_info as $key => $val) {
$buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val));
}
// If safe_mode
if (ini_get('safe_mode')) {
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($ftp_info->ftp_host, $ftp_info->ftp_port)) {
return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host));
}
if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
if (!is_dir(_XE_PATH_ . 'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path . 'files')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_mkdir_fail');
}
if (!$oFtp->ftp_site("CHMOD 777 " . $ftp_info->ftp_root_path . 'files')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_chmod_fail');
}
if (!is_dir(_XE_PATH_ . 'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path . 'files/config')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_mkdir_fail');
}
if (!$oFtp->ftp_site("CHMOD 777 " . $ftp_info->ftp_root_path . 'files/config')) {
$oFtp->ftp_quit();
return new Object(-1, 'msg_ftp_chmod_fail');
}
$oFtp->ftp_quit();
}
FileHandler::WriteFile(Context::getFTPConfigFile(), join(PHP_EOL, $buff));
}
示例5: procInstallAdminSaveFTPInfo
/**
* @brief FTP 정보 등록
**/
function procInstallAdminSaveFTPInfo()
{
$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;
}
$buff = '<?php if(!defined("__ZBXE__")) exit();' . "\n";
foreach ($ftp_info as $key => $val) {
$buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val));
}
$buff .= "?>";
$config_file = Context::getFTPConfigFile();
FileHandler::WriteFile($config_file, $buff);
$this->setMessage('success_updated');
}