static function file_put_contents($file_name, $content, $options = array()) { $default_options = array('ftp' => defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP, 'base_path' => self::getDefaultBasePath($file_name)); $options = array_merge($default_options, $options); $file_name = self::getRestrictedPath($file_name, $options); if ($options['ftp']) { if (!AkFtp::is_dir(dirname($file_name))) { AkFtp::make_dir(dirname($file_name)); } return AkFtp::put_contents($file_name, $content); } else { $base_path = self::getNormalizedBasePath($options); if (!is_dir(dirname($base_path . $file_name))) { self::make_dir(dirname($base_path . $file_name), $options); } if (!($result = file_put_contents($base_path . $file_name, $content))) { if (!empty($content)) { trigger_error(Ak::t("Could not write to file: %file_name. Please change file/dir permissions or enable FTP file handling on your Akelos application.", array('%file_name' => '"' . $base_path . $file_name . '"')), E_USER_ERROR); } } return $result; } }
function file_put_contents($file_name, $content, $options = array()) { $default_options = array('ftp' => defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP, 'base_path' => AK_BASE_DIR); $options = array_merge($default_options, $options); if (!function_exists('file_put_contents')) { include_once AK_CONTRIB_DIR . DS . 'pear' . DS . 'PHP' . DS . 'Compat.php'; PHP_Compat::loadFunction(array('file_put_contents')); } $file_name = trim(str_replace($options['base_path'], '', $file_name), DS); if ($options['ftp']) { require_once AK_LIB_DIR . DS . 'AkFtp.php'; $file_name = trim(str_replace(array(DS, '//'), array('/', '/'), $file_name), '/'); if (!AkFtp::is_dir(dirname($file_name))) { AkFtp::make_dir(dirname($file_name)); } return AkFtp::put_contents($file_name, $content); } else { if (!is_dir(dirname($options['base_path'] . DS . $file_name))) { Ak::make_dir(dirname($options['base_path'] . DS . $file_name), $options); } if (!($result = file_put_contents($options['base_path'] . DS . $file_name, $content))) { if (!empty($content)) { Ak::trace("Could not write to file: \"" . $options['base_path'] . DS . "{$file_name}\". Please change file/dir permissions or enable FTP file handling by" . " setting the following on your config/" . AK_ENVIRONMENT . ".php file \n<pre>define('AK_UPLOAD_FILES_USING_FTP', true);\n" . "define('AK_READ_FILES_USING_FTP', false);\n" . "define('AK_DELETE_FILES_USING_FTP', true);\n" . "define('AK_FTP_PATH', 'ftp://*****:*****@example.com/path_to_the_framework');\n" . "define('AK_FTP_AUTO_DISCONNECT', true);\n</pre>"); } } return $result; } }
static function file_put_contents($file_name, $content, $options = array()) { $default_options = array('ftp' => defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP, 'base_path' => strstr($file_name, AK_TMP_DIR) ? AK_TMP_DIR : AK_BASE_DIR); $options = array_merge($default_options, $options); $file_name = trim(str_replace($options['base_path'], '', $file_name), DS); if ($options['ftp']) { $file_name = trim(str_replace(array(DS, '//'), array('/', '/'), $file_name), '/'); if (!AkFtp::is_dir(dirname($file_name))) { AkFtp::make_dir(dirname($file_name)); } return AkFtp::put_contents($file_name, $content); } else { $base_path = AK_WIN && empty($options['base_path']) ? '' : $options['base_path'] . DS; if (!is_dir(dirname($base_path . $file_name))) { Ak::make_dir(dirname($base_path . $file_name), $options); } if (!($result = file_put_contents($base_path . $file_name, $content))) { if (!empty($content)) { trigger_error(Ak::t("Could not write to file: %file_name. Please change file/dir permissions or enable FTP file handling on your Akelos application.", array('%file_name' => '"' . $base_path . $file_name . '"')), E_USER_ERROR); } } return $result; } }