本文整理匯總了PHP中is_really_writable函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_really_writable函數的具體用法?PHP is_really_writable怎麽用?PHP is_really_writable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_really_writable函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _write_cache
/**
* Write a Cache File
*
* @access public
* @return void
*/
function _write_cache($output)
{
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$cache_path = $path == '' ? 'system/cache/' : $path;
if (!is_dir($cache_path) or !is_really_writable($cache_path)) {
log_message('error', "Unable to write cache file: " . $cache_path);
return;
}
$uri = $CI->config->item('base_url') . $CI->config->item('index_page') . $CI->uri->uri_string();
// buld query strings
$querystrings = $_SERVER['QUERY_STRING'];
if ($querystrings != null) {
$querystrings = "?" . $querystrings;
}
$uri = $uri . $querystrings;
$cache_path .= md5($uri);
if (!($fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))) {
log_message('error', "Unable to write cache file: " . $cache_path);
return;
}
$expire = time() + $this->cache_expiration * 60;
if (flock($fp, LOCK_EX)) {
fwrite($fp, $expire . 'TS--->' . $output);
flock($fp, LOCK_UN);
} else {
log_message('error', "Unable to secure a file lock for file at: " . $cache_path);
return;
}
fclose($fp);
@chmod($cache_path, FILE_WRITE_MODE);
log_message('debug', "Cache file written: " . $cache_path);
}
示例2: _display_file_cache
/**
* Update/serve a cached file
*
* @access public
* @param string
* @param string
* @return mixed
*/
function _display_file_cache($url, $path_section)
{
$CFG =& load_class('Config', 'core');
$filepath = $CFG->item($path_section, 'static_cache_path');
$linkpath = $filepath == '' || FALSE === $filepath ? 'cache/' : 'cache/' . $filepath . '/';
$filepath = $filepath == '' || FALSE === $filepath ? ROOTPATH . 'cache/' : ROOTPATH . 'cache/' . $filepath . '/';
$linkpath .= md5($url);
$filepath .= md5($url);
if (!@file_exists($filepath)) {
return FALSE;
}
if (!($fp = @fopen($filepath, FOPEN_READ))) {
return FALSE;
}
flock($fp, LOCK_SH);
$cache = '';
if (filesize($filepath) > 0) {
$cache = fread($fp, filesize($filepath));
}
flock($fp, LOCK_UN);
fclose($fp);
// Strip out the embedded timestamp
if (!preg_match("/(\\d+TS--->)/", $cache, $match)) {
return FALSE;
}
// Has the file expired? If so we'll delete it.
if (time() >= trim(str_replace('TS--->', '', $match['1']))) {
if (is_really_writable($filepath)) {
@unlink($filepath);
log_message('debug', "Cache file has expired. File deleted");
return FALSE;
}
}
return urlencode($linkpath);
}
示例3: __construct
public function __construct()
{
date_default_timezone_set('UTC');
parent::__construct();
@session_start();
// load database
$this->load->database();
//
$this->load->library(array('session', 'javascript'));
$this->load->helper(array('url_helper', 'language', 'date'));
$RTR =& load_class('Router', 'core');
$this->current_dir = $RTR->fetch_directory();
$this->current_class = $RTR->fetch_class();
$this->current_method = $RTR->fetch_method();
$this->controller_base = '/' . $this->current_dir . $this->current_class . '/';
$doc_root = getcwd() . "/";
if (!is_dir($doc_root . 'images/upload')) {
if (is_really_writable($doc_root . 'images')) {
mkdir($doc_root . 'images/upload');
} else {
show_error('Folder is not writable: ' . $doc_root . 'images');
}
}
$vars['controller'] = $this->current_class;
$vars['method'] = $this->current_method;
// load_models
$this->_load_models(get_class_vars($this->current_class));
$vars['checkout_url'] = 'http://' . $_SERVER['SERVER_NAME'] . '/cart/checkout';
$vars['base_url'] = $this->config->item('base_url');
$vars['ci'] = $this;
$this->load->vars($vars);
}
示例4: set_file_path
public function set_file_path($dir)
{
$dir = rtrim($dir, '/') . '/';
if (is_file($dir)) {
log_message('debug', 'Qrcode: Set File Path to a file.');
} else {
if (!is_dir($dir)) {
$parent_dir = $dir;
do {
$parent_dir = dirname($parent_dir);
} while (!is_dir($parent_dir));
$perms = '0' . substr(sprintf('%o', fileperms($parent_dir)), -3);
if (@mkdir($dir, $perms, TRUE)) {
@chmod($dir, $perms);
} else {
log_message('debug', 'Qrcode: Can not make new dir.');
}
}
if (!is_dir($dir) || !is_really_writable($dir)) {
log_message('debug', 'Qrcode: Set to a unwritable dir.');
} else {
$this->_dir_path = $dir;
}
}
return $this;
}
示例5: index
public function index()
{
$config = $this->config->item('upload');
$this->data['message']['success'] = '';
$this->data['message']['warning'] = '';
$this->data['message']['error'] = '';
$this->data['styles'] = $this->assets->css('admin_styles');
$this->data['jquery'] = $this->assets->js('jquery');
$this->data['jqueryui'] = $this->assets->js('jqueryui');
$this->data['scripts'] = $this->assets->js('scripts');
$this->data['grid'] = $this->assets->css('grid');
$this->data['lobster'] = $this->assets->css('lobster');
$this->data['logo'] = $this->assets->img('logo');
$this->data['page_title'] = 'Uploader';
$this->data['doc_title'] = 'Uploader';
if (!is_really_writable(ROOT . $config['upload_path'])) {
$this->data['message']['warning'] = '<span class="warning">Ths path: ' . $config['upload_path'] . ' is not writable</span>';
}
if (!file_exists(ROOT . $config['upload_path'])) {
$this->data['message']['error'] = '<span class="error">Ths path: ' . $config['upload_path'] . ' does not exist</span>';
}
$this->data['categories'] = $this->categories->find();
$this->data['content'] = $this->load->view('admin/pinups/upload', $this->data, true);
$upload_data = $this->session->userdata('upload_data');
if (!empty($upload_data)) {
$this->data['upload_data'] = $upload_data;
$this->session->unset_userdata('upload_data');
$this->data['img_tag'] = '<img src="' . $upload_data['public_uri'] . $upload_data['file_name'] . '" />';
} else {
$error = $this->session->userdata('upload_error');
$this->data['error'] = $error;
}
$this->load->view('admin/template', $this->data);
}
示例6: index
public function index($action = '')
{
$folders = array('/system/cache/' => FALSE, '/system/cache/templates_c/' => FALSE, '/uploads/' => FALSE, '/uploads/images' => FALSE, '/uploads/files' => FALSE, '/uploads/media' => FALSE, '/captcha/' => FALSE);
foreach ($folders as $k => $v) {
$folders[$k] = is_really_writable(PUBPATH . $k);
}
$this->template->assign('folders', $folders);
if ($this->db->dbdriver == 'mysql') {
$this->load->helper('number');
$sql = "SHOW TABLE STATUS FROM `" . $this->db->database . "`";
$query = $this->db->query($sql)->result_array();
// Get total DB size
$total_size = 0;
$total_rows = 0;
foreach ($query as $k => $v) {
$total_size += $v['Data_length'] + $v['Index_length'];
$total_rows += $v['Rows'];
}
$sql = "SELECT VERSION()";
$query = $this->db->query($sql);
$version = $query->row_array();
$this->template->add_array(array('db_version' => $version['VERSION()'], 'db_size' => byte_format($total_size), 'db_rows' => $total_rows));
}
$this->template->show('sys_info', FALSE);
}
示例7: upload_add
public function upload_add()
{
$post = $this->input->post(NULL, TRUE);
//echo $post['userfile'];
$tmp = $_FILES['userfile']['name'];
$ext = $ext = pathinfo($tmp, PATHINFO_EXTENSION);
$config['upload_path'] = 'C:/wamp/www/booksnstud/assets/images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '2400';
$config['max_height'] = '1000';
$name = $config['file_name'] = str_replace(' ', '_', $post['title']) . '_' . time() . '.' . $ext;
$this->load->library('upload', $config);
if (!is_really_writable($config['upload_path'])) {
//$this->set_error('upload_not_writable');
echo "Not writatable directory";
}
if (!$this->upload->do_upload('userfile')) {
$error = array('error' => $this->upload->display_errors());
echo "Something went wrong!! :! ";
foreach ($error as $key => $value) {
echo $value;
echo $config['upload_path'];
}
} else {
$this->load->model('upload_add_model');
$post['name'] = $name;
$this->upload_add_model->new_add($post);
}
redirect('/');
}
示例8: _write_cache
/**
* Write a Cache File
*
* @access public
* @return void
*/
function _write_cache($output)
{
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$cache_path = $path == '' ? APPPATH . 'cache/' : $path;
if (!is_dir($cache_path) or !is_really_writable($cache_path)) {
log_message('error', "Unable to write cache file: " . $cache_path);
return;
}
$uri = $CI->config->item('base_url') . $CI->config->item('index_page') . $CI->uri->uri_string();
$cache_path .= md5($uri);
if (!($fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))) {
log_message('error', "Unable to write cache file: " . $cache_path);
return;
}
$expire = time() + $this->cache_expiration * 60;
$headers = array();
foreach ($this->headers as $header) {
$headers[] = $header[0] . (int) (bool) $header[1];
}
$headers = implode("\n", $headers);
if (flock($fp, LOCK_EX)) {
fwrite($fp, $expire . 'TS--->' . $headers . 'H--->' . $output);
flock($fp, LOCK_UN);
} else {
log_message('error', "Unable to secure a file lock for file at: " . $cache_path);
return;
}
fclose($fp);
@chmod($cache_path, FILE_WRITE_MODE);
log_message('debug', "Cache file written: " . $cache_path);
}
示例9: CI_Jquery_ext
/**
* JQuery Constructor
*
* Loads the config form ./system/application/config/jquery_ext.php
*
* @return CI_Jquery
*/
function CI_Jquery_ext()
{
log_message('debug', "Jquery Ext Class Initialized");
// Set the super object to a local variable for use throughout the class
$this->CI =& get_instance();
// Loads the jquery config (jquery.php under ./system/application/config/)
$this->CI->load->config('jquery_ext');
$tmp_config =& get_config();
if (count($tmp_config['jquery_ext']) > 0) {
$this->config = $tmp_config['jquery_ext'];
// stores the jquery class configuration in a class variable
unset($tmp_config);
} else {
$this->_error('jquery_ext_configuration_error');
}
if ($this->config['auto_insert_jquery']) {
// loads the jquery library if set in the config file
$this->add_jquery();
}
if (count($this->config['autoload'])) {
foreach ($this->config['autoload'] as $v) {
$this->add_plugin($v);
}
}
if ($this->config['generate_js_files'] == TRUE) {
if (!is_dir($this->config['js_files_fs_path']) or !is_really_writable($this->config['js_files_fs_path'])) {
$this->_error("jquery_ext_cant_write_path", $this->config['js_files_fs_path']);
}
}
return;
}
示例10: OCS_Log
/**
* Constructor
*
* @access public
*/
function OCS_Log()
{
// adapted from CI's Log.php
$config =& get_config();
if (is_numeric($config['log_threshold'])) {
$this->_threshold = $config['log_threshold'];
}
if ($config['log_date_format'] != '') {
$this->_date_fmt = $config['log_date_format'];
}
if (isset($config['log_backtrace_func'])) {
$this->_backtrace_func = $config['log_backtrace_func'];
}
if (isset($config['log_backtrace_line'])) {
$this->_backtrace_line = $config['log_backtrace_line'];
}
if (isset($config['log_use_syslog'])) {
$this->_use_syslog = $config['log_use_syslog'];
}
if (isset($config['log_syslog_facility'])) {
$this->_syslog_facility = $config['log_syslog_facility'];
}
if ($this->_use_syslog === TRUE) {
if (!openlog("ocs", LOG_PID, $this->_syslog_facility)) {
$this->_enable = FALSE;
}
} else {
$this->log_path = $config['log_path'] != '' ? $config['log_path'] : BASEPATH . 'logs/';
if (!is_dir($this->log_path) or !is_really_writable($this->log_path)) {
$this->_enabled = FALSE;
}
}
}
示例11: delete
function delete($theme_name = "")
{
$this->load->helper('file');
$name_array = $theme_name != "" ? array($theme_name) : $this->input->post('action_to');
// Delete multiple
if (!empty($name_array)) {
$deleted = 0;
$to_delete = 0;
foreach ($name_array as $theme_name) {
$theme_name = urldecode($theme_name);
$to_delete++;
if ($this->settings->item('default_theme') == $theme_name) {
$this->session->set_flashdata('error', lang('themes.default_delete_error'));
} else {
$theme_dir = APPPATH . 'themes/' . $theme_name;
if (is_really_writable($theme_dir)) {
delete_files($theme_dir, TRUE);
if (@rmdir($theme_dir)) {
$deleted++;
}
} else {
$this->session->set_flashdata('error', sprintf(lang('themes.delete_error'), APPPATH . 'themes/' . $theme_name));
}
}
}
if ($deleted == $to_delete) {
$this->session->set_flashdata('success', sprintf(lang('themes.mass_delete_success'), $delete, $to_delete));
}
} else {
$this->session->set_flashdata('error', lang('themes.delete_select_error'));
}
redirect('admin/themes');
}
示例12: object_create
/**
* Creates a new object
*
* @access public
* @param none
* @return void
**/
public function object_create($data)
{
$_bucket = !empty($data->bucket->slug) ? $data->bucket->slug : '';
$_filename = !empty($data->filename) ? $data->filename : '';
$_source = !empty($data->file) ? $data->file : '';
// --------------------------------------------------------------------------
// Check directory exists
if (!is_dir(DEPLOY_CDN_PATH . $_bucket)) {
// Hmm, not writeable, can we create it?
if (!@mkdir(DEPLOY_CDN_PATH . $_bucket)) {
// Nope, failed to create the directory - we iz gonna have problems if we continue, innit.
$this->cdn->set_error(lang('cdn_error_target_write_fail_mkdir', DEPLOY_CDN_PATH . $_bucket));
return FALSE;
}
}
// --------------------------------------------------------------------------
// Check bucket is writeable
if (!is_really_writable(DEPLOY_CDN_PATH . $_bucket)) {
$this->cdn->set_error(lang('cdn_error_target_write_fail', DEPLOY_CDN_PATH . $_bucket));
return FALSE;
}
// --------------------------------------------------------------------------
// Move the file
$_dest = DEPLOY_CDN_PATH . $_bucket . '/' . $_filename;
if (@move_uploaded_file($_source, $_dest)) {
return TRUE;
// Hmm, failed to move, try copying it.
} elseif (@copy($_source, $_dest)) {
return TRUE;
} else {
$this->cdn->set_error(lang('cdn_error_couldnotmove'));
return FALSE;
}
}
示例13: __construct
public function __construct()
{
$this->_ci =& get_instance();
$this->log_path = APPPATH . "logs/access/";
if (!is_dir($this->log_path) or !is_really_writable($this->log_path)) {
$this->enabled = FALSE;
}
}
示例14: __construct
/**
* Constructor
*/
public function __construct()
{
$config =& get_config();
$this->_log_path = $config['log_path'] != '' ? $config['log_path'] : APPPATH . 'logs/';
if (!is_dir($this->_log_path) or !is_really_writable($this->_log_path)) {
$this->_enabled = FALSE;
}
}
示例15: getSettingsFile
/**
* @return string
* @throws Exception
*/
private function getSettingsFile()
{
$path = $_SERVER['DOCUMENT_ROOT'] . '/' . self::SETTINGS_FILE;
if (!is_really_writable($path)) {
throw new Exception('file: "' . $path . '" must be writable!');
}
$file = file_get_contents($path);
return $file;
}