本文整理汇总了PHP中fn_copy函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_copy函数的具体用法?PHP fn_copy怎么用?PHP fn_copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_copy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_settings_actions_addons_webmail
function fn_settings_actions_addons_webmail(&$new_value, $old_value)
{
if ($new_value == 'A') {
// Copy data directory to "var"
$dir_data = DIR_ROOT . '/var/webmail';
if (fn_copy(DIR_ADDONS . 'webmail/lib/webmail/data', $dir_data) == false) {
$msg = fn_get_lang_var('text_cannot_write_directory');
fn_set_notification('E', fn_get_lang_var('error'), str_replace('[directory]', $dir_data, $msg));
$new_value = 'D';
return false;
}
$config = Registry::get('config');
$_settings = $dir_data . '/settings/settings.xml';
// 1 step, generate config file
$xml = simplexml_load_file($_settings);
$xml->Common->DBLogin = $config['db_user'];
$xml->Common->DBPassword = $config['db_password'];
$xml->Common->DBName = $config['db_name'];
$xml->Common->DBHost = $config['db_host'];
if (fn_put_contents($_settings, $xml->asXML()) == false) {
$msg = fn_get_lang_var('cannot_write_file');
fn_set_notification('E', fn_get_lang_var('error'), str_replace('[file]', $_settings, $msg));
$new_value = 'D';
return false;
}
include DIR_ADDONS . 'webmail/lib/webmail/web/class_settings.php';
include DIR_ADDONS . 'webmail/lib/webmail/web/class_dbstorage.php';
// Init mailbee core
$null = null;
$settings =& Settings::CreateInstance();
$dbStorage =& DbStorageCreator::CreateDatabaseStorage($null);
$dbStorage->Connect();
$dbStorage->CreateTables($settings->DbPrefix);
}
}
示例2: process
function process($tmp_filename, $content_type)
{
$dest_filename = OUTPUT_FILE_DIRECTORY . $this->filename_escape($this->get_filename()) . "." . $content_type->default_extension;
fn_copy($tmp_filename, $dest_filename);
$text = $this->_link_text;
$text = preg_replace('/%link%/', 'file://' . $dest_filename, $text);
$text = preg_replace('/%name%/', $this->get_filename(), $text);
print $text;
}
示例3: save
/**
* Saves uploaded pattern to theme
* @param string $style_id style ID
* @param array $style style
* @param array $uploaded_data uploaded data
* @return array modified style
*/
public static function save($style_id, $style, $uploaded_data)
{
$style_id = fn_basename($style_id);
$patterns = self::getPath($style_id);
if (!is_dir($patterns)) {
fn_mkdir($patterns);
}
foreach ($uploaded_data as $var => $file) {
$fname = $var . '.' . fn_get_file_ext($file['name']);
if (fn_copy($file['path'], $patterns . '/' . $fname)) {
$style['data'][$var] = "url('" . self::getRelPath($style_id) . '/' . $fname . '?' . TIME . "')";
}
}
return $style;
}
示例4: downloadPackage
public function downloadPackage($schema, $package_path)
{
if (!empty($schema['download_key'])) {
$upgrade_path = $this->settings['packages_server'] . $this->settings['addon'] . '/' . $schema['file'];
$addon_upgrades_dir = Registry::get('config.dir.addons') . $this->settings['addon'] . '/upgrades/';
$addon_upgrades_path = $addon_upgrades_dir . $schema['file'];
if (!file_exists($addon_upgrades_path)) {
fn_mkdir($addon_upgrades_dir);
$addon_upgrade_data = fn_get_contents($upgrade_path);
fn_put_contents($addon_upgrades_path, $addon_upgrade_data);
}
$result = fn_copy($addon_upgrades_path, $package_path);
if ($result) {
fn_rm($addon_upgrades_path);
}
//cleanup
$message = $result ? '' : __('failed') . '-' . $addon_upgrades_path;
return array($result, $message);
} else {
return array(false, __($schema['error_message']));
}
}
示例5: foreach
if ($mode == 'm_delete') {
if (!empty($_REQUEST['backup_files'])) {
foreach ($_REQUEST['backup_files'] as $file) {
@unlink(Registry::get('config.dir.backups') . fn_basename($file));
}
}
}
if ($mode == 'upload') {
$dump = fn_filter_uploaded_data('dump', array('sql', 'tgz', 'zip'));
if (!empty($dump)) {
$dump = array_shift($dump);
// Check if backups folder exists. If not - create it
if (!is_dir(Registry::get('config.dir.backups'))) {
fn_mkdir(Registry::get('config.dir.backups'));
}
if (fn_copy($dump['path'], Registry::get('config.dir.backups') . $dump['name'])) {
fn_set_notification('N', __('notice'), __('done'));
} else {
fn_set_notification('E', __('error'), __('cant_create_backup_file'));
}
} else {
fn_set_notification('E', __('error'), __('cant_upload_file'));
}
}
if ($mode == 'optimize') {
// Log database optimization
fn_log_event('database', 'optimize');
$all_tables = db_get_fields("SHOW TABLES");
fn_set_progress('parts', sizeof($all_tables));
foreach ($all_tables as $table) {
fn_set_progress('echo', __('optimizing_table') . " <b>{$table}</b>...<br />");
示例6: _getUploadedLogos
private static function _getUploadedLogos()
{
$logos = fn_filter_uploaded_data('tw_settings');
$logo_names = array('logo', 'favicon');
$options = array();
foreach ($logo_names as $logo_name) {
if ($logos and !empty($logos[$logo_name])) {
$logo = $logos[$logo_name];
$filename = fn_twg_get_images_path() . $logo['name'];
// On some hosts files copy buggy
touch($filename);
if (!fn_copy($logo['path'], $filename)) {
$_text = __('text_cannot_create_file');
$text = str_replace('[file]', $filename, $_text);
fn_set_notification('E', __('error'), $text);
} else {
$options[$logo_name . '_url'] = $filename;
}
@unlink($logo['path']);
}
}
return $options;
}
示例7: fn_get_contents
if (fn_te_check_path($fname) && !in_array(fn_strtolower(fn_get_file_ext($fname)), Registry::get('config.forbidden_file_extensions'))) {
Tygh::$app['ajax']->assign('content', fn_get_contents($fname));
} else {
fn_set_notification('E', __('error'), __('you_have_no_permissions'));
}
exit;
} elseif ($mode == 'restore') {
$copied = false;
$file_path = fn_te_normalize_path($_REQUEST, $root_dir);
if (fn_te_check_path($file_path)) {
$repo_path = str_replace($root_dir, fn_te_get_root('repo'), $file_path);
if (!file_exists($repo_path) && fn_get_theme_path('[theme]') != Registry::get('config.base_theme') && is_dir(fn_get_theme_path('[repo]/[theme]'))) {
$repo_path = preg_replace("/\\/themes_repository\\/(\\w+)\\//", "/themes_repository/" . Registry::get('config.base_theme') . "/", $repo_path);
}
$object_base = is_file($repo_path) ? 'file' : (is_dir($repo_path) ? 'directory' : '');
if (!empty($object_base) && fn_copy($repo_path, $file_path)) {
fn_set_notification('N', __('notice'), __("text_{$object_base}_restored", array("[{$object_base}]" => fn_basename($file_path))));
Tygh::$app['ajax']->assign('content', fn_get_contents($file_path));
$copied = true;
}
}
if (!$copied) {
$object_base = empty($object_base) ? 'file' : $object_base;
fn_set_notification('E', __('error'), __("text_cannot_restore_{$object_base}", array("[{$object_base}]" => fn_basename($file_path))));
}
return array(CONTROLLER_STATUS_REDIRECT, 'templates.init_view?dir=' . $_REQUEST['file_path'] . '/' . $_REQUEST['file']);
}
/**
* Checks if working path is inside root directory
* @param string $path working path
* @return boolean true of success, false - otherwise
示例8: fn_addons_move_and_install
/**
* Move addon pack from temporarily folder to specified place and install it if possible
*
* @param string $from Source path
* @param string $to Destination path
* @return bool true if installed, false otherwise
*/
function fn_addons_move_and_install($from, $to)
{
if (defined('AJAX_REQUEST')) {
Registry::get('ajax')->assign('non_ajax_notifications', true);
}
$struct = fn_get_dir_contents($from, false, true, '', '', true);
$addon_name = '';
foreach ($struct as $file) {
if (preg_match('/app.+?addons[^a-zA-Z0-9_]+([a-zA-Z0-9_-]+).+?addon.xml$/i', $file, $matches)) {
if (!empty($matches[1])) {
$addon_name = $matches[1];
break;
}
}
}
$relative_addon_path = str_replace(Registry::get('config.dir.root') . '/', '', Registry::get('config.dir.addons'));
if (!file_exists($from . $relative_addon_path . $addon_name . '/addon.xml')) {
fn_set_notification('E', __('error'), __('broken_addon_pack'));
return false;
}
fn_copy($from, $to);
fn_install_addon($addon_name);
fn_rm($from);
return true;
}
示例9: fn_get_theme_path
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']);
}
}
exit;
示例10: fn_update_payment
/**
* Create/Update payments data
*
* @param array $payment_data
* @param int $payment_id
* @param string $lang_code 2-letter language code
* @return int Payment id
*/
function fn_update_payment($payment_data, $payment_id, $lang_code = DESCR_SL)
{
$certificate_file = fn_filter_uploaded_data('payment_certificate');
$certificates_dir = Registry::get('config.dir.certificates');
fn_set_hook('update_payment_pre', $payment_data, $payment_id, $lang_code, $certificate_file, $certificates_dir);
/**
* Create/update the certificate file
* only for an existing payment method.
*
* Non-existing payment method will be created first,
* then will be updated. (fn_update_payment calling at line 450).
*/
if ($payment_id) {
if ($certificate_file) {
$file = reset($certificate_file);
$filename = $payment_id . '/' . $file['name'];
fn_mkdir($certificates_dir . $payment_id);
fn_copy($file['path'], $certificates_dir . $filename);
$payment_data['processor_params']['certificate_filename'] = $filename;
}
$old_params = fn_get_processor_data($payment_id);
if (empty($payment_data['processor_params']['certificate_filename']) && isset($old_params['processor_params']['certificate_filename'])) {
$payment_data['processor_params']['certificate_filename'] = $old_params['processor_params']['certificate_filename'];
}
if (!empty($payment_data['processor_params']['certificate_filename'])) {
if (!empty($old_params['processor_params']['certificate_filename']) && $payment_data['processor_params']['certificate_filename'] != $old_params['processor_params']['certificate_filename']) {
fn_rm($certificates_dir . $old_params['processor_params']['certificate_filename']);
}
if (!file_exists($certificates_dir . $payment_data['processor_params']['certificate_filename'])) {
$payment_data['processor_params']['certificate_filename'] = '';
}
}
}
if (!empty($payment_data['processor_id'])) {
$payment_data['template'] = db_get_field("SELECT processor_template FROM ?:payment_processors WHERE processor_id = ?i", $payment_data['processor_id']);
}
$payment_data['localization'] = !empty($payment_data['localization']) ? fn_implode_localizations($payment_data['localization']) : '';
$payment_data['usergroup_ids'] = empty($payment_data['usergroup_ids']) ? USERGROUP_ALL : (is_array($payment_data['usergroup_ids']) ? implode(',', $payment_data['usergroup_ids']) : $payment_data['usergroup_ids']);
$payment_data['tax_ids'] = !empty($payment_data['tax_ids']) ? fn_create_set($payment_data['tax_ids']) : '';
// Update payment processor settings
$processor_params = array();
if (!empty($payment_data['processor_params'])) {
$processor_params = $payment_data['processor_params'];
$payment_data['processor_params'] = serialize($payment_data['processor_params']);
}
if (!empty($payment_id)) {
$arow = db_query("UPDATE ?:payments SET ?u WHERE payment_id = ?i", $payment_data, $payment_id);
db_query("UPDATE ?:payment_descriptions SET ?u WHERE payment_id = ?i AND lang_code = ?s", $payment_data, $payment_id, $lang_code);
if ($arow === false) {
fn_set_notification('E', __('error'), __('object_not_found', array('[object]' => __('payment'))), '', '404');
$payment_id = false;
}
} else {
$payment_data['payment_id'] = $payment_id = db_query("INSERT INTO ?:payments ?e", $payment_data);
foreach (fn_get_translation_languages() as $payment_data['lang_code'] => $_v) {
db_query("INSERT INTO ?:payment_descriptions ?e", $payment_data);
}
/**
* Update the certificate
*/
if ($certificate_file && $payment_id) {
unset($payment_data['lang_code']);
$payment_data['processor_params'] = $processor_params;
fn_update_payment($payment_data, $payment_id, $lang_code);
}
}
fn_attach_image_pairs('payment_image', 'payment', $payment_id, $lang_code);
fn_set_hook('update_payment_post', $payment_data, $payment_id, $lang_code, $certificate_file, $certificates_dir, $processor_params);
return $payment_id;
}
示例11: fn_update_attachments
function fn_update_attachments($attachment_data, $attachment_id, $object_type, $object_id, $type = 'M', $lang_code = CART_LANGUAGE)
{
$object_id = intval($object_id);
if (!fn_mkdir(DIR_ATTACHMENTS)) {
return false;
}
$revision_id = 0;
if (AREA == 'A' && Registry::is_exist('revisions') && !Registry::get('revisions.working')) {
$revisions = Registry::get('revisions');
if (!empty($revisions['objects'][$object_type]) && !empty($revisions['objects'][$object_type]['tables'])) {
$object_data = $revisions['objects'][$object_type];
if ($object_data['attachments']) {
$entry = array($object_data['key'] => $object_id);
list($revision, $revision_id) = fn_revisions_get_last($object_type, $entry, 0, 'attachments');
}
}
}
if ($revision_id) {
$_ = 'rev_';
$revision_condition = db_quote(" AND revision = ?s AND revision_id = ?i", $revision, $revision_id);
} else {
$_ = '';
$revision_condition = '';
}
$directory = DIR_ATTACHMENTS . '/' . $object_type . ($revision_condition ? '_rev' : '') . '/' . $object_id;
if (!fn_mkdir($directory)) {
return false;
}
$uploaded_data = fn_filter_uploaded_data('attachment_files');
$rec = array('usergroup_ids' => empty($attachment_data['usergroup_ids']) ? '' : implode(',', $attachment_data['usergroup_ids']), 'position' => $attachment_data['position']);
db_query("UPDATE ?:{$_}attachment_descriptions SET description = ?s WHERE attachment_id = ?i AND lang_code = ?s ?p", $attachment_data['description'], $attachment_id, $lang_code, $revision_condition);
db_query("UPDATE ?:{$_}attachments SET ?u WHERE attachment_id = ?i AND object_type = ?s AND object_id = ?i AND type = ?s ?p", $rec, $attachment_id, $object_type, $object_id, $type, $revision_condition);
if ($attachment_id && !empty($uploaded_data[$attachment_id]) && $uploaded_data[$attachment_id]['size']) {
$filename = $uploaded_data[$attachment_id]['name'];
$old_filename = db_get_field("SELECT filename FROM ?:{$_}attachments WHERE attachment_id = ?i ?p", $attachment_id, $revision_condition);
if (!$revision_id && $old_filename && is_file($directory . '/' . $old_filename)) {
unlink($directory . '/' . $old_filename);
}
$i = 1;
while (is_file($directory . '/' . $filename)) {
$filename = substr_replace($uploaded_data[$attachment_id]['name'], sprintf('%03d', $i) . '.', strrpos($uploaded_data[$attachment_id]['name'], '.'), 1);
$i++;
}
fn_copy($uploaded_data[$attachment_id]['path'], $directory . '/' . $filename);
if (is_file($directory . '/' . $filename)) {
$filesize = filesize($directory . '/' . $filename);
db_query("UPDATE ?:{$_}attachments SET filename = ?s, filesize = ?i WHERE attachment_id = ?i ?p", $filename, $filesize, $attachment_id, $revision_condition);
}
}
return true;
}
示例12: processThemesFiles
/**
* Copies theme files from the theme_repository to design folder
*
* @param array $schema UC package schema
* @return array List of processed files
*/
protected function processThemesFiles($schema)
{
if (empty($schema['files'])) {
return array();
}
$repo_files = array();
$repo_path = str_replace($this->config['dir']['root'] . '/', '', $this->config['dir']['themes_repository']);
// Process themes_repository
foreach ($schema['files'] as $file_path => $file_data) {
if (strpos($file_path, $repo_path) !== false) {
$path = str_replace($repo_path, '', $file_path);
$path = explode('/', $path);
$theme_name = array_shift($path);
$repo_files[$theme_name][] = implode('/', $path);
}
}
$themes = fn_get_dir_contents($this->config['dir']['root'] . '/design/themes/');
foreach ($themes as $theme_name) {
$manifest = Themes::factory($theme_name)->getManifest();
$parent_theme = empty($manifest['parent_theme']) ? 'basic' : $manifest['parent_theme'];
if (!empty($repo_files[$parent_theme])) {
foreach ($repo_files[$parent_theme] as $file_path) {
// Check if we need to create folders path before copying
$dir_path = dirname($this->config['dir']['root'] . '/design/themes/' . $theme_name . '/' . $file_path);
fn_mkdir($dir_path);
fn_copy($this->config['dir']['themes_repository'] . $parent_theme . '/' . $file_path, $this->config['dir']['root'] . '/design/themes/' . $theme_name . '/' . $file_path);
}
}
}
return $repo_files;
}
示例13: removeLessFiles
/**
* Remove LESS files
*
* @param string $from The directory the LESS files are removed from
* @param string $backup_dir Backup directory
* @param array $exclude The list of directories to skip while removing
*
* @return boolean Result
*/
protected function removeLessFiles($from, $backup_dir, $exclude = array())
{
$less_files = fn_get_dir_contents($from, false, true, '.less', '', true, $exclude);
foreach ($less_files as $less_file) {
if (!empty($backup_dir)) {
if (!(fn_mkdir(dirname($backup_dir . '/' . $less_file)) && fn_copy($from . '/' . $less_file, $backup_dir . '/' . $less_file))) {
return false;
}
}
fn_rm($from . '/' . $less_file);
}
return true;
}
示例14: elseif
} elseif ($mode == 'upload') {
if (defined('RESTRICTED_ADMIN') || Registry::get('runtime.company_id')) {
fn_set_notification('E', __('error'), __('access_denied'));
return array(CONTROLLER_STATUS_REDIRECT, 'addons.manage');
}
$addon_pack = fn_filter_uploaded_data('addon_pack', Registry::get('config.allowed_pack_exts'));
if (empty($addon_pack[0])) {
fn_set_notification('E', __('error'), __('text_allowed_to_upload_file_extension', array('[ext]' => implode(',', Registry::get('config.allowed_pack_exts')))));
} else {
// Extract the add-on pack and check the permissions
$extract_path = fn_get_cache_path(false) . 'tmp/addon_pack/';
$addon_pack = $addon_pack[0];
// Re-create source folder
fn_rm($extract_path);
fn_mkdir($extract_path);
fn_copy($addon_pack['path'], $extract_path . $addon_pack['name']);
if (fn_decompress_files($extract_path . $addon_pack['name'], $extract_path)) {
fn_rm($extract_path . $addon_pack['name']);
$struct = fn_get_dir_contents($extract_path, false, true, '', '', true);
$addon_name = '';
$relative_addon_path = str_replace(Registry::get('config.dir.root') . '/', '', Registry::get('config.dir.addons'));
foreach ($struct as $file) {
if (preg_match('#' . $relative_addon_path . '[^a-zA-Z0-9_]*([a-zA-Z0-9_-]+).+?addon.xml$#i', $file, $matches)) {
if (!empty($matches[1])) {
$addon_name = $matches[1];
}
}
}
if (empty($addon_name)) {
fn_set_notification('E', __('error'), __('broken_addon_pack'));
if (defined('AJAX_REQUEST')) {
示例15: foreach
// cleanup cache
}
$suffix = '?selected_section=restore';
}
if ($mode == 'delete') {
if (!empty($_REQUEST['backup_files'])) {
foreach ($_REQUEST['backup_files'] as $file) {
@unlink(DIR_DATABASE . 'backup/' . $file);
}
}
}
if ($mode == 'upload') {
$sql_dump = fn_filter_uploaded_data('sql_dump');
if (!empty($sql_dump)) {
$sql_dump = array_shift($sql_dump);
fn_copy($sql_dump['path'], DIR_DATABASE . 'backup/' . $sql_dump['name']);
}
}
if ($mode == 'optimize') {
// Log database optimization
fn_log_event('database', 'optimize');
$all_tables = db_get_fields("SHOW TABLES");
fn_start_scroller();
foreach ($all_tables as $table) {
fn_echo(fn_get_lang_var('optimizing_table') . " <b>{$table}</b>...<br />");
db_query("OPTIMIZE TABLE {$table}");
db_query("ANALYZE TABLE {$table}");
$fields = db_get_hash_array("SHOW COLUMNS FROM {$table}", 'Field');
if (!empty($fields['is_global'])) {
// Sort table by is_global field
fn_echo(fn_get_lang_var('sorting_data') . " <b>{$table}</b>...<br />");