本文整理汇总了PHP中fn_normalize_path函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_normalize_path函数的具体用法?PHP fn_normalize_path怎么用?PHP fn_normalize_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_normalize_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_ftp_chmod_file
function fn_ftp_chmod_file($filename, $perm = DEFAULT_FILE_PERMISSIONS, $recursive = false)
{
$result = false;
$ftp = Registry::get('ftp_connection');
if (is_resource($ftp)) {
$dest = dirname($filename);
$dest = rtrim($dest, '/') . '/';
// force adding trailing slash to path
$rel_path = str_replace(Registry::get('config.dir.root') . '/', '', $dest);
$cdir = ftp_pwd($ftp);
if (empty($rel_path)) {
// if rel_path is empty, assume it's root directory
$rel_path = $cdir;
}
if (@ftp_chdir($ftp, $rel_path)) {
$result = @ftp_site($ftp, 'CHMOD ' . sprintf('0%o', $perm) . ' ' . fn_basename($filename));
if ($recursive) {
$path = fn_normalize_path($cdir . '/' . $rel_path . fn_basename($filename));
if (is_dir($path)) {
$_files = fn_get_dir_contents($path, true, true, '', '', true);
if (!empty($_files)) {
foreach ($_files as $_file) {
fn_ftp_chmod_file($path . '/' . $_file, $perm, false);
}
}
}
}
ftp_chdir($ftp, $cdir);
}
}
return $result;
}
示例2: urlToCss
/**
* Converts URL (http://e.com/a.png) to CSS property ( url("../a.png") )
* @param string $style_id style ID
* @param array $style_data style data (fields)
* @return array modified style data
*/
private function urlToCss($style_id, $style_data)
{
$patterns_url = Patterns::instance($this->params)->getUrl($style_id, true);
if (!empty($this->schema['backgrounds']['fields'])) {
foreach ($this->schema['backgrounds']['fields'] as $field) {
if (!empty($field['properties']['pattern'])) {
$var_name = $field['properties']['pattern'];
if (!empty($style_data[$var_name]) && strpos($style_data[$var_name], '//') !== false) {
$url = preg_replace('/url\\([\'"]?(.*?)[\'"]?\\)/', '$1', $style_data[$var_name]);
if (strpos($url, '//') === 0) {
$url = 'http:' . $url;
}
$url = fn_normalize_path($url);
if (strpos($url, $patterns_url) !== false) {
$url = str_replace($patterns_url, '..', $url);
if (strpos($url, '?') !== false) {
// URL is parsed by Less::parseUrls method, so remove everything after ?
list($url) = explode('?', $url);
}
} elseif ($style_id) {
// external url
$tmp_file = fn_create_temp_file();
fn_put_contents($tmp_file, fn_get_contents($url));
$_style = Patterns::instance($this->params)->save($style_id, array('data' => $style_data), array($var_name => array('name' => fn_basename($url), 'path' => $tmp_file)));
$style_data = $_style['data'];
continue;
// assignment done in save method
}
$style_data[$var_name] = 'url(' . $url . ')';
}
}
}
}
return $style_data;
}
示例3: fn_get_server_data
/**
* Create temporary file for uploaded file
*
* @param $val file path
* @return array $val
*/
function fn_get_server_data($val)
{
$tmp = fn_strip_slashes($val);
if (defined('IS_WINDOWS')) {
$tmp = str_replace('\\', '/', $tmp);
}
if (strpos($tmp, DIR_ROOT) === 0) {
$tmp = substr_replace($tmp, '', 0, strlen(DIR_ROOT));
}
$val = array();
setlocale(LC_ALL, 'en_US.UTF8');
$val['name'] = basename($tmp);
$val['path'] = fn_normalize_path(DIR_ROOT . '/' . $tmp);
$tempfile = fn_create_temp_file();
fn_copy($val['path'], $tempfile);
clearstatcache();
$val['path'] = $tempfile;
$val['size'] = filesize($val['path']);
$cache =& Registry::get('temp_fs_data');
if (!isset($cache[$val['path']])) {
// cache file to allow multiple usage
$cache[$val['path']] = $tempfile;
}
return $val;
}
示例4: fn_get_default_layouts_sources
function fn_get_default_layouts_sources($theme_name = '', $themes_path = '')
{
$layouts_sources = array();
if (empty($themes_path)) {
$themes_path = fn_get_theme_path('[themes]', 'C');
}
if (empty($theme_name)) {
$installed_themes = fn_get_dir_contents($themes_path, true);
foreach ($installed_themes as $theme_name) {
$layouts_sources = array_merge($layouts_sources, fn_get_default_layouts_sources($theme_name, $themes_path));
}
} else {
$layouts_path = $themes_path . '/' . $theme_name . '/layouts/';
$layouts = fn_get_dir_contents($layouts_path, false, true, '.xml');
foreach ($layouts as $layout_name) {
$layout_path = fn_normalize_path($layouts_path . $layout_name);
if (file_exists($layout_path)) {
$layout_data = Exim::instance(Registry::get('runtime.company_id'), 0, $theme_name)->getLayoutData($layout_path, false);
if (!empty($layout_data)) {
$layout_data['theme_name'] = $theme_name;
$layout_data['filename'] = $layout_name;
$layouts_sources[] = $layout_data;
}
}
}
}
return $layouts_sources;
}
示例5: fn_te_normalize_path
function fn_te_normalize_path($request, $base_path)
{
$file = $request['file'];
$file_path = $request['file_path'];
return fn_normalize_path($base_path . $file_path . '/' . $file);
}
示例6: fn_mkdir
function fn_mkdir($dir, $perms = DEFAULT_DIR_PERMISSIONS)
{
$result = false;
// Truncate the full path to related to avoid problems with
// some buggy hostings
if (strpos($dir, DIR_ROOT) === 0) {
$dir = './' . substr($dir, strlen(DIR_ROOT) + 1);
$old_dir = getcwd();
chdir(DIR_ROOT);
}
if (!empty($dir)) {
$result = true;
if (@(!is_dir($dir))) {
$dir = fn_normalize_path($dir, '/');
$path = '';
$dir_arr = array();
if (strstr($dir, '/')) {
$dir_arr = explode('/', $dir);
} else {
$dir_arr[] = $dir;
}
foreach ($dir_arr as $k => $v) {
$path .= (empty($k) ? '' : '/') . $v;
if (!@is_dir($path)) {
umask(0);
mkdir($path, $perms);
}
}
}
}
if (!empty($old_dir)) {
chdir($old_dir);
}
return $result;
}
示例7: fn_trusted_vars
fn_trusted_vars('content');
$ext = fn_strtolower(fn_get_file_ext($_REQUEST['file']));
if ($ext == 'tpl') {
$theme_path = fn_get_theme_path('[themes]/[theme]/templates/', 'C');
if (fn_put_contents($_REQUEST['file'], $_REQUEST['content'], $theme_path)) {
fn_set_notification('N', __('notice'), __('text_file_saved', array('[file]' => fn_basename($_REQUEST['file']))));
}
}
return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['current_url']);
}
if ($mode == 'restore_template') {
$copied = false;
$full_path = fn_get_theme_path('[themes]/[theme]', 'C') . '/templates/' . $_REQUEST['file'];
if (fn_check_path($full_path)) {
$c_name = fn_normalize_path($full_path);
$r_name = fn_normalize_path(Registry::get('config.dir.themes_repository') . Registry::get('config.base_theme') . '/templates/' . $_REQUEST['file']);
if (is_file($r_name)) {
$copied = fn_copy($r_name, $c_name);
}
if ($copied) {
fn_set_notification('N', __('notice'), __('text_file_restored', array('[file]' => fn_basename($_REQUEST['file']))));
} else {
fn_set_notification('E', __('error'), __('text_cannot_restore_file', array('[file]' => fn_basename($_REQUEST['file']))));
}
if ($copied) {
if (defined('AJAX_REQUEST')) {
Registry::get('ajax')->assign('force_redirection', fn_url($_REQUEST['current_url']));
Registry::get('ajax')->assign('non_ajax_notifications', true);
}
return array(CONTROLLER_STATUS_OK, $_REQUEST['current_url']);
}
示例8: json_encode
}
if (Registry::get('config.demo_mode')) {
// ElFinder should not work in demo mode
$message = json_encode(array('error' => __('error_demo_mode')));
exit($message);
}
if (AREA == 'C') {
if (!Registry::get('runtime.customization_mode.live_editor')) {
die('Access denied');
}
}
$private_files_path = fn_get_files_dir_path();
$public_files_path = fn_get_public_files_path();
fn_mkdir($private_files_path);
fn_mkdir($public_files_path);
$start_path = '';
if (!empty($_REQUEST['init']) && !empty($_REQUEST['start_path'])) {
unset($_GET['target']);
$start_path = fn_normalize_path($private_files_path . $_REQUEST['start_path']);
if (strpos($start_path, $private_files_path) !== 0) {
$start_path = '';
}
}
$extra_path = str_replace(Storage::instance('images')->getAbsolutePath(''), '', $public_files_path);
$opts = array('roots' => array(array('driver' => 'Tygh\\ElFinder\\Volume', 'uploadDeny' => Registry::get('config.forbidden_mime_types'), 'fileMode' => DEFAULT_FILE_PERMISSIONS, 'dirMode' => DEFAULT_DIR_PERMISSIONS, 'uploadMaxSize' => Bootstrap::getIniParam('upload_max_filesize', true), 'alias' => __('private_files'), 'tmbPath' => '', 'path' => $private_files_path, 'startPath' => $start_path, 'mimeDetect' => 'internal', 'archiveMimes' => array('application/zip'), 'icon' => Registry::get('config.current_location') . '/js/lib/elfinder/img/volume_icon_local.png'), array('driver' => 'Tygh\\ElFinder\\Volume', 'uploadDeny' => Registry::get('config.forbidden_mime_types'), 'fileMode' => DEFAULT_FILE_PERMISSIONS, 'dirMode' => DEFAULT_DIR_PERMISSIONS, 'uploadMaxSize' => Bootstrap::getIniParam('upload_max_filesize', true), 'alias' => __('public_files'), 'tmbPath' => '', 'path' => $public_files_path, 'URL' => Storage::instance('images')->getUrl($extra_path), 'mimeDetect' => 'internal', 'archiveMimes' => array('application/zip'), 'icon' => Registry::get('config.current_location') . '/js/lib/elfinder/img/volume_icon_local.png')));
if ($mode == 'images') {
unset($opts['roots'][0]);
}
$connector = new \elFinderConnector(new Core($opts));
$connector->run();
exit;
示例9: fn_install_theme
/**
* Installs theme
*
* @param int $layout_id layout ID to create logo for
* @param string $theme_name theme name
* @param int $company_id company ID
* @return boolean always true
*/
function fn_install_theme($theme_name, $company_id = null, $install_layouts = true)
{
// Copy files
fn_install_theme_files($theme_name, $theme_name, true);
Settings::instance()->updateValue('theme_name', $theme_name, '', true, $company_id);
$repo_dest = fn_get_theme_path('[themes]/' . $theme_name, 'C', $company_id, false);
$logo_ids = array();
// Import theme layout
$layouts = fn_get_dir_contents($repo_dest . '/layouts/', false, true, '.xml');
// FIXME: Backward compability for layouts
if (empty($layouts) && file_exists($repo_dest . '/layouts.xml')) {
$layouts = array('../layouts.xml');
}
if (!empty($layouts) && $install_layouts) {
foreach ($layouts as $layout_name) {
$layout_path = fn_normalize_path($repo_dest . '/layouts/' . $layout_name);
if (file_exists($layout_path)) {
$layout_id = Exim::instance($company_id, 0, $theme_name)->importFromFile($layout_path, array('override_by_dispatch' => true, 'clean_up' => true, 'import_style' => 'create'));
if (empty($layout_id)) {
continue;
}
$layout_data = Layout::instance()->get($layout_id);
$_o_ids = fn_create_theme_logos_by_layout_id($theme_name, $layout_id, $company_id, false, $layout_data['style_id']);
$logo_ids = array_merge($logo_ids, $_o_ids);
}
}
} else {
$params = array('theme_name' => $theme_name);
$exists = Layout::instance($company_id)->getList($params);
if (empty($exists)) {
$layout_id = Layout::instance($company_id)->update(array('name' => __('main'), 'theme_name' => $theme_name, 'is_default' => 1));
$layout_data = Layout::instance()->get($layout_id);
$logo_ids = fn_create_theme_logos_by_layout_id($theme_name, $layout_id, $company_id, false, $layout_data['style_id']);
}
}
return $logo_ids;
}
示例10: fn_find_file
/**
* Finds file and return real path to it
*
* @param string $prefix path to search in
* @param string $file Filename, can be URL, absolute or relative path
* @return mixed String path to the file or false if file is not found.
*/
function fn_find_file($prefix, $file)
{
$file = Bootstrap::stripSlashes($file);
// Url
if (strpos($file, '://') !== false) {
return $file;
}
$prefix = fn_normalize_path(rtrim($prefix, '/'));
$file = fn_normalize_path($file);
$files_path = fn_get_files_dir_path();
// Absolute path
if (is_file($file) && strpos($file, $files_path) === 0) {
return $file;
}
// Path is relative to files directory
if (is_file($files_path . $file)) {
return $files_path . $file;
}
// Path is relative to prefix inside files directory
if (is_file($files_path . $prefix . '/' . $file)) {
return $files_path . $prefix . '/' . $file;
}
// Prefix is absolute path
if (strpos($prefix, $files_path) === 0 && is_file($prefix . '/' . $file)) {
return $prefix . '/' . $file;
}
return false;
}
示例11: fn_update_image
function fn_update_image($image_data, $image_id = '0', $image_type = 'product', $rev_data = array(), $lang_code = CART_LANGUAGE)
{
$table = 'images_links';
$itable = 'images';
$images_path = $image_type . '/';
$cond = '';
$_data = array();
if (!empty($rev_data)) {
$table = 'rev_images_links';
$itable = 'rev_images';
$images_path = $image_type . '_rev/';
$cond = db_quote(" AND revision = ?s AND revision_id = ?i", $rev_data['revision'], $rev_data['revision_id']);
$_data['revision'] = $rev_data['revision'];
$_data['revision_id'] = $rev_data['revision_id'];
}
if (empty($image_id)) {
$max_id = db_get_field("SELECT MAX(image_id) FROM ?:{$itable}");
$images_path .= floor($max_id / MAX_FILES_IN_DIR) . "/";
} else {
$images_path .= floor($image_id / MAX_FILES_IN_DIR) . "/";
}
if (!fn_mkdir(DIR_IMAGES . $images_path)) {
return false;
}
list($_data['image_x'], $_data['image_y'], $mime_type) = fn_get_image_size($image_data['path']);
// Get the real image type
$ext = fn_get_image_extension($mime_type);
if (strpos($image_data['name'], '.') !== false) {
$image_data['name'] = substr_replace($image_data['name'], $ext, strrpos($image_data['name'], '.') + 1);
} else {
$image_data['name'] .= '.' . $ext;
}
$fd = fopen($image_data['path'], "rb", true);
if (!empty($fd)) {
// Check if image path already set
$image_path = db_get_field("SELECT image_path FROM ?:{$itable} WHERE image_id = ?i ?p", $image_id, $cond);
// Delete image file if already exists
if ($image_path != $image_data['name'] && empty($rev_data)) {
fn_delete_file(DIR_IMAGES . $images_path . $image_path);
}
// Generate new filename if file with the same name is already exists
if (file_exists(DIR_IMAGES . $images_path . $image_data['name']) && $image_path != $image_data['name']) {
$image_data['name'] = substr_replace($image_data['name'], uniqid(time()) . '.', strrpos($image_data['name'], '.'), 1);
}
$_data['image_path'] = $image_data['name'];
if (@fn_rename($image_data['path'], DIR_IMAGES . $images_path . $image_data['name']) == false) {
fn_copy($image_data['path'], DIR_IMAGES . $images_path . $image_data['name']);
@unlink($image_data['path']);
}
fclose($fd);
}
$_data['image_size'] = $image_data['size'];
$_data['image_path'] = empty($_data['image_path']) ? '' : fn_normalize_path($_data['image_path']);
if (!empty($image_id)) {
db_query("UPDATE ?:{$itable} SET ?u WHERE image_id = ?i ?p", $_data, $image_id, $cond);
} else {
$image_id = db_query("INSERT INTO ?:{$itable} ?e", $_data);
}
return $image_id;
}
示例12: str_replace
$ajax->assign('img', Registry::get('config.http_location') . str_replace(DIR_ROOT, '', $fname));
} else {
$ajax->assign('content', fn_get_contents($fname));
}
}
exit;
} elseif ($mode == 'restore') {
$copied = false;
$file = basename($_REQUEST['file']);
$c_name = fn_normalize_path(DIR_SKINS . $current_path . $file);
$b_path = fn_normalize_path($current_path);
// First, try to restore object from the base repository
$arr = explode('/', $b_path);
$arr[0] = 'base';
$b_path = implode('/', $arr);
$b_name = fn_normalize_path(DIR_SKINS . $b_path . $file);
$o_name = str_replace('/skins/', '/var/skins_repository/', $b_name);
$object_base = is_file($o_name) ? 'file' : (is_dir($o_name) ? 'directory' : '');
if (!empty($object_base)) {
$copied = fn_copy($o_name, $c_name);
}
$o_name = str_replace('/skins/', '/var/skins_repository/', $c_name);
$object_scheme = is_file($o_name) ? 'file' : (is_dir($o_name) ? 'directory' : '');
if (!empty($object_scheme)) {
$copied = fn_copy($o_name, $c_name);
}
$object = is_file($c_name) ? 'file' : (is_dir($c_name) ? 'directory' : '');
if ($copied == true) {
$msg = fn_get_lang_var("text_{$object}_restored");
$action_type = '';
} else {
示例13: fn_exim_import_file
function fn_exim_import_file($product_id, $filename, $path, $delete_files = 'N')
{
$path = fn_get_files_dir_path() . fn_normalize_path($path);
// Clean up the directory above if flag is set
if ($delete_files == 'Y') {
fn_delete_product_file_folders(0, $product_id);
fn_delete_product_files(0, $product_id);
}
// Check if we have several files
$files = fn_explode(',', $filename);
$folders = array();
// Create folders
foreach ($files as $file) {
if (strpos($file, '/') !== false) {
list($folder) = fn_explode('/', $file);
if (!isset($folders[$folder])) {
$folder_data = array('product_id' => $product_id, 'folder_name' => $folder);
$folders[$folder] = fn_update_product_file_folder($folder_data, 0);
}
}
}
// Copy files
foreach ($files as $file) {
if (strpos($file, '/') !== false) {
list($folder_name, $file) = fn_explode('/', $file);
} else {
$folder_name = '';
}
if (strpos($file, '#') !== false) {
list($f, $pr) = fn_explode('#', $file);
} else {
$f = $file;
$pr = '';
}
$file = fn_find_file($path, $f);
if (!empty($file)) {
$uploads = array('file_base_file' => array($file), 'type_base_file' => array('server'));
if (!empty($pr)) {
$preview = fn_find_file($path, $pr);
if (!empty($preview)) {
$uploads['file_file_preview'] = array($preview);
$uploads['type_file_preview'] = array('server');
}
} else {
$uploads['file_file_preview'] = "";
$uploads['type_file_preview'] = "";
}
$_REQUEST = fn_array_merge($_REQUEST, $uploads);
// not good to add data to $_REQUEST
$file_data = array('product_id' => $product_id);
if (!empty($folder_name)) {
$file_data['folder_id'] = $folders[$folder_name];
}
if (fn_update_product_file($file_data, 0) == false) {
return false;
}
}
}
return true;
}
示例14: fn_is_valid_path
/**
* Checks if path to directory/file is under base directory
* @param string $base_dir base directory
* @param string $path path to be checked
* @return boolean true if path is valid, false - otherwise
*/
function fn_is_valid_path($base_dir, $path)
{
$base_dir = rtrim($base_dir, '/') . '/';
if (strpos($path, $base_dir) !== 0) {
// relative path
$path = fn_normalize_path($base_dir . $path);
}
if (strpos($path, $base_dir) !== 0) {
return false;
}
return true;
}
示例15: fn_get_contents
if ($ext == 'tpl') {
$ajax->assign('content', fn_get_contents($_REQUEST['file'], DIR_SKINS . Registry::get('config.skin_name') . '/' . AREA_NAME . '/'));
}
exit;
} elseif ($mode == 'save_template') {
fn_trusted_vars('content');
if (defined('DEVELOPMENT')) {
exit;
}
$ext = strtolower(fn_get_file_ext($_REQUEST['file']));
if ($ext == 'tpl') {
fn_put_contents($_REQUEST['file'], $_REQUEST['content'], DIR_SKINS . Registry::get('config.skin_name') . '/' . AREA_NAME . '/');
}
return array(CONTROLLER_STATUS_OK, $_REQUEST['current_url']);
} elseif ($mode == 'restore_template') {
$copied = false;
$full_path = DIR_SKINS . Registry::get('config.skin_name') . '/' . AREA_NAME . '/' . $_REQUEST['file'];
if (fn_check_path($full_path)) {
$c_name = fn_normalize_path($full_path);
$r_name = str_replace('/skins/', '/var/skins_repository/', $c_name);
if (is_file($r_name)) {
$copied = fn_copy($r_name, $c_name);
}
$msg = $copied ? fn_get_lang_var("text_file_restored") : fn_get_lang_var("text_cannot_restore_file");
fn_set_notification('N', fn_get_lang_var('notice'), str_replace("[file]", basename($_REQUEST['file']), $msg));
if ($copied) {
return array(CONTROLLER_STATUS_OK, $_REQUEST['current_url']);
}
}
exit;
}