Example #1
0
 /**
  * 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);
 }
 /**
  * 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);
 }
Example #3
0
 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);
 }
Example #4
0
 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;
 }
Example #5
0
 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);
 }
Example #6
0
 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);
 }
Example #7
0
 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('/');
 }
Example #8
0
 /**
  * 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);
 }
 /**
  * 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;
 }
Example #10
0
 /**
  * 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;
         }
     }
 }
Example #11
0
 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');
 }
Example #12
0
 /**
  * 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;
     }
 }
Example #13
0
 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;
     }
 }
Example #14
0
 /**
  * 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;
     }
 }
Example #15
0
 /**
  * @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;
 }
Example #16
0
 /**
  * 激活插件方法,如果激活失败,直接抛出异常
  * 
  * @access public
  * @return void
  * @throws Typecho_Plugin_Exception
  */
 public static function activate()
 {
     Typecho_Plugin::factory('Widget_Abstract_Contents')->filter = array('APlayer_Plugin', 'playerfilter');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('APlayer_Plugin', 'playerparse');
     Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('APlayer_Plugin', 'playerparse');
     Typecho_Plugin::factory('Widget_Archive')->header = array('APlayer_Plugin', 'playercss');
     Typecho_Plugin::factory('Widget_Archive')->footer = array('APlayer_Plugin', 'footerjs');
     $info = is_really_writable(dirname(__FILE__) . "/cache") ? "插件启用成功!!" : "APlayer插件目录的cache目录不可写,可能会导致博客加载缓慢!";
     return _t($info);
 }
Example #17
0
 public function checkWritable($writables = array())
 {
     $writables = empty($writables) ? array_merge($this->writable_files, $this->writable_folders) : array();
     $this->CI->load->helper('file');
     $data = array();
     foreach ($writables as $writable) {
         $data[$writable] = array('file' => $writable, 'status' => is_really_writable(ROOTPATH . $writable));
     }
     return $data;
 }
 private static function _bootstrap()
 {
     if (self::$bootrap) {
         return TRUE;
     }
     self::$bootrap = TRUE;
     if (!is_dir(self::$location) or !is_really_writable(self::$location)) {
         self::$enabled = FALSE;
     }
 }
Example #19
0
 /**
  * 获取备份文件夹状态
  *
  */
 public function get_folder_status()
 {
     if (!file_exists($this->_backup_path)) {
         return '备份文件夹不存在!请先在admin目录下建立backup文件夹';
     } else {
         if (!is_really_writable($this->_backup_path)) {
             return '备份文件夹不可写!';
         }
     }
     return TRUE;
 }
Example #20
0
 public function step1()
 {
     $data['config_writable'] = is_really_writable($this->config_path) ? TRUE : FALSE;
     $data['upload_writable'] = is_really_writable($this->upload_path) ? TRUE : FALSE;
     $data['curl_installed'] = function_exists('curl_init');
     $data['php_version'] = phpversion() >= 5.2;
     $data['can_continue'] = ($data['config_writable'] and $data['upload_writable'] and $data['php_version'] and $data['curl_installed']);
     if ($data['can_continue']) {
         $this->session->set_userdata('last_step', '1');
     }
     $this->_output_step('steps/step1', $data);
 }
Example #21
0
 /**
  * Test if gallery upload folder exists.
  */
 private function test_uploads_folder($path)
 {
     if (!file_exists($path)) {
         @mkdir($path);
         @chmod($path, 0777);
     }
     if (!is_really_writable($this->conf['upload_path']) or !file_exists($this->conf['upload_path'])) {
         $this->template->add_array(array('error' => lang("Create a directory to continue your work with the gallery", 'gallery') . $this->conf['upload_path'] . lang("Set the write access", 'gallery')));
         $this->display_tpl('error');
         exit;
     }
 }
Example #22
0
 /** 
  * Displays the System Diagnostic Panel
  * @param	string		Menu ID
  *
  */
 public function index()
 {
     // Write rights
     $folders = array(array('path' => config_item('cache_path') == '' ? FCPATH . 'cache/' : config_item('cache_path'), 'write' => FALSE), array('path' => config_item('files_path') == '' ? FCPATH . 'files/' : FCPATH . config_item('files_path'), 'write' => FALSE), array('path' => FCPATH . 'themes/' . Settings::get('theme'), 'write' => FALSE));
     foreach ($folders as $key => $folder) {
         if (is_dir($folder['path']) and is_really_writable($folder['path'])) {
             $folders[$key]['write'] = TRUE;
         }
     }
     $this->template['folders'] = $folders;
     $this->output('system/check');
 }
 private function _is_wratible()
 {
     $this->db->where('s_name', 'main');
     $this->db->select('site_template');
     $query = $this->db->get('settings')->row_array();
     $this->widgets_path = PUBPATH . '/templates/' . $query['site_template'] . '/widgets/';
     if (!is_really_writable($this->widgets_path)) {
         return false;
     } else {
         return true;
     }
 }
