当前位置: 首页>>代码示例>>PHP>>正文


PHP fn_put_contents函数代码示例

本文整理汇总了PHP中fn_put_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_put_contents函数的具体用法?PHP fn_put_contents怎么用?PHP fn_put_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fn_put_contents函数的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);
    }
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:35,代码来源:actions.post.php

示例2: put

 /**
  * Put file to storage
  *
  * @param  string $file   file path in storage
  * @param  array  $params uploaded data and options
  * @return array  file size and file name
  */
 public function put($file, $params)
 {
     if (empty($params['overwrite'])) {
         $file = $this->generateName($file);
         // check if name is unique and generate new if not
     }
     $file = $this->prefix($file);
     if (!empty($params['compress'])) {
         if (!empty($params['contents'])) {
             $params['contents'] = gzencode($params['contents']);
         }
     }
     if (!fn_mkdir(dirname($file))) {
         return false;
     }
     if (!empty($params['file'])) {
         fn_copy($params['file'], $file);
     } else {
         fn_put_contents($file, $params['contents']);
     }
     if (!file_exists($file)) {
         return false;
     }
     $filesize = filesize($file);
     if (!empty($params['file']) && empty($params['keep_origins'])) {
         fn_rm($params['file']);
     }
     return array($filesize, str_replace($this->prefix(), '', $file));
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:36,代码来源:File.php

示例3: smarty_function_script

/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_script($params, &$smarty)
{
    static $scripts = array();
    static $packer_loaded = false;
    /*if (!empty($params['include'])) {
    		return implode("\n", $scripts);
    	}*/
    if (!isset($scripts[$params['src']])) {
        $path = Registry::get('config.current_path');
        if (Registry::get('config.tweaks.js_compression') == true && strpos($params['src'], 'lib/') === false) {
            if (!file_exists(DIR_CACHE . $params['src'])) {
                if ($packer_loaded == false) {
                    include_once DIR_LIB . 'packer/class.JavaScriptPacker.php';
                    $packer_loaded = true;
                }
                fn_mkdir(dirname(DIR_CACHE . $params['src']));
                $packer = new JavaScriptPacker(fn_get_contents(DIR_ROOT . '/' . $params['src']));
                fn_put_contents(DIR_CACHE . $params['src'], $packer->pack());
            }
            $path = Registry::get('config.cache_path');
        }
        $scripts[$params['src']] = '<script type="text/javascript" src="' . $path . '/' . $params['src'] . '"></script>';
        // If output is captured, don't print script tag in the buffer, it will be printed directly to the screen
        if (!empty($smarty->_in_capture)) {
            $buff = array_pop($smarty->_in_capture);
            $smarty->_in_capture[] = $buff;
            $smarty->_scripts[$buff][] = $scripts[$params['src']];
            return '';
        }
        return $scripts[$params['src']];
    }
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:37,代码来源:function.script.php

示例4: fn_replace_rewrite_condition

function fn_replace_rewrite_condition($file_name, $condition, $comment)
{
    if (!empty($condition)) {
        $condition = "\n" . "# {$comment}\n" . "<IfModule mod_rewrite.c>\n" . "RewriteEngine on\n" . $condition . "</IfModule>\n" . "# /{$comment}";
    }
    $content = fn_get_contents($file_name);
    if ($content === false) {
        $content = '';
    } elseif (!empty($content)) {
        // remove old instructions
        $data = explode("\n", $content);
        $remove_start = false;
        foreach ($data as $k => $line) {
            if (preg_match("/# {$comment}/", $line)) {
                $remove_start = true;
            }
            if ($remove_start) {
                unset($data[$k]);
            }
            if (preg_match("/# \\/{$comment}/", $line)) {
                $remove_start = false;
            }
        }
        $content = implode("\n", $data);
    }
    $content .= $condition;
    return fn_put_contents($file_name, $content);
}
开发者ID:askzap,项目名称:ultimate,代码行数:28,代码来源:func.php

示例5: fn_hidpi_update_image

/**
 * Hook: generates low-resolution image from HiDPI one
 * @param array &$image_data
 * @param int &$image_id
 * @param string &$image_type
 * @param string &$images_path
 * @param array &$_data
 */
function fn_hidpi_update_image(&$image_data, &$image_id, &$image_type, &$images_path, &$_data)
{
    // Save original image
    $filename = fn_hdpi_form_name($image_data['name']);
    Storage::instance('images')->put($images_path . $filename, array('file' => $image_data['path'], 'keep_origins' => true));
    // Resize original image to non-hidpi resolution
    $_data['image_x'] = intval($_data['image_x'] / 2);
    $_data['image_y'] = intval($_data['image_y'] / 2);
    fn_put_contents($image_data['path'], fn_resize_image($image_data['path'], $_data['image_x'], $_data['image_y']));
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:18,代码来源:func.php

示例6: updateViaFtp

 public function updateViaFtp($content, $settings)
 {
     $this->saveBackup();
     $tmp_file = fn_create_temp_file();
     fn_put_contents($tmp_file, $content);
     $ftp_copy_result = fn_copy_by_ftp($tmp_file, $this->path, $settings);
     fn_rm($tmp_file);
     $status = $ftp_copy_result === true;
     return array($status, $ftp_copy_result);
 }
开发者ID:askzap,项目名称:ultimate,代码行数:10,代码来源:Robots.php

示例7: create

 /**
  * Generates new snapshot
  * @param array $params params list
  */
 public static function create($params)
 {
     if (empty($params['dir_root'])) {
         $params['dir_root'] = Registry::get('config.dir.root');
     }
     if (empty($params['dist'])) {
         $params['dist'] = false;
     }
     $dir_root = $params['dir_root'];
     $dist = $params['dist'];
     $folders = array('app', 'js', $params['theme_rel_backend']);
     if ($dist) {
         $themes_dir = $params['themes_repo'];
         $themes_dir_to = $params['themes_frontend'];
     } else {
         $themes_dir = $params['themes_frontend'];
     }
     $themes = fn_get_dir_contents($themes_dir);
     $snapshot = array('time' => time(), 'files' => array(), 'dirs' => array(), 'themes' => array());
     if ($dist) {
         $snapshot['db_scheme'] = fn_get_contents($dir_root . '/install/database/scheme.sql');
         // remove myslqdump comments
         $snapshot['db_scheme'] = preg_replace('|/\\*!.+\\*/;\\n|imSU', '', $snapshot['db_scheme']);
         // form list of tables
         preg_match_all('/create table `(.+)`/imSU', $snapshot['db_scheme'], $tables);
         $snapshot['db_tables'] = !empty($tables[1]) ? $tables[1] : array();
     }
     $new_snapshot = self::make($dir_root, $folders, array('config.local.php'));
     self::arrayMerge($snapshot, $new_snapshot);
     foreach ($folders as $folder_name) {
         $path = $dir_root . '/' . $folder_name;
         $new_snapshot = self::make($path);
         self::arrayMerge($snapshot, $new_snapshot);
     }
     foreach ($themes as $theme_name) {
         if (is_numeric($theme_name) && $theme_name === strval($theme_name + 0)) {
             continue;
             // this is company subfolder
         }
         $path = "{$themes_dir}/{$theme_name}";
         if ($dist) {
             $new_snapshot = self::make($path, array(), array(), array($themes_dir => $themes_dir_to), true);
         } else {
             $new_snapshot = self::make($path, array(), array(), array(), true);
         }
         $snapshot['themes'][$theme_name]['files'] = $snapshot['themes'][$theme_name]['dirs'] = array();
         self::arrayMerge($snapshot['themes'][$theme_name], $new_snapshot);
     }
     $snapshot['addons'] = fn_get_dir_contents(Registry::get('config.dir.addons'));
     fn_mkdir(Registry::get('config.dir.snapshots'));
     $snapshot_filename = fn_strtolower(PRODUCT_VERSION . '_' . (PRODUCT_STATUS ? PRODUCT_STATUS . '_' : '') . PRODUCT_EDITION . ($dist ? '_dist' : ''));
     $snapshot_filecontent = '<?php $snapshot' . ($dist ? '_dist' : '') . ' = ' . var_export($snapshot, true) . '; ?>';
     fn_put_contents(Registry::get('config.dir.snapshots') . "{$snapshot_filename}.php", $snapshot_filecontent);
 }
开发者ID:askzap,项目名称:ultimate,代码行数:58,代码来源:Snapshot.php

示例8: acquireLock

 public function acquireLock($key, $cache_level)
 {
     $fname = $this->_mapTags('locks') . '/' . $key . $cache_level;
     if (file_exists($fname)) {
         $ttl = fn_get_contents($fname);
         if ($ttl < time()) {
             // lock expired
             return fn_put_contents($fname, time() + Registry::LOCK_EXPIRY);
         }
     } else {
         return fn_put_contents($fname, time() + Registry::LOCK_EXPIRY);
     }
     return false;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:14,代码来源:File.php

示例9: clear

 static function clear($changed_tables)
 {
     $tags = array();
     foreach ($changed_tables as $table => $flag) {
         if (!empty(self::$_cache_handlers[$table])) {
             $tags = fn_array_merge($tags, array_keys(self::$_cache_handlers[$table]), false);
         }
     }
     foreach ($tags as $tag) {
         fn_rm(DIR_CACHE . $tag, true);
     }
     fn_put_contents(DIR_CACHE . self::$_handlers_name, serialize(self::$_cache_handlers));
     return true;
 }
开发者ID:diedsmiling,项目名称:busenika,代码行数:14,代码来源:class.cache_backend_file.php

示例10: fn_hidpi_update_image

/**
 * Hook: generates low-resolution image from HiDPI one
 * @param array &$image_data
 * @param int &$image_id
 * @param string &$image_type
 * @param string &$images_path
 * @param array &$_data
 */
function fn_hidpi_update_image(&$image_data, &$image_id, &$image_type, &$images_path, &$_data)
{
    // Save original image
    $filename = fn_hdpi_form_name($image_data['name']);
    Storage::instance('images')->put($images_path . $filename, array('file' => $image_data['path'], 'keep_origins' => true));
    $ext = fn_get_file_ext($filename);
    // We should not process ICO files
    if ($ext == 'ico') {
        return false;
    }
    // Resize original image to non-hidpi resolution
    $_data['image_x'] = intval($_data['image_x'] / 2);
    $_data['image_y'] = intval($_data['image_y'] / 2);
    fn_put_contents($image_data['path'], fn_resize_image($image_data['path'], $_data['image_x'], $_data['image_y'], Registry::get('settings.Thumbnails.thumbnail_background_color')));
}
开发者ID:askzap,项目名称:ultimate,代码行数:23,代码来源:func.php

示例11: downloadPackage

 /**
  * Downloads upgrade package from the Upgade server
  *
  * @param  array  $schema       Package schema
  * @param  string $package_path Path where the upgrade pack must be saved
  * @return bool   True if upgrade package was successfully downloaded, false otherwise
  */
 public function downloadPackage($schema, $package_path)
 {
     $data = fn_get_contents(Registry::get('config.resources.updates_server') . '/index.php?dispatch=product_updates.get_package&package_id=' . $schema['package_id'] . '&edition=' . PRODUCT_EDITION . '&license_number=' . $this->uc_settings['license_number']);
     if (!empty($data)) {
         fn_put_contents($package_path, $data);
         if (md5_file($package_path) == $schema['md5']) {
             $result = array(true, '');
         } else {
             fn_rm($package_path);
             $result = array(false, __('text_uc_broken_package'));
         }
     } else {
         $result = array(false, __('text_uc_cant_download_package'));
     }
     return $result;
 }
开发者ID:arpad9,项目名称:bygmarket,代码行数:23,代码来源:Connector.php

示例12: 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']));
     }
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:22,代码来源:Connector.php

示例13: fn_generate_thumbnail

function fn_generate_thumbnail($image_path, $width, $height = 0, $make_box = false, $force = null)
{
    if (empty($image_path)) {
        return '';
    }
    if (strpos($image_path, '://') === false) {
        if (strpos($image_path, '/') !== 0) {
            // relative path
            $image_path = Registry::get('config.current_path') . '/' . $image_path;
        }
        $image_path = (defined('HTTPS') ? 'https://' . Registry::get('config.https_host') : 'http://' . Registry::get('config.http_host')) . $image_path;
    }
    $_path = str_replace(Registry::get('config.current_location') . '/', '', $image_path);
    $image_url = explode('/', $_path);
    $image_name = array_pop($image_url);
    $image_dir = array_pop($image_url);
    $image_dir .= '/' . $width . (empty($height) ? '' : '/' . $height);
    $filename = $image_dir . '/' . $image_name;
    $real_path = htmlspecialchars_decode(DIR_ROOT . '/' . $_path, ENT_QUOTES);
    $th_path = htmlspecialchars_decode(DIR_THUMBNAILS . $filename, ENT_QUOTES);
    if (!fn_mkdir(DIR_THUMBNAILS . $image_dir)) {
        return '';
    }
    if (!file_exists($th_path) || $force != null) {
        if (fn_get_image_size($real_path)) {
            $image = fn_get_contents($real_path);
            fn_put_contents($th_path, $image);
            if ($force == "new") {
                fn_place_new($th_path);
            }
            fn_resize_image($th_path, $th_path, $width, $height, $make_box);
        } else {
            return '';
        }
    }
    return Registry::get('config.thumbnails_path') . $filename;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:37,代码来源:fn.images.php

示例14: fn_sdek_get_ticket_order

function fn_sdek_get_ticket_order($data_auth, $order_id, $chek_id)
{
    unset($data_auth['Number']);
    $xml = '            ' . RusSdek::arraySimpleXml('OrdersPrint', $data_auth, 'open');
    $order_sdek = array('Number' => $order_id . '_' . $chek_id, 'Date' => $data_auth['Date']);
    $xml .= '            ' . RusSdek::arraySimpleXml('Order', $order_sdek);
    $xml .= '            ' . '</OrdersPrint>';
    $response = RusSdek::xmlRequest('http://gw.edostavka.ru:11443/orders_print.php', $xml, $data_auth);
    $download_file_dir = fn_get_files_dir_path() . '/sdek' . '/' . $chek_id . '/';
    fn_rm($download_file_dir);
    fn_mkdir($download_file_dir);
    $name = $order_id . '.pdf';
    $download_file_path = $download_file_dir . $name;
    if (!fn_is_empty($response)) {
        fn_put_contents($download_file_path, $response);
    }
}
开发者ID:ambient-lounge,项目名称:site,代码行数:17,代码来源:orders.post.php

示例15: logMessage

 /**
  * Add a new record to LOG file.
  *
  * @param  string $type    notification type (E - error, W - warning, N - notice)
  * @param  string $title   notification title
  * @param  string $message notification message
  * @return bool   true if record was added
  */
 public function logMessage($type, $title, $message)
 {
     $log_wrote = false;
     $file_path = Registry::get('config.dir.root') . '/' . self::LOG_FILE;
     // Create file if not exists
     if (!file_exists($file_path)) {
         fn_put_contents($file_path, '');
     }
     if (is_file($file_path) && is_writable($file_path)) {
         file_put_contents($file_path, $this->_formatLogMessage($type, $title, $message), FILE_APPEND);
         $log_wrote = true;
     }
     return $log_wrote;
 }
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:22,代码来源:App.php


注:本文中的fn_put_contents函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。