Example #24
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $config =& get_config();
     if (!is_really_writable(LOG_PATH)) {
         $this->_enabled = FALSE;
     }
     if (is_numeric($config['log_threshold'])) {
         $this->_threshold = $config['log_threshold'];
     }
     if ($config['log_date_format'] != '') {
         $this->_date_fmt = $config['log_date_format'];
     }
 }
Example #25
0
 public function common_functions()
 {
     echo is_php('5.3');
     echo is_really_writable('file.php');
     echo config_item('key');
     echo set_status_header('200', 'text');
     echo remove_invisible_characters('Java\\0script');
     echo html_escape(array());
     echo get_mimes();
     echo is_https();
     echo is_cli();
     echo function_usable('eval');
 }
Example #26
0
 /**
  * Initializes the instance
  */
 protected function _initialize()
 {
     if (empty($this->path)) {
         $this->path = APPPATH . 'cache/';
     }
     if (!is_dir($this->path)) {
         throw new InvalidArgumentException("Cache Path not found: {$this->path}");
     }
     if (!is_really_writable($this->path)) {
         throw new InvalidArgumentException("Cannot write to Cache Path: {$this->path}");
     }
     log_message('debug', 'Cache Class Initialized.');
 }
Example #27
0
 /**
  * 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;
     }
     if (is_numeric($config['log_threshold'])) {
         $this->_threshold = $config['log_threshold'];
     }
     if ($config['log_date_format'] != '') {
         $this->_date_fmt = $config['log_date_format'];
     }
 }
 function create_avatar_img($data = '', $img_path = '', $img_url = '', $font_path = '')
 {
     $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '215', 'img_height' => '215', 'img_type' => 'png', 'font_path' => BASEPATH . 'fonts/texb.ttf', 'word_length' => 1, 'font_size' => 100, 'img_id' => '');
     foreach ($defaults as $key => $val) {
         if (!is_array($data) && empty(${$key})) {
             ${$key} = $val;
         } else {
             ${$key} = isset($data[$key]) ? $data[$key] : $val;
         }
     }
     if ($img_path === '' or $img_url === '' or !is_dir($img_path) or !is_really_writable($img_path) or !extension_loaded('gd')) {
         return FALSE;
     }
     $im = function_exists('imagecreatetruecolor') ? imagecreatetruecolor($img_width, $img_height) : imagecreate($img_width, $img_height);
     $i = strtoupper(substr($word, 0, 1));
     $r = rand(0, 255);
     $g = rand(0, 255);
     $b = rand(0, 255);
     $x = (imagesx($im) - $font_size * strlen($i)) / 2;
     $y = (imagesy($im) + ($font_size - $font_size * 0.25)) / 2;
     $bg = imagecolorallocate($im, $r, $g, $b);
     $tc = imagecolorallocate($im, 255, 255, 255);
     // Create the rectangle
     ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg);
     $use_font = $font_path !== '' && file_exists($font_path) && function_exists('imagettftext');
     if ($use_font === FALSE) {
         $font_size > 5 && ($font_size = 5);
         imagestring($im, $font_size, $x, $y, $i, $tc);
     } else {
         // ($font_size > 30) && $font_size = 30;
         imagettftext($im, $font_size, 0, $x, $y, $tc, $font_path, $i);
     }
     // -----------------------------------
     //  Generate the image
     // -----------------------------------
     $now = microtime(TRUE);
     $img_url = rtrim($img_url, '/') . '/';
     if ($img_type == 'jpeg') {
         $img_filename = $now . '.jpg';
         imagejpeg($im, $img_path . $img_filename);
     } elseif ($img_type == 'png') {
         $img_filename = $now . '.png';
         imagepng($im, $img_path . $img_filename);
     } else {
         return FALSE;
     }
     $img = '<img ' . ($img_id === '' ? '' : 'id="' . $img_id . '"') . ' src="' . $img_url . $img_filename . '" style="width: ' . $img_width . '; height: ' . $img_height . '; border: 0;" alt=" " />';
     ImageDestroy($im);
     return array('image' => $img, 'file_path' => $img_path . $img_filename, 'file_url' => $img_url . $img_filename, 'filename' => $img_filename);
 }
Example #29
0
 /**
  * Constructor
  *
  * @access	public
  */
 function CI_Log()
 {
     $config = get_config();
     $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;
     }
     if (is_numeric($config['log_threshold'])) {
         $this->_threshold = $config['log_threshold'];
     }
     if ($config['log_date_format'] != '') {
         $this->_date_fmt = $config['log_date_format'];
     }
 }
 public function __construct($params)
 {
     $this->_is_logging = (bool) $params["is_cusa_log"];
     $config =& get_config();
     $this->_log_path = $config['cusa_log_path'] != '' ? $config['cusa_log_path'] : APPPATH . 'cusa_log/';
     if (!is_dir($this->_log_path) or !is_really_writable($this->_log_path)) {
         $this->_enabled = FALSE;
     }
     if (is_numeric($config['log_threshold'])) {
         $this->_threshold = $config['log_threshold'];
     }
     if ($config['log_date_format'] != '') {
         $this->_date_fmt = $config['log_date_format'];
     }
 }