code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2006 - 2012, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Migration Class
*
* All migrations should implement this, forces up() and down() and gives
* access to the CI super-global.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author Reactor Engineers
* @link
*/
class CI_Migration {
protected $_migration_enabled = FALSE;
protected $_migration_path = NULL;
protected $_migration_version = 0;
protected $_error_string = '';
public function __construct($config = array())
{
# Only run this constructor on main library load
if (get_parent_class($this) !== FALSE)
{
return;
}
foreach ($config as $key => $val)
{
$this->{'_' . $key} = $val;
}
log_message('debug', 'Migrations class initialized');
// Are they trying to use migrations while it is disabled?
if ($this->_migration_enabled !== TRUE)
{
show_error('Migrations has been loaded but is disabled or set up incorrectly.');
}
// If not set, set it
$this->_migration_path == '' AND $this->_migration_path = APPPATH . 'migrations/';
// Add trailing slash if not set
$this->_migration_path = rtrim($this->_migration_path, '/').'/';
// Load migration language
$this->lang->load('migration');
// They'll probably be using dbforge
$this->load->dbforge();
// If the migrations table is missing, make it
if ( ! $this->db->table_exists('migrations'))
{
$this->dbforge->add_field(array(
'version' => array('type' => 'INT', 'constraint' => 3),
));
$this->dbforge->create_table('migrations', TRUE);
$this->db->insert('migrations', array('version' => 0));
}
}
// --------------------------------------------------------------------
/**
* Migrate to a schema version
*
* Calls each migration step required to get to the schema version of
* choice
*
* @param int Target schema version
* @return mixed TRUE if already latest, FALSE if failed, int if upgraded
*/
public function version($target_version)
{
$start = $current_version = $this->_get_version();
$stop = $target_version;
if ($target_version > $current_version)
{
// Moving Up
++$start;
++$stop;
$step = 1;
}
else
{
// Moving Down
$step = -1;
}
$method = ($step === 1) ? 'up' : 'down';
$migrations = array();
// We now prepare to actually DO the migrations
// But first let's make sure that everything is the way it should be
for ($i = $start; $i != $stop; $i += $step)
{
$f = glob(sprintf($this->_migration_path . '%03d_*.php', $i));
// Only one migration per step is permitted
if (count($f) > 1)
{
$this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $i);
return FALSE;
}
// Migration step not found
if (count($f) == 0)
{
// If trying to migrate up to a version greater than the last
// existing one, migrate to the last one.
if ($step == 1)
{
break;
}
// If trying to migrate down but we're missing a step,
// something must definitely be wrong.
$this->_error_string = sprintf($this->lang->line('migration_not_found'), $i);
return FALSE;
}
$file = basename($f[0]);
$name = basename($f[0], '.php');
// Filename validations
if (preg_match('/^\d{3}_(\w+)$/', $name, $match))
{
$match[1] = strtolower($match[1]);
// Cannot repeat a migration at different steps
if (in_array($match[1], $migrations))
{
$this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $match[1]);
return FALSE;
}
include $f[0];
$class = 'Migration_' . ucfirst($match[1]);
if ( ! class_exists($class))
{
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
return FALSE;
}
if ( ! is_callable(array($class, $method)))
{
$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
return FALSE;
}
$migrations[] = $match[1];
}
else
{
$this->_error_string = sprintf($this->lang->line('migration_invalid_filename'), $file);
return FALSE;
}
}
log_message('debug', 'Current migration: ' . $current_version);
$version = $i + ($step == 1 ? -1 : 0);
// If there is nothing to do so quit
if ($migrations === array())
{
return TRUE;
}
log_message('debug', 'Migrating from ' . $method . ' to version ' . $version);
// Loop through the migrations
foreach ($migrations AS $migration)
{
// Run the migration class
$class = 'Migration_' . ucfirst(strtolower($migration));
call_user_func(array(new $class, $method));
$current_version += $step;
$this->_update_version($current_version);
}
log_message('debug', 'Finished migrating to '.$current_version);
return $current_version;
}
// --------------------------------------------------------------------
/**
* Set's the schema to the latest migration
*
* @return mixed true if already latest, false if failed, int if upgraded
*/
public function latest()
{
if ( ! $migrations = $this->find_migrations())
{
$this->_error_string = $this->line->lang('migration_none_found');
return false;
}
$last_migration = basename(end($migrations));
// Calculate the last migration step from existing migration
// filenames and procceed to the standard version migration
return $this->version((int) substr($last_migration, 0, 3));
}
// --------------------------------------------------------------------
/**
* Set's the schema to the migration version set in config
*
* @return mixed true if already current, false if failed, int if upgraded
*/
public function current()
{
return $this->version($this->_migration_version);
}
// --------------------------------------------------------------------
/**
* Error string
*
* @return string Error message returned as a string
*/
public function error_string()
{
return $this->_error_string;
}
// --------------------------------------------------------------------
/**
* Set's the schema to the latest migration
*
* @return mixed true if already latest, false if failed, int if upgraded
*/
protected function find_migrations()
{
// Load all *_*.php files in the migrations path
$files = glob($this->_migration_path . '*_*.php');
$file_count = count($files);
for ($i = 0; $i < $file_count; $i++)
{
// Mark wrongly formatted files as false for later filtering
$name = basename($files[$i], '.php');
if ( ! preg_match('/^\d{3}_(\w+)$/', $name))
{
$files[$i] = FALSE;
}
}
sort($files);
return $files;
}
// --------------------------------------------------------------------
/**
* Retrieves current schema version
*
* @return int Current Migration
*/
protected function _get_version()
{
$row = $this->db->get('migrations')->row();
return $row ? $row->version : 0;
}
// --------------------------------------------------------------------
/**
* Stores the current schema version
*
* @param int Migration reached
* @return bool
*/
protected function _update_version($migrations)
{
return $this->db->update('migrations', array(
'version' => $migrations
));
}
// --------------------------------------------------------------------
/**
* Enable the use of CI super-global
*
* @param mixed $var
* @return mixed
*/
public function __get($var)
{
return get_instance()->$var;
}
}
/* End of file Migration.php */
/* Location: ./system/libraries/Migration.php */ | 069h-course-management | trunk/ci/system/libraries/Migration.php | PHP | mit | 7,993 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Pagination Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Pagination
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/pagination.html
*/
class CI_Pagination {
var $base_url = ''; // The page we are linking to
var $prefix = ''; // A custom prefix added to the path.
var $suffix = ''; // A custom suffix added to the path.
var $total_rows = 0; // Total number of items (database results)
var $per_page = 10; // Max number of items you want shown per page
var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
var $cur_page = 0; // The current page being viewed
var $use_page_numbers = FALSE; // Use page number for segment instead of offset
var $first_link = '‹ First';
var $next_link = '>';
var $prev_link = '<';
var $last_link = 'Last ›';
var $uri_segment = 3;
var $full_tag_open = '';
var $full_tag_close = '';
var $first_tag_open = '';
var $first_tag_close = ' ';
var $last_tag_open = ' ';
var $last_tag_close = '';
var $first_url = ''; // Alternative URL for the First Page.
var $cur_tag_open = ' <strong>';
var $cur_tag_close = '</strong>';
var $next_tag_open = ' ';
var $next_tag_close = ' ';
var $prev_tag_open = ' ';
var $prev_tag_close = '';
var $num_tag_open = ' ';
var $num_tag_close = '';
var $page_query_string = FALSE;
var $query_string_segment = 'per_page';
var $display_pages = TRUE;
var $anchor_class = '';
/**
* Constructor
*
* @access public
* @param array initialization parameters
*/
public function __construct($params = array())
{
if (count($params) > 0)
{
$this->initialize($params);
}
if ($this->anchor_class != '')
{
$this->anchor_class = 'class="'.$this->anchor_class.'" ';
}
log_message('debug', "Pagination Class Initialized");
}
// --------------------------------------------------------------------
/**
* Initialize Preferences
*
* @access public
* @param array initialization parameters
* @return void
*/
function initialize($params = array())
{
if (count($params) > 0)
{
foreach ($params as $key => $val)
{
if (isset($this->$key))
{
$this->$key = $val;
}
}
}
}
// --------------------------------------------------------------------
/**
* Generate the pagination links
*
* @access public
* @return string
*/
function create_links()
{
// If our item count or per-page total is zero there is no need to continue.
if ($this->total_rows == 0 OR $this->per_page == 0)
{
return '';
}
// Calculate the total number of pages
$num_pages = ceil($this->total_rows / $this->per_page);
// Is there only one page? Hm... nothing more to do here then.
if ($num_pages == 1)
{
return '';
}
// Set the base page index for starting page number
if ($this->use_page_numbers)
{
$base_page = 1;
}
else
{
$base_page = 0;
}
// Determine the current page number.
$CI =& get_instance();
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
if ($CI->input->get($this->query_string_segment) != $base_page)
{
$this->cur_page = $CI->input->get($this->query_string_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
}
else
{
if ($CI->uri->segment($this->uri_segment) != $base_page)
{
$this->cur_page = $CI->uri->segment($this->uri_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
}
// Set current page to 1 if using page numbers instead of offset
if ($this->use_page_numbers AND $this->cur_page == 0)
{
$this->cur_page = $base_page;
}
$this->num_links = (int)$this->num_links;
if ($this->num_links < 1)
{
show_error('Your number of links must be a positive number.');
}
if ( ! is_numeric($this->cur_page))
{
$this->cur_page = $base_page;
}
// Is the page number beyond the result range?
// If so we show the last page
if ($this->use_page_numbers)
{
if ($this->cur_page > $num_pages)
{
$this->cur_page = $num_pages;
}
}
else
{
if ($this->cur_page > $this->total_rows)
{
$this->cur_page = ($num_pages - 1) * $this->per_page;
}
}
$uri_page_number = $this->cur_page;
if ( ! $this->use_page_numbers)
{
$this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
}
// Calculate the start and end numbers. These determine
// which number to start and end the digit links with
$start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
$end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
// Is pagination being used over GET or POST? If get, add a per_page query
// string. If post, add a trailing slash to the base URL if needed
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
$this->base_url = rtrim($this->base_url).'&'.$this->query_string_segment.'=';
}
else
{
$this->base_url = rtrim($this->base_url, '/') .'/';
}
// And here we go...
$output = '';
// Render the "First" link
if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))
{
$first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
$output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}
// Render the "previous" link
if ($this->prev_link !== FALSE AND $this->cur_page != 1)
{
if ($this->use_page_numbers)
{
$i = $uri_page_number - 1;
}
else
{
$i = $uri_page_number - $this->per_page;
}
if ($i == 0 && $this->first_url != '')
{
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
else
{
$i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix;
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
}
// Render the pages
if ($this->display_pages !== FALSE)
{
// Write the digit links
for ($loop = $start -1; $loop <= $end; $loop++)
{
if ($this->use_page_numbers)
{
$i = $loop;
}
else
{
$i = ($loop * $this->per_page) - $this->per_page;
}
if ($i >= $base_page)
{
if ($this->cur_page == $loop)
{
$output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
}
else
{
$n = ($i == $base_page) ? '' : $i;
if ($n == '' && $this->first_url != '')
{
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close;
}
else
{
$n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
}
}
}
}
}
// Render the "next" link
if ($this->next_link !== FALSE AND $this->cur_page < $num_pages)
{
if ($this->use_page_numbers)
{
$i = $this->cur_page + 1;
}
else
{
$i = ($this->cur_page * $this->per_page);
}
$output .= $this->next_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->next_link.'</a>'.$this->next_tag_close;
}
// Render the "Last" link
if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages)
{
if ($this->use_page_numbers)
{
$i = $num_pages;
}
else
{
$i = (($num_pages * $this->per_page) - $this->per_page);
}
$output .= $this->last_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.'</a>'.$this->last_tag_close;
}
// Kill double slashes. Note: Sometimes we can end up with a double slash
// in the penultimate link so we'll kill all double slashes.
$output = preg_replace("#([^:])//+#", "\\1/", $output);
// Add the wrapper HTML if exists
$output = $this->full_tag_open.$output.$this->full_tag_close;
return $output;
}
}
// END Pagination Class
/* End of file Pagination.php */
/* Location: ./system/libraries/Pagination.php */ | 069h-course-management | trunk/ci/system/libraries/Pagination.php | PHP | mit | 9,053 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SHA1 Encoding Class
*
* Purpose: Provides 160 bit hashing using The Secure Hash Algorithm
* developed at the National Institute of Standards and Technology. The 40
* character SHA1 message hash is computationally infeasible to crack.
*
* This class is a fallback for servers that are not running PHP greater than
* 4.3, or do not have the MHASH library.
*
* This class is based on two scripts:
*
* Marcus Campbell's PHP implementation (GNU license)
* http://www.tecknik.net/sha-1/
*
* ...which is based on Paul Johnston's JavaScript version
* (BSD license). http://pajhome.org.uk/
*
* I encapsulated the functions and wrote one additional method to fix
* a hex conversion bug. - Rick Ellis
*
* @package CodeIgniter
* @subpackage Libraries
* @category Encryption
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/general/encryption.html
*/
class CI_SHA1 {
public function __construct()
{
log_message('debug', "SHA1 Class Initialized");
}
/**
* Generate the Hash
*
* @access public
* @param string
* @return string
*/
function generate($str)
{
$n = ((strlen($str) + 8) >> 6) + 1;
for ($i = 0; $i < $n * 16; $i++)
{
$x[$i] = 0;
}
for ($i = 0; $i < strlen($str); $i++)
{
$x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8);
}
$x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
$x[$n * 16 - 1] = strlen($str) * 8;
$a = 1732584193;
$b = -271733879;
$c = -1732584194;
$d = 271733878;
$e = -1009589776;
for ($i = 0; $i < count($x); $i += 16)
{
$olda = $a;
$oldb = $b;
$oldc = $c;
$oldd = $d;
$olde = $e;
for ($j = 0; $j < 80; $j++)
{
if ($j < 16)
{
$w[$j] = $x[$i + $j];
}
else
{
$w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
}
$t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j)));
$e = $d;
$d = $c;
$c = $this->_rol($b, 30);
$b = $a;
$a = $t;
}
$a = $this->_safe_add($a, $olda);
$b = $this->_safe_add($b, $oldb);
$c = $this->_safe_add($c, $oldc);
$d = $this->_safe_add($d, $oldd);
$e = $this->_safe_add($e, $olde);
}
return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
}
// --------------------------------------------------------------------
/**
* Convert a decimal to hex
*
* @access private
* @param string
* @return string
*/
function _hex($str)
{
$str = dechex($str);
if (strlen($str) == 7)
{
$str = '0'.$str;
}
return $str;
}
// --------------------------------------------------------------------
/**
* Return result based on iteration
*
* @access private
* @return string
*/
function _ft($t, $b, $c, $d)
{
if ($t < 20)
return ($b & $c) | ((~$b) & $d);
if ($t < 40)
return $b ^ $c ^ $d;
if ($t < 60)
return ($b & $c) | ($b & $d) | ($c & $d);
return $b ^ $c ^ $d;
}
// --------------------------------------------------------------------
/**
* Determine the additive constant
*
* @access private
* @return string
*/
function _kt($t)
{
if ($t < 20)
{
return 1518500249;
}
else if ($t < 40)
{
return 1859775393;
}
else if ($t < 60)
{
return -1894007588;
}
else
{
return -899497514;
}
}
// --------------------------------------------------------------------
/**
* Add integers, wrapping at 2^32
*
* @access private
* @return string
*/
function _safe_add($x, $y)
{
$lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
$msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
return ($msw << 16) | ($lsw & 0xFFFF);
}
// --------------------------------------------------------------------
/**
* Bitwise rotate a 32-bit number
*
* @access private
* @return integer
*/
function _rol($num, $cnt)
{
return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
}
// --------------------------------------------------------------------
/**
* Pad string with zero
*
* @access private
* @return string
*/
function _zero_fill($a, $b)
{
$bin = decbin($a);
if (strlen($bin) < $b)
{
$bin = 0;
}
else
{
$bin = substr($bin, 0, strlen($bin) - $b);
}
for ($i=0; $i < $b; $i++)
{
$bin = "0".$bin;
}
return bindec($bin);
}
}
// END CI_SHA
/* End of file Sha1.php */
/* Location: ./system/libraries/Sha1.php */ | 069h-course-management | trunk/ci/system/libraries/Sha1.php | PHP | mit | 4,995 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006 - 2012 EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
* @link
*/
class CI_Cache extends CI_Driver_Library {
protected $valid_drivers = array(
'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
);
protected $_cache_path = NULL; // Path of cache files (if file-based cache)
protected $_adapter = 'dummy';
protected $_backup_driver;
// ------------------------------------------------------------------------
/**
* Constructor
*
* @param array
*/
public function __construct($config = array())
{
if ( ! empty($config))
{
$this->_initialize($config);
}
}
// ------------------------------------------------------------------------
/**
* Get
*
* Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
* @param string
* @return mixed value that is stored/FALSE on failure
*/
public function get($id)
{
return $this->{$this->_adapter}->get($id);
}
// ------------------------------------------------------------------------
/**
* Cache Save
*
* @param string Unique Key
* @param mixed Data to store
* @param int Length of time (in seconds) to cache the data
*
* @return boolean true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
return $this->{$this->_adapter}->save($id, $data, $ttl);
}
// ------------------------------------------------------------------------
/**
* Delete from Cache
*
* @param mixed unique identifier of the item in the cache
* @return boolean true on success/false on failure
*/
public function delete($id)
{
return $this->{$this->_adapter}->delete($id);
}
// ------------------------------------------------------------------------
/**
* Clean the cache
*
* @return boolean false on failure/true on success
*/
public function clean()
{
return $this->{$this->_adapter}->clean();
}
// ------------------------------------------------------------------------
/**
* Cache Info
*
* @param string user/filehits
* @return mixed array on success, false on failure
*/
public function cache_info($type = 'user')
{
return $this->{$this->_adapter}->cache_info($type);
}
// ------------------------------------------------------------------------
/**
* Get Cache Metadata
*
* @param mixed key to get cache metadata on
* @return mixed return value from child method
*/
public function get_metadata($id)
{
return $this->{$this->_adapter}->get_metadata($id);
}
// ------------------------------------------------------------------------
/**
* Initialize
*
* Initialize class properties based on the configuration array.
*
* @param array
* @return void
*/
private function _initialize($config)
{
$default_config = array(
'adapter',
'memcached'
);
foreach ($default_config as $key)
{
if (isset($config[$key]))
{
$param = '_'.$key;
$this->{$param} = $config[$key];
}
}
if (isset($config['backup']))
{
if (in_array('cache_'.$config['backup'], $this->valid_drivers))
{
$this->_backup_driver = $config['backup'];
}
}
}
// ------------------------------------------------------------------------
/**
* Is the requested driver supported in this environment?
*
* @param string The driver to test.
* @return array
*/
public function is_supported($driver)
{
static $support = array();
if ( ! isset($support[$driver]))
{
$support[$driver] = $this->{$driver}->is_supported();
}
return $support[$driver];
}
// ------------------------------------------------------------------------
/**
* __get()
*
* @param child
* @return object
*/
public function __get($child)
{
$obj = parent::__get($child);
if ( ! $this->is_supported($child))
{
$this->_adapter = $this->_backup_driver;
}
return $obj;
}
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache.php */
/* Location: ./system/libraries/Cache/Cache.php */ | 069h-course-management | trunk/ci/system/libraries/Cache/Cache.php | PHP | mit | 4,679 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006 - 2012 EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter APC Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
* @link
*/
class CI_Cache_apc extends CI_Driver {
/**
* Get
*
* Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
* @param string
* @return mixed value that is stored/FALSE on failure
*/
public function get($id)
{
$data = apc_fetch($id);
return (is_array($data)) ? $data[0] : FALSE;
}
// ------------------------------------------------------------------------
/**
* Cache Save
*
* @param string Unique Key
* @param mixed Data to store
* @param int Length of time (in seconds) to cache the data
*
* @return boolean true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
return apc_store($id, array($data, time(), $ttl), $ttl);
}
// ------------------------------------------------------------------------
/**
* Delete from Cache
*
* @param mixed unique identifier of the item in the cache
* @param boolean true on success/false on failure
*/
public function delete($id)
{
return apc_delete($id);
}
// ------------------------------------------------------------------------
/**
* Clean the cache
*
* @return boolean false on failure/true on success
*/
public function clean()
{
return apc_clear_cache('user');
}
// ------------------------------------------------------------------------
/**
* Cache Info
*
* @param string user/filehits
* @return mixed array on success, false on failure
*/
public function cache_info($type = NULL)
{
return apc_cache_info($type);
}
// ------------------------------------------------------------------------
/**
* Get Cache Metadata
*
* @param mixed key to get cache metadata on
* @return mixed array on success/false on failure
*/
public function get_metadata($id)
{
$stored = apc_fetch($id);
if (count($stored) !== 3)
{
return FALSE;
}
list($data, $time, $ttl) = $stored;
return array(
'expire' => $time + $ttl,
'mtime' => $time,
'data' => $data
);
}
// ------------------------------------------------------------------------
/**
* is_supported()
*
* Check to see if APC is available on this system, bail if it isn't.
*/
public function is_supported()
{
if ( ! extension_loaded('apc') OR ini_get('apc.enabled') != "1")
{
log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
return FALSE;
}
return TRUE;
}
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache_apc.php */
/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
| 069h-course-management | trunk/ci/system/libraries/Cache/drivers/Cache_apc.php | PHP | mit | 3,307 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006 - 2012 EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Memcached Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
* @link
*/
class CI_Cache_file extends CI_Driver {
protected $_cache_path;
/**
* Constructor
*/
public function __construct()
{
$CI =& get_instance();
$CI->load->helper('file');
$path = $CI->config->item('cache_path');
$this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path;
}
// ------------------------------------------------------------------------
/**
* Fetch from cache
*
* @param mixed unique key id
* @return mixed data on success/false on failure
*/
public function get($id)
{
if ( ! file_exists($this->_cache_path.$id))
{
return FALSE;
}
$data = read_file($this->_cache_path.$id);
$data = unserialize($data);
if (time() > $data['time'] + $data['ttl'])
{
unlink($this->_cache_path.$id);
return FALSE;
}
return $data['data'];
}
// ------------------------------------------------------------------------
/**
* Save into cache
*
* @param string unique key
* @param mixed data to store
* @param int length of time (in seconds) the cache is valid
* - Default is 60 seconds
* @return boolean true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
$contents = array(
'time' => time(),
'ttl' => $ttl,
'data' => $data
);
if (write_file($this->_cache_path.$id, serialize($contents)))
{
@chmod($this->_cache_path.$id, 0777);
return TRUE;
}
return FALSE;
}
// ------------------------------------------------------------------------
/**
* Delete from Cache
*
* @param mixed unique identifier of item in cache
* @return boolean true on success/false on failure
*/
public function delete($id)
{
return unlink($this->_cache_path.$id);
}
// ------------------------------------------------------------------------
/**
* Clean the Cache
*
* @return boolean false on failure/true on success
*/
public function clean()
{
return delete_files($this->_cache_path);
}
// ------------------------------------------------------------------------
/**
* Cache Info
*
* Not supported by file-based caching
*
* @param string user/filehits
* @return mixed FALSE
*/
public function cache_info($type = NULL)
{
return get_dir_file_info($this->_cache_path);
}
// ------------------------------------------------------------------------
/**
* Get Cache Metadata
*
* @param mixed key to get cache metadata on
* @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
if ( ! file_exists($this->_cache_path.$id))
{
return FALSE;
}
$data = read_file($this->_cache_path.$id);
$data = unserialize($data);
if (is_array($data))
{
$mtime = filemtime($this->_cache_path.$id);
if ( ! isset($data['ttl']))
{
return FALSE;
}
return array(
'expire' => $mtime + $data['ttl'],
'mtime' => $mtime
);
}
return FALSE;
}
// ------------------------------------------------------------------------
/**
* Is supported
*
* In the file driver, check to see that the cache directory is indeed writable
*
* @return boolean
*/
public function is_supported()
{
return is_really_writable($this->_cache_path);
}
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache_file.php */
/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ | 069h-course-management | trunk/ci/system/libraries/Cache/drivers/Cache_file.php | PHP | mit | 4,113 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006 - 2012 EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Dummy Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
* @link
*/
class CI_Cache_dummy extends CI_Driver {
/**
* Get
*
* Since this is the dummy class, it's always going to return FALSE.
*
* @param string
* @return Boolean FALSE
*/
public function get($id)
{
return FALSE;
}
// ------------------------------------------------------------------------
/**
* Cache Save
*
* @param string Unique Key
* @param mixed Data to store
* @param int Length of time (in seconds) to cache the data
*
* @return boolean TRUE, Simulating success
*/
public function save($id, $data, $ttl = 60)
{
return TRUE;
}
// ------------------------------------------------------------------------
/**
* Delete from Cache
*
* @param mixed unique identifier of the item in the cache
* @param boolean TRUE, simulating success
*/
public function delete($id)
{
return TRUE;
}
// ------------------------------------------------------------------------
/**
* Clean the cache
*
* @return boolean TRUE, simulating success
*/
public function clean()
{
return TRUE;
}
// ------------------------------------------------------------------------
/**
* Cache Info
*
* @param string user/filehits
* @return boolean FALSE
*/
public function cache_info($type = NULL)
{
return FALSE;
}
// ------------------------------------------------------------------------
/**
* Get Cache Metadata
*
* @param mixed key to get cache metadata on
* @return boolean FALSE
*/
public function get_metadata($id)
{
return FALSE;
}
// ------------------------------------------------------------------------
/**
* Is this caching driver supported on the system?
* Of course this one is.
*
* @return TRUE;
*/
public function is_supported()
{
return TRUE;
}
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache_dummy.php */
/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ | 069h-course-management | trunk/ci/system/libraries/Cache/drivers/Cache_dummy.php | PHP | mit | 2,656 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006 - 2012 EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Memcached Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
* @link
*/
class CI_Cache_memcached extends CI_Driver {
private $_memcached; // Holds the memcached object
protected $_memcache_conf = array(
'default' => array(
'default_host' => '127.0.0.1',
'default_port' => 11211,
'default_weight' => 1
)
);
// ------------------------------------------------------------------------
/**
* Fetch from cache
*
* @param mixed unique key id
* @return mixed data on success/false on failure
*/
public function get($id)
{
$data = $this->_memcached->get($id);
return (is_array($data)) ? $data[0] : FALSE;
}
// ------------------------------------------------------------------------
/**
* Save
*
* @param string unique identifier
* @param mixed data being cached
* @param int time to live
* @return boolean true on success, false on failure
*/
public function save($id, $data, $ttl = 60)
{
if (get_class($this->_memcached) == 'Memcached')
{
return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
}
else if (get_class($this->_memcached) == 'Memcache')
{
return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
}
return FALSE;
}
// ------------------------------------------------------------------------
/**
* Delete from Cache
*
* @param mixed key to be deleted.
* @return boolean true on success, false on failure
*/
public function delete($id)
{
return $this->_memcached->delete($id);
}
// ------------------------------------------------------------------------
/**
* Clean the Cache
*
* @return boolean false on failure/true on success
*/
public function clean()
{
return $this->_memcached->flush();
}
// ------------------------------------------------------------------------
/**
* Cache Info
*
* @param null type not supported in memcached
* @return mixed array on success, false on failure
*/
public function cache_info($type = NULL)
{
return $this->_memcached->getStats();
}
// ------------------------------------------------------------------------
/**
* Get Cache Metadata
*
* @param mixed key to get cache metadata on
* @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
$stored = $this->_memcached->get($id);
if (count($stored) !== 3)
{
return FALSE;
}
list($data, $time, $ttl) = $stored;
return array(
'expire' => $time + $ttl,
'mtime' => $time,
'data' => $data
);
}
// ------------------------------------------------------------------------
/**
* Setup memcached.
*/
private function _setup_memcached()
{
// Try to load memcached server info from the config file.
$CI =& get_instance();
if ($CI->config->load('memcached', TRUE, TRUE))
{
if (is_array($CI->config->config['memcached']))
{
$this->_memcache_conf = NULL;
foreach ($CI->config->config['memcached'] as $name => $conf)
{
$this->_memcache_conf[$name] = $conf;
}
}
}
$this->_memcached = new Memcached();
foreach ($this->_memcache_conf as $name => $cache_server)
{
if ( ! array_key_exists('hostname', $cache_server))
{
$cache_server['hostname'] = $this->_default_options['default_host'];
}
if ( ! array_key_exists('port', $cache_server))
{
$cache_server['port'] = $this->_default_options['default_port'];
}
if ( ! array_key_exists('weight', $cache_server))
{
$cache_server['weight'] = $this->_default_options['default_weight'];
}
$this->_memcached->addServer(
$cache_server['hostname'], $cache_server['port'], $cache_server['weight']
);
}
}
// ------------------------------------------------------------------------
/**
* Is supported
*
* Returns FALSE if memcached is not supported on the system.
* If it is, we setup the memcached object & return TRUE
*/
public function is_supported()
{
if ( ! extension_loaded('memcached'))
{
log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
return FALSE;
}
$this->_setup_memcached();
return TRUE;
}
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache_memcached.php */
/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ | 069h-course-management | trunk/ci/system/libraries/Cache/drivers/Cache_memcached.php | PHP | mit | 5,029 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Logging Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Logging
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/general/errors.html
*/
class CI_Log {
protected $_log_path;
protected $_threshold = 1;
protected $_date_fmt = 'Y-m-d H:i:s';
protected $_enabled = TRUE;
protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
/**
* 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'];
}
}
// --------------------------------------------------------------------
/**
* Write Log File
*
* Generally this function will be called using the global log_message() function
*
* @param string the error level
* @param string the error message
* @param bool whether the error is a native PHP error
* @return bool
*/
public function write_log($level = 'error', $msg, $php_error = FALSE)
{
if ($this->_enabled === FALSE)
{
return FALSE;
}
$level = strtoupper($level);
if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
{
return FALSE;
}
$filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
$message = '';
if ( ! file_exists($filepath))
{
$message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
{
return FALSE;
}
$message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
flock($fp, LOCK_EX);
fwrite($fp, $message);
flock($fp, LOCK_UN);
fclose($fp);
@chmod($filepath, FILE_WRITE_MODE);
return TRUE;
}
}
// END Log Class
/* End of file Log.php */
/* Location: ./system/libraries/Log.php */ | 069h-course-management | trunk/ci/system/libraries/Log.php | PHP | mit | 2,696 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2006 - 2012, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Driver Library Class
*
* This class enables you to create "Driver" libraries that add runtime ability
* to extend the capabilities of a class via additional driver objects
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author EllisLab Dev Team
* @link
*/
class CI_Driver_Library {
protected $valid_drivers = array();
protected $lib_name;
// The first time a child is used it won't exist, so we instantiate it
// subsequents calls will go straight to the proper child.
function __get($child)
{
if ( ! isset($this->lib_name))
{
$this->lib_name = get_class($this);
}
// The class will be prefixed with the parent lib
$child_class = $this->lib_name.'_'.$child;
// Remove the CI_ prefix and lowercase
$lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name)));
$driver_name = strtolower(str_replace('CI_', '', $child_class));
if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
{
// check and see if the driver is in a separate file
if ( ! class_exists($child_class))
{
// check application path first
foreach (get_instance()->load->get_package_paths(TRUE) as $path)
{
// loves me some nesting!
foreach (array(ucfirst($driver_name), $driver_name) as $class)
{
$filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.'.php';
if (file_exists($filepath))
{
include_once $filepath;
break;
}
}
}
// it's a valid driver, but the file simply can't be found
if ( ! class_exists($child_class))
{
log_message('error', "Unable to load the requested driver: ".$child_class);
show_error("Unable to load the requested driver: ".$child_class);
}
}
$obj = new $child_class;
$obj->decorate($this);
$this->$child = $obj;
return $this->$child;
}
// The requested driver isn't valid!
log_message('error', "Invalid driver requested: ".$child_class);
show_error("Invalid driver requested: ".$child_class);
}
// --------------------------------------------------------------------
}
// END CI_Driver_Library CLASS
/**
* CodeIgniter Driver Class
*
* This class enables you to create drivers for a Library based on the Driver Library.
* It handles the drivers' access to the parent library
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author EllisLab Dev Team
* @link
*/
class CI_Driver {
protected $parent;
private $methods = array();
private $properties = array();
private static $reflections = array();
/**
* Decorate
*
* Decorates the child with the parent driver lib's methods and properties
*
* @param object
* @return void
*/
public function decorate($parent)
{
$this->parent = $parent;
// Lock down attributes to what is defined in the class
// and speed up references in magic methods
$class_name = get_class($parent);
if ( ! isset(self::$reflections[$class_name]))
{
$r = new ReflectionObject($parent);
foreach ($r->getMethods() as $method)
{
if ($method->isPublic())
{
$this->methods[] = $method->getName();
}
}
foreach ($r->getProperties() as $prop)
{
if ($prop->isPublic())
{
$this->properties[] = $prop->getName();
}
}
self::$reflections[$class_name] = array($this->methods, $this->properties);
}
else
{
list($this->methods, $this->properties) = self::$reflections[$class_name];
}
}
// --------------------------------------------------------------------
/**
* __call magic method
*
* Handles access to the parent driver library's methods
*
* @access public
* @param string
* @param array
* @return mixed
*/
public function __call($method, $args = array())
{
if (in_array($method, $this->methods))
{
return call_user_func_array(array($this->parent, $method), $args);
}
$trace = debug_backtrace();
_exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']);
exit;
}
// --------------------------------------------------------------------
/**
* __get magic method
*
* Handles reading of the parent driver library's properties
*
* @param string
* @return mixed
*/
public function __get($var)
{
if (in_array($var, $this->properties))
{
return $this->parent->$var;
}
}
// --------------------------------------------------------------------
/**
* __set magic method
*
* Handles writing to the parent driver library's properties
*
* @param string
* @param array
* @return mixed
*/
public function __set($var, $val)
{
if (in_array($var, $this->properties))
{
$this->parent->$var = $val;
}
}
// --------------------------------------------------------------------
}
// END CI_Driver CLASS
/* End of file Driver.php */
/* Location: ./system/libraries/Driver.php */ | 069h-course-management | trunk/ci/system/libraries/Driver.php | PHP | mit | 5,415 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Trackback Class
*
* Trackback Sending/Receiving Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Trackbacks
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/trackback.html
*/
class CI_Trackback {
var $time_format = 'local';
var $charset = 'UTF-8';
var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
var $convert_ascii = TRUE;
var $response = '';
var $error_msg = array();
/**
* Constructor
*
* @access public
*/
public function __construct()
{
log_message('debug', "Trackback Class Initialized");
}
// --------------------------------------------------------------------
/**
* Send Trackback
*
* @access public
* @param array
* @return bool
*/
function send($tb_data)
{
if ( ! is_array($tb_data))
{
$this->set_error('The send() method must be passed an array');
return FALSE;
}
// Pre-process the Trackback Data
foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item)
{
if ( ! isset($tb_data[$item]))
{
$this->set_error('Required item missing: '.$item);
return FALSE;
}
switch ($item)
{
case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]);
break;
case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
break;
case 'url' : $$item = str_replace('-', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
break;
default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item])));
break;
}
// Convert High ASCII Characters
if ($this->convert_ascii == TRUE)
{
if ($item == 'excerpt')
{
$$item = $this->convert_ascii($$item);
}
elseif ($item == 'title')
{
$$item = $this->convert_ascii($$item);
}
elseif ($item == 'blog_name')
{
$$item = $this->convert_ascii($$item);
}
}
}
// Build the Trackback data string
$charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset'];
$data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset);
// Send Trackback(s)
$return = TRUE;
if (count($ping_url) > 0)
{
foreach ($ping_url as $url)
{
if ($this->process($url, $data) == FALSE)
{
$return = FALSE;
}
}
}
return $return;
}
// --------------------------------------------------------------------
/**
* Receive Trackback Data
*
* This function simply validates the incoming TB data.
* It returns FALSE on failure and TRUE on success.
* If the data is valid it is set to the $this->data array
* so that it can be inserted into a database.
*
* @access public
* @return bool
*/
function receive()
{
foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
{
if ( ! isset($_POST[$val]) OR $_POST[$val] == '')
{
$this->set_error('The following required POST variable is missing: '.$val);
return FALSE;
}
$this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
if ($val != 'url' && function_exists('mb_convert_encoding'))
{
$_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
}
$_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]);
if ($val == 'excerpt')
{
$_POST['excerpt'] = $this->limit_characters($_POST['excerpt']);
}
$this->data[$val] = $_POST[$val];
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Send Trackback Error Message
*
* Allows custom errors to be set. By default it
* sends the "incomplete information" error, as that's
* the most common one.
*
* @access public
* @param string
* @return void
*/
function send_error($message = 'Incomplete Information')
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>";
exit;
}
// --------------------------------------------------------------------
/**
* Send Trackback Success Message
*
* This should be called when a trackback has been
* successfully received and inserted.
*
* @access public
* @return void
*/
function send_success()
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
exit;
}
// --------------------------------------------------------------------
/**
* Fetch a particular item
*
* @access public
* @param string
* @return string
*/
function data($item)
{
return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
}
// --------------------------------------------------------------------
/**
* Process Trackback
*
* Opens a socket connection and passes the data to
* the server. Returns TRUE on success, FALSE on failure
*
* @access public
* @param string
* @param string
* @return bool
*/
function process($url, $data)
{
$target = parse_url($url);
// Open the socket
if ( ! $fp = @fsockopen($target['host'], 80))
{
$this->set_error('Invalid Connection: '.$url);
return FALSE;
}
// Build the path
$ppath = ( ! isset($target['path'])) ? $url : $target['path'];
$path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath;
// Add the Trackback ID to the data string
if ($id = $this->get_id($url))
{
$data = "tb_id=".$id."&".$data;
}
// Transfer the data
fputs ($fp, "POST " . $path . " HTTP/1.0\r\n" );
fputs ($fp, "Host: " . $target['host'] . "\r\n" );
fputs ($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
fputs ($fp, "Content-length: " . strlen($data) . "\r\n" );
fputs ($fp, "Connection: close\r\n\r\n" );
fputs ($fp, $data);
// Was it successful?
$this->response = "";
while ( ! feof($fp))
{
$this->response .= fgets($fp, 128);
}
@fclose($fp);
if (stristr($this->response, '<error>0</error>') === FALSE)
{
$message = 'An unknown error was encountered';
if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
{
$message = trim($match['1']);
}
$this->set_error($message);
return FALSE;
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Extract Trackback URLs
*
* This function lets multiple trackbacks be sent.
* It takes a string of URLs (separated by comma or
* space) and puts each URL into an array
*
* @access public
* @param string
* @return string
*/
function extract_urls($urls)
{
// Remove the pesky white space and replace with a comma.
$urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
// If they use commas get rid of the doubles.
$urls = str_replace(",,", ",", $urls);
// Remove any comma that might be at the end
if (substr($urls, -1) == ",")
{
$urls = substr($urls, 0, -1);
}
// Break into an array via commas
$urls = preg_split('/[,]/', $urls);
// Removes duplicates
$urls = array_unique($urls);
array_walk($urls, array($this, 'validate_url'));
return $urls;
}
// --------------------------------------------------------------------
/**
* Validate URL
*
* Simply adds "http://" if missing
*
* @access public
* @param string
* @return string
*/
function validate_url($url)
{
$url = trim($url);
if (substr($url, 0, 4) != "http")
{
$url = "http://".$url;
}
}
// --------------------------------------------------------------------
/**
* Find the Trackback URL's ID
*
* @access public
* @param string
* @return string
*/
function get_id($url)
{
$tb_id = "";
if (strpos($url, '?') !== FALSE)
{
$tb_array = explode('/', $url);
$tb_end = $tb_array[count($tb_array)-1];
if ( ! is_numeric($tb_end))
{
$tb_end = $tb_array[count($tb_array)-2];
}
$tb_array = explode('=', $tb_end);
$tb_id = $tb_array[count($tb_array)-1];
}
else
{
$url = rtrim($url, '/');
$tb_array = explode('/', $url);
$tb_id = $tb_array[count($tb_array)-1];
if ( ! is_numeric($tb_id))
{
$tb_id = $tb_array[count($tb_array)-2];
}
}
if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
{
return FALSE;
}
else
{
return $tb_id;
}
}
// --------------------------------------------------------------------
/**
* Convert Reserved XML characters to Entities
*
* @access public
* @param string
* @return string
*/
function convert_xml($str)
{
$temp = '__TEMP_AMPERSANDS__';
$str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
$str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
$str = str_replace(array("&","<",">","\"", "'", "-"),
array("&", "<", ">", """, "'", "-"),
$str);
$str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
$str = preg_replace("/$temp(\w+);/","&\\1;", $str);
return $str;
}
// --------------------------------------------------------------------
/**
* Character limiter
*
* Limits the string based on the character count. Will preserve complete words.
*
* @access public
* @param string
* @param integer
* @param string
* @return string
*/
function limit_characters($str, $n = 500, $end_char = '…')
{
if (strlen($str) < $n)
{
return $str;
}
$str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
if (strlen($str) <= $n)
{
return $str;
}
$out = "";
foreach (explode(' ', trim($str)) as $val)
{
$out .= $val.' ';
if (strlen($out) >= $n)
{
return trim($out).$end_char;
}
}
}
// --------------------------------------------------------------------
/**
* High ASCII to Entities
*
* Converts Hight ascii text and MS Word special chars
* to character entities
*
* @access public
* @param string
* @return string
*/
function convert_ascii($str)
{
$count = 1;
$out = '';
$temp = array();
for ($i = 0, $s = strlen($str); $i < $s; $i++)
{
$ordinal = ord($str[$i]);
if ($ordinal < 128)
{
$out .= $str[$i];
}
else
{
if (count($temp) == 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
if (count($temp) == $count)
{
$number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
$out .= '&#'.$number.';';
$count = 1;
$temp = array();
}
}
}
return $out;
}
// --------------------------------------------------------------------
/**
* Set error message
*
* @access public
* @param string
* @return void
*/
function set_error($msg)
{
log_message('error', $msg);
$this->error_msg[] = $msg;
}
// --------------------------------------------------------------------
/**
* Show error messages
*
* @access public
* @param string
* @param string
* @return string
*/
function display_errors($open = '<p>', $close = '</p>')
{
$str = '';
foreach ($this->error_msg as $val)
{
$str .= $open.$val.$close;
}
return $str;
}
}
// END Trackback Class
/* End of file Trackback.php */
/* Location: ./system/libraries/Trackback.php */ | 069h-course-management | trunk/ci/system/libraries/Trackback.php | PHP | mit | 11,994 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
if ( ! function_exists('xml_parser_create'))
{
show_error('Your PHP installation does not support XML');
}
if ( ! class_exists('CI_Xmlrpc'))
{
show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
}
// ------------------------------------------------------------------------
/**
* XML-RPC server class
*
* @package CodeIgniter
* @subpackage Libraries
* @category XML-RPC
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/xmlrpc.html
*/
class CI_Xmlrpcs extends CI_Xmlrpc
{
var $methods = array(); //array of methods mapped to function names and signatures
var $debug_msg = ''; // Debug Message
var $system_methods = array(); // XML RPC Server methods
var $controller_obj;
var $object = FALSE;
/**
* Constructor
*/
public function __construct($config=array())
{
parent::__construct();
$this->set_system_methods();
if (isset($config['functions']) && is_array($config['functions']))
{
$this->methods = array_merge($this->methods, $config['functions']);
}
log_message('debug', "XML-RPC Server Class Initialized");
}
// --------------------------------------------------------------------
/**
* Initialize Prefs and Serve
*
* @access public
* @param mixed
* @return void
*/
function initialize($config=array())
{
if (isset($config['functions']) && is_array($config['functions']))
{
$this->methods = array_merge($this->methods, $config['functions']);
}
if (isset($config['debug']))
{
$this->debug = $config['debug'];
}
if (isset($config['object']) && is_object($config['object']))
{
$this->object = $config['object'];
}
if (isset($config['xss_clean']))
{
$this->xss_clean = $config['xss_clean'];
}
}
// --------------------------------------------------------------------
/**
* Setting of System Methods
*
* @access public
* @return void
*/
function set_system_methods()
{
$this->methods = array(
'system.listMethods' => array(
'function' => 'this.listMethods',
'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
'docstring' => 'Returns an array of available methods on this server'),
'system.methodHelp' => array(
'function' => 'this.methodHelp',
'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
'docstring' => 'Returns a documentation string for the specified method'),
'system.methodSignature' => array(
'function' => 'this.methodSignature',
'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
'docstring' => 'Returns an array describing the return type and required parameters of a method'),
'system.multicall' => array(
'function' => 'this.multicall',
'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
);
}
// --------------------------------------------------------------------
/**
* Main Server Function
*
* @access public
* @return void
*/
function serve()
{
$r = $this->parseRequest();
$payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
$payload .= $this->debug_msg;
$payload .= $r->prepare_response();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($payload));
exit($payload);
}
// --------------------------------------------------------------------
/**
* Add Method to Class
*
* @access public
* @param string method name
* @param string function
* @param string signature
* @param string docstring
* @return void
*/
function add_to_map($methodname, $function, $sig, $doc)
{
$this->methods[$methodname] = array(
'function' => $function,
'signature' => $sig,
'docstring' => $doc
);
}
// --------------------------------------------------------------------
/**
* Parse Server Request
*
* @access public
* @param string data
* @return object xmlrpc response
*/
function parseRequest($data='')
{
global $HTTP_RAW_POST_DATA;
//-------------------------------------
// Get Data
//-------------------------------------
if ($data == '')
{
$data = $HTTP_RAW_POST_DATA;
}
//-------------------------------------
// Set up XML Parser
//-------------------------------------
$parser = xml_parser_create($this->xmlrpc_defencoding);
$parser_object = new XML_RPC_Message("filler");
$parser_object->xh[$parser] = array();
$parser_object->xh[$parser]['isf'] = 0;
$parser_object->xh[$parser]['isf_reason'] = '';
$parser_object->xh[$parser]['params'] = array();
$parser_object->xh[$parser]['stack'] = array();
$parser_object->xh[$parser]['valuestack'] = array();
$parser_object->xh[$parser]['method'] = '';
xml_set_object($parser, $parser_object);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($parser, 'open_tag', 'closing_tag');
xml_set_character_data_handler($parser, 'character_data');
//xml_set_default_handler($parser, 'default_handler');
//-------------------------------------
// PARSE + PROCESS XML DATA
//-------------------------------------
if ( ! xml_parse($parser, $data, 1))
{
// return XML error as a faultCode
$r = new XML_RPC_Response(0,
$this->xmlrpcerrxml + xml_get_error_code($parser),
sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser)));
xml_parser_free($parser);
}
elseif ($parser_object->xh[$parser]['isf'])
{
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
}
else
{
xml_parser_free($parser);
$m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
$plist='';
for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
{
if ($this->debug === TRUE)
{
$plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
}
$m->addParam($parser_object->xh[$parser]['params'][$i]);
}
if ($this->debug === TRUE)
{
echo "<pre>";
echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
echo "</pre>";
}
$r = $this->_execute($m);
}
//-------------------------------------
// SET DEBUGGING MESSAGE
//-------------------------------------
if ($this->debug === TRUE)
{
$this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n";
}
return $r;
}
// --------------------------------------------------------------------
/**
* Executes the Method
*
* @access protected
* @param object
* @return mixed
*/
function _execute($m)
{
$methName = $m->method_name;
// Check to see if it is a system call
$system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE;
if ($this->xss_clean == FALSE)
{
$m->xss_clean = FALSE;
}
//-------------------------------------
// Valid Method
//-------------------------------------
if ( ! isset($this->methods[$methName]['function']))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
//-------------------------------------
// Check for Method (and Object)
//-------------------------------------
$method_parts = explode(".", $this->methods[$methName]['function']);
$objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE;
if ($system_call === TRUE)
{
if ( ! is_callable(array($this,$method_parts['1'])))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
else
{
if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1'])))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
//-------------------------------------
// Checking Methods Signature
//-------------------------------------
if (isset($this->methods[$methName]['signature']))
{
$sig = $this->methods[$methName]['signature'];
for ($i=0; $i<count($sig); $i++)
{
$current_sig = $sig[$i];
if (count($current_sig) == count($m->params)+1)
{
for ($n=0; $n < count($m->params); $n++)
{
$p = $m->params[$n];
$pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
if ($pt != $current_sig[$n+1])
{
$pno = $n+1;
$wanted = $current_sig[$n+1];
return new XML_RPC_Response(0,
$this->xmlrpcerr['incorrect_params'],
$this->xmlrpcstr['incorrect_params'] .
": Wanted {$wanted}, got {$pt} at param {$pno})");
}
}
}
}
}
//-------------------------------------
// Calls the Function
//-------------------------------------
if ($objectCall === TRUE)
{
if ($method_parts[0] == "this" && $system_call == TRUE)
{
return call_user_func(array($this, $method_parts[1]), $m);
}
else
{
if ($this->object === FALSE)
{
$CI =& get_instance();
return $CI->$method_parts['1']($m);
}
else
{
return $this->object->$method_parts['1']($m);
//return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
}
}
}
else
{
return call_user_func($this->methods[$methName]['function'], $m);
}
}
// --------------------------------------------------------------------
/**
* Server Function: List Methods
*
* @access public
* @param mixed
* @return object
*/
function listMethods($m)
{
$v = new XML_RPC_Values();
$output = array();
foreach ($this->methods as $key => $value)
{
$output[] = new XML_RPC_Values($key, 'string');
}
foreach ($this->system_methods as $key => $value)
{
$output[]= new XML_RPC_Values($key, 'string');
}
$v->addArray($output);
return new XML_RPC_Response($v);
}
// --------------------------------------------------------------------
/**
* Server Function: Return Signature for Method
*
* @access public
* @param mixed
* @return object
*/
function methodSignature($m)
{
$parameters = $m->output_parameters();
$method_name = $parameters[0];
if (isset($this->methods[$method_name]))
{
if ($this->methods[$method_name]['signature'])
{
$sigs = array();
$signature = $this->methods[$method_name]['signature'];
for ($i=0; $i < count($signature); $i++)
{
$cursig = array();
$inSig = $signature[$i];
for ($j=0; $j<count($inSig); $j++)
{
$cursig[]= new XML_RPC_Values($inSig[$j], 'string');
}
$sigs[]= new XML_RPC_Values($cursig, 'array');
}
$r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
}
else
{
$r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
}
}
else
{
$r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
return $r;
}
// --------------------------------------------------------------------
/**
* Server Function: Doc String for Method
*
* @access public
* @param mixed
* @return object
*/
function methodHelp($m)
{
$parameters = $m->output_parameters();
$method_name = $parameters[0];
if (isset($this->methods[$method_name]))
{
$docstring = isset($this->methods[$method_name]['docstring']) ? $this->methods[$method_name]['docstring'] : '';
return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
}
else
{
return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
}
// --------------------------------------------------------------------
/**
* Server Function: Multi-call
*
* @access public
* @param mixed
* @return object
*/
function multicall($m)
{
// Disabled
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
$parameters = $m->output_parameters();
$calls = $parameters[0];
$result = array();
foreach ($calls as $value)
{
//$attempt = $this->_execute(new XML_RPC_Message($value[0], $value[1]));
$m = new XML_RPC_Message($value[0]);
$plist='';
for ($i=0; $i < count($value[1]); $i++)
{
$m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
}
$attempt = $this->_execute($m);
if ($attempt->faultCode() != 0)
{
return $attempt;
}
$result[] = new XML_RPC_Values(array($attempt->value()), 'array');
}
return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
}
// --------------------------------------------------------------------
/**
* Multi-call Function: Error Handling
*
* @access public
* @param mixed
* @return object
*/
function multicall_error($err)
{
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
$code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
$struct['faultCode'] = new XML_RPC_Values($code, 'int');
$struct['faultString'] = new XML_RPC_Values($str, 'string');
return new XML_RPC_Values($struct, 'struct');
}
// --------------------------------------------------------------------
/**
* Multi-call Function: Processes method
*
* @access public
* @param mixed
* @return object
*/
function do_multicall($call)
{
if ($call->kindOf() != 'struct')
{
return $this->multicall_error('notstruct');
}
elseif ( ! $methName = $call->me['struct']['methodName'])
{
return $this->multicall_error('nomethod');
}
list($scalar_type,$scalar_value)=each($methName->me);
$scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string')
{
return $this->multicall_error('notstring');
}
elseif ($scalar_value == 'system.multicall')
{
return $this->multicall_error('recursion');
}
elseif ( ! $params = $call->me['struct']['params'])
{
return $this->multicall_error('noparams');
}
elseif ($params->kindOf() != 'array')
{
return $this->multicall_error('notarray');
}
list($a,$b)=each($params->me);
$numParams = count($b);
$msg = new XML_RPC_Message($scalar_value);
for ($i = 0; $i < $numParams; $i++)
{
$msg->params[] = $params->me['array'][$i];
}
$result = $this->_execute($msg);
if ($result->faultCode() != 0)
{
return $this->multicall_error($result);
}
return new XML_RPC_Values(array($result->value()), 'array');
}
}
// END XML_RPC_Server class
/* End of file Xmlrpcs.php */
/* Location: ./system/libraries/Xmlrpcs.php */ | 069h-course-management | trunk/ci/system/libraries/Xmlrpcs.php | PHP | mit | 15,552 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Common Functions
*
* Loads the base classes and executes the request.
*
* @package CodeIgniter
* @subpackage codeigniter
* @category Common Functions
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/
*/
// ------------------------------------------------------------------------
/**
* Determines if the current version of PHP is greater then the supplied value
*
* Since there are a few places where we conditionally test for PHP > 5
* we'll set a static variable.
*
* @access public
* @param string
* @return bool TRUE if the current version is $version or higher
*/
if ( ! function_exists('is_php'))
{
function is_php($version = '5.0.0')
{
static $_is_php;
$version = (string)$version;
if ( ! isset($_is_php[$version]))
{
$_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
}
return $_is_php[$version];
}
}
// ------------------------------------------------------------------------
/**
* Tests for file writability
*
* is_writable() returns TRUE on Windows servers when you really can't write to
* the file, based on the read-only attribute. is_writable() is also unreliable
* on Unix servers if safe_mode is on.
*
* @access private
* @return void
*/
if ( ! function_exists('is_really_writable'))
{
function is_really_writable($file)
{
// If we're on a Unix server with safe_mode off we call is_writable
if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE)
{
return is_writable($file);
}
// For windows servers and safe_mode "on" installations we'll actually
// write a file then read it. Bah...
if (is_dir($file))
{
$file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100));
if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
{
return FALSE;
}
fclose($fp);
@chmod($file, DIR_WRITE_MODE);
@unlink($file);
return TRUE;
}
elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
{
return FALSE;
}
fclose($fp);
return TRUE;
}
}
// ------------------------------------------------------------------------
/**
* Class registry
*
* This function acts as a singleton. If the requested class does not
* exist it is instantiated and set to a static variable. If it has
* previously been instantiated the variable is returned.
*
* @access public
* @param string the class name being requested
* @param string the directory where the class should be found
* @param string the class name prefix
* @return object
*/
if ( ! function_exists('load_class'))
{
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
static $_classes = array();
// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}
$name = FALSE;
// Look for the class first in the local application/libraries folder
// then in the native system/libraries folder
foreach (array(APPPATH, BASEPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = $prefix.$class;
if (class_exists($name) === FALSE)
{
require($path.$directory.'/'.$class.'.php');
}
break;
}
}
// Is the request a class extension? If so we load it too
if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
{
$name = config_item('subclass_prefix').$class;
if (class_exists($name) === FALSE)
{
require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
}
}
// Did we find the class?
if ($name === FALSE)
{
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Excptions class
exit('Unable to locate the specified class: '.$class.'.php');
}
// Keep track of what we just loaded
is_loaded($class);
$_classes[$class] = new $name();
return $_classes[$class];
}
}
// --------------------------------------------------------------------
/**
* Keeps track of which libraries have been loaded. This function is
* called by the load_class() function above
*
* @access public
* @return array
*/
if ( ! function_exists('is_loaded'))
{
function &is_loaded($class = '')
{
static $_is_loaded = array();
if ($class != '')
{
$_is_loaded[strtolower($class)] = $class;
}
return $_is_loaded;
}
}
// ------------------------------------------------------------------------
/**
* Loads the main config.php file
*
* This function lets us grab the config file even if the Config class
* hasn't been instantiated yet
*
* @access private
* @return array
*/
if ( ! function_exists('get_config'))
{
function &get_config($replace = array())
{
static $_config;
if (isset($_config))
{
return $_config[0];
}
// Is the config file in the environment folder?
if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
{
$file_path = APPPATH.'config/config.php';
}
// Fetch the config file
if ( ! file_exists($file_path))
{
exit('The configuration file does not exist.');
}
require($file_path);
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
exit('Your config file does not appear to be formatted correctly.');
}
// Are any values being dynamically replaced?
if (count($replace) > 0)
{
foreach ($replace as $key => $val)
{
if (isset($config[$key]))
{
$config[$key] = $val;
}
}
}
return $_config[0] =& $config;
}
}
// ------------------------------------------------------------------------
/**
* Returns the specified config item
*
* @access public
* @return mixed
*/
if ( ! function_exists('config_item'))
{
function config_item($item)
{
static $_config_item = array();
if ( ! isset($_config_item[$item]))
{
$config =& get_config();
if ( ! isset($config[$item]))
{
return FALSE;
}
$_config_item[$item] = $config[$item];
}
return $_config_item[$item];
}
}
// ------------------------------------------------------------------------
/**
* Error Handler
*
* This function lets us invoke the exception class and
* display errors using the standard error template located
* in application/errors/errors.php
* This function will send the error page directly to the
* browser and exit.
*
* @access public
* @return void
*/
if ( ! function_exists('show_error'))
{
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
{
$_error =& load_class('Exceptions', 'core');
echo $_error->show_error($heading, $message, 'error_general', $status_code);
exit;
}
}
// ------------------------------------------------------------------------
/**
* 404 Page Handler
*
* This function is similar to the show_error() function above
* However, instead of the standard error template it displays
* 404 errors.
*
* @access public
* @return void
*/
if ( ! function_exists('show_404'))
{
function show_404($page = '', $log_error = TRUE)
{
$_error =& load_class('Exceptions', 'core');
$_error->show_404($page, $log_error);
exit;
}
}
// ------------------------------------------------------------------------
/**
* Error Logging Interface
*
* We use this as a simple mechanism to access the logging
* class and send messages to be logged.
*
* @access public
* @return void
*/
if ( ! function_exists('log_message'))
{
function log_message($level = 'error', $message, $php_error = FALSE)
{
static $_log;
if (config_item('log_threshold') == 0)
{
return;
}
$_log =& load_class('Log');
$_log->write_log($level, $message, $php_error);
}
}
// ------------------------------------------------------------------------
/**
* Set HTTP Status Header
*
* @access public
* @param int the status code
* @param string
* @return void
*/
if ( ! function_exists('set_status_header'))
{
function set_status_header($code = 200, $text = '')
{
$stati = array(
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
304 => 'Not Modified',
305 => 'Use Proxy',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported'
);
if ($code == '' OR ! is_numeric($code))
{
show_error('Status codes must be numeric', 500);
}
if (isset($stati[$code]) AND $text == '')
{
$text = $stati[$code];
}
if ($text == '')
{
show_error('No status text available. Please check your status code number or supply your own message text.', 500);
}
$server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
if (substr(php_sapi_name(), 0, 3) == 'cgi')
{
header("Status: {$code} {$text}", TRUE);
}
elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
{
header($server_protocol." {$code} {$text}", TRUE, $code);
}
else
{
header("HTTP/1.1 {$code} {$text}", TRUE, $code);
}
}
}
// --------------------------------------------------------------------
/**
* Exception Handler
*
* This is the custom exception handler that is declaired at the top
* of Codeigniter.php. The main reason we use this is to permit
* PHP errors to be logged in our own log files since the user may
* not have access to server logs. Since this function
* effectively intercepts PHP errors, however, we also need
* to display errors based on the current error_reporting level.
* We do that with the use of a PHP error template.
*
* @access private
* @return void
*/
if ( ! function_exists('_exception_handler'))
{
function _exception_handler($severity, $message, $filepath, $line)
{
// We don't bother with "strict" notices since they tend to fill up
// the log file with excess information that isn't normally very helpful.
// For example, if you are running PHP 5 and you use version 4 style
// class functions (without prefixes like "public", "private", etc.)
// you'll get notices telling you that these have been deprecated.
if ($severity == E_STRICT)
{
return;
}
$_error =& load_class('Exceptions', 'core');
// Should we display the error? We'll get the current error_reporting
// level and add its bits with the severity bits to find out.
if (($severity & error_reporting()) == $severity)
{
$_error->show_php_error($severity, $message, $filepath, $line);
}
// Should we log the error? No? We're done...
if (config_item('log_threshold') == 0)
{
return;
}
$_error->log_exception($severity, $message, $filepath, $line);
}
}
// --------------------------------------------------------------------
/**
* Remove Invisible Characters
*
* This prevents sandwiching null characters
* between ascii characters, like Java\0script.
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('remove_invisible_characters'))
{
function remove_invisible_characters($str, $url_encoded = TRUE)
{
$non_displayables = array();
// every control character except newline (dec 10)
// carriage return (dec 13), and horizontal tab (dec 09)
if ($url_encoded)
{
$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
}
$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
do
{
$str = preg_replace($non_displayables, '', $str, -1, $count);
}
while ($count);
return $str;
}
}
// ------------------------------------------------------------------------
/**
* Returns HTML escaped variable
*
* @access public
* @param mixed
* @return mixed
*/
if ( ! function_exists('html_escape'))
{
function html_escape($var)
{
if (is_array($var))
{
return array_map('html_escape', $var);
}
else
{
return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
}
}
}
/* End of file Common.php */
/* Location: ./system/core/Common.php */ | 069h-course-management | trunk/ci/system/core/Common.php | PHP | mit | 13,417 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* System Initialization File
*
* Loads the base classes and executes the request.
*
* @package CodeIgniter
* @subpackage codeigniter
* @category Front-controller
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/
*/
/**
* CodeIgniter Version
*
* @var string
*
*/
define('CI_VERSION', '2.1.3');
/**
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
*
* @var boolean
*
*/
define('CI_CORE', FALSE);
/*
* ------------------------------------------------------
* Load the global functions
* ------------------------------------------------------
*/
require(BASEPATH.'core/Common.php');
/*
* ------------------------------------------------------
* Load the framework constants
* ------------------------------------------------------
*/
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
{
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
}
else
{
require(APPPATH.'config/constants.php');
}
/*
* ------------------------------------------------------
* Define a custom error handler so we can log PHP errors
* ------------------------------------------------------
*/
set_error_handler('_exception_handler');
if ( ! is_php('5.3'))
{
@set_magic_quotes_runtime(0); // Kill magic quotes
}
/*
* ------------------------------------------------------
* Set the subclass_prefix
* ------------------------------------------------------
*
* Normally the "subclass_prefix" is set in the config file.
* The subclass prefix allows CI to know if a core class is
* being extended via a library in the local application
* "libraries" folder. Since CI allows config items to be
* overriden via data set in the main index. php file,
* before proceeding we need to know if a subclass_prefix
* override exists. If so, we will set this value now,
* before any classes are loaded
* Note: Since the config file data is cached it doesn't
* hurt to load it here.
*/
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
/*
* ------------------------------------------------------
* Set a liberal script execution time limit
* ------------------------------------------------------
*/
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
@set_time_limit(300);
}
/*
* ------------------------------------------------------
* Start the timer... tick tock tick tock...
* ------------------------------------------------------
*/
$BM =& load_class('Benchmark', 'core');
$BM->mark('total_execution_time_start');
$BM->mark('loading_time:_base_classes_start');
/*
* ------------------------------------------------------
* Instantiate the hooks class
* ------------------------------------------------------
*/
$EXT =& load_class('Hooks', 'core');
/*
* ------------------------------------------------------
* Is there a "pre_system" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_system');
/*
* ------------------------------------------------------
* Instantiate the config class
* ------------------------------------------------------
*/
$CFG =& load_class('Config', 'core');
// Do we have any manually set config items in the index.php file?
if (isset($assign_to_config))
{
$CFG->_assign_to_config($assign_to_config);
}
/*
* ------------------------------------------------------
* Instantiate the UTF-8 class
* ------------------------------------------------------
*
* Note: Order here is rather important as the UTF-8
* class needs to be used very early on, but it cannot
* properly determine if UTf-8 can be supported until
* after the Config class is instantiated.
*
*/
$UNI =& load_class('Utf8', 'core');
/*
* ------------------------------------------------------
* Instantiate the URI class
* ------------------------------------------------------
*/
$URI =& load_class('URI', 'core');
/*
* ------------------------------------------------------
* Instantiate the routing class and set the routing
* ------------------------------------------------------
*/
$RTR =& load_class('Router', 'core');
$RTR->_set_routing();
// Set any routing overrides that may exist in the main index file
if (isset($routing))
{
$RTR->_set_overrides($routing);
}
/*
* ------------------------------------------------------
* Instantiate the output class
* ------------------------------------------------------
*/
$OUT =& load_class('Output', 'core');
/*
* ------------------------------------------------------
* Is there a valid cache file? If so, we're done...
* ------------------------------------------------------
*/
if ($EXT->_call_hook('cache_override') === FALSE)
{
if ($OUT->_display_cache($CFG, $URI) == TRUE)
{
exit;
}
}
/*
* -----------------------------------------------------
* Load the security class for xss and csrf support
* -----------------------------------------------------
*/
$SEC =& load_class('Security', 'core');
/*
* ------------------------------------------------------
* Load the Input class and sanitize globals
* ------------------------------------------------------
*/
$IN =& load_class('Input', 'core');
/*
* ------------------------------------------------------
* Load the Language class
* ------------------------------------------------------
*/
$LANG =& load_class('Lang', 'core');
/*
* ------------------------------------------------------
* Load the app controller and local controller
* ------------------------------------------------------
*
*/
// Load the base controller class
require BASEPATH.'core/Controller.php';
function &get_instance()
{
return CI_Controller::get_instance();
}
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
{
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
}
// Load the local application controller
// Note: The Router class automatically validates the controller path using the router->_validate_request().
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
// Set a mark point for benchmarking
$BM->mark('loading_time:_base_classes_end');
/*
* ------------------------------------------------------
* Security check
* ------------------------------------------------------
*
* None of the functions in the app controller or the
* loader class can be called via the URI, nor can
* controller functions that begin with an underscore
*/
$class = $RTR->fetch_class();
$method = $RTR->fetch_method();
if ( ! class_exists($class)
OR strncmp($method, '_', 1) == 0
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
)
{
if ( ! empty($RTR->routes['404_override']))
{
$x = explode('/', $RTR->routes['404_override']);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
show_404("{$class}/{$method}");
}
include_once(APPPATH.'controllers/'.$class.'.php');
}
}
else
{
show_404("{$class}/{$method}");
}
}
/*
* ------------------------------------------------------
* Is there a "pre_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_controller');
/*
* ------------------------------------------------------
* Instantiate the requested controller
* ------------------------------------------------------
*/
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
$CI = new $class();
/*
* ------------------------------------------------------
* Is there a "post_controller_constructor" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_controller_constructor');
/*
* ------------------------------------------------------
* Call the requested method
* ------------------------------------------------------
*/
// Is there a "remap" function? If so, we call it instead
if (method_exists($CI, '_remap'))
{
$CI->_remap($method, array_slice($URI->rsegments, 2));
}
else
{
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
// methods, so we'll use this workaround for consistent behavior
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
{
// Check and see if we are using a 404 override and use it.
if ( ! empty($RTR->routes['404_override']))
{
$x = explode('/', $RTR->routes['404_override']);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
show_404("{$class}/{$method}");
}
include_once(APPPATH.'controllers/'.$class.'.php');
unset($CI);
$CI = new $class();
}
}
else
{
show_404("{$class}/{$method}");
}
}
// Call the requested method.
// Any URI segments present (besides the class/function) will be passed to the method for convenience
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
}
// Mark a benchmark end point
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
/*
* ------------------------------------------------------
* Is there a "post_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_controller');
/*
* ------------------------------------------------------
* Send the final rendered output to the browser
* ------------------------------------------------------
*/
if ($EXT->_call_hook('display_override') === FALSE)
{
$OUT->_display();
}
/*
* ------------------------------------------------------
* Is there a "post_system" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_system');
/*
* ------------------------------------------------------
* Close the DB connection if one exists
* ------------------------------------------------------
*/
if (class_exists('CI_DB') AND isset($CI->db))
{
$CI->db->close();
}
/* End of file CodeIgniter.php */
/* Location: ./system/core/CodeIgniter.php */ | 069h-course-management | trunk/ci/system/core/CodeIgniter.php | PHP | mit | 11,392 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 069h-course-management | trunk/ci/system/core/index.html | HTML | mit | 114 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Benchmark Class
*
* This class enables you to mark points and calculate the time difference
* between them. Memory consumption can also be displayed.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/benchmark.html
*/
class CI_Benchmark {
/**
* List of all benchmark markers and when they were added
*
* @var array
*/
var $marker = array();
// --------------------------------------------------------------------
/**
* Set a benchmark marker
*
* Multiple calls to this function can be made so that several
* execution points can be timed
*
* @access public
* @param string $name name of the marker
* @return void
*/
function mark($name)
{
$this->marker[$name] = microtime();
}
// --------------------------------------------------------------------
/**
* Calculates the time difference between two marked points.
*
* If the first parameter is empty this function instead returns the
* {elapsed_time} pseudo-variable. This permits the full system
* execution time to be shown in a template. The output class will
* swap the real value for this variable.
*
* @access public
* @param string a particular marked point
* @param string a particular marked point
* @param integer the number of decimal places
* @return mixed
*/
function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
{
if ($point1 == '')
{
return '{elapsed_time}';
}
if ( ! isset($this->marker[$point1]))
{
return '';
}
if ( ! isset($this->marker[$point2]))
{
$this->marker[$point2] = microtime();
}
list($sm, $ss) = explode(' ', $this->marker[$point1]);
list($em, $es) = explode(' ', $this->marker[$point2]);
return number_format(($em + $es) - ($sm + $ss), $decimals);
}
// --------------------------------------------------------------------
/**
* Memory Usage
*
* This function returns the {memory_usage} pseudo-variable.
* This permits it to be put it anywhere in a template
* without the memory being calculated until the end.
* The output class will swap the real value for this variable.
*
* @access public
* @return string
*/
function memory_usage()
{
return '{memory_usage}';
}
}
// END CI_Benchmark class
/* End of file Benchmark.php */
/* Location: ./system/core/Benchmark.php */ | 069h-course-management | trunk/ci/system/core/Benchmark.php | PHP | mit | 2,949 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Exceptions Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Exceptions
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/exceptions.html
*/
class CI_Exceptions {
var $action;
var $severity;
var $message;
var $filename;
var $line;
/**
* Nesting level of the output buffering mechanism
*
* @var int
* @access public
*/
var $ob_level;
/**
* List if available error levels
*
* @var array
* @access public
*/
var $levels = array(
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
);
/**
* Constructor
*/
public function __construct()
{
$this->ob_level = ob_get_level();
// Note: Do not log messages from this constructor.
}
// --------------------------------------------------------------------
/**
* Exception Logger
*
* This function logs PHP generated error messages
*
* @access private
* @param string the error severity
* @param string the error string
* @param string the error filepath
* @param string the error line number
* @return string
*/
function log_exception($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
}
// --------------------------------------------------------------------
/**
* 404 Page Not Found Handler
*
* @access private
* @param string the page
* @param bool log error yes/no
* @return string
*/
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
// --------------------------------------------------------------------
/**
* General Error Page
*
* This function takes an error message as input
* (either as a string or an array) and displays
* it using the specified template.
*
* @access private
* @param string the heading
* @param string the message
* @param string the template name
* @param int the status code
* @return string
*/
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
set_status_header($status_code);
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/'.$template.'.php');
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
// --------------------------------------------------------------------
/**
* Native PHP error handler
*
* @access private
* @param string the error severity
* @param string the error string
* @param string the error filepath
* @param string the error line number
* @return string
*/
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/error_php.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
}
// END Exceptions Class
/* End of file Exceptions.php */
/* Location: ./system/core/Exceptions.php */ | 069h-course-management | trunk/ci/system/core/Exceptions.php | PHP | mit | 4,695 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Router Class
*
* Parses URIs and determines routing
*
* @package CodeIgniter
* @subpackage Libraries
* @author ExpressionEngine Dev Team
* @category Libraries
* @link http://codeigniter.com/user_guide/general/routing.html
*/
class CI_Router {
/**
* Config class
*
* @var object
* @access public
*/
var $config;
/**
* List of routes
*
* @var array
* @access public
*/
var $routes = array();
/**
* List of error routes
*
* @var array
* @access public
*/
var $error_routes = array();
/**
* Current class name
*
* @var string
* @access public
*/
var $class = '';
/**
* Current method name
*
* @var string
* @access public
*/
var $method = 'index';
/**
* Sub-directory that contains the requested controller class
*
* @var string
* @access public
*/
var $directory = '';
/**
* Default controller (and method if specific)
*
* @var string
* @access public
*/
var $default_controller;
/**
* Constructor
*
* Runs the route mapping function.
*/
function __construct()
{
$this->config =& load_class('Config', 'core');
$this->uri =& load_class('URI', 'core');
log_message('debug', "Router Class Initialized");
}
// --------------------------------------------------------------------
/**
* Set the route mapping
*
* This function determines what should be served based on the URI request,
* as well as any "routes" that have been set in the routing config file.
*
* @access private
* @return void
*/
function _set_routing()
{
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
// since URI segments are more search-engine friendly, but they can optionally be used.
// If this feature is enabled, we will gather the directory/class/method a little differently
$segments = array();
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
{
if (isset($_GET[$this->config->item('directory_trigger')]))
{
$this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
$segments[] = $this->fetch_directory();
}
if (isset($_GET[$this->config->item('controller_trigger')]))
{
$this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
$segments[] = $this->fetch_class();
}
if (isset($_GET[$this->config->item('function_trigger')]))
{
$this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
$segments[] = $this->fetch_method();
}
}
// Load the routes.php file.
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
elseif (is_file(APPPATH.'config/routes.php'))
{
include(APPPATH.'config/routes.php');
}
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
// Set the default controller so we can display it in the event
// the URI doesn't correlated to a valid controller.
$this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
// Were there any query string segments? If so, we'll validate them and bail out since we're done.
if (count($segments) > 0)
{
return $this->_validate_request($segments);
}
// Fetch the complete URI string
$this->uri->_fetch_uri_string();
// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
if ($this->uri->uri_string == '')
{
return $this->_set_default_controller();
}
// Do we need to remove the URL suffix?
$this->uri->_remove_url_suffix();
// Compile the segments into an array
$this->uri->_explode_segments();
// Parse any custom routing that may exist
$this->_parse_routes();
// Re-index the segment array so that it starts with 1 rather than 0
$this->uri->_reindex_segments();
}
// --------------------------------------------------------------------
/**
* Set the default controller
*
* @access private
* @return void
*/
function _set_default_controller()
{
if ($this->default_controller === FALSE)
{
show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
}
// Is the method being specified?
if (strpos($this->default_controller, '/') !== FALSE)
{
$x = explode('/', $this->default_controller);
$this->set_class($x[0]);
$this->set_method($x[1]);
$this->_set_request($x);
}
else
{
$this->set_class($this->default_controller);
$this->set_method('index');
$this->_set_request(array($this->default_controller, 'index'));
}
// re-index the routed segments array so it starts with 1 rather than 0
$this->uri->_reindex_segments();
log_message('debug', "No URI present. Default controller set.");
}
// --------------------------------------------------------------------
/**
* Set the Route
*
* This function takes an array of URI segments as
* input, and sets the current class/method
*
* @access private
* @param array
* @param bool
* @return void
*/
function _set_request($segments = array())
{
$segments = $this->_validate_request($segments);
if (count($segments) == 0)
{
return $this->_set_default_controller();
}
$this->set_class($segments[0]);
if (isset($segments[1]))
{
// A standard method request
$this->set_method($segments[1]);
}
else
{
// This lets the "routed" segment array identify that the default
// index method is being used.
$segments[1] = 'index';
}
// Update our "routed" segment array to contain the segments.
// Note: If there is no custom routing, this array will be
// identical to $this->uri->segments
$this->uri->rsegments = $segments;
}
// --------------------------------------------------------------------
/**
* Validates the supplied segments. Attempts to determine the path to
* the controller.
*
* @access private
* @param array
* @return array
*/
function _validate_request($segments)
{
if (count($segments) == 0)
{
return $segments;
}
// Does the requested controller exist in the root folder?
if (file_exists(APPPATH.'controllers/'.$segments[0].'.php'))
{
return $segments;
}
// Is the controller in a sub-folder?
if (is_dir(APPPATH.'controllers/'.$segments[0]))
{
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);
if (count($segments) > 0)
{
// Does the requested controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
{
if ( ! empty($this->routes['404_override']))
{
$x = explode('/', $this->routes['404_override']);
$this->set_directory('');
$this->set_class($x[0]);
$this->set_method(isset($x[1]) ? $x[1] : 'index');
return $x;
}
else
{
show_404($this->fetch_directory().$segments[0]);
}
}
}
else
{
// Is the method being specified in the route?
if (strpos($this->default_controller, '/') !== FALSE)
{
$x = explode('/', $this->default_controller);
$this->set_class($x[0]);
$this->set_method($x[1]);
}
else
{
$this->set_class($this->default_controller);
$this->set_method('index');
}
// Does the default controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php'))
{
$this->directory = '';
return array();
}
}
return $segments;
}
// If we've gotten this far it means that the URI does not correlate to a valid
// controller class. We will now see if there is an override
if ( ! empty($this->routes['404_override']))
{
$x = explode('/', $this->routes['404_override']);
$this->set_class($x[0]);
$this->set_method(isset($x[1]) ? $x[1] : 'index');
return $x;
}
// Nothing else to do at this point but show a 404
show_404($segments[0]);
}
// --------------------------------------------------------------------
/**
* Parse Routes
*
* This function matches any routes that may exist in
* the config/routes.php file against the URI to
* determine if the class/method need to be remapped.
*
* @access private
* @return void
*/
function _parse_routes()
{
// Turn the segment array into a URI string
$uri = implode('/', $this->uri->segments);
// Is there a literal match? If so we're done
if (isset($this->routes[$uri]))
{
return $this->_set_request(explode('/', $this->routes[$uri]));
}
// Loop through the route array looking for wild-cards
foreach ($this->routes as $key => $val)
{
// Convert wild-cards to RegEx
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
// Does the RegEx match?
if (preg_match('#^'.$key.'$#', $uri))
{
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
{
$val = preg_replace('#^'.$key.'$#', $val, $uri);
}
return $this->_set_request(explode('/', $val));
}
}
// If we got this far it means we didn't encounter a
// matching route so we'll set the site default route
$this->_set_request($this->uri->segments);
}
// --------------------------------------------------------------------
/**
* Set the class name
*
* @access public
* @param string
* @return void
*/
function set_class($class)
{
$this->class = str_replace(array('/', '.'), '', $class);
}
// --------------------------------------------------------------------
/**
* Fetch the current class
*
* @access public
* @return string
*/
function fetch_class()
{
return $this->class;
}
// --------------------------------------------------------------------
/**
* Set the method name
*
* @access public
* @param string
* @return void
*/
function set_method($method)
{
$this->method = $method;
}
// --------------------------------------------------------------------
/**
* Fetch the current method
*
* @access public
* @return string
*/
function fetch_method()
{
if ($this->method == $this->fetch_class())
{
return 'index';
}
return $this->method;
}
// --------------------------------------------------------------------
/**
* Set the directory name
*
* @access public
* @param string
* @return void
*/
function set_directory($dir)
{
$this->directory = str_replace(array('/', '.'), '', $dir).'/';
}
// --------------------------------------------------------------------
/**
* Fetch the sub-directory (if any) that contains the requested controller class
*
* @access public
* @return string
*/
function fetch_directory()
{
return $this->directory;
}
// --------------------------------------------------------------------
/**
* Set the controller overrides
*
* @access public
* @param array
* @return null
*/
function _set_overrides($routing)
{
if ( ! is_array($routing))
{
return;
}
if (isset($routing['directory']))
{
$this->set_directory($routing['directory']);
}
if (isset($routing['controller']) AND $routing['controller'] != '')
{
$this->set_class($routing['controller']);
}
if (isset($routing['function']))
{
$routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
$this->set_method($routing['function']);
}
}
}
// END Router Class
/* End of file Router.php */
/* Location: ./system/core/Router.php */ | 069h-course-management | trunk/ci/system/core/Router.php | PHP | mit | 12,394 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Output Class
*
* Responsible for sending final output to browser
*
* @package CodeIgniter
* @subpackage Libraries
* @category Output
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/output.html
*/
class CI_Output {
/**
* Current output string
*
* @var string
* @access protected
*/
protected $final_output;
/**
* Cache expiration time
*
* @var int
* @access protected
*/
protected $cache_expiration = 0;
/**
* List of server headers
*
* @var array
* @access protected
*/
protected $headers = array();
/**
* List of mime types
*
* @var array
* @access protected
*/
protected $mime_types = array();
/**
* Determines wether profiler is enabled
*
* @var book
* @access protected
*/
protected $enable_profiler = FALSE;
/**
* Determines if output compression is enabled
*
* @var bool
* @access protected
*/
protected $_zlib_oc = FALSE;
/**
* List of profiler sections
*
* @var array
* @access protected
*/
protected $_profiler_sections = array();
/**
* Whether or not to parse variables like {elapsed_time} and {memory_usage}
*
* @var bool
* @access protected
*/
protected $parse_exec_vars = TRUE;
/**
* Constructor
*
*/
function __construct()
{
$this->_zlib_oc = @ini_get('zlib.output_compression');
// Get mime types for later
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
}
else
{
include APPPATH.'config/mimes.php';
}
$this->mime_types = $mimes;
log_message('debug', "Output Class Initialized");
}
// --------------------------------------------------------------------
/**
* Get Output
*
* Returns the current output string
*
* @access public
* @return string
*/
function get_output()
{
return $this->final_output;
}
// --------------------------------------------------------------------
/**
* Set Output
*
* Sets the output string
*
* @access public
* @param string
* @return void
*/
function set_output($output)
{
$this->final_output = $output;
return $this;
}
// --------------------------------------------------------------------
/**
* Append Output
*
* Appends data onto the output string
*
* @access public
* @param string
* @return void
*/
function append_output($output)
{
if ($this->final_output == '')
{
$this->final_output = $output;
}
else
{
$this->final_output .= $output;
}
return $this;
}
// --------------------------------------------------------------------
/**
* Set Header
*
* Lets you set a server header which will be outputted with the final display.
*
* Note: If a file is cached, headers will not be sent. We need to figure out
* how to permit header data to be saved with the cache data...
*
* @access public
* @param string
* @param bool
* @return void
*/
function set_header($header, $replace = TRUE)
{
// If zlib.output_compression is enabled it will compress the output,
// but it will not modify the content-length header to compensate for
// the reduction, causing the browser to hang waiting for more data.
// We'll just skip content-length in those cases.
if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0)
{
return;
}
$this->headers[] = array($header, $replace);
return $this;
}
// --------------------------------------------------------------------
/**
* Set Content Type Header
*
* @access public
* @param string extension of the file we're outputting
* @return void
*/
function set_content_type($mime_type)
{
if (strpos($mime_type, '/') === FALSE)
{
$extension = ltrim($mime_type, '.');
// Is this extension supported?
if (isset($this->mime_types[$extension]))
{
$mime_type =& $this->mime_types[$extension];
if (is_array($mime_type))
{
$mime_type = current($mime_type);
}
}
}
$header = 'Content-Type: '.$mime_type;
$this->headers[] = array($header, TRUE);
return $this;
}
// --------------------------------------------------------------------
/**
* Set HTTP Status Header
* moved to Common procedural functions in 1.7.2
*
* @access public
* @param int the status code
* @param string
* @return void
*/
function set_status_header($code = 200, $text = '')
{
set_status_header($code, $text);
return $this;
}
// --------------------------------------------------------------------
/**
* Enable/disable Profiler
*
* @access public
* @param bool
* @return void
*/
function enable_profiler($val = TRUE)
{
$this->enable_profiler = (is_bool($val)) ? $val : TRUE;
return $this;
}
// --------------------------------------------------------------------
/**
* Set Profiler Sections
*
* Allows override of default / config settings for Profiler section display
*
* @access public
* @param array
* @return void
*/
function set_profiler_sections($sections)
{
foreach ($sections as $section => $enable)
{
$this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE;
}
return $this;
}
// --------------------------------------------------------------------
/**
* Set Cache
*
* @access public
* @param integer
* @return void
*/
function cache($time)
{
$this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
return $this;
}
// --------------------------------------------------------------------
/**
* Display Output
*
* All "view" data is automatically put into this variable by the controller class:
*
* $this->final_output
*
* This function sends the finalized output data to the browser along
* with any server headers and profile data. It also stops the
* benchmark timer so the page rendering speed and memory usage can be shown.
*
* @access public
* @param string
* @return mixed
*/
function _display($output = '')
{
// Note: We use globals because we can't use $CI =& get_instance()
// since this function is sometimes called by the caching mechanism,
// which happens before the CI super object is available.
global $BM, $CFG;
// Grab the super object if we can.
if (class_exists('CI_Controller'))
{
$CI =& get_instance();
}
// --------------------------------------------------------------------
// Set the output data
if ($output == '')
{
$output =& $this->final_output;
}
// --------------------------------------------------------------------
// Do we need to write a cache file? Only if the controller does not have its
// own _output() method and we are not dealing with a cache file, which we
// can determine by the existence of the $CI object above
if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
{
$this->_write_cache($output);
}
// --------------------------------------------------------------------
// Parse out the elapsed time and memory usage,
// then swap the pseudo-variables with the data
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
if ($this->parse_exec_vars === TRUE)
{
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{elapsed_time}', $elapsed, $output);
$output = str_replace('{memory_usage}', $memory, $output);
}
// --------------------------------------------------------------------
// Is compression requested?
if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
{
if (extension_loaded('zlib'))
{
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
{
ob_start('ob_gzhandler');
}
}
}
// --------------------------------------------------------------------
// Are there any server headers to send?
if (count($this->headers) > 0)
{
foreach ($this->headers as $header)
{
@header($header[0], $header[1]);
}
}
// --------------------------------------------------------------------
// Does the $CI object exist?
// If not we know we are dealing with a cache file so we'll
// simply echo out the data and exit.
if ( ! isset($CI))
{
echo $output;
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
return TRUE;
}
// --------------------------------------------------------------------
// Do we need to generate profile data?
// If so, load the Profile class and run it.
if ($this->enable_profiler == TRUE)
{
$CI->load->library('profiler');
if ( ! empty($this->_profiler_sections))
{
$CI->profiler->set_sections($this->_profiler_sections);
}
// If the output data contains closing </body> and </html> tags
// we will remove them and add them back after we insert the profile data
if (preg_match("|</body>.*?</html>|is", $output))
{
$output = preg_replace("|</body>.*?</html>|is", '', $output);
$output .= $CI->profiler->run();
$output .= '</body></html>';
}
else
{
$output .= $CI->profiler->run();
}
}
// --------------------------------------------------------------------
// Does the controller contain a function named _output()?
// If so send the output there. Otherwise, echo it.
if (method_exists($CI, '_output'))
{
$CI->_output($output);
}
else
{
echo $output; // Send it to the browser!
}
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
}
// --------------------------------------------------------------------
/**
* Write a Cache File
*
* @access public
* @param string
* @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);
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 object config class
* @param object uri class
* @return void
*/
function _display_cache(&$CFG, &$URI)
{
$cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path');
// Build the file path. The file name is an MD5 hash of the full URI
$uri = $CFG->item('base_url').
$CFG->item('index_page').
$URI->uri_string;
$filepath = $cache_path.md5($uri);
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($cache_path))
{
@unlink($filepath);
log_message('debug', "Cache file has expired. File deleted");
return FALSE;
}
}
// Display the cache
$this->_display(str_replace($match['0'], '', $cache));
log_message('debug', "Cache file is current. Sending it to browser.");
return TRUE;
}
}
// END Output Class
/* End of file Output.php */
/* Location: ./system/core/Output.php */ | 069h-course-management | trunk/ci/system/core/Output.php | PHP | mit | 12,935 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Hooks Class
*
* Provides a mechanism to extend the base system without hacking.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/encryption.html
*/
class CI_Hooks {
/**
* Determines wether hooks are enabled
*
* @var bool
*/
var $enabled = FALSE;
/**
* List of all hooks set in config/hooks.php
*
* @var array
*/
var $hooks = array();
/**
* Determines wether hook is in progress, used to prevent infinte loops
*
* @var bool
*/
var $in_progress = FALSE;
/**
* Constructor
*
*/
function __construct()
{
$this->_initialize();
log_message('debug', "Hooks Class Initialized");
}
// --------------------------------------------------------------------
/**
* Initialize the Hooks Preferences
*
* @access private
* @return void
*/
function _initialize()
{
$CFG =& load_class('Config', 'core');
// If hooks are not enabled in the config file
// there is nothing else to do
if ($CFG->item('enable_hooks') == FALSE)
{
return;
}
// Grab the "hooks" definition file.
// If there are no hooks, we're done.
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
}
elseif (is_file(APPPATH.'config/hooks.php'))
{
include(APPPATH.'config/hooks.php');
}
if ( ! isset($hook) OR ! is_array($hook))
{
return;
}
$this->hooks =& $hook;
$this->enabled = TRUE;
}
// --------------------------------------------------------------------
/**
* Call Hook
*
* Calls a particular hook
*
* @access private
* @param string the hook name
* @return mixed
*/
function _call_hook($which = '')
{
if ( ! $this->enabled OR ! isset($this->hooks[$which]))
{
return FALSE;
}
if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
{
foreach ($this->hooks[$which] as $val)
{
$this->_run_hook($val);
}
}
else
{
$this->_run_hook($this->hooks[$which]);
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Run Hook
*
* Runs a particular hook
*
* @access private
* @param array the hook details
* @return bool
*/
function _run_hook($data)
{
if ( ! is_array($data))
{
return FALSE;
}
// -----------------------------------
// Safety - Prevents run-away loops
// -----------------------------------
// If the script being called happens to have the same
// hook call within it a loop can happen
if ($this->in_progress == TRUE)
{
return;
}
// -----------------------------------
// Set file path
// -----------------------------------
if ( ! isset($data['filepath']) OR ! isset($data['filename']))
{
return FALSE;
}
$filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
if ( ! file_exists($filepath))
{
return FALSE;
}
// -----------------------------------
// Set class/function name
// -----------------------------------
$class = FALSE;
$function = FALSE;
$params = '';
if (isset($data['class']) AND $data['class'] != '')
{
$class = $data['class'];
}
if (isset($data['function']))
{
$function = $data['function'];
}
if (isset($data['params']))
{
$params = $data['params'];
}
if ($class === FALSE AND $function === FALSE)
{
return FALSE;
}
// -----------------------------------
// Set the in_progress flag
// -----------------------------------
$this->in_progress = TRUE;
// -----------------------------------
// Call the requested class and/or function
// -----------------------------------
if ($class !== FALSE)
{
if ( ! class_exists($class))
{
require($filepath);
}
$HOOK = new $class;
$HOOK->$function($params);
}
else
{
if ( ! function_exists($function))
{
require($filepath);
}
$function($params);
}
$this->in_progress = FALSE;
return TRUE;
}
}
// END CI_Hooks class
/* End of file Hooks.php */
/* Location: ./system/core/Hooks.php */ | 069h-course-management | trunk/ci/system/core/Hooks.php | PHP | mit | 4,697 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Language Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Language
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/language.html
*/
class CI_Lang {
/**
* List of translations
*
* @var array
*/
var $language = array();
/**
* List of loaded language files
*
* @var array
*/
var $is_loaded = array();
/**
* Constructor
*
* @access public
*/
function __construct()
{
log_message('debug', "Language Class Initialized");
}
// --------------------------------------------------------------------
/**
* Load a language file
*
* @access public
* @param mixed the name of the language file to be loaded. Can be an array
* @param string the language (english, etc.)
* @param bool return loaded array of translations
* @param bool add suffix to $langfile
* @param string alternative path to look for language file
* @return mixed
*/
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
$langfile = str_replace('.php', '', $langfile);
if ($add_suffix == TRUE)
{
$langfile = str_replace('_lang.', '', $langfile).'_lang';
}
$langfile .= '.php';
if (in_array($langfile, $this->is_loaded, TRUE))
{
return;
}
$config =& get_config();
if ($idiom == '')
{
$deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
}
// Determine where the language file is and load it
if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
{
include($alt_path.'language/'.$idiom.'/'.$langfile);
}
else
{
$found = FALSE;
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
{
if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
{
include($package_path.'language/'.$idiom.'/'.$langfile);
$found = TRUE;
break;
}
}
if ($found !== TRUE)
{
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
}
}
if ( ! isset($lang))
{
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
return;
}
if ($return == TRUE)
{
return $lang;
}
$this->is_loaded[] = $langfile;
$this->language = array_merge($this->language, $lang);
unset($lang);
log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
return TRUE;
}
// --------------------------------------------------------------------
/**
* Fetch a single line of text from the language array
*
* @access public
* @param string $line the language line
* @return string
*/
function line($line = '')
{
$value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
// Because killer robots like unicorns!
if ($value === FALSE)
{
log_message('error', 'Could not find the language line "'.$line.'"');
}
return $value;
}
}
// END Language Class
/* End of file Lang.php */
/* Location: ./system/core/Lang.php */
| 069h-course-management | trunk/ci/system/core/Lang.php | PHP | mit | 3,632 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Config Class
*
* This class contains functions that enable config files to be managed
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/config.html
*/
class CI_Config {
/**
* List of all loaded config values
*
* @var array
*/
var $config = array();
/**
* List of all loaded config files
*
* @var array
*/
var $is_loaded = array();
/**
* List of paths to search when trying to load a config file
*
* @var array
*/
var $_config_paths = array(APPPATH);
/**
* Constructor
*
* Sets the $config data from the primary config.php file as a class variable
*
* @access public
* @param string the config file name
* @param boolean if configuration values should be loaded into their own section
* @param boolean true if errors should just return false, false if an error message should be displayed
* @return boolean if the file was successfully loaded or not
*/
function __construct()
{
$this->config =& get_config();
log_message('debug', "Config Class Initialized");
// Set the base_url automatically if none was provided
if ($this->config['base_url'] == '')
{
if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
else
{
$base_url = 'http://localhost/';
}
$this->set_item('base_url', $base_url);
}
}
// --------------------------------------------------------------------
/**
* Load Config File
*
* @access public
* @param string the config file name
* @param boolean if configuration values should be loaded into their own section
* @param boolean true if errors should just return false, false if an error message should be displayed
* @return boolean if the file was loaded correctly
*/
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'config' : str_replace('.php', '', $file);
$found = FALSE;
$loaded = FALSE;
$check_locations = defined('ENVIRONMENT')
? array(ENVIRONMENT.'/'.$file, $file)
: array($file);
foreach ($this->_config_paths as $path)
{
foreach ($check_locations as $location)
{
$file_path = $path.'config/'.$location.'.php';
if (in_array($file_path, $this->is_loaded, TRUE))
{
$loaded = TRUE;
continue 2;
}
if (file_exists($file_path))
{
$found = TRUE;
break;
}
}
if ($found === FALSE)
{
continue;
}
include($file_path);
if ( ! isset($config) OR ! is_array($config))
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
}
if ($use_sections === TRUE)
{
if (isset($this->config[$file]))
{
$this->config[$file] = array_merge($this->config[$file], $config);
}
else
{
$this->config[$file] = $config;
}
}
else
{
$this->config = array_merge($this->config, $config);
}
$this->is_loaded[] = $file_path;
unset($config);
$loaded = TRUE;
log_message('debug', 'Config file loaded: '.$file_path);
break;
}
if ($loaded === FALSE)
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('The configuration file '.$file.'.php does not exist.');
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Fetch a config file item
*
*
* @access public
* @param string the config item name
* @param string the index name
* @param bool
* @return string
*/
function item($item, $index = '')
{
if ($index == '')
{
if ( ! isset($this->config[$item]))
{
return FALSE;
}
$pref = $this->config[$item];
}
else
{
if ( ! isset($this->config[$index]))
{
return FALSE;
}
if ( ! isset($this->config[$index][$item]))
{
return FALSE;
}
$pref = $this->config[$index][$item];
}
return $pref;
}
// --------------------------------------------------------------------
/**
* Fetch a config file item - adds slash after item (if item is not empty)
*
* @access public
* @param string the config item name
* @param bool
* @return string
*/
function slash_item($item)
{
if ( ! isset($this->config[$item]))
{
return FALSE;
}
if( trim($this->config[$item]) == '')
{
return '';
}
return rtrim($this->config[$item], '/').'/';
}
// --------------------------------------------------------------------
/**
* Site URL
* Returns base_url . index_page [. uri_string]
*
* @access public
* @param string the URI string
* @return string
*/
function site_url($uri = '')
{
if ($uri == '')
{
return $this->slash_item('base_url').$this->item('index_page');
}
if ($this->item('enable_query_strings') == FALSE)
{
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
}
else
{
return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
}
}
// -------------------------------------------------------------
/**
* Base URL
* Returns base_url [. uri_string]
*
* @access public
* @param string $uri
* @return string
*/
function base_url($uri = '')
{
return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/');
}
// -------------------------------------------------------------
/**
* Build URI string for use in Config::site_url() and Config::base_url()
*
* @access protected
* @param $uri
* @return string
*/
protected function _uri_string($uri)
{
if ($this->item('enable_query_strings') == FALSE)
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
$uri = trim($uri, '/');
}
else
{
if (is_array($uri))
{
$i = 0;
$str = '';
foreach ($uri as $key => $val)
{
$prefix = ($i == 0) ? '' : '&';
$str .= $prefix.$key.'='.$val;
$i++;
}
$uri = $str;
}
}
return $uri;
}
// --------------------------------------------------------------------
/**
* System URL
*
* @access public
* @return string
*/
function system_url()
{
$x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH));
return $this->slash_item('base_url').end($x).'/';
}
// --------------------------------------------------------------------
/**
* Set a config file item
*
* @access public
* @param string the config item key
* @param string the config item value
* @return void
*/
function set_item($item, $value)
{
$this->config[$item] = $value;
}
// --------------------------------------------------------------------
/**
* Assign to Config
*
* This function is called by the front controller (CodeIgniter.php)
* after the Config class is instantiated. It permits config items
* to be assigned or overriden by variables contained in the index.php file
*
* @access private
* @param array
* @return void
*/
function _assign_to_config($items = array())
{
if (is_array($items))
{
foreach ($items as $key => $val)
{
$this->set_item($key, $val);
}
}
}
}
// END CI_Config class
/* End of file Config.php */
/* Location: ./system/core/Config.php */
| 069h-course-management | trunk/ci/system/core/Config.php | PHP | mit | 8,157 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Model Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/config.html
*/
class CI_Model {
/**
* Constructor
*
* @access public
*/
function __construct()
{
log_message('debug', "Model Class Initialized");
}
/**
* __get
*
* Allows models to access CI's loaded classes using the same
* syntax as controllers.
*
* @param string
* @access private
*/
function __get($key)
{
$CI =& get_instance();
return $CI->$key;
}
}
// END Model Class
/* End of file Model.php */
/* Location: ./system/core/Model.php */ | 069h-course-management | trunk/ci/system/core/Model.php | PHP | mit | 1,190 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Input Class
*
* Pre-processes global input data for security
*
* @package CodeIgniter
* @subpackage Libraries
* @category Input
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/input.html
*/
class CI_Input {
/**
* IP address of the current user
*
* @var string
*/
var $ip_address = FALSE;
/**
* user agent (web browser) being used by the current user
*
* @var string
*/
var $user_agent = FALSE;
/**
* If FALSE, then $_GET will be set to an empty array
*
* @var bool
*/
var $_allow_get_array = TRUE;
/**
* If TRUE, then newlines are standardized
*
* @var bool
*/
var $_standardize_newlines = TRUE;
/**
* Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
* Set automatically based on config setting
*
* @var bool
*/
var $_enable_xss = FALSE;
/**
* Enables a CSRF cookie token to be set.
* Set automatically based on config setting
*
* @var bool
*/
var $_enable_csrf = FALSE;
/**
* List of all HTTP request headers
*
* @var array
*/
protected $headers = array();
/**
* Constructor
*
* Sets whether to globally enable the XSS processing
* and whether to allow the $_GET array
*
* @return void
*/
public function __construct()
{
log_message('debug', "Input Class Initialized");
$this->_allow_get_array = (config_item('allow_get_array') === TRUE);
$this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
$this->_enable_csrf = (config_item('csrf_protection') === TRUE);
global $SEC;
$this->security =& $SEC;
// Do we need the UTF-8 class?
if (UTF8_ENABLED === TRUE)
{
global $UNI;
$this->uni =& $UNI;
}
// Sanitize global arrays
$this->_sanitize_globals();
}
// --------------------------------------------------------------------
/**
* Fetch from array
*
* This is a helper function to retrieve values from global arrays
*
* @access private
* @param array
* @param string
* @param bool
* @return string
*/
function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
{
if ( ! isset($array[$index]))
{
return FALSE;
}
if ($xss_clean === TRUE)
{
return $this->security->xss_clean($array[$index]);
}
return $array[$index];
}
// --------------------------------------------------------------------
/**
* Fetch an item from the GET array
*
* @access public
* @param string
* @param bool
* @return string
*/
function get($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL AND ! empty($_GET))
{
$get = array();
// loop through the full _GET array
foreach (array_keys($_GET) as $key)
{
$get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
}
return $get;
}
return $this->_fetch_from_array($_GET, $index, $xss_clean);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the POST array
*
* @access public
* @param string
* @param bool
* @return string
*/
function post($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL AND ! empty($_POST))
{
$post = array();
// Loop through the full _POST array and return it
foreach (array_keys($_POST) as $key)
{
$post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
}
return $post;
}
return $this->_fetch_from_array($_POST, $index, $xss_clean);
}
// --------------------------------------------------------------------
/**
* Fetch an item from either the GET array or the POST
*
* @access public
* @param string The index key
* @param bool XSS cleaning
* @return string
*/
function get_post($index = '', $xss_clean = FALSE)
{
if ( ! isset($_POST[$index]) )
{
return $this->get($index, $xss_clean);
}
else
{
return $this->post($index, $xss_clean);
}
}
// --------------------------------------------------------------------
/**
* Fetch an item from the COOKIE array
*
* @access public
* @param string
* @param bool
* @return string
*/
function cookie($index = '', $xss_clean = FALSE)
{
return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
}
// ------------------------------------------------------------------------
/**
* Set cookie
*
* Accepts six parameter, or you can submit an associative
* array in the first parameter containing all the values.
*
* @access public
* @param mixed
* @param string the value of the cookie
* @param string the number of seconds until expiration
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
* @param bool true makes the cookie secure
* @return void
*/
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item)
{
if (isset($name[$item]))
{
$$item = $name[$item];
}
}
}
if ($prefix == '' AND config_item('cookie_prefix') != '')
{
$prefix = config_item('cookie_prefix');
}
if ($domain == '' AND config_item('cookie_domain') != '')
{
$domain = config_item('cookie_domain');
}
if ($path == '/' AND config_item('cookie_path') != '/')
{
$path = config_item('cookie_path');
}
if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
{
$secure = config_item('cookie_secure');
}
if ( ! is_numeric($expire))
{
$expire = time() - 86500;
}
else
{
$expire = ($expire > 0) ? time() + $expire : 0;
}
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
}
// --------------------------------------------------------------------
/**
* Fetch an item from the SERVER array
*
* @access public
* @param string
* @param bool
* @return string
*/
function server($index = '', $xss_clean = FALSE)
{
return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
}
// --------------------------------------------------------------------
/**
* Fetch the IP Address
*
* @return string
*/
public function ip_address()
{
if ($this->ip_address !== FALSE)
{
return $this->ip_address;
}
$proxy_ips = config_item('proxy_ips');
if ( ! empty($proxy_ips))
{
$proxy_ips = explode(',', str_replace(' ', '', $proxy_ips));
foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header)
{
if (($spoof = $this->server($header)) !== FALSE)
{
// Some proxies typically list the whole chain of IP
// addresses through which the client has reached us.
// e.g. client_ip, proxy_ip1, proxy_ip2, etc.
if (strpos($spoof, ',') !== FALSE)
{
$spoof = explode(',', $spoof, 2);
$spoof = $spoof[0];
}
if ( ! $this->valid_ip($spoof))
{
$spoof = FALSE;
}
else
{
break;
}
}
}
$this->ip_address = ($spoof !== FALSE && in_array($_SERVER['REMOTE_ADDR'], $proxy_ips, TRUE))
? $spoof : $_SERVER['REMOTE_ADDR'];
}
else
{
$this->ip_address = $_SERVER['REMOTE_ADDR'];
}
if ( ! $this->valid_ip($this->ip_address))
{
$this->ip_address = '0.0.0.0';
}
return $this->ip_address;
}
// --------------------------------------------------------------------
/**
* Validate IP Address
*
* @access public
* @param string
* @param string ipv4 or ipv6
* @return bool
*/
public function valid_ip($ip, $which = '')
{
$which = strtolower($which);
// First check if filter_var is available
if (is_callable('filter_var'))
{
switch ($which) {
case 'ipv4':
$flag = FILTER_FLAG_IPV4;
break;
case 'ipv6':
$flag = FILTER_FLAG_IPV6;
break;
default:
$flag = '';
break;
}
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flag);
}
if ($which !== 'ipv6' && $which !== 'ipv4')
{
if (strpos($ip, ':') !== FALSE)
{
$which = 'ipv6';
}
elseif (strpos($ip, '.') !== FALSE)
{
$which = 'ipv4';
}
else
{
return FALSE;
}
}
$func = '_valid_'.$which;
return $this->$func($ip);
}
// --------------------------------------------------------------------
/**
* Validate IPv4 Address
*
* Updated version suggested by Geert De Deckere
*
* @access protected
* @param string
* @return bool
*/
protected function _valid_ipv4($ip)
{
$ip_segments = explode('.', $ip);
// Always 4 segments needed
if (count($ip_segments) !== 4)
{
return FALSE;
}
// IP can not start with 0
if ($ip_segments[0][0] == '0')
{
return FALSE;
}
// Check each segment
foreach ($ip_segments as $segment)
{
// IP segments must be digits and can not be
// longer than 3 digits or greater then 255
if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
{
return FALSE;
}
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Validate IPv6 Address
*
* @access protected
* @param string
* @return bool
*/
protected function _valid_ipv6($str)
{
// 8 groups, separated by :
// 0-ffff per group
// one set of consecutive 0 groups can be collapsed to ::
$groups = 8;
$collapsed = FALSE;
$chunks = array_filter(
preg_split('/(:{1,2})/', $str, NULL, PREG_SPLIT_DELIM_CAPTURE)
);
// Rule out easy nonsense
if (current($chunks) == ':' OR end($chunks) == ':')
{
return FALSE;
}
// PHP supports IPv4-mapped IPv6 addresses, so we'll expect those as well
if (strpos(end($chunks), '.') !== FALSE)
{
$ipv4 = array_pop($chunks);
if ( ! $this->_valid_ipv4($ipv4))
{
return FALSE;
}
$groups--;
}
while ($seg = array_pop($chunks))
{
if ($seg[0] == ':')
{
if (--$groups == 0)
{
return FALSE; // too many groups
}
if (strlen($seg) > 2)
{
return FALSE; // long separator
}
if ($seg == '::')
{
if ($collapsed)
{
return FALSE; // multiple collapsed
}
$collapsed = TRUE;
}
}
elseif (preg_match("/[^0-9a-f]/i", $seg) OR strlen($seg) > 4)
{
return FALSE; // invalid segment
}
}
return $collapsed OR $groups == 1;
}
// --------------------------------------------------------------------
/**
* User Agent
*
* @access public
* @return string
*/
function user_agent()
{
if ($this->user_agent !== FALSE)
{
return $this->user_agent;
}
$this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
return $this->user_agent;
}
// --------------------------------------------------------------------
/**
* Sanitize Globals
*
* This function does the following:
*
* Unsets $_GET data (if query strings are not enabled)
*
* Unsets all globals if register_globals is enabled
*
* Standardizes newline characters to \n
*
* @access private
* @return void
*/
function _sanitize_globals()
{
// It would be "wrong" to unset any of these GLOBALS.
$protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST',
'_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
'system_folder', 'application_folder', 'BM', 'EXT',
'CFG', 'URI', 'RTR', 'OUT', 'IN');
// Unset globals for securiy.
// This is effectively the same as register_globals = off
foreach (array($_GET, $_POST, $_COOKIE) as $global)
{
if ( ! is_array($global))
{
if ( ! in_array($global, $protected))
{
global $$global;
$$global = NULL;
}
}
else
{
foreach ($global as $key => $val)
{
if ( ! in_array($key, $protected))
{
global $$key;
$$key = NULL;
}
}
}
}
// Is $_GET data allowed? If not we'll set the $_GET to an empty array
if ($this->_allow_get_array == FALSE)
{
$_GET = array();
}
else
{
if (is_array($_GET) AND count($_GET) > 0)
{
foreach ($_GET as $key => $val)
{
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}
}
// Clean $_POST Data
if (is_array($_POST) AND count($_POST) > 0)
{
foreach ($_POST as $key => $val)
{
$_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}
// Clean $_COOKIE Data
if (is_array($_COOKIE) AND count($_COOKIE) > 0)
{
// Also get rid of specially treated cookies that might be set by a server
// or silly application, that are of no use to a CI application anyway
// but that when present will trip our 'Disallowed Key Characters' alarm
// http://www.ietf.org/rfc/rfc2109.txt
// note that the key names below are single quoted strings, and are not PHP variables
unset($_COOKIE['$Version']);
unset($_COOKIE['$Path']);
unset($_COOKIE['$Domain']);
foreach ($_COOKIE as $key => $val)
{
$_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}
// Sanitize PHP_SELF
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
// CSRF Protection check on HTTP requests
if ($this->_enable_csrf == TRUE && ! $this->is_cli_request())
{
$this->security->csrf_verify();
}
log_message('debug', "Global POST and COOKIE data sanitized");
}
// --------------------------------------------------------------------
/**
* Clean Input Data
*
* This is a helper function. It escapes data and
* standardizes newline characters to \n
*
* @access private
* @param string
* @return string
*/
function _clean_input_data($str)
{
if (is_array($str))
{
$new_array = array();
foreach ($str as $key => $val)
{
$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
return $new_array;
}
/* We strip slashes if magic quotes is on to keep things consistent
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
it will probably not exist in future versions at all.
*/
if ( ! is_php('5.4') && get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
// Remove control characters
$str = remove_invisible_characters($str);
// Should we filter the input data?
if ($this->_enable_xss === TRUE)
{
$str = $this->security->xss_clean($str);
}
// Standardize newlines if needed
if ($this->_standardize_newlines == TRUE)
{
if (strpos($str, "\r") !== FALSE)
{
$str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str);
}
}
return $str;
}
// --------------------------------------------------------------------
/**
* Clean Keys
*
* This is a helper function. To prevent malicious users
* from trying to exploit keys we make sure that keys are
* only named with alpha-numeric text and a few other items.
*
* @access private
* @param string
* @return string
*/
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Request Headers
*
* In Apache, you can simply call apache_request_headers(), however for
* people running other webservers the function is undefined.
*
* @param bool XSS cleaning
*
* @return array
*/
public function request_headers($xss_clean = FALSE)
{
// Look at Apache go!
if (function_exists('apache_request_headers'))
{
$headers = apache_request_headers();
}
else
{
$headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
foreach ($_SERVER as $key => $val)
{
if (strncmp($key, 'HTTP_', 5) === 0)
{
$headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean);
}
}
}
// take SOME_HEADER and turn it into Some-Header
foreach ($headers as $key => $val)
{
$key = str_replace('_', ' ', strtolower($key));
$key = str_replace(' ', '-', ucwords($key));
$this->headers[$key] = $val;
}
return $this->headers;
}
// --------------------------------------------------------------------
/**
* Get Request Header
*
* Returns the value of a single member of the headers class member
*
* @param string array key for $this->headers
* @param boolean XSS Clean or not
* @return mixed FALSE on failure, string on success
*/
public function get_request_header($index, $xss_clean = FALSE)
{
if (empty($this->headers))
{
$this->request_headers();
}
if ( ! isset($this->headers[$index]))
{
return FALSE;
}
if ($xss_clean === TRUE)
{
return $this->security->xss_clean($this->headers[$index]);
}
return $this->headers[$index];
}
// --------------------------------------------------------------------
/**
* Is ajax Request?
*
* Test to see if a request contains the HTTP_X_REQUESTED_WITH header
*
* @return boolean
*/
public function is_ajax_request()
{
return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
}
// --------------------------------------------------------------------
/**
* Is cli Request?
*
* Test to see if a request was made from the command line
*
* @return bool
*/
public function is_cli_request()
{
return (php_sapi_name() === 'cli' OR defined('STDIN'));
}
}
/* End of file Input.php */
/* Location: ./system/core/Input.php */ | 069h-course-management | trunk/ci/system/core/Input.php | PHP | mit | 18,324 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Utf8 Class
*
* Provides support for UTF-8 environments
*
* @package CodeIgniter
* @subpackage Libraries
* @category UTF-8
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/utf8.html
*/
class CI_Utf8 {
/**
* Constructor
*
* Determines if UTF-8 support is to be enabled
*
*/
function __construct()
{
log_message('debug', "Utf8 Class Initialized");
global $CFG;
if (
preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
AND function_exists('iconv') // iconv must be installed
AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
)
{
log_message('debug', "UTF-8 Support Enabled");
define('UTF8_ENABLED', TRUE);
// set internal encoding for multibyte string functions if necessary
// and set a flag so we don't have to repeatedly use extension_loaded()
// or function_exists()
if (extension_loaded('mbstring'))
{
define('MB_ENABLED', TRUE);
mb_internal_encoding('UTF-8');
}
else
{
define('MB_ENABLED', FALSE);
}
}
else
{
log_message('debug', "UTF-8 Support Disabled");
define('UTF8_ENABLED', FALSE);
}
}
// --------------------------------------------------------------------
/**
* Clean UTF-8 strings
*
* Ensures strings are UTF-8
*
* @access public
* @param string
* @return string
*/
function clean_string($str)
{
if ($this->_is_ascii($str) === FALSE)
{
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Remove ASCII control characters
*
* Removes all ASCII control characters except horizontal tabs,
* line feeds, and carriage returns, as all others can cause
* problems in XML
*
* @access public
* @param string
* @return string
*/
function safe_ascii_for_xml($str)
{
return remove_invisible_characters($str, FALSE);
}
// --------------------------------------------------------------------
/**
* Convert to UTF-8
*
* Attempts to convert a string to UTF-8
*
* @access public
* @param string
* @param string - input encoding
* @return string
*/
function convert_to_utf8($str, $encoding)
{
if (function_exists('iconv'))
{
$str = @iconv($encoding, 'UTF-8', $str);
}
elseif (function_exists('mb_convert_encoding'))
{
$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
}
else
{
return FALSE;
}
return $str;
}
// --------------------------------------------------------------------
/**
* Is ASCII?
*
* Tests if a string is standard 7-bit ASCII or not
*
* @access public
* @param string
* @return bool
*/
function _is_ascii($str)
{
return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
}
// --------------------------------------------------------------------
}
// End Utf8 Class
/* End of file Utf8.php */
/* Location: ./system/core/Utf8.php */ | 069h-course-management | trunk/ci/system/core/Utf8.php | PHP | mit | 3,584 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Loader Class
*
* Loads views and files
*
* @package CodeIgniter
* @subpackage Libraries
* @author ExpressionEngine Dev Team
* @category Loader
* @link http://codeigniter.com/user_guide/libraries/loader.html
*/
class CI_Loader {
// All these are set automatically. Don't mess with them.
/**
* Nesting level of the output buffering mechanism
*
* @var int
* @access protected
*/
protected $_ci_ob_level;
/**
* List of paths to load views from
*
* @var array
* @access protected
*/
protected $_ci_view_paths = array();
/**
* List of paths to load libraries from
*
* @var array
* @access protected
*/
protected $_ci_library_paths = array();
/**
* List of paths to load models from
*
* @var array
* @access protected
*/
protected $_ci_model_paths = array();
/**
* List of paths to load helpers from
*
* @var array
* @access protected
*/
protected $_ci_helper_paths = array();
/**
* List of loaded base classes
* Set by the controller class
*
* @var array
* @access protected
*/
protected $_base_classes = array(); // Set by the controller class
/**
* List of cached variables
*
* @var array
* @access protected
*/
protected $_ci_cached_vars = array();
/**
* List of loaded classes
*
* @var array
* @access protected
*/
protected $_ci_classes = array();
/**
* List of loaded files
*
* @var array
* @access protected
*/
protected $_ci_loaded_files = array();
/**
* List of loaded models
*
* @var array
* @access protected
*/
protected $_ci_models = array();
/**
* List of loaded helpers
*
* @var array
* @access protected
*/
protected $_ci_helpers = array();
/**
* List of class name mappings
*
* @var array
* @access protected
*/
protected $_ci_varmap = array('unit_test' => 'unit',
'user_agent' => 'agent');
/**
* Constructor
*
* Sets the path to the view files and gets the initial output buffering level
*/
public function __construct()
{
$this->_ci_ob_level = ob_get_level();
$this->_ci_library_paths = array(APPPATH, BASEPATH);
$this->_ci_helper_paths = array(APPPATH, BASEPATH);
$this->_ci_model_paths = array(APPPATH);
$this->_ci_view_paths = array(APPPATH.'views/' => TRUE);
log_message('debug', "Loader Class Initialized");
}
// --------------------------------------------------------------------
/**
* Initialize the Loader
*
* This method is called once in CI_Controller.
*
* @param array
* @return object
*/
public function initialize()
{
$this->_ci_classes = array();
$this->_ci_loaded_files = array();
$this->_ci_models = array();
$this->_base_classes =& is_loaded();
$this->_ci_autoloader();
return $this;
}
// --------------------------------------------------------------------
/**
* Is Loaded
*
* A utility function to test if a class is in the self::$_ci_classes array.
* This function returns the object name if the class tested for is loaded,
* and returns FALSE if it isn't.
*
* It is mainly used in the form_helper -> _get_validation_object()
*
* @param string class being checked for
* @return mixed class object name on the CI SuperObject or FALSE
*/
public function is_loaded($class)
{
if (isset($this->_ci_classes[$class]))
{
return $this->_ci_classes[$class];
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Class Loader
*
* This function lets users load and instantiate classes.
* It is designed to be called from a user's app controllers.
*
* @param string the name of the class
* @param mixed the optional parameters
* @param string an optional object name
* @return void
*/
public function library($library = '', $params = NULL, $object_name = NULL)
{
if (is_array($library))
{
foreach ($library as $class)
{
$this->library($class, $params);
}
return;
}
if ($library == '' OR isset($this->_base_classes[$library]))
{
return FALSE;
}
if ( ! is_null($params) && ! is_array($params))
{
$params = NULL;
}
$this->_ci_load_class($library, $params, $object_name);
}
// --------------------------------------------------------------------
/**
* Model Loader
*
* This function lets users load and instantiate models.
*
* @param string the name of the class
* @param string name for the model
* @param bool database connection
* @return void
*/
public function model($model, $name = '', $db_conn = FALSE)
{
if (is_array($model))
{
foreach ($model as $babe)
{
$this->model($babe);
}
return;
}
if ($model == '')
{
return;
}
$path = '';
// Is the model in a sub-folder? If so, parse out the filename and path.
if (($last_slash = strrpos($model, '/')) !== FALSE)
{
// The path is in front of the last slash
$path = substr($model, 0, $last_slash + 1);
// And the model name behind it
$model = substr($model, $last_slash + 1);
}
if ($name == '')
{
$name = $model;
}
if (in_array($name, $this->_ci_models, TRUE))
{
return;
}
$CI =& get_instance();
if (isset($CI->$name))
{
show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
}
$model = strtolower($model);
foreach ($this->_ci_model_paths as $mod_path)
{
if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
{
continue;
}
if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
{
if ($db_conn === TRUE)
{
$db_conn = '';
}
$CI->load->database($db_conn, FALSE, TRUE);
}
if ( ! class_exists('CI_Model'))
{
load_class('Model', 'core');
}
require_once($mod_path.'models/'.$path.$model.'.php');
$model = ucfirst($model);
$CI->$name = new $model();
$this->_ci_models[] = $name;
return;
}
// couldn't find the model
show_error('Unable to locate the model you have specified: '.$model);
}
// --------------------------------------------------------------------
/**
* Database Loader
*
* @param string the DB credentials
* @param bool whether to return the DB object
* @param bool whether to enable active record (this allows us to override the config setting)
* @return object
*/
public function database($params = '', $return = FALSE, $active_record = NULL)
{
// Grab the super object
$CI =& get_instance();
// Do we even need to load the database class?
if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
{
return FALSE;
}
require_once(BASEPATH.'database/DB.php');
if ($return === TRUE)
{
return DB($params, $active_record);
}
// Initialize the db variable. Needed to prevent
// reference errors with some configurations
$CI->db = '';
// Load the DB class
$CI->db =& DB($params, $active_record);
}
// --------------------------------------------------------------------
/**
* Load the Utilities Class
*
* @return string
*/
public function dbutil()
{
if ( ! class_exists('CI_DB'))
{
$this->database();
}
$CI =& get_instance();
// for backwards compatibility, load dbforge so we can extend dbutils off it
// this use is deprecated and strongly discouraged
$CI->load->dbforge();
require_once(BASEPATH.'database/DB_utility.php');
require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php');
$class = 'CI_DB_'.$CI->db->dbdriver.'_utility';
$CI->dbutil = new $class();
}
// --------------------------------------------------------------------
/**
* Load the Database Forge Class
*
* @return string
*/
public function dbforge()
{
if ( ! class_exists('CI_DB'))
{
$this->database();
}
$CI =& get_instance();
require_once(BASEPATH.'database/DB_forge.php');
require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php');
$class = 'CI_DB_'.$CI->db->dbdriver.'_forge';
$CI->dbforge = new $class();
}
// --------------------------------------------------------------------
/**
* Load View
*
* This function is used to load a "view" file. It has three parameters:
*
* 1. The name of the "view" file to be included.
* 2. An associative array of data to be extracted for use in the view.
* 3. TRUE/FALSE - whether to return the data or load it. In
* some cases it's advantageous to be able to return data so that
* a developer can process it in some way.
*
* @param string
* @param array
* @param bool
* @return void
*/
public function view($view, $vars = array(), $return = FALSE)
{
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}
// --------------------------------------------------------------------
/**
* Load File
*
* This is a generic file loader
*
* @param string
* @param bool
* @return string
*/
public function file($path, $return = FALSE)
{
return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return));
}
// --------------------------------------------------------------------
/**
* Set Variables
*
* Once variables are set they become available within
* the controller class and its "view" files.
*
* @param array
* @param string
* @return void
*/
public function vars($vars = array(), $val = '')
{
if ($val != '' AND is_string($vars))
{
$vars = array($vars => $val);
}
$vars = $this->_ci_object_to_array($vars);
if (is_array($vars) AND count($vars) > 0)
{
foreach ($vars as $key => $val)
{
$this->_ci_cached_vars[$key] = $val;
}
}
}
// --------------------------------------------------------------------
/**
* Get Variable
*
* Check if a variable is set and retrieve it.
*
* @param array
* @return void
*/
public function get_var($key)
{
return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL;
}
// --------------------------------------------------------------------
/**
* Load Helper
*
* This function loads the specified helper file.
*
* @param mixed
* @return void
*/
public function helper($helpers = array())
{
foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
{
if (isset($this->_ci_helpers[$helper]))
{
continue;
}
$ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php';
// Is this a helper extension request?
if (file_exists($ext_helper))
{
$base_helper = BASEPATH.'helpers/'.$helper.'.php';
if ( ! file_exists($base_helper))
{
show_error('Unable to load the requested file: helpers/'.$helper.'.php');
}
include_once($ext_helper);
include_once($base_helper);
$this->_ci_helpers[$helper] = TRUE;
log_message('debug', 'Helper loaded: '.$helper);
continue;
}
// Try to load the helper
foreach ($this->_ci_helper_paths as $path)
{
if (file_exists($path.'helpers/'.$helper.'.php'))
{
include_once($path.'helpers/'.$helper.'.php');
$this->_ci_helpers[$helper] = TRUE;
log_message('debug', 'Helper loaded: '.$helper);
break;
}
}
// unable to load the helper
if ( ! isset($this->_ci_helpers[$helper]))
{
show_error('Unable to load the requested file: helpers/'.$helper.'.php');
}
}
}
// --------------------------------------------------------------------
/**
* Load Helpers
*
* This is simply an alias to the above function in case the
* user has written the plural form of this function.
*
* @param array
* @return void
*/
public function helpers($helpers = array())
{
$this->helper($helpers);
}
// --------------------------------------------------------------------
/**
* Loads a language file
*
* @param array
* @param string
* @return void
*/
public function language($file = array(), $lang = '')
{
$CI =& get_instance();
if ( ! is_array($file))
{
$file = array($file);
}
foreach ($file as $langfile)
{
$CI->lang->load($langfile, $lang);
}
}
// --------------------------------------------------------------------
/**
* Loads a config file
*
* @param string
* @param bool
* @param bool
* @return void
*/
public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$CI =& get_instance();
$CI->config->load($file, $use_sections, $fail_gracefully);
}
// --------------------------------------------------------------------
/**
* Driver
*
* Loads a driver library
*
* @param string the name of the class
* @param mixed the optional parameters
* @param string an optional object name
* @return void
*/
public function driver($library = '', $params = NULL, $object_name = NULL)
{
if ( ! class_exists('CI_Driver_Library'))
{
// we aren't instantiating an object here, that'll be done by the Library itself
require BASEPATH.'libraries/Driver.php';
}
if ($library == '')
{
return FALSE;
}
// We can save the loader some time since Drivers will *always* be in a subfolder,
// and typically identically named to the library
if ( ! strpos($library, '/'))
{
$library = ucfirst($library).'/'.$library;
}
return $this->library($library, $params, $object_name);
}
// --------------------------------------------------------------------
/**
* Add Package Path
*
* Prepends a parent path to the library, model, helper, and config path arrays
*
* @param string
* @param boolean
* @return void
*/
public function add_package_path($path, $view_cascade=TRUE)
{
$path = rtrim($path, '/').'/';
array_unshift($this->_ci_library_paths, $path);
array_unshift($this->_ci_model_paths, $path);
array_unshift($this->_ci_helper_paths, $path);
$this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths;
// Add config file path
$config =& $this->_ci_get_component('config');
array_unshift($config->_config_paths, $path);
}
// --------------------------------------------------------------------
/**
* Get Package Paths
*
* Return a list of all package paths, by default it will ignore BASEPATH.
*
* @param string
* @return void
*/
public function get_package_paths($include_base = FALSE)
{
return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths;
}
// --------------------------------------------------------------------
/**
* Remove Package Path
*
* Remove a path from the library, model, and helper path arrays if it exists
* If no path is provided, the most recently added path is removed.
*
* @param type
* @param bool
* @return type
*/
public function remove_package_path($path = '', $remove_config_path = TRUE)
{
$config =& $this->_ci_get_component('config');
if ($path == '')
{
$void = array_shift($this->_ci_library_paths);
$void = array_shift($this->_ci_model_paths);
$void = array_shift($this->_ci_helper_paths);
$void = array_shift($this->_ci_view_paths);
$void = array_shift($config->_config_paths);
}
else
{
$path = rtrim($path, '/').'/';
foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var)
{
if (($key = array_search($path, $this->{$var})) !== FALSE)
{
unset($this->{$var}[$key]);
}
}
if (isset($this->_ci_view_paths[$path.'views/']))
{
unset($this->_ci_view_paths[$path.'views/']);
}
if (($key = array_search($path, $config->_config_paths)) !== FALSE)
{
unset($config->_config_paths[$key]);
}
}
// make sure the application default paths are still in the array
$this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH)));
$this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH)));
$this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH)));
$this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE));
$config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH)));
}
// --------------------------------------------------------------------
/**
* Loader
*
* This function is used to load views and files.
* Variables are prefixed with _ci_ to avoid symbol collision with
* variables made available to view files
*
* @param array
* @return void
*/
protected function _ci_load($_ci_data)
{
// Set the default data variables
foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
{
$$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
}
$file_exists = FALSE;
// Set the path to the requested file
if ($_ci_path != '')
{
$_ci_x = explode('/', $_ci_path);
$_ci_file = end($_ci_x);
}
else
{
$_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
$_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view;
foreach ($this->_ci_view_paths as $view_file => $cascade)
{
if (file_exists($view_file.$_ci_file))
{
$_ci_path = $view_file.$_ci_file;
$file_exists = TRUE;
break;
}
if ( ! $cascade)
{
break;
}
}
}
if ( ! $file_exists && ! file_exists($_ci_path))
{
show_error('Unable to load the requested file: '.$_ci_file);
}
// This allows anything loaded using $this->load (views, files, etc.)
// to become accessible from within the Controller and Model functions.
$_ci_CI =& get_instance();
foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
{
if ( ! isset($this->$_ci_key))
{
$this->$_ci_key =& $_ci_CI->$_ci_key;
}
}
/*
* Extract and cache variables
*
* You can either set variables using the dedicated $this->load_vars()
* function or via the second parameter of this function. We'll merge
* the two types and cache them so that views that are embedded within
* other views can have access to these variables.
*/
if (is_array($_ci_vars))
{
$this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
}
extract($this->_ci_cached_vars);
/*
* Buffer the output
*
* We buffer the output for two reasons:
* 1. Speed. You get a significant speed boost.
* 2. So that the final rendered template can be
* post-processed by the output class. Why do we
* need post processing? For one thing, in order to
* show the elapsed page load time. Unless we
* can intercept the content right before it's sent to
* the browser and then stop the timer it won't be accurate.
*/
ob_start();
// If the PHP installation does not support short tags we'll
// do a little string replacement, changing the short tags
// to standard PHP echo statements.
if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
{
echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
}
else
{
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
}
log_message('debug', 'File loaded: '.$_ci_path);
// Return the file data if requested
if ($_ci_return === TRUE)
{
$buffer = ob_get_contents();
@ob_end_clean();
return $buffer;
}
/*
* Flush the buffer... or buff the flusher?
*
* In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it can be seen and included properly by the first included
* template and any subsequent ones. Oy!
*
*/
if (ob_get_level() > $this->_ci_ob_level + 1)
{
ob_end_flush();
}
else
{
$_ci_CI->output->append_output(ob_get_contents());
@ob_end_clean();
}
}
// --------------------------------------------------------------------
/**
* Load class
*
* This function loads the requested class.
*
* @param string the item that is being loaded
* @param mixed any additional parameters
* @param string an optional object name
* @return void
*/
protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
{
// Get the class name, and while we're at it trim any slashes.
// The directory path can be included as part of the class name,
// but we don't want a leading slash
$class = str_replace('.php', '', trim($class, '/'));
// Was the path included with the class name?
// We look for a slash to determine this
$subdir = '';
if (($last_slash = strrpos($class, '/')) !== FALSE)
{
// Extract the path
$subdir = substr($class, 0, $last_slash + 1);
// Get the filename from the path
$class = substr($class, $last_slash + 1);
}
// We'll test for both lowercase and capitalized versions of the file name
foreach (array(ucfirst($class), strtolower($class)) as $class)
{
$subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
// Is this a class extension request?
if (file_exists($subclass))
{
$baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php';
if ( ! file_exists($baseclass))
{
log_message('error', "Unable to load the requested class: ".$class);
show_error("Unable to load the requested class: ".$class);
}
// Safety: Was the class already loaded by a previous call?
if (in_array($subclass, $this->_ci_loaded_files))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ( ! is_null($object_name))
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
}
$is_duplicate = TRUE;
log_message('debug', $class." class already loaded. Second attempt ignored.");
return;
}
include_once($baseclass);
include_once($subclass);
$this->_ci_loaded_files[] = $subclass;
return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
// Lets search for the requested library file and load it.
$is_duplicate = FALSE;
foreach ($this->_ci_library_paths as $path)
{
$filepath = $path.'libraries/'.$subdir.$class.'.php';
// Does the file exist? No? Bummer...
if ( ! file_exists($filepath))
{
continue;
}
// Safety: Was the class already loaded by a previous call?
if (in_array($filepath, $this->_ci_loaded_files))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ( ! is_null($object_name))
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_class($class, '', $params, $object_name);
}
}
$is_duplicate = TRUE;
log_message('debug', $class." class already loaded. Second attempt ignored.");
return;
}
include_once($filepath);
$this->_ci_loaded_files[] = $filepath;
return $this->_ci_init_class($class, '', $params, $object_name);
}
} // END FOREACH
// One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
if ($subdir == '')
{
$path = strtolower($class).'/'.$class;
return $this->_ci_load_class($path, $params);
}
// If we got this far we were unable to find the requested class.
// We do not issue errors if the load call failed due to a duplicate request
if ($is_duplicate == FALSE)
{
log_message('error', "Unable to load the requested class: ".$class);
show_error("Unable to load the requested class: ".$class);
}
}
// --------------------------------------------------------------------
/**
* Instantiates a class
*
* @param string
* @param string
* @param bool
* @param string an optional object name
* @return null
*/
protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
{
// Is there an associated config file for this class? Note: these should always be lowercase
if ($config === NULL)
{
// Fetch the config paths containing any package paths
$config_component = $this->_ci_get_component('config');
if (is_array($config_component->_config_paths))
{
// Break on the first found file, thus package files
// are not overridden by default paths
foreach ($config_component->_config_paths as $path)
{
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names. Check for environment
// first, global next
if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
{
include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
break;
}
elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
{
include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
break;
}
elseif (file_exists($path .'config/'.strtolower($class).'.php'))
{
include($path .'config/'.strtolower($class).'.php');
break;
}
elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php'))
{
include($path .'config/'.ucfirst(strtolower($class)).'.php');
break;
}
}
}
}
if ($prefix == '')
{
if (class_exists('CI_'.$class))
{
$name = 'CI_'.$class;
}
elseif (class_exists(config_item('subclass_prefix').$class))
{
$name = config_item('subclass_prefix').$class;
}
else
{
$name = $class;
}
}
else
{
$name = $prefix.$class;
}
// Is the class name valid?
if ( ! class_exists($name))
{
log_message('error', "Non-existent class: ".$name);
show_error("Non-existent class: ".$class);
}
// Set the variable name we will assign the class to
// Was a custom class name supplied? If so we'll use it
$class = strtolower($class);
if (is_null($object_name))
{
$classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
}
else
{
$classvar = $object_name;
}
// Save the class name and object name
$this->_ci_classes[$class] = $classvar;
// Instantiate the class
$CI =& get_instance();
if ($config !== NULL)
{
$CI->$classvar = new $name($config);
}
else
{
$CI->$classvar = new $name;
}
}
// --------------------------------------------------------------------
/**
* Autoloader
*
* The config/autoload.php file contains an array that permits sub-systems,
* libraries, and helpers to be loaded automatically.
*
* @param array
* @return void
*/
private function _ci_autoloader()
{
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
}
else
{
include(APPPATH.'config/autoload.php');
}
if ( ! isset($autoload))
{
return FALSE;
}
// Autoload packages
if (isset($autoload['packages']))
{
foreach ($autoload['packages'] as $package_path)
{
$this->add_package_path($package_path);
}
}
// Load any custom config file
if (count($autoload['config']) > 0)
{
$CI =& get_instance();
foreach ($autoload['config'] as $key => $val)
{
$CI->config->load($val);
}
}
// Autoload helpers and languages
foreach (array('helper', 'language') as $type)
{
if (isset($autoload[$type]) AND count($autoload[$type]) > 0)
{
$this->$type($autoload[$type]);
}
}
// A little tweak to remain backward compatible
// The $autoload['core'] item was deprecated
if ( ! isset($autoload['libraries']) AND isset($autoload['core']))
{
$autoload['libraries'] = $autoload['core'];
}
// Load libraries
if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0)
{
// Load the database driver.
if (in_array('database', $autoload['libraries']))
{
$this->database();
$autoload['libraries'] = array_diff($autoload['libraries'], array('database'));
}
// Load all other libraries
foreach ($autoload['libraries'] as $item)
{
$this->library($item);
}
}
// Autoload models
if (isset($autoload['model']))
{
$this->model($autoload['model']);
}
}
// --------------------------------------------------------------------
/**
* Object to Array
*
* Takes an object as input and converts the class variables to array key/vals
*
* @param object
* @return array
*/
protected function _ci_object_to_array($object)
{
return (is_object($object)) ? get_object_vars($object) : $object;
}
// --------------------------------------------------------------------
/**
* Get a reference to a specific library or model
*
* @param string
* @return bool
*/
protected function &_ci_get_component($component)
{
$CI =& get_instance();
return $CI->$component;
}
// --------------------------------------------------------------------
/**
* Prep filename
*
* This function preps the name of various items to make loading them more reliable.
*
* @param mixed
* @param string
* @return array
*/
protected function _ci_prep_filename($filename, $extension)
{
if ( ! is_array($filename))
{
return array(strtolower(str_replace('.php', '', str_replace($extension, '', $filename)).$extension));
}
else
{
foreach ($filename as $key => $val)
{
$filename[$key] = strtolower(str_replace('.php', '', str_replace($extension, '', $val)).$extension);
}
return $filename;
}
}
}
/* End of file Loader.php */
/* Location: ./system/core/Loader.php */ | 069h-course-management | trunk/ci/system/core/Loader.php | PHP | mit | 30,576 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* URI Class
*
* Parses URIs and determines routing
*
* @package CodeIgniter
* @subpackage Libraries
* @category URI
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/uri.html
*/
class CI_URI {
/**
* List of cached uri segments
*
* @var array
* @access public
*/
var $keyval = array();
/**
* Current uri string
*
* @var string
* @access public
*/
var $uri_string;
/**
* List of uri segments
*
* @var array
* @access public
*/
var $segments = array();
/**
* Re-indexed list of uri segments
* Starts at 1 instead of 0
*
* @var array
* @access public
*/
var $rsegments = array();
/**
* Constructor
*
* Simply globalizes the $RTR object. The front
* loads the Router class early on so it's not available
* normally as other classes are.
*
* @access public
*/
function __construct()
{
$this->config =& load_class('Config', 'core');
log_message('debug', "URI Class Initialized");
}
// --------------------------------------------------------------------
/**
* Get the URI String
*
* @access private
* @return string
*/
function _fetch_uri_string()
{
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
{
// Is the request coming from the command line?
if (php_sapi_name() == 'cli' or defined('STDIN'))
{
$this->_set_uri_string($this->_parse_cli_args());
return;
}
// Let's try the REQUEST_URI first, this will work in most situations
if ($uri = $this->_detect_uri())
{
$this->_set_uri_string($uri);
return;
}
// Is there a PATH_INFO variable?
// Note: some servers seem to have trouble with getenv() so we'll test it two ways
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
if (trim($path, '/') != '' && $path != "/".SELF)
{
$this->_set_uri_string($path);
return;
}
// No PATH_INFO?... What about QUERY_STRING?
$path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
if (trim($path, '/') != '')
{
$this->_set_uri_string($path);
return;
}
// As a last ditch effort lets try using the $_GET array
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
{
$this->_set_uri_string(key($_GET));
return;
}
// We've exhausted all our options...
$this->uri_string = '';
return;
}
$uri = strtoupper($this->config->item('uri_protocol'));
if ($uri == 'REQUEST_URI')
{
$this->_set_uri_string($this->_detect_uri());
return;
}
elseif ($uri == 'CLI')
{
$this->_set_uri_string($this->_parse_cli_args());
return;
}
$path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
$this->_set_uri_string($path);
}
// --------------------------------------------------------------------
/**
* Set the URI String
*
* @access public
* @param string
* @return string
*/
function _set_uri_string($str)
{
// Filter out control characters
$str = remove_invisible_characters($str, FALSE);
// If the URI contains only a slash we'll kill it
$this->uri_string = ($str == '/') ? '' : $str;
}
// --------------------------------------------------------------------
/**
* Detects the URI
*
* This function will detect the URI automatically and fix the query string
* if necessary.
*
* @access private
* @return string
*/
private function _detect_uri()
{
if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
{
return '';
}
$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
if (strncmp($uri, '?/', 2) === 0)
{
$uri = substr($uri, 2);
}
$parts = preg_split('#\?#i', $uri, 2);
$uri = $parts[0];
if (isset($parts[1]))
{
$_SERVER['QUERY_STRING'] = $parts[1];
parse_str($_SERVER['QUERY_STRING'], $_GET);
}
else
{
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
if ($uri == '/' || empty($uri))
{
return '/';
}
$uri = parse_url($uri, PHP_URL_PATH);
// Do some final cleaning of the URI and return it
return str_replace(array('//', '../'), '/', trim($uri, '/'));
}
// --------------------------------------------------------------------
/**
* Parse cli arguments
*
* Take each command line argument and assume it is a URI segment.
*
* @access private
* @return string
*/
private function _parse_cli_args()
{
$args = array_slice($_SERVER['argv'], 1);
return $args ? '/' . implode('/', $args) : '';
}
// --------------------------------------------------------------------
/**
* Filter segments for malicious characters
*
* @access private
* @param string
* @return string
*/
function _filter_uri($str)
{
if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
{
// preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
// compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
{
show_error('The URI you submitted has disallowed characters.', 400);
}
}
// Convert programatic characters to entities
$bad = array('$', '(', ')', '%28', '%29');
$good = array('$', '(', ')', '(', ')');
return str_replace($bad, $good, $str);
}
// --------------------------------------------------------------------
/**
* Remove the suffix from the URL if needed
*
* @access private
* @return void
*/
function _remove_url_suffix()
{
if ($this->config->item('url_suffix') != "")
{
$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
}
}
// --------------------------------------------------------------------
/**
* Explode the URI Segments. The individual segments will
* be stored in the $this->segments array.
*
* @access private
* @return void
*/
function _explode_segments()
{
foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
// Filter segments for security
$val = trim($this->_filter_uri($val));
if ($val != '')
{
$this->segments[] = $val;
}
}
}
// --------------------------------------------------------------------
/**
* Re-index Segments
*
* This function re-indexes the $this->segment array so that it
* starts at 1 rather than 0. Doing so makes it simpler to
* use functions like $this->uri->segment(n) since there is
* a 1:1 relationship between the segment array and the actual segments.
*
* @access private
* @return void
*/
function _reindex_segments()
{
array_unshift($this->segments, NULL);
array_unshift($this->rsegments, NULL);
unset($this->segments[0]);
unset($this->rsegments[0]);
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment
*
* This function returns the URI segment based on the number provided.
*
* @access public
* @param integer
* @param bool
* @return string
*/
function segment($n, $no_result = FALSE)
{
return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
}
// --------------------------------------------------------------------
/**
* Fetch a URI "routed" Segment
*
* This function returns the re-routed URI segment (assuming routing rules are used)
* based on the number provided. If there is no routing this function returns the
* same result as $this->segment()
*
* @access public
* @param integer
* @param bool
* @return string
*/
function rsegment($n, $no_result = FALSE)
{
return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
}
// --------------------------------------------------------------------
/**
* Generate a key value pair from the URI string
*
* This function generates and associative array of URI data starting
* at the supplied segment. For example, if this is your URI:
*
* example.com/user/search/name/joe/location/UK/gender/male
*
* You can use this function to generate an array with this prototype:
*
* array (
* name => joe
* location => UK
* gender => male
* )
*
* @access public
* @param integer the starting segment number
* @param array an array of default values
* @return array
*/
function uri_to_assoc($n = 3, $default = array())
{
return $this->_uri_to_assoc($n, $default, 'segment');
}
/**
* Identical to above only it uses the re-routed segment array
*
* @access public
* @param integer the starting segment number
* @param array an array of default values
* @return array
*
*/
function ruri_to_assoc($n = 3, $default = array())
{
return $this->_uri_to_assoc($n, $default, 'rsegment');
}
// --------------------------------------------------------------------
/**
* Generate a key value pair from the URI string or Re-routed URI string
*
* @access private
* @param integer the starting segment number
* @param array an array of default values
* @param string which array we should use
* @return array
*/
function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
{
if ($which == 'segment')
{
$total_segments = 'total_segments';
$segment_array = 'segment_array';
}
else
{
$total_segments = 'total_rsegments';
$segment_array = 'rsegment_array';
}
if ( ! is_numeric($n))
{
return $default;
}
if (isset($this->keyval[$n]))
{
return $this->keyval[$n];
}
if ($this->$total_segments() < $n)
{
if (count($default) == 0)
{
return array();
}
$retval = array();
foreach ($default as $val)
{
$retval[$val] = FALSE;
}
return $retval;
}
$segments = array_slice($this->$segment_array(), ($n - 1));
$i = 0;
$lastval = '';
$retval = array();
foreach ($segments as $seg)
{
if ($i % 2)
{
$retval[$lastval] = $seg;
}
else
{
$retval[$seg] = FALSE;
$lastval = $seg;
}
$i++;
}
if (count($default) > 0)
{
foreach ($default as $val)
{
if ( ! array_key_exists($val, $retval))
{
$retval[$val] = FALSE;
}
}
}
// Cache the array for reuse
$this->keyval[$n] = $retval;
return $retval;
}
// --------------------------------------------------------------------
/**
* Generate a URI string from an associative array
*
*
* @access public
* @param array an associative array of key/values
* @return array
*/
function assoc_to_uri($array)
{
$temp = array();
foreach ((array)$array as $key => $val)
{
$temp[] = $key;
$temp[] = $val;
}
return implode('/', $temp);
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment and add a trailing slash
*
* @access public
* @param integer
* @param string
* @return string
*/
function slash_segment($n, $where = 'trailing')
{
return $this->_slash_segment($n, $where, 'segment');
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment and add a trailing slash
*
* @access public
* @param integer
* @param string
* @return string
*/
function slash_rsegment($n, $where = 'trailing')
{
return $this->_slash_segment($n, $where, 'rsegment');
}
// --------------------------------------------------------------------
/**
* Fetch a URI Segment and add a trailing slash - helper function
*
* @access private
* @param integer
* @param string
* @param string
* @return string
*/
function _slash_segment($n, $where = 'trailing', $which = 'segment')
{
$leading = '/';
$trailing = '/';
if ($where == 'trailing')
{
$leading = '';
}
elseif ($where == 'leading')
{
$trailing = '';
}
return $leading.$this->$which($n).$trailing;
}
// --------------------------------------------------------------------
/**
* Segment Array
*
* @access public
* @return array
*/
function segment_array()
{
return $this->segments;
}
// --------------------------------------------------------------------
/**
* Routed Segment Array
*
* @access public
* @return array
*/
function rsegment_array()
{
return $this->rsegments;
}
// --------------------------------------------------------------------
/**
* Total number of segments
*
* @access public
* @return integer
*/
function total_segments()
{
return count($this->segments);
}
// --------------------------------------------------------------------
/**
* Total number of routed segments
*
* @access public
* @return integer
*/
function total_rsegments()
{
return count($this->rsegments);
}
// --------------------------------------------------------------------
/**
* Fetch the entire URI string
*
* @access public
* @return string
*/
function uri_string()
{
return $this->uri_string;
}
// --------------------------------------------------------------------
/**
* Fetch the entire Re-routed URI string
*
* @access public
* @return string
*/
function ruri_string()
{
return '/'.implode('/', $this->rsegment_array());
}
}
// END URI Class
/* End of file URI.php */
/* Location: ./system/core/URI.php */ | 069h-course-management | trunk/ci/system/core/URI.php | PHP | mit | 14,443 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Security Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Security
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/security.html
*/
class CI_Security {
/**
* Random Hash for protecting URLs
*
* @var string
* @access protected
*/
protected $_xss_hash = '';
/**
* Random Hash for Cross Site Request Forgery Protection Cookie
*
* @var string
* @access protected
*/
protected $_csrf_hash = '';
/**
* Expiration time for Cross Site Request Forgery Protection Cookie
* Defaults to two hours (in seconds)
*
* @var int
* @access protected
*/
protected $_csrf_expire = 7200;
/**
* Token name for Cross Site Request Forgery Protection Cookie
*
* @var string
* @access protected
*/
protected $_csrf_token_name = 'ci_csrf_token';
/**
* Cookie name for Cross Site Request Forgery Protection Cookie
*
* @var string
* @access protected
*/
protected $_csrf_cookie_name = 'ci_csrf_token';
/**
* List of never allowed strings
*
* @var array
* @access protected
*/
protected $_never_allowed_str = array(
'document.cookie' => '[removed]',
'document.write' => '[removed]',
'.parentNode' => '[removed]',
'.innerHTML' => '[removed]',
'window.location' => '[removed]',
'-moz-binding' => '[removed]',
'<!--' => '<!--',
'-->' => '-->',
'<![CDATA[' => '<![CDATA[',
'<comment>' => '<comment>'
);
/* never allowed, regex replacement */
/**
* List of never allowed regex replacement
*
* @var array
* @access protected
*/
protected $_never_allowed_regex = array(
'javascript\s*:',
'expression\s*(\(|&\#40;)', // CSS and IE
'vbscript\s*:', // IE, surprise!
'Redirect\s+302',
"([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?"
);
/**
* Constructor
*
* @return void
*/
public function __construct()
{
// Is CSRF protection enabled?
if (config_item('csrf_protection') === TRUE)
{
// CSRF config
foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
{
if (FALSE !== ($val = config_item($key)))
{
$this->{'_'.$key} = $val;
}
}
// Append application specific cookie prefix
if (config_item('cookie_prefix'))
{
$this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name;
}
// Set the CSRF hash
$this->_csrf_set_hash();
}
log_message('debug', "Security Class Initialized");
}
// --------------------------------------------------------------------
/**
* Verify Cross Site Request Forgery Protection
*
* @return object
*/
public function csrf_verify()
{
// If it's not a POST request we will set the CSRF cookie
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST')
{
return $this->csrf_set_cookie();
}
// Do the tokens exist in both the _POST and _COOKIE arrays?
if ( ! isset($_POST[$this->_csrf_token_name], $_COOKIE[$this->_csrf_cookie_name]))
{
$this->csrf_show_error();
}
// Do the tokens match?
if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name])
{
$this->csrf_show_error();
}
// We kill this since we're done and we don't want to
// polute the _POST array
unset($_POST[$this->_csrf_token_name]);
// Nothing should last forever
unset($_COOKIE[$this->_csrf_cookie_name]);
$this->_csrf_set_hash();
$this->csrf_set_cookie();
log_message('debug', 'CSRF token verified');
return $this;
}
// --------------------------------------------------------------------
/**
* Set Cross Site Request Forgery Protection Cookie
*
* @return object
*/
public function csrf_set_cookie()
{
$expire = time() + $this->_csrf_expire;
$secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 0;
if ($secure_cookie && (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) === 'off'))
{
return FALSE;
}
setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie);
log_message('debug', "CRSF cookie Set");
return $this;
}
// --------------------------------------------------------------------
/**
* Show CSRF Error
*
* @return void
*/
public function csrf_show_error()
{
show_error('The action you have requested is not allowed.');
}
// --------------------------------------------------------------------
/**
* Get CSRF Hash
*
* Getter Method
*
* @return string self::_csrf_hash
*/
public function get_csrf_hash()
{
return $this->_csrf_hash;
}
// --------------------------------------------------------------------
/**
* Get CSRF Token Name
*
* Getter Method
*
* @return string self::csrf_token_name
*/
public function get_csrf_token_name()
{
return $this->_csrf_token_name;
}
// --------------------------------------------------------------------
/**
* XSS Clean
*
* Sanitizes data so that Cross Site Scripting Hacks can be
* prevented. This function does a fair amount of work but
* it is extremely thorough, designed to prevent even the
* most obscure XSS attempts. Nothing is ever 100% foolproof,
* of course, but I haven't been able to get anything passed
* the filter.
*
* Note: This function should only be used to deal with data
* upon submission. It's not something that should
* be used for general runtime processing.
*
* This function was based in part on some code and ideas I
* got from Bitflux: http://channel.bitflux.ch/wiki/XSS_Prevention
*
* To help develop this script I used this great list of
* vulnerabilities along with a few other hacks I've
* harvested from examining vulnerabilities in other programs:
* http://ha.ckers.org/xss.html
*
* @param mixed string or array
* @param bool
* @return string
*/
public function xss_clean($str, $is_image = FALSE)
{
/*
* Is the string an array?
*
*/
if (is_array($str))
{
while (list($key) = each($str))
{
$str[$key] = $this->xss_clean($str[$key]);
}
return $str;
}
/*
* Remove Invisible Characters
*/
$str = remove_invisible_characters($str);
// Validate Entities in URLs
$str = $this->_validate_entities($str);
/*
* URL Decode
*
* Just in case stuff like this is submitted:
*
* <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
*
* Note: Use rawurldecode() so it does not remove plus signs
*
*/
$str = rawurldecode($str);
/*
* Convert character entities to ASCII
*
* This permits our tests below to work reliably.
* We only convert entities that are within tags since
* these are the ones that will pose security problems.
*
*/
$str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
$str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str);
/*
* Remove Invisible Characters Again!
*/
$str = remove_invisible_characters($str);
/*
* Convert all tabs to spaces
*
* This prevents strings like this: ja vascript
* NOTE: we deal with spaces between characters later.
* NOTE: preg_replace was found to be amazingly slow here on
* large blocks of data, so we use str_replace.
*/
if (strpos($str, "\t") !== FALSE)
{
$str = str_replace("\t", ' ', $str);
}
/*
* Capture converted string for later comparison
*/
$converted_string = $str;
// Remove Strings that are never allowed
$str = $this->_do_never_allowed($str);
/*
* Makes PHP tags safe
*
* Note: XML tags are inadvertently replaced too:
*
* <?xml
*
* But it doesn't seem to pose a problem.
*/
if ($is_image === TRUE)
{
// Images have a tendency to have the PHP short opening and
// closing tags every so often so we skip those and only
// do the long opening tags.
$str = preg_replace('/<\?(php)/i', "<?\\1", $str);
}
else
{
$str = str_replace(array('<?', '?'.'>'), array('<?', '?>'), $str);
}
/*
* Compact any exploded words
*
* This corrects words like: j a v a s c r i p t
* These words are compacted back to their correct state.
*/
$words = array(
'javascript', 'expression', 'vbscript', 'script', 'base64',
'applet', 'alert', 'document', 'write', 'cookie', 'window'
);
foreach ($words as $word)
{
$temp = '';
for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++)
{
$temp .= substr($word, $i, 1)."\s*";
}
// We only want to do this when it is followed by a non-word character
// That way valid stuff like "dealer to" does not become "dealerto"
$str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str);
}
/*
* Remove disallowed Javascript in links or img tags
* We used to do some version comparisons and use of stripos for PHP5,
* but it is dog slow compared to these simplified non-capturing
* preg_match(), especially if the pattern exists in the string
*/
do
{
$original = $str;
if (preg_match("/<a/i", $str))
{
$str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
}
if (preg_match("/<img/i", $str))
{
$str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str);
}
if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str))
{
$str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str);
}
}
while($original != $str);
unset($original);
// Remove evil attributes such as style, onclick and xmlns
$str = $this->_remove_evil_attributes($str, $is_image);
/*
* Sanitize naughty HTML elements
*
* If a tag containing any of the words in the list
* below is found, the tag gets converted to entities.
*
* So this: <blink>
* Becomes: <blink>
*/
$naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss';
$str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
/*
* Sanitize naughty scripting elements
*
* Similar to above, only instead of looking for
* tags it looks for PHP and JavaScript commands
* that are disallowed. Rather than removing the
* code, it simply converts the parenthesis to entities
* rendering the code un-executable.
*
* For example: eval('some code')
* Becomes: eval('some code')
*/
$str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2(\\3)", $str);
// Final clean up
// This adds a bit of extra precaution in case
// something got through the above filters
$str = $this->_do_never_allowed($str);
/*
* Images are Handled in a Special Way
* - Essentially, we want to know that after all of the character
* conversion is done whether any unwanted, likely XSS, code was found.
* If not, we return TRUE, as the image is clean.
* However, if the string post-conversion does not matched the
* string post-removal of XSS, then it fails, as there was unwanted XSS
* code found and removed/changed during processing.
*/
if ($is_image === TRUE)
{
return ($str == $converted_string) ? TRUE: FALSE;
}
log_message('debug', "XSS Filtering completed");
return $str;
}
// --------------------------------------------------------------------
/**
* Random Hash for protecting URLs
*
* @return string
*/
public function xss_hash()
{
if ($this->_xss_hash == '')
{
mt_srand();
$this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
}
return $this->_xss_hash;
}
// --------------------------------------------------------------------
/**
* HTML Entities Decode
*
* This function is a replacement for html_entity_decode()
*
* The reason we are not using html_entity_decode() by itself is because
* while it is not technically correct to leave out the semicolon
* at the end of an entity most browsers will still interpret the entity
* correctly. html_entity_decode() does not convert entities without
* semicolons, so we are left with our own little solution here. Bummer.
*
* @param string
* @param string
* @return string
*/
public function entity_decode($str, $charset='UTF-8')
{
if (stristr($str, '&') === FALSE)
{
return $str;
}
$str = html_entity_decode($str, ENT_COMPAT, $charset);
$str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
}
// --------------------------------------------------------------------
/**
* Filename Security
*
* @param string
* @param bool
* @return string
*/
public function sanitize_filename($str, $relative_path = FALSE)
{
$bad = array(
"../",
"<!--",
"-->",
"<",
">",
"'",
'"',
'&',
'$',
'#',
'{',
'}',
'[',
']',
'=',
';',
'?',
"%20",
"%22",
"%3c", // <
"%253c", // <
"%3e", // >
"%0e", // >
"%28", // (
"%29", // )
"%2528", // (
"%26", // &
"%24", // $
"%3f", // ?
"%3b", // ;
"%3d" // =
);
if ( ! $relative_path)
{
$bad[] = './';
$bad[] = '/';
}
$str = remove_invisible_characters($str, FALSE);
return stripslashes(str_replace($bad, '', $str));
}
// ----------------------------------------------------------------
/**
* Compact Exploded Words
*
* Callback function for xss_clean() to remove whitespace from
* things like j a v a s c r i p t
*
* @param type
* @return type
*/
protected function _compact_exploded_words($matches)
{
return preg_replace('/\s+/s', '', $matches[1]).$matches[2];
}
// --------------------------------------------------------------------
/*
* Remove Evil HTML Attributes (like evenhandlers and style)
*
* It removes the evil attribute and either:
* - Everything up until a space
* For example, everything between the pipes:
* <a |style=document.write('hello');alert('world');| class=link>
* - Everything inside the quotes
* For example, everything between the pipes:
* <a |style="document.write('hello'); alert('world');"| class="link">
*
* @param string $str The string to check
* @param boolean $is_image TRUE if this is an image
* @return string The string with the evil attributes removed
*/
protected function _remove_evil_attributes($str, $is_image)
{
// All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
$evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction');
if ($is_image === TRUE)
{
/*
* Adobe Photoshop puts XML metadata into JFIF images,
* including namespacing, so we have to allow this for images.
*/
unset($evil_attributes[array_search('xmlns', $evil_attributes)]);
}
do {
$count = 0;
$attribs = array();
// find occurrences of illegal attribute strings without quotes
preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER);
foreach ($matches as $attr)
{
$attribs[] = preg_quote($attr[0], '/');
}
// find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes)
preg_match_all("/(".implode('|', $evil_attributes).")\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is", $str, $matches, PREG_SET_ORDER);
foreach ($matches as $attr)
{
$attribs[] = preg_quote($attr[0], '/');
}
// replace illegal attribute strings that are inside an html tag
if (count($attribs) > 0)
{
$str = preg_replace("/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)(".implode('|', $attribs).")(.*?)([\s><])([><]*)/i", '<$1 $3$5$6$7', $str, -1, $count);
}
} while ($count);
return $str;
}
// --------------------------------------------------------------------
/**
* Sanitize Naughty HTML
*
* Callback function for xss_clean() to remove naughty HTML elements
*
* @param array
* @return string
*/
protected function _sanitize_naughty_html($matches)
{
// encode opening brace
$str = '<'.$matches[1].$matches[2].$matches[3];
// encode captured opening or closing brace to prevent recursive vectors
$str .= str_replace(array('>', '<'), array('>', '<'),
$matches[4]);
return $str;
}
// --------------------------------------------------------------------
/**
* JS Link Removal
*
* Callback function for xss_clean() to sanitize links
* This limits the PCRE backtracks, making it more performance friendly
* and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
* PHP 5.2+ on link-heavy strings
*
* @param array
* @return string
*/
protected function _js_link_removal($match)
{
return str_replace(
$match[1],
preg_replace(
'#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|data\s*:)#si',
'',
$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
),
$match[0]
);
}
// --------------------------------------------------------------------
/**
* JS Image Removal
*
* Callback function for xss_clean() to sanitize image tags
* This limits the PCRE backtracks, making it more performance friendly
* and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
* PHP 5.2+ on image tag heavy strings
*
* @param array
* @return string
*/
protected function _js_img_removal($match)
{
return str_replace(
$match[1],
preg_replace(
'#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si',
'',
$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
),
$match[0]
);
}
// --------------------------------------------------------------------
/**
* Attribute Conversion
*
* Used as a callback for XSS Clean
*
* @param array
* @return string
*/
protected function _convert_attribute($match)
{
return str_replace(array('>', '<', '\\'), array('>', '<', '\\\\'), $match[0]);
}
// --------------------------------------------------------------------
/**
* Filter Attributes
*
* Filters tag attributes for consistency and safety
*
* @param string
* @return string
*/
protected function _filter_attributes($str)
{
$out = '';
if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches))
{
foreach ($matches[0] as $match)
{
$out .= preg_replace("#/\*.*?\*/#s", '', $match);
}
}
return $out;
}
// --------------------------------------------------------------------
/**
* HTML Entity Decode Callback
*
* Used as a callback for XSS Clean
*
* @param array
* @return string
*/
protected function _decode_entity($match)
{
return $this->entity_decode($match[0], strtoupper(config_item('charset')));
}
// --------------------------------------------------------------------
/**
* Validate URL entities
*
* Called by xss_clean()
*
* @param string
* @return string
*/
protected function _validate_entities($str)
{
/*
* Protect GET variables in URLs
*/
// 901119URL5918AMP18930PROTECT8198
$str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str);
/*
* Validate standard character entities
*
* Add a semicolon if missing. We do this to enable
* the conversion of entities to ASCII later.
*
*/
$str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str);
/*
* Validate UTF16 two byte encoding (x00)
*
* Just as above, adds a semicolon if missing.
*
*/
$str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str);
/*
* Un-Protect GET variables in URLs
*/
$str = str_replace($this->xss_hash(), '&', $str);
return $str;
}
// ----------------------------------------------------------------------
/**
* Do Never Allowed
*
* A utility function for xss_clean()
*
* @param string
* @return string
*/
protected function _do_never_allowed($str)
{
$str = str_replace(array_keys($this->_never_allowed_str), $this->_never_allowed_str, $str);
foreach ($this->_never_allowed_regex as $regex)
{
$str = preg_replace('#'.$regex.'#is', '[removed]', $str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Set Cross Site Request Forgery Protection Cookie
*
* @return string
*/
protected function _csrf_set_hash()
{
if ($this->_csrf_hash == '')
{
// If the cookie exists we will use it's value.
// We don't necessarily want to regenerate it with
// each page load since a page could contain embedded
// sub-pages causing this feature to fail
if (isset($_COOKIE[$this->_csrf_cookie_name]) &&
preg_match('#^[0-9a-f]{32}$#iS', $_COOKIE[$this->_csrf_cookie_name]) === 1)
{
return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name];
}
return $this->_csrf_hash = md5(uniqid(rand(), TRUE));
}
return $this->_csrf_hash;
}
}
/* End of file Security.php */
/* Location: ./system/libraries/Security.php */ | 069h-course-management | trunk/ci/system/core/Security.php | PHP | mit | 22,006 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Application Controller Class
*
* This class object is the super class that every library in
* CodeIgniter will be assigned to.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/general/controllers.html
*/
class CI_Controller {
private static $instance;
/**
* Constructor
*/
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->initialize();
log_message('debug', "Controller Class Initialized");
}
public static function &get_instance()
{
return self::$instance;
}
}
// END Controller class
/* End of file Controller.php */
/* Location: ./system/core/Controller.php */ | 069h-course-management | trunk/ci/system/core/Controller.php | PHP | mit | 1,567 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 069h-course-management | trunk/ci/system/fonts/index.html | HTML | mit | 114 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter License Agreement : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
<script type="text/javascript" src="nav/nav.js"></script>
<script type="text/javascript" src="nav/prototype.lite.js"></script>
<script type="text/javascript" src="nav/moo.fx.js"></script>
<script type="text/javascript" src="nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('null');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="index.html">User Guide Home</a> ›
License Agreement
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>CodeIgniter License Agreement</h1>
<p>Copyright (c) 2008 - 2011, EllisLab, Inc.<br />
All rights reserved.</p>
<p>This license is a legal agreement between you and EllisLab Inc. for the use of CodeIgniter Software (the "Software"). By obtaining the Software you agree to comply with the terms and conditions of this license.</p>
<h2>Permitted Use</h2>
<p>You are permitted to use, copy, modify, and distribute the Software and its documentation, with or without modification, for any purpose, provided that the following conditions are met:</p>
<ol>
<li>A copy of this license agreement must be included with the distribution.</li>
<li>Redistributions of source code must retain the above copyright notice in all source code files.</li>
<li>Redistributions in binary form must reproduce the above copyright notice in the documentation and/or other materials provided with the distribution.</li>
<li>Any files that have been modified must carry notices stating the nature of the change and the names of those who changed them.</li>
<li>Products derived from the Software must include an acknowledgment that they are derived from CodeIgniter in their documentation and/or other materials provided with the distribution.</li>
<li>Products derived from the Software may not be called "CodeIgniter", nor may "CodeIgniter" appear in their name, without prior written permission from EllisLab, Inc.</li>
</ol>
<h2>Indemnity</h2>
<p>You agree to indemnify and hold harmless the authors of the Software and any contributors for any direct, indirect, incidental, or consequential third-party claims, actions or suits, as well as any related expenses, liabilities, damages, settlements or fees arising from your use or misuse of the Software, or a violation of any terms of this license.</p>
<h2>Disclaimer of Warranty</h2>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF QUALITY, PERFORMANCE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.</p>
<h2>Limitations of Liability</h2>
<p>YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE BE LIABLE FOR CLAIMS, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="general/requirements.html">Server Requirements</a>
·
<a href="#top">Top of Page</a> ·
<a href="index.html">User Guide Home</a> ·
Next Topic: <a href="changelog.html">Change Log</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/license.html | HTML | mit | 5,676 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to CodeIgniter : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
<script type="text/javascript" src="nav/nav.js"></script>
<script type="text/javascript" src="nav/prototype.lite.js"></script>
<script type="text/javascript" src="nav/moo.fx.js"></script>
<script type="text/javascript" src="nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('null');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> › CodeIgniter User Guide
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<br clear="all" />
<div class="center"><img src="images/ci_logo_flame.jpg" width="150" height="164" border="0" alt="CodeIgniter" /></div>
<!-- START CONTENT -->
<div id="content">
<h2>Welcome to CodeIgniter</h2>
<p>CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP.
Its goal is to enable you to develop projects much faster than you could if you were writing code
from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and
logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by
minimizing the amount of code needed for a given task.</p>
<h2>Who is CodeIgniter For?</h2>
<p>CodeIgniter is right for you if:</p>
<ul>
<li>You want a framework with a small footprint.</li>
<li>You need exceptional performance.</li>
<li>You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.</li>
<li>You want a framework that requires nearly zero configuration.</li>
<li>You want a framework that does not require you to use the command line.</li>
<li>You want a framework that does not require you to adhere to restrictive coding rules.</li>
<li>You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).</li>
<li>You eschew complexity, favoring simple solutions.</li>
<li>You need clear, thorough documentation.</li>
</ul>
</div>
<!-- END CONTENT -->
<div id="footer">
<p><a href="#top">Top of Page</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/index.html | HTML | mit | 4,056 |
function create_menu(basepath)
{
var base = (basepath == 'null') ? '' : basepath;
document.write(
'<table cellpadding="0" cellspaceing="0" border="0" style="width:98%"><tr>' +
'<td class="td" valign="top">' +
'<ul>' +
'<li><a href="'+base+'index.html">User Guide Home</a></li>' +
'<li><a href="'+base+'toc.html">Table of Contents Page</a></li>' +
'</ul>' +
'<h3>Basic Info</h3>' +
'<ul>' +
'<li><a href="'+base+'general/requirements.html">Server Requirements</a></li>' +
'<li><a href="'+base+'license.html">License Agreement</a></li>' +
'<li><a href="'+base+'changelog.html">Change Log</a></li>' +
'<li><a href="'+base+'general/credits.html">Credits</a></li>' +
'</ul>' +
'<h3>Installation</h3>' +
'<ul>' +
'<li><a href="'+base+'installation/downloads.html">Downloading CodeIgniter</a></li>' +
'<li><a href="'+base+'installation/index.html">Installation Instructions</a></li>' +
'<li><a href="'+base+'installation/upgrading.html">Upgrading from a Previous Version</a></li>' +
'<li><a href="'+base+'installation/troubleshooting.html">Troubleshooting</a></li>' +
'</ul>' +
'<h3>Introduction</h3>' +
'<ul>' +
'<li><a href="'+base+'overview/getting_started.html">Getting Started</a></li>' +
'<li><a href="'+base+'overview/at_a_glance.html">CodeIgniter at a Glance</a></li>' +
'<li><a href="'+base+'overview/cheatsheets.html">CodeIgniter Cheatsheets</a></li>' +
'<li><a href="'+base+'overview/features.html">Supported Features</a></li>' +
'<li><a href="'+base+'overview/appflow.html">Application Flow Chart</a></li>' +
'<li><a href="'+base+'overview/mvc.html">Model-View-Controller</a></li>' +
'<li><a href="'+base+'overview/goals.html">Architectural Goals</a></li>' +
'</ul>' +
'<h3>Tutorial</h3>' +
'<ul>' +
'<li><a href="'+base+'tutorial/index.html">Introduction</a></li>' +
'<li><a href="'+base+'tutorial/static_pages.html">Static pages</a></li>' +
'<li><a href="'+base+'tutorial/news_section.html">News section</a></li>' +
'<li><a href="'+base+'tutorial/create_news_items.html">Create news items</a></li>' +
'<li><a href="'+base+'tutorial/conclusion.html">Conclusion</a></li>' +
'</ul>' +
'</td><td class="td_sep" valign="top">' +
'<h3>General Topics</h3>' +
'<ul>' +
'<li><a href="'+base+'general/urls.html">CodeIgniter URLs</a></li>' +
'<li><a href="'+base+'general/controllers.html">Controllers</a></li>' +
'<li><a href="'+base+'general/reserved_names.html">Reserved Names</a></li>' +
'<li><a href="'+base+'general/views.html">Views</a></li>' +
'<li><a href="'+base+'general/models.html">Models</a></li>' +
'<li><a href="'+base+'general/helpers.html">Helpers</a></li>' +
'<li><a href="'+base+'general/libraries.html">Using CodeIgniter Libraries</a></li>' +
'<li><a href="'+base+'general/creating_libraries.html">Creating Your Own Libraries</a></li>' +
'<li><a href="'+base+'general/drivers.html">Using CodeIgniter Drivers</a></li>' +
'<li><a href="'+base+'general/creating_drivers.html">Creating Your Own Drivers</a></li>' +
'<li><a href="'+base+'general/core_classes.html">Creating Core Classes</a></li>' +
'<li><a href="'+base+'general/hooks.html">Hooks - Extending the Core</a></li>' +
'<li><a href="'+base+'general/autoloader.html">Auto-loading Resources</a></li>' +
'<li><a href="'+base+'general/common_functions.html">Common Functions</a></li>' +
'<li><a href="'+base+'general/routing.html">URI Routing</a></li>' +
'<li><a href="'+base+'general/errors.html">Error Handling</a></li>' +
'<li><a href="'+base+'general/caching.html">Caching</a></li>' +
'<li><a href="'+base+'general/profiling.html">Profiling Your Application</a></li>' +
'<li><a href="'+base+'general/cli.html">Running via the CLI</a></li>' +
'<li><a href="'+base+'general/managing_apps.html">Managing Applications</a></li>' +
'<li><a href="'+base+'general/environments.html">Handling Multiple Environments</a></li>' +
'<li><a href="'+base+'general/alternative_php.html">Alternative PHP Syntax</a></li>' +
'<li><a href="'+base+'general/security.html">Security</a></li>' +
'<li><a href="'+base+'general/styleguide.html">PHP Style Guide</a></li>' +
'<li><a href="'+base+'doc_style/index.html">Writing Documentation</a></li>' +
'</ul>' +
'<h3>Additional Resources</h3>' +
'<ul>' +
'<li><a href="http://codeigniter.com/forums/">Community Forums</a></li>' +
'<li><a href="http://codeigniter.com/wiki/">Community Wiki</a></li>' +
'</ul>' +
'</td><td class="td_sep" valign="top">' +
'<h3>Class Reference</h3>' +
'<ul>' +
'<li><a href="'+base+'libraries/benchmark.html">Benchmarking Class</a></li>' +
'<li><a href="'+base+'libraries/calendar.html">Calendar Class</a></li>' +
'<li><a href="'+base+'libraries/cart.html">Cart Class</a></li>' +
'<li><a href="'+base+'libraries/config.html">Config Class</a></li>' +
'<li><a href="'+base+'libraries/email.html">Email Class</a></li>' +
'<li><a href="'+base+'libraries/encryption.html">Encryption Class</a></li>' +
'<li><a href="'+base+'libraries/file_uploading.html">File Uploading Class</a></li>' +
'<li><a href="'+base+'libraries/form_validation.html">Form Validation Class</a></li>' +
'<li><a href="'+base+'libraries/ftp.html">FTP Class</a></li>' +
'<li><a href="'+base+'libraries/table.html">HTML Table Class</a></li>' +
'<li><a href="'+base+'libraries/image_lib.html">Image Manipulation Class</a></li>' +
'<li><a href="'+base+'libraries/input.html">Input Class</a></li>' +
'<li><a href="'+base+'libraries/javascript.html">Javascript Class</a></li>' +
'<li><a href="'+base+'libraries/loader.html">Loader Class</a></li>' +
'<li><a href="'+base+'libraries/language.html">Language Class</a></li>' +
'<li><a href="'+base+'libraries/migration.html">Migration Class</a></li>' +
'<li><a href="'+base+'libraries/output.html">Output Class</a></li>' +
'<li><a href="'+base+'libraries/pagination.html">Pagination Class</a></li>' +
'<li><a href="'+base+'libraries/security.html">Security Class</a></li>' +
'<li><a href="'+base+'libraries/sessions.html">Session Class</a></li>' +
'<li><a href="'+base+'libraries/trackback.html">Trackback Class</a></li>' +
'<li><a href="'+base+'libraries/parser.html">Template Parser Class</a></li>' +
'<li><a href="'+base+'libraries/typography.html">Typography Class</a></li>' +
'<li><a href="'+base+'libraries/unit_testing.html">Unit Testing Class</a></li>' +
'<li><a href="'+base+'libraries/uri.html">URI Class</a></li>' +
'<li><a href="'+base+'libraries/user_agent.html">User Agent Class</a></li>' +
'<li><a href="'+base+'libraries/xmlrpc.html">XML-RPC Class</a></li>' +
'<li><a href="'+base+'libraries/zip.html">Zip Encoding Class</a></li>' +
'</ul>' +
'</td><td class="td_sep" valign="top">' +
'<h3>Driver Reference</h3>' +
'<ul>' +
'<li><a href="'+base+'libraries/caching.html">Caching Class</a></li>' +
'<li><a href="'+base+'database/index.html">Database Class</a></li>' +
'<li><a href="'+base+'libraries/javascript.html">Javascript Class</a></li>' +
'</ul>' +
'<h3>Helper Reference</h3>' +
'<ul>' +
'<li><a href="'+base+'helpers/array_helper.html">Array Helper</a></li>' +
'<li><a href="'+base+'helpers/captcha_helper.html">CAPTCHA Helper</a></li>' +
'<li><a href="'+base+'helpers/cookie_helper.html">Cookie Helper</a></li>' +
'<li><a href="'+base+'helpers/date_helper.html">Date Helper</a></li>' +
'<li><a href="'+base+'helpers/directory_helper.html">Directory Helper</a></li>' +
'<li><a href="'+base+'helpers/download_helper.html">Download Helper</a></li>' +
'<li><a href="'+base+'helpers/email_helper.html">Email Helper</a></li>' +
'<li><a href="'+base+'helpers/file_helper.html">File Helper</a></li>' +
'<li><a href="'+base+'helpers/form_helper.html">Form Helper</a></li>' +
'<li><a href="'+base+'helpers/html_helper.html">HTML Helper</a></li>' +
'<li><a href="'+base+'helpers/inflector_helper.html">Inflector Helper</a></li>' +
'<li><a href="'+base+'helpers/language_helper.html">Language Helper</a></li>' +
'<li><a href="'+base+'helpers/number_helper.html">Number Helper</a></li>' +
'<li><a href="'+base+'helpers/path_helper.html">Path Helper</a></li>' +
'<li><a href="'+base+'helpers/security_helper.html">Security Helper</a></li>' +
'<li><a href="'+base+'helpers/smiley_helper.html">Smiley Helper</a></li>' +
'<li><a href="'+base+'helpers/string_helper.html">String Helper</a></li>' +
'<li><a href="'+base+'helpers/text_helper.html">Text Helper</a></li>' +
'<li><a href="'+base+'helpers/typography_helper.html">Typography Helper</a></li>' +
'<li><a href="'+base+'helpers/url_helper.html">URL Helper</a></li>' +
'<li><a href="'+base+'helpers/xml_helper.html">XML Helper</a></li>' +
'</ul>' +
'</td></tr></table>');
} | 069h-course-management | trunk/ci/user_guide/nav/nav.js | JavaScript | mit | 8,801 |
/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
10/24/2005
v(1.0.2)
*/
//base
var fx = new Object();
fx.Base = function(){};
fx.Base.prototype = {
setOptions: function(options) {
this.options = {
duration: 500,
onComplete: ''
}
Object.extend(this.options, options || {});
},
go: function() {
this.duration = this.options.duration;
this.startTime = (new Date).getTime();
this.timer = setInterval (this.step.bind(this), 13);
},
step: function() {
var time = (new Date).getTime();
var Tpos = (time - this.startTime) / (this.duration);
if (time >= this.duration+this.startTime) {
this.now = this.to;
clearInterval (this.timer);
this.timer = null;
if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
}
else {
this.now = ((-Math.cos(Tpos*Math.PI)/2) + 0.5) * (this.to-this.from) + this.from;
//this time-position, sinoidal transition thing is from script.aculo.us
}
this.increase();
},
custom: function(from, to) {
if (this.timer != null) return;
this.from = from;
this.to = to;
this.go();
},
hide: function() {
this.now = 0;
this.increase();
},
clearTimer: function() {
clearInterval(this.timer);
this.timer = null;
}
}
//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
initialize: function(el, options) {
this.el = $(el);
this.el.style.overflow = "hidden";
this.el.iniWidth = this.el.offsetWidth;
this.el.iniHeight = this.el.offsetHeight;
this.setOptions(options);
}
});
fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {
increase: function() {
this.el.style.height = this.now + "px";
},
toggle: function() {
if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
else this.custom(0, this.el.scrollHeight);
}
});
| 069h-course-management | trunk/ci/user_guide/nav/moo.fx.js | JavaScript | mit | 1,996 |
window.onload = function() {
myHeight = new fx.Height('nav', {duration: 400});
myHeight.hide();
} | 069h-course-management | trunk/ci/user_guide/nav/user_guide_menu.js | JavaScript | mit | 99 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting Started With CodeIgniter : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Getting Started
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Getting Started With CodeIgniter</h1>
<p>Any software application requires some effort to learn. We've done our best to minimize the learning
curve while making the process as enjoyable as possible.
</p>
<p>The first step is to <a href="../installation/index.html">install</a> CodeIgniter, then read
all the topics in the <strong>Introduction</strong> section of the Table of Contents.</p>
<p>Next, read each of the <strong>General Topics</strong> pages in order.
Each topic builds on the previous one, and includes code examples that you are encouraged to try.</p>
<p>Once you understand the basics you'll be ready to explore the <strong>Class Reference</strong> and
<strong>Helper Reference</strong> pages to learn to utilize the native libraries and helper files.</p>
<p>Feel free to take advantage of our <a href="http://codeigniter.com/forums/">Community Forums</a>
if you have questions or problems, and
our <a href="http://codeigniter.com/wiki/">Wiki</a> to see code examples posted by other users.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="at_a_glance.html">CodeIgniter At a Glance</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/getting_started.html | HTML | mit | 3,970 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter Overview : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Introduction
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>CodeIgniter Overview</h1>
<p>The following pages describe the broad concepts behind CodeIgniter:</p>
<ul>
<li><a href="at_a_glance.html">CodeIgniter at a Glance</a></li>
<li><a href="features.html">Supported Features</a></li>
<li><a href="appflow.html">Application Flow Chart</a></li>
<li><a href="mvc.html">Introduction to the Model-View-Controller</a></li>
<li><a href="goals.html">Design and Architectural Goals</a></li>
<li><a href="package.html">Package Description</a></li>
</ul>
</div>
<!-- END CONTENT -->
<div id="footer">
<p><a href="#top">Top of Page</a> · <a href="../index.html">User Guide Home</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/index.html | HTML | mit | 3,308 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Application Flow Chart : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Appflow
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Application Flow Chart</h1>
<p>The following graphic illustrates how data flows throughout the system:</p>
<div><img src="../images/appflowchart.gif" width="769" height="212" alt="CodeIgniter application flow"></div>
<ol>
<li>The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.</li>
<li>The Router examines the HTTP request to determine what should be done with it.</li>
<li>If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.</li>
<li>Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.</li>
<li>The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.</li>
<li>The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so
that on subsequent requests it can be served.</li>
</ol>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="features.html">CodeIgniter Features</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="mvc.html">Model-View-Controller</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/appflow.html | HTML | mit | 4,030 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter Features : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Features
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>CodeIgniter Features</h1>
<p>Features in and of themselves are a very poor way to judge an application since they tell you nothing
about the user experience, or how intuitively or intelligently it is designed. Features
don't reveal anything about the quality of the code, or the performance, or the attention to detail, or security practices.
The only way to really judge an app is to try it and get to know the code. <a href="../installation/">Installing</a>
CodeIgniter is child's play so we encourage you to do just that. In the mean time here's a list of CodeIgniter's main features.</p>
<ul>
<li>Model-View-Controller Based System</li>
<li>Extremely Light Weight</li>
<li>Full Featured database classes with support for several platforms.</li>
<li>Active Record Database Support</li>
<li>Form and Data Validation</li>
<li>Security and XSS Filtering</li>
<li>Session Management</li>
<li>Email Sending Class. Supports Attachments, HTML/Text email, multiple protocols (sendmail, SMTP, and Mail) and more.</li>
<li>Image Manipulation Library (cropping, resizing, rotating, etc.). Supports GD, ImageMagick, and NetPBM</li>
<li>File Uploading Class</li>
<li>FTP Class</li>
<li>Localization</li>
<li>Pagination</li>
<li>Data Encryption</li>
<li>Benchmarking</li>
<li>Full Page Caching</li>
<li>Error Logging</li>
<li>Application Profiling</li>
<li>Calendaring Class</li>
<li>User Agent Class</li>
<li>Zip Encoding Class</li>
<li>Template Engine Class</li>
<li>Trackback Class</li>
<li>XML-RPC Library</li>
<li>Unit Testing Class</li>
<li>Search-engine Friendly URLs</li>
<li>Flexible URI Routing</li>
<li>Support for Hooks and Class Extensions</li>
<li>Large library of "helper" functions</li>
</ul>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="cheatsheets.html">CodeIgniter Cheatsheets</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="appflow.html">Application Flow Chart</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/features.html | HTML | mit | 4,757 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter at a Glance : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
What is CodeIgniter?
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>CodeIgniter at a Glance</h1>
<h2>CodeIgniter is an Application Framework</h2>
<p>CodeIgniter is a toolkit for people who build web applications using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code
from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and
logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by
minimizing the amount of code needed for a given task.</p>
<h2>CodeIgniter is Free</h2>
<p>CodeIgniter is licensed under an Apache/BSD-style open source license so you can use it however you please.
For more information please read the <a href="../license.html">license agreement</a>.</p>
<h2>CodeIgniter is Light Weight</h2>
<p>Truly light weight. The core system requires only a few very small libraries. This is in stark contrast to many frameworks that require significantly more resources.
Additional libraries are loaded dynamically upon request, based on your needs for a given process, so the base system
is very lean and quite fast.
</p>
<h2>CodeIgniter is Fast</h2>
<p>Really fast. We challenge you to find a framework that has better performance than CodeIgniter.</p>
<h2>CodeIgniter Uses M-V-C</h2>
<p>CodeIgniter uses the Model-View-Controller approach, which allows great separation between logic and presentation.
This is particularly good for projects in which designers are working with your template files, as the code these file contain will be minimized. We describe MVC in more detail on its own page.</p>
<h2>CodeIgniter Generates Clean URLs</h2>
<p>The URLs generated by CodeIgniter are clean and search-engine friendly. Rather than using the standard "query string"
approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a segment-based approach:</p>
<code>example.com/<var>news</var>/<dfn>article</dfn>/<samp>345</samp></code>
<p>Note: By default the index.php file is included in the URL but it can be removed using a simple .htaccess file.</p>
<h2>CodeIgniter Packs a Punch</h2>
<p>CodeIgniter comes with full-range of libraries that enable the most commonly needed web development tasks,
like accessing a database, sending email, validating form data, maintaining sessions, manipulating images, working with XML-RPC data and
much more.</p>
<h2>CodeIgniter is Extensible</h2>
<p>The system can be easily extended through the use of your own libraries, helpers, or through class extensions or system hooks.</p>
<h2>CodeIgniter Does Not Require a Template Engine</h2>
<p>Although CodeIgniter <em>does</em> come with a simple template parser that can be optionally used, it does not force you to use one.
Template engines simply can not match the performance of native PHP, and the syntax that must be learned to use a template
engine is usually only marginally easier than learning the basics of PHP. Consider this block of PHP code:</p>
<code><ul><br />
<br />
<?php foreach ($addressbook as $name):?><br />
<br />
<li><?=$name?></li><br />
<br />
<?php endforeach; ?><br />
<br />
</ul></code>
<p>Contrast this with the pseudo-code used by a template engine:</p>
<code><ul><br />
<br />
{foreach from=$addressbook item="name"}<br />
<br />
<li>{$name}</li><br />
<br />
{/foreach}<br />
<br />
</ul></code>
<p>Yes, the template engine example is a bit cleaner, but it comes at the price of performance, as the pseudo-code must be converted
back into PHP to run. Since one of our goals is <em>maximum performance</em>, we opted to not require the use of a template engine.</p>
<h2>CodeIgniter is Thoroughly Documented</h2>
<p>Programmers love to code and hate to write documentation. We're no different, of course, but
since documentation is <strong>as important</strong> as the code itself,
we are committed to doing it. Our source code is extremely clean and well commented as well.</p>
<h2>CodeIgniter has a Friendly Community of Users</h2>
<p>Our growing community of users can be seen actively participating in our <a href="http://codeigniter.com/forums/">Community Forums</a>.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="getting_started.html">Getting Started</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="cheatsheets.html">CodeIgniter Cheatsheets</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/at_a_glance.html | HTML | mit | 7,231 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Design and Architectural Goals : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Goals
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h2>Design and Architectural Goals</h2>
<p>Our goal for CodeIgniter is <dfn>maximum performance, capability, and flexibility in the smallest, lightest possible package</dfn>.</p>
<p>To meet this goal we are committed to benchmarking, re-factoring, and simplifying at every step of the development process,
rejecting anything that doesn't further the stated objective.</p>
<p>From a technical and architectural standpoint, CodeIgniter was created with the following objectives:</p>
<ul>
<li><strong>Dynamic Instantiation.</strong> In CodeIgniter, components are loaded and routines executed only when requested, rather than globally. No assumptions are made by the system regarding what may be needed beyond the minimal core resources, so the system is very light-weight by default. The events, as triggered by the HTTP request, and the controllers and views you design will determine what is invoked.</li>
<li><strong>Loose Coupling.</strong> Coupling is the degree to which components of a system rely on each other. The less components depend on each other the more reusable and flexible the system becomes. Our goal was a very loosely coupled system.</li>
<li><strong>Component Singularity.</strong> Singularity is the degree to which components have a narrowly focused purpose. In CodeIgniter, each class and its functions are highly autonomous in order to allow maximum usefulness.</li>
</ul>
<p>CodeIgniter is a dynamically instantiated, loosely coupled system with high component singularity. It strives for simplicity, flexibility, and high performance in a small footprint package.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="mvc.html">Model-View-Controller</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="./getting_started.html">Getting Started</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/goals.html | HTML | mit | 4,660 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model-View-Controller : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
MVC
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Model-View-Controller</h1>
<p>CodeIgniter is based on the Model-View-Controller development pattern.
MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.</p>
<ul>
<li>The <strong>Model</strong> represents your data structures. Typically your model classes will contain functions that help you
retrieve, insert, and update information in your database.</li>
<li>The <strong>View</strong> is the information that is being presented to a user. A View will normally be a web page, but
in CodeIgniter, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of "page".</li>
<li>The <strong>Controller</strong> serves as an <em>intermediary</em> between the Model, the View,
and any other resources needed to process the HTTP request and generate a web page.</li>
</ul>
<p>CodeIgniter has a fairly loose approach to MVC since Models are not required.
If you don't need the added separation, or find that maintaining models requires more complexity than you
want, you can ignore them and build your application minimally using Controllers and Views. CodeIgniter also
enables you to incorporate your own existing scripts, or even develop core libraries for the system,
enabling you to work in a way that makes the most sense to you.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="appflow.html">Application Flow Chart</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="goals.html">Architectural Goals</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/mvc.html | HTML | mit | 4,481 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter Cheatsheets : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
CodeIgniter Cheatsheets
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>CodeIgniter Cheatsheets</h1>
<h2>Library Reference</h2>
<div><a href="../images/codeigniter_1.7.1_library_reference.pdf"><img src="../images/codeigniter_1.7.1_library_reference.png" width="600" height="195" border="0" alt="CodeIgniter Library Reference" /></a></div>
<h2>Helpers Reference</h2>
<div><a href="../images/codeigniter_1.7.1_helper_reference.pdf"><img src="../images/codeigniter_1.7.1_helper_reference.png" width="600" height="196" border="0" alt="CodeIgniter Library Reference" /></a></div>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="at_a_glance.html">CodeIgniter at a Glance</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="features.html">CodeIgniter Features</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/overview/cheatsheets.html | HTML | mit | 3,573 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.5.0 to 1.5.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.5.0 to 1.5.2</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.5.0 or 1.5.1. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/helpers/download_helper.php</dfn></li>
<li><dfn>system/helpers/form_helper.php</dfn></li>
<li><dfn>system/libraries/Table.php</dfn></li>
<li><dfn>system/libraries/User_agent.php</dfn></li>
<li><dfn>system/libraries/Exceptions.php</dfn></li>
<li><dfn>system/libraries/Input.php</dfn></li>
<li><dfn>system/libraries/Router.php</dfn></li>
<li><dfn>system/libraries/Loader.php</dfn></li>
<li><dfn>system/libraries/Image_lib.php</dfn></li>
<li><dfn>system/language/english/unit_test_lang.php</dfn></li>
<li><dfn>system/database/DB_active_rec.php</dfn></li>
<li><dfn> system/database/drivers/mysqli/mysqli_driver.php</dfn></li>
<li><dfn>codeigniter/</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_152.html | HTML | mit | 4,479 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.1.1 to 2.1.2 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.1.1 to 2.1.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.1.1 to 2.1.2</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_212.html | HTML | mit | 3,617 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Installation Instructions : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Installation Instructions
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Installation Instructions</h1>
<p>CodeIgniter is installed in four steps:</p>
<ol>
<li>Unzip the package.</li>
<li>Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.</li>
<li>Open the <dfn>application/config/config.php</dfn> file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.</li>
<li>If you intend to use a database, open the <dfn>application/config/database.php</dfn> file with a text editor and set your database settings.</li>
</ol>
<p>If you wish to increase security by hiding the location of your CodeIgniter files you can rename the <dfn>system</dfn> and <dfn>application</dfn> folders
to something more private. If you do rename them, you must open your main <kbd>index.php</kbd> file and set the <samp>$system_folder</samp> and <samp>$application_folder</samp>
variables at the top of the file with the new name you've chosen.</p>
<p>For the best security, both the <dfn>system</dfn> and any <dfn>application</dfn> folders should be placed above web root so that they are not directly accessible via a browser. By default, .htaccess files are included in each folder to help prevent direct access, but it is best to remove them from public access entirely in case the web server configuration changes or doesn't abide by the .htaccess.</p>
<p>After moving them, open your main <kdb>index.php</kbd> file and set the <samp>$system_folder</samp> and <samp>$application_folder</samp> variables, preferably with a full path, e.g. '<dfn>/www/MyUser/system</dfn>'.</p>
<p>
One additional measure to take in production environments is to disable
PHP error reporting and any other development-only functionality. In CodeIgniter,
this can be done by setting the <kbd>ENVIRONMENT</kbd> constant, which is
more fully described on the <a href="../general/security.html">security page</a>.
</p>
<p>That's it!</p>
<p>If you're new to CodeIgniter, please read the <a href="../overview/getting_started.html">Getting Started</a> section of the User Guide to begin learning how
to build dynamic PHP applications. Enjoy!</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="../general/credits.html">Credits</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="upgrading.html">Upgrading from a Previous Version</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/index.html | HTML | mit | 5,244 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.0.2 to 2.0.3 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.0.2 to 2.0.3
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.0.2 to 2.0.3</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your main index.php file</h2>
<p>If you are running a stock <dfn>index.php</dfn> file simply replace your version with the new one.</p>
<p>If your <dfn>index.php</dfn> file has internal modifications, please add your modifications to the new file and use it.</p>
<h2>Step 3: Replace config/user_agents.php</h2>
<p>This config file has been updated to contain more user agent types, please copy it to <kbd>application/config/user_agents.php</kbd>.</p>
<h2>Step 4: Change references of the EXT constant to ".php"</h2>
<p class="important"><strong>Note:</strong> The EXT Constant has been marked as deprecated, but has not been removed from the application. You are encouraged to make the changes sooner rather than later.</p>
<h2>Step 5: Remove APPPATH.'third_party' from autoload.php</h2>
<p>Open application/autoload.php, and look for the following:</p>
<code>$autoload['packages'] = array(APPPATH.'third_party');</code>
<p>If you have not chosen to load any additional packages, that line can be changed to:</p>
<code>$autoload['packages'] = array();</code>
<p>Which should provide for nominal performance gains if not autoloading packages.</p>
<h2>Update Sessions Database Tables</h2>
<p>If you are using database sessions with the CI Session Library, please update your <samp>ci_sessions</samp> database table as follows:</p>
<code>
CREATE INDEX last_activity_idx ON ci_sessions(last_activity);
ALTER TABLE ci_sessions MODIFY user_agent VARCHAR(120);
</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_203.html | HTML | mit | 5,124 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.1.0 to 2.1.1 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.1.0 to 2.1.1
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.1.0 to 2.1.1</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Replace config/mimes.php</h2>
<p>This config file has been updated to contain more user mime-types, please copy it to <kbd>application/config/mimes.php</kbd>.</p>
<h2>Step 3: Update your IP address tables:</h2>
<p>This upgrade adds support for IPv6 IP addresses. In order to store them, you need to enlarge your <var>ip_address</var> columns to 45 characters. For example, CodeIgniter's session table will need to change:</p>
<code>ALTER TABLE ci_sessions CHANGE ip_address ip_address varchar(45) default '0' NOT NULL</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_211.html | HTML | mit | 4,160 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from Beta 1.1 to Final 1.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading From Beta 1.0 to Final 1.2</h1>
<p>To upgrade to Version 1.2 please replace the following directories with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>drivers</li>
<li>helpers</li>
<li>init</li>
<li>language</li>
<li>libraries</li>
<li>plugins</li>
<li>scaffolding</li>
</ul>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_120.html | HTML | mit | 3,550 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Troubleshooting : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Trouble Shooting
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Troubleshooting</h1>
<p>If you find that no matter what you put in your URL only your default page is loading, it might be that your server
does not support the PATH_INFO variable needed to serve search-engine friendly URLs.
As a first step, open your <dfn>application/config/config.php</dfn> file and look for the <kbd>URI Protocol</kbd>
information. It will recommend that you try a couple alternate settings. If it still doesn't work after you've tried this you'll need
to force CodeIgniter to add a question mark to your URLs. To do this open your <kbd>application/config/config.php</kbd> file and change this:</p>
<code>$config['index_page'] = "index.php";</code>
<p>To this:</p>
<code>$config['index_page'] = "index.php?";</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="upgrading.html">Upgrading from a Previous Version</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="../overview/at_a_glance.html">CodeIgniter at a Glance</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/troubleshooting.html | HTML | mit | 3,822 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.4.0 to 1.4.1 </td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.4.0 to 1.4.1</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.4.0. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace the following directories in your "system" folder with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>codeigniter</li>
<li>drivers</li>
<li>helpers</li>
<li>libraries</li>
</ul>
<h2>Step 2: Update your config.php file</h2>
<p>Open your <dfn>application/config/config.php</dfn> file and add this new item:</p>
<pre>
/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
|
| Enables Gzip output compression for faster page loads. When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts. For
| compression to work, nothing can be sent before the output buffer is called
| by the output class. Do not "echo" any values with compression enabled.
|
*/
$config['compress_output'] = FALSE;
</pre>
<h2>Step 3: Rename an Autoload Item</h2>
<p>Open the following file: <dfn>application/config/autoload.php</dfn></p>
<p>Find this array item:</p>
<code>$autoload['core'] = array();</code>
<p>And rename it to this:</p>
<code>$autoload['libraries'] = array();</code>
<p>This change was made to improve clarity since some users were not sure that their own libraries could be auto-loaded.</p>
<h2>Step 4: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_141.html | HTML | mit | 5,298 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.7.2 to 2.0.0 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.7.2 to 2.0.0
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.7.2 to 2.0.0</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder <strong>except</strong> your <kbd>application</kbd> folder.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Adjust get_dir_file_info() where necessary</h2>
<p>Version 2.0.0 brings a non-backwards compatible change to <kbd>get_dir_file_info()</kbd> in the <a href="../helpers/file_helper.html">File Helper</a>. Non-backwards compatible changes are extremely rare
in CodeIgniter, but this one we feel was warranted due to how easy it was to create serious server performance issues. If you <em>need</em>
recursiveness where you are using this helper function, change such instances, setting the second parameter, <kbd>$top_level_only</kbd> to FALSE:</p>
<code>get_dir_file_info('/path/to/directory', <kbd>FALSE</kbd>);</code>
</p>
<h2>Step 3: Convert your Plugins to Helpers</h2>
<p>2.0.0 gets rid of the "Plugin" system as their functionality was identical to Helpers, but non-extensible. You will need to rename your plugin files from <var>filename_pi.php</var> to <var>filename_helper.php</var>, move them to your <kbd>helpers</kbd> folder, and change all instances of:
<code>$this->load->plugin('foo');</code>
to
<code>$this->load->helper('foo');</code>
</p>
<h2>Step 4: Update stored encrypted data</h2>
<p class="important"><strong>Note:</strong> If your application does not use the Encryption library, does not store Encrypted data permanently, or is on an environment that does not support Mcrypt, you may skip this step.</p>
<p>The Encryption library has had a number of improvements, some for encryption strength and some for performance, that has an unavoidable consequence of
making it no longer possible to decode encrypted data produced by the original version of this library. To help with the transition, a new method has
been added, <kbd>encode_from_legacy()</kbd> that will decode the data with the original algorithm and return a re-encoded string using the improved methods.
This will enable you to easily replace stale encrypted data with fresh in your applications, either on the fly or en masse.</p>
<p>Please read <a href="../libraries/encryption.html#legacy">how to use this method</a> in the Encryption library documentation.</p>
<h2>Step 5: Remove loading calls for the compatibility helper.</h2>
<p>The compatibility helper has been removed from the CodeIgniter core. All methods in it should be natively available in supported PHP versions.</p>
<h2>Step 6: Update Class extension</h2>
<p>All core classes are now prefixed with <kbd>CI_</kbd>. Update Models and Controllers to extend CI_Model and CI_Controller, respectively.</p>
<h2>Step 7: Update Parent Constructor calls</h2>
<p>All native CodeIgniter classes now use the PHP 5 <kbd>__construct()</kbd> convention. Please update extended libraries to call <kbd>parent::__construct()</kbd>.</p>
<h2>Step 8: Update your user guide</h2>
<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_200.html | HTML | mit | 6,402 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> › Upgrading from 1.5.2 to 1.5.3
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.5.2 to 1.5.3</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/database/drivers</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/libraries/Input.php</dfn></li>
<li><dfn>system/libraries/Loader.php</dfn></li>
<li><dfn>system/libraries/Profiler.php</dfn></li>
<li><dfn>system/libraries/Table.php</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_153.html | HTML | mit | 3,890 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.0.3 to 2.1.0 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.0.3 to 2.1.0
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.0.3 to 2.1.0</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Replace config/user_agents.php</h2>
<p>This config file has been updated to contain more user agent types, please copy it to <kbd>application/config/user_agents.php</kbd>.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_210.html | HTML | mit | 3,809 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Downloading CodeIgniter : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Downloading CodeIgniter
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Downloading CodeIgniter</h1>
<ul>
<li><a href="http://codeigniter.com/downloads/">CodeIgniter V 2.1.3 (Current version)</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.1.2.zip">CodeIgniter V 2.1.2</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.1.1.zip">CodeIgniter V 2.1.1</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.1.0.zip">CodeIgniter V 2.1.0</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.0.3.zip">CodeIgniter V 2.0.3</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.0.2.zip">CodeIgniter V 2.0.2</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.0.1.zip">CodeIgniter V 2.0.1</a></li>
<li><a href="http://codeigniter.com/download_files/reactor/CodeIgniter_2.0.0.zip">CodeIgniter V 2.0.0</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.3.zip">CodeIgniter V 1.7.3</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.2.zip">CodeIgniter V 1.7.2</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.1.zip">CodeIgniter V 1.7.1</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.7.0.zip">CodeIgniter V 1.7.0</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.3.zip">CodeIgniter V 1.6.3</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.2.zip">CodeIgniter V 1.6.2</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.1.zip">CodeIgniter V 1.6.1</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.6.0.zip">CodeIgniter V 1.6.0</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.4.zip">CodeIgniter V 1.5.4</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.3.zip">CodeIgniter V 1.5.3</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.2.zip">CodeIgniter V 1.5.2</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.5.1.zip">CodeIgniter V 1.5.1</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.4.1.zip">CodeIgniter V 1.4.1</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.3.zip">CodeIgniter V 1.3.3</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.2.zip">CodeIgniter V 1.3.2</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.1.zip">CodeIgniter V 1.3.1</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.3.zip">CodeIgniter V 1.3</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.2.zip">CodeIgniter V 1.2</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.1b.zip">CodeIgniter V 1.1</a></li>
<li><a href="http://codeigniter.com/download_files/CodeIgniter_1.0b.zip">CodeIgniter V 1.0</a></li>
</ul>
<h1 id="git">Git Server</h1>
<p><a href="http://git-scm.com/about">Git</a> is a distributed version control system.</p>
<p>Public Git access is available at <a href="https://github.com/EllisLab/CodeIgniter">GitHub</a>.
Please note that while every effort is made to keep this code base functional, we cannot guarantee the functionality of code taken
from the tip.</p>
<p>Beginning with version 2.0.3, stable tags are also available via GitHub, simply select the version from the Tags dropdown.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="../general/credits.html">Credits</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="../installation/index.html">Installation Instructions</a>
</p>
<p><a href="http://codeigniter.com/">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/downloads.html | HTML | mit | 6,570 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.3 to 1.3.1
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.3 to 1.3.1</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace the following directories in your "system" folder with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>drivers</li>
<li>init/init_unit_test.php (new for 1.3.1)</li>
<li>language/</li>
<li>libraries</li>
<li>scaffolding</li>
</ul>
<h2>Step 2: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_131.html | HTML | mit | 3,915 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading From a Previous Version : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from a Previous Version
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading From a Previous Version</h1>
<p>Please read the upgrade notes corresponding to the version you are upgrading from.</p>
<ul>
<li><a href="upgrade_213.html">Upgrading from 2.1.2 to 2.1.3</a></li>
<li><a href="upgrade_212.html">Upgrading from 2.1.1 to 2.1.2</a></li>
<li><a href="upgrade_211.html">Upgrading from 2.1.0 to 2.1.1</a></li>
<li><a href="upgrade_210.html">Upgrading from 2.0.3 to 2.1.0</a></li>
<li><a href="upgrade_203.html">Upgrading from 2.0.2 to 2.0.3</a></li>
<li><a href="upgrade_202.html">Upgrading from 2.0.1 to 2.0.2</a></li>
<li><a href="upgrade_201.html">Upgrading from 2.0 to 2.0.1</a></li>
<li><a href="upgrade_200.html">Upgrading from 1.7.2 to 2.0</a></li>
<li><a href="upgrade_172.html">Upgrading from 1.7.1 to 1.7.2</a></li>
<li><a href="upgrade_171.html">Upgrading from 1.7.0 to 1.7.1</a></li>
<li><a href="upgrade_170.html">Upgrading from 1.6.3 to 1.7.0</a></li>
<li><a href="upgrade_163.html">Upgrading from 1.6.2 to 1.6.3</a></li>
<li><a href="upgrade_162.html">Upgrading from 1.6.1 to 1.6.2</a></li>
<li><a href="upgrade_161.html">Upgrading from 1.6.0 to 1.6.1</a></li>
<li><a href="upgrade_160.html">Upgrading from 1.5.4 to 1.6.0</a></li>
<li><a href="upgrade_154.html">Upgrading from 1.5.3 to 1.5.4</a></li>
<li><a href="upgrade_153.html">Upgrading from 1.5.2 to 1.5.3</a></li>
<li><a href="upgrade_152.html">Upgrading from 1.5.0 or 1.5.1 to 1.5.2</a></li>
<li><a href="upgrade_150.html">Upgrading from 1.4.1 to 1.5.0</a></li>
<li><a href="upgrade_141.html">Upgrading from 1.4.0 to 1.4.1</a></li>
<li><a href="upgrade_140.html">Upgrading from 1.3.3 to 1.4.0</a></li>
<li><a href="upgrade_133.html">Upgrading from 1.3.2 to 1.3.3</a></li>
<li><a href="upgrade_132.html">Upgrading from 1.3.1 to 1.3.2</a></li>
<li><a href="upgrade_131.html">Upgrading from 1.3 to 1.3.1</a></li>
<li><a href="upgrade_130.html">Upgrading from 1.2 to 1.3</a></li>
<li><a href="upgrade_120.html">Upgrading from 1.1 to 1.2</a></li>
<li><a href="upgrade_b11.html">Upgrading from Beta 1.0 to Beta 1.1</a></li>
</ul>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrading.html | HTML | mit | 5,146 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.3.3 to 1.4.0
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.3.3 to 1.4.0</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.3. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace the following directories in your "system" folder with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>application/config/<strong>hooks.php</strong></li>
<li>application/config/<strong>mimes.php</strong></li>
<li>codeigniter</li>
<li>drivers</li>
<li>helpers</li>
<li>init</li>
<li>language</li>
<li>libraries</li>
<li>scaffolding</li>
</ul>
<h2>Step 2: Update your config.php file</h2>
<p>Open your <dfn>application/config/config.php</dfn> file and add these new items:</p>
<pre>
/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the "hooks" feature you must enable it by
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;
/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify which characters are permitted within your URLs.
| When someone tries to submit a URL with disallowed characters they will
| get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
</pre>
<h2>Step 3: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_140.html | HTML | mit | 5,264 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.7.0 to 1.7.1 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.7.0 to 1.7.1
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.7.0 to 1.7.1</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/language</dfn></li>
<li><dfn>system/libraries</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your user guide</h2>
<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_171.html | HTML | mit | 3,855 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.5.3 to 1.5.4 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.5.3 to 1.5.4
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.5.3 to 1.5.4</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>application/config/mimes.php</dfn></li>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/libraries</dfn></li>
<li><dfn>system/plugins</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Add charset to your config.php </h2>
<p>Add the following to application/config/config.php</p>
<code>/*<br />
|--------------------------------------------------------------------------<br />
| Default Character Set<br />
|--------------------------------------------------------------------------<br />
|<br />
| This determines which character set is used by default in various methods<br />
| that require a character set to be provided.<br />
|<br />
*/<br />
$config['charset'] = "UTF-8";</code>
<h2>Step 3: Autoloading language files </h2>
<p>If you want to autoload any language files, add this line to application/config/autoload.php</p>
<code>$autoload['language'] = array();</code>
<h2>Step 4: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_154.html | HTML | mit | 4,606 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.6.2 to 1.6.3 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.6.2 to 1.6.3
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.6.2 to 1.6.3</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/language</dfn></li>
<li><dfn>system/libraries</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_163.html | HTML | mit | 3,834 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.3.2 to 1.3.3
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.3.2 to 1.3.3</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.2. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace the following directories in your "system" folder with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>codeigniter</li>
<li>drivers</li>
<li>helpers</li>
<li>init</li>
<li>libraries</li>
</ul>
<h2>Step 2: Update your Models</h2>
<p>If you are <strong>NOT</strong> using CodeIgniter's <a href="../general/models.html">Models</a> feature disregard this step.</p>
<p>As of version 1.3.3, CodeIgniter does <strong>not</strong> connect automatically to your database when a model is loaded. This
allows you greater flexibility in determining which databases you would like used with your models. If your application is not connecting
to your database prior to a model being loaded you will have to update your code. There are several options for connecting,
<a href="../general/models.html">as described here</a>.</p>
<h2>Step 3: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_133.html | HTML | mit | 4,511 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.6.1 to 1.6.2 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.6.1 to 1.6.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.6.1 to 1.6.2</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/language</dfn></li>
<li><dfn>system/libraries</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Encryption Key</h2>
<p>If you are using sessions, open up application/config/config.php and verify you've set an encryption key.</p>
<h2>Step 3: Constants File</h2>
<p>Copy /application/config/constants.php to your installation, and modify if necessary.</p>
<h2>Step 4: Mimes File</h2>
<p>Replace /application/config/mimes.php with the dowloaded version. If you've added custom mime types, you'll need to re-add them.</p>
<h2>Step 5: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_162.html | HTML | mit | 4,269 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.1.2 to 2.1.3 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.1.1 to 2.1.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.1.2 to 2.1.3</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_213.html | HTML | mit | 3,617 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.4.1 to 1.5.0
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.4.1 to 1.5.0</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.4.1. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>application/config/user_agents.php</dfn> (new file for 1.5)</li>
<li><dfn>application/config/smileys.php</dfn> (new file for 1.5)</li>
<li><dfn>codeigniter/</dfn></li>
<li><dfn>database/</dfn> (new folder for 1.5. Replaces the "drivers" folder)</li>
<li><dfn>helpers/</dfn></li>
<li><dfn>language/</dfn></li>
<li><dfn>libraries/</dfn></li>
<li><dfn>scaffolding/</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your database.php file</h2>
<p>Open your <dfn>application/config/database.php</dfn> file and add these new items:</p>
<pre>
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
</pre>
<h2>Step 3: Update your config.php file</h2>
<p>Open your <dfn>application/config/config.php</dfn> file and <kbd>ADD</kbd> these new items:</p>
<pre>
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries. For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/core_classes.html
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = FALSE;
</pre>
<p>In that same file <kbd>REMOVE</kbd> this item:</p>
<pre>
/*
|--------------------------------------------------------------------------
| Enable/Disable Error Logging
|--------------------------------------------------------------------------
|
| If you would like errors or debug messages logged set this variable to
| TRUE (boolean). Note: You must set the file permissions on the "logs" folder
| such that it is writable.
|
*/
$config['log_errors'] = FALSE;
</pre>
<p>Error logging is now disabled simply by setting the threshold to zero.</p>
<h2>Step 4: Update your main index.php file</h2>
<p>If you are running a stock <dfn>index.php</dfn> file simply replace your version with the new one.</p>
<p>If your <dfn>index.php</dfn> file has internal modifications, please add your modifications to the new file and use it.</p>
<h2>Step 5: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_150.html | HTML | mit | 6,334 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.3.1 to 1.3.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.3.1 to 1.3.2</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.3.1. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace the following directories in your "system" folder with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>drivers</li>
<li>init</li>
<li>libraries</li>
</ul>
<h2>Step 2: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_132.html | HTML | mit | 3,846 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.6.3 to 1.7.0 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.6.3 to 1.7.0
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.6.3 to 1.7.0</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/language</dfn></li>
<li><dfn>system/libraries</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your Session Table</h2>
<p>If you are using the Session class in your application, AND if you are storing session data to a database, you must add a new column named <dfn>user_data</dfn> to your session table.
Here is an example of what this column might look like for MySQL:</p>
<code>user_data text NOT NULL</code>
<p>To add this column you will run a query similar to this:</p>
<code>ALTER TABLE `ci_sessions` ADD `user_data` text NOT NULL</code>
<p>You'll find more information regarding the new Session functionality in the <a href="../libraries/sessions.html">Session class</a> page.</p>
<h2>Step 3: Update your Validation Syntax</h2>
<p>This is an <strong>optional</strong>, but recommended step, for people currently using the Validation class. CI 1.7 introduces a new <a href="../libraries/form_validation.html">Form Validation class</a>, which
deprecates the old Validation library. We have left the old one in place so that existing applications that use it will not break, but you are encouraged to
migrate to the new version as soon as possible. Please read the user guide carefully as the new library works a little differently, and has several new features.</p>
<h2>Step 4: Update your user guide</h2>
<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_170.html | HTML | mit | 5,068 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.7.1 to 1.7.2 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.7.1 to 1.7.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.7.1 to 1.7.2</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/language</dfn></li>
<li><dfn>system/libraries</dfn></li>
<li><dfn>index.php</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Remove header() from 404 error template</h2>
<p>If you are using header() in your 404 error template, such as the case with the default <samp>error_404.php</samp> template shown below, remove that line of code.</p>
<code><?php header("HTTP/1.1 404 Not Found"); ?></code>
<p>404 status headers are now properly handled in the show_404() method itself.</p>
<h2>Step 3: Confirm your system_path</h2>
<p>In your updated index.php file, confirm that the <dfn>$system_path</dfn> variable is set to your application's system folder.</p>
<h2>Step 4: Update your user guide</h2>
<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_172.html | HTML | mit | 4,447 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.6.0 to 1.6.1 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.6.0 to 1.6.1
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.6.0 to 1.6.1</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/language</dfn></li>
<li><dfn>system/libraries</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_161.html | HTML | mit | 3,833 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 1.5.4 to 1.6.0 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.5.4 to 1.6.0
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.5.4 to 1.6.0</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace these files and directories in your "system" folder with the new versions:</p>
<ul>
<li><dfn>system/codeigniter</dfn></li>
<li><dfn>system/database</dfn></li>
<li><dfn>system/helpers</dfn></li>
<li><dfn>system/libraries</dfn></li>
<li><dfn>system/plugins</dfn></li>
<li><dfn>system/language</dfn></li>
</ul>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Add time_to_update to your config.php </h2>
<p>Add the following to application/config/config.php with the other session configuration options</p>
<p><code>$config['sess_time_to_update'] = 300;</code></p>
<h2>Step 3: Add $autoload['model']</h2>
<p>Add the following to application/config/autoload.php</p>
<p><code> /*<br />
| -------------------------------------------------------------------<br />
| Auto-load Model files<br />
| -------------------------------------------------------------------<br />
| Prototype:<br />
|<br />
| $autoload['model'] = array('my_model');<br />
|<br />
*/<br />
<br />
$autoload['model'] = array();</code></p>
<h2>Step 4: Add to your database.php </h2>
<p>Make the following changes to your application/config/database.php file:</p>
<p>Add the following variable above the database configuration options, with <dfn>$active_group</dfn></p>
<p><code>$active_record = TRUE;</code></p>
<p>Remove the following from your database configuration options</p>
<p><code>$db['default']['active_r'] = TRUE;</code></p>
<p>Add the following to your database configuration options</p>
<p><code>$db['default']['char_set'] = "utf8";<br />
$db['default']['dbcollat'] = "utf8_general_ci";</code></p>
<h2>Step 5: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_160.html | HTML | mit | 5,133 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from Beta 1.0 to Beta 1.1
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading From Beta 1.0 to Beta 1.1</h1>
<p>To upgrade to Beta 1.1 please perform the following steps:</p>
<h2>Step 1: Replace your index file</h2>
<p>Replace your main <kbd>index.php</kbd> file with the new index.php file. Note: If you have renamed your "system" folder you will need to edit this info in the new file.</p>
<h2>Step 2: Relocate your config folder</h2>
<p>This version of CodeIgniter now permits multiple sets of "applications" to all share a common set of backend files. In order to enable
each application to have its own configuration values, the <kbd>config</kbd> directory must now reside
inside of your <dfn>application</dfn> folder, so please move it there.</p>
<h2>Step 3: Replace directories</h2>
<p>Replace the following directories with the new versions:</p>
<ul>
<li>drivers</li>
<li>helpers</li>
<li>init</li>
<li>libraries</li>
<li>scaffolding</li>
</ul>
<h2>Step 4: Add the calendar language file</h2>
<p>There is a new language file corresponding to the new calendaring class which must be added to your language folder. Add
the following item to your version: <dfn>language/english/calendar_lang.php</dfn></p>
<h2>Step 5: Edit your config file</h2>
<p>The original <kbd>application/config/config.php</kbd> file has a typo in it Open the file and look for the items related to cookies:</p>
<code>$conf['cookie_prefix'] = "";<br />
$conf['cookie_domain'] = "";<br />
$conf['cookie_path'] = "/";</code>
<p>Change the array name from <kbd>$conf</kbd> to <kbd>$config</kbd>, like this:</p>
<code>$config['cookie_prefix'] = "";<br />
$config['cookie_domain'] = "";<br />
$config['cookie_path'] = "/";</code>
<p>Lastly, add the following new item to the config file (and edit the option if needed):</p>
<code><br />
/*<br />
|------------------------------------------------<br />
| URI PROTOCOL<br />
|------------------------------------------------<br />
|<br />
| This item determines which server global <br />
| should be used to retrieve the URI string. The <br />
| default setting of "auto" works for most servers.<br />
| If your links do not seem to work, try one of <br />
| the other delicious flavors:<br />
| <br />
| 'auto' Default - auto detects<br />
| 'path_info' Uses the PATH_INFO <br />
| 'query_string' Uses the QUERY_STRING<br />
*/<br />
<br />
$config['uri_protocol'] = "auto";</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_b11.html | HTML | mit | 5,415 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.0.1 to 2.0.2 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.0.1 to 2.0.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.0.1 to 2.0.2</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Remove loading calls for the Security Library</h2>
<p>Security has been moved to the core and is now always loaded automatically. Make sure you remove any loading calls as they will result in PHP errors.</p>
<h2>Step 3: Move MY_Security</h2>
<p>If you are overriding or extending the Security library, you will need to move it to <kbd>application/core</kbd>.</p>
<p><samp>csrf_token_name</samp> and <samp>csrf_hash</samp> have changed to protected class properties. Please use <samp>security->get_csrf_hash()</samp> and <samp>security->get_csrf_token_name()</samp> to access those values.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_202.html | HTML | mit | 4,231 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 1.2 to 1.3
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 1.2 to 1.3</h1>
<p class="important"><strong>Note:</strong> The instructions on this page assume you are running version 1.2. If you
have not upgraded to that version please do so first.</p>
<p>Before performing an update you should take your site offline by replacing the index.php file
with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace the following directories in your "system" folder with the new versions:</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<ul>
<li>application/<strong>models</strong>/ (new for 1.3)</li>
<li>codeigniter (new for 1.3)</li>
<li>drivers</li>
<li>helpers</li>
<li>init</li>
<li>language</li>
<li>libraries</li>
<li>plugins</li>
<li>scaffolding</li>
</ul>
<h2>Step 2: Update your error files</h2>
<p>Version 1.3 contains two new error templates located in <dfn>application/errors</dfn>, and for naming consistency the other error templates have
been renamed.</p>
<p>If you <strong>have not</strong> customized any of the error templates simply
replace this folder:</p>
<ul>
<li>application/errors/</li>
</ul>
<p>If you <strong>have</strong> customized your error templates, rename them as follows:</p>
<ul>
<li>404.php = error_404.php</li>
<li>error.php = error_general.php</li>
<li>error_db.php (new)</li>
<li>error_php.php (new)</li>
</ul>
<h2>Step 3: Update your index.php file</h2>
<p>Please open your main <dfn>index.php</dfn> file (located at your root). At the very bottom of the file, change this:</p>
<code>require_once BASEPATH.'libraries/Front_controller'.EXT;</code>
<p>To this:</p>
<code>require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;</code>
<h2>Step 4: Update your config.php file</h2>
<p>Open your <dfn>application/config/config.php</dfn> file and add these new items:</p>
<pre>
/*
|------------------------------------------------
| URL suffix
|------------------------------------------------
|
| This option allows you to add a suffix to all URLs.
| For example, if a URL is this:
|
| example.com/index.php/products/view/shoes
|
| You can optionally add a suffix, like ".html",
| making the page appear to be of a certain type:
|
| example.com/index.php/products/view/shoes.html
|
*/
$config['url_suffix'] = "";
/*
|------------------------------------------------
| Enable Query Strings
|------------------------------------------------
|
| By default CodeIgniter uses search-engine and
| human-friendly segment based URLs:
|
| example.com/who/what/where/
|
| You can optionally enable standard query string
| based URLs:
|
| example.com?who=me&what=something&where=here
|
| Options are: TRUE or FALSE (boolean)
|
| The two other items let you set the query string "words"
| that will invoke your controllers and functions:
| example.com/index.php?c=controller&m=function
|
*/
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
</pre>
<h2>Step 5: Update your database.php file</h2>
<p>Open your <dfn>application/config/database.php</dfn> file and add these new items:</p>
<pre>
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
</pre>
<h2>Step 6: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_130.html | HTML | mit | 6,500 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from 2.0.0 to 2.0.1 : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Upgrading from 2.0.0 to 2.0.1
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Upgrading from 2.0.0 to 2.0.1</h1>
<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
<h2>Step 1: Update your CodeIgniter files</h2>
<p>Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.</p>
<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
<h2>Step 2: Replace config/mimes.php</h2>
<p>This config file has been updated to contain more mime types, please copy it to <kbd>application/config/mimes.php</kbd>.</p>
<h2>Step 3: Check for forms posting to default controller</h2>
<p>
The default behavior for <kbd>form_open()</kbd> when called with no parameters used to be to post to the default controller, but it will now just leave an empty action="" meaning the form will submit to the current URL.
If submitting to the default controller was the expected behavior it will need to be changed from:
</p>
<code>echo form_open(); //<form action="" method="post" accept-charset="utf-8"></code>
<p>to use either a / or <kbd>base_url()</kbd>:</p>
<code>echo form_open('/'); //<form action="http://example.com/index.php/" method="post" accept-charset="utf-8"><br/>
echo form_open(base_url()); //<form action="http://example.com/" method="post" accept-charset="utf-8"></code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Installation Instructions</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="troubleshooting.html">Troubleshooting</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/installation/upgrade_201.html | HTML | mit | 4,564 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Email Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Email Helper</h1>
<p>The Email Helper provides some assistive functions for working with Email. For a more robust email solution, see CodeIgniter's <a href="../libraries/email.html">Email Class</a>.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<p><code>$this->load->helper('email');</code></p>
<p>The following functions are available:</p>
<h2>valid_email('<var>email</var>')</h2>
<p>Checks if an email is a correctly formatted email. Note that is doesn't actually prove the email will recieve mail, simply that it is a validly formed address.</p>
<p>It returns TRUE/FALSE</p>
<code> $this->load->helper('email');<br />
<br />
if (valid_email('email@somesite.com'))<br />
{<br />
echo 'email is valid';<br />
}<br />
else<br />
{<br />
echo 'email is not valid';<br />
}</code>
<h2>send_email('<var>recipient</var>', '<var>subject</var>', '<var>message</var>')</h2>
<p>Sends an email using PHP's native <a href="http://www.php.net/function.mail">mail()</a> function. For a more robust email solution, see CodeIgniter's <a href="../libraries/email.html">Email Class</a>.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="download_helper.html">Download Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="file_helper.html">File Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/email_helper.html | HTML | mit | 4,212 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Text Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Text Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Text Helper</h1>
<p>The Text Helper file contains functions that assist in working with text.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('text');</code>
<p>The following functions are available:</p>
<h2>word_limiter()</h2>
<p>Truncates a string to the number of <strong>words</strong> specified. Example:</p>
<code>
$string = "Here is a nice text string consisting of eleven words.";<br />
<br />
$string = word_limiter($string, 4);<br /><br />
// Returns: Here is a nice…
</code>
<p>The third parameter is an optional suffix added to the string. By default it adds an ellipsis.</p>
<h2>character_limiter()</h2>
<p>Truncates a string to the number of <strong>characters</strong> specified. It maintains the integrity
of words so the character count may be slightly more or less then what you specify. Example:</p>
<code>
$string = "Here is a nice text string consisting of eleven words.";<br />
<br />
$string = character_limiter($string, 20);<br /><br />
// Returns: Here is a nice text string…
</code>
<p>The third parameter is an optional suffix added to the string, if undeclared this helper uses an ellipsis.</p>
<h2>ascii_to_entities()</h2>
<p>Converts ASCII values to character entities, including high ASCII and MS Word characters that can cause problems when used in a web page,
so that they can be shown consistently regardless of browser settings or stored reliably in a database.
There is some dependence on your server's supported character sets, so it may not be 100% reliable in all cases, but for the most
part it should correctly identify characters outside the normal range (like accented characters). Example:</p>
<code>$string = ascii_to_entities($string);</code>
<h2>entities_to_ascii()</h2>
<p>This function does the opposite of the previous one; it turns character entities back into ASCII.</p>
<h2>convert_accented_characters()</h2>
<p>Transliterates high ASCII characters to low ASCII equivalents, useful when non-English characters need to be used where only standard ASCII characters are safely used, for instance, in URLs.</p>
<code>$string = convert_accented_characters($string);</code>
<p>This function uses a companion config file <dfn>application/config/foreign_chars.php</dfn> to define the to and from array for transliteration.</p>
<h2>word_censor()</h2>
<p>Enables you to censor words within a text string. The first parameter will contain the original string. The
second will contain an array of words which you disallow. The third (optional) parameter can contain a replacement value
for the words. If not specified they are replaced with pound signs: ####. Example:</p>
<code>
$disallowed = array('darn', 'shucks', 'golly', 'phooey');<br />
<br />
$string = word_censor($string, $disallowed, 'Beep!');</code>
<h2>highlight_code()</h2>
<p>Colorizes a string of code (PHP, HTML, etc.). Example:</p>
<code>$string = highlight_code($string);</code>
<p>The function uses PHP's highlight_string() function, so the colors used are the ones specified in your php.ini file.</p>
<h2>highlight_phrase()</h2>
<p>Will highlight a phrase within a text string. The first parameter will contain the original string, the second will
contain the phrase you wish to highlight. The third and fourth parameters will contain the opening/closing HTML tags
you would like the phrase wrapped in. Example:</p>
<code>
$string = "Here is a nice text string about nothing in particular.";<br />
<br />
$string = highlight_phrase($string, "nice text", '<span style="color:#990000">', '</span>');
</code>
<p>The above text returns:</p>
<p>Here is a <span style="color:#990000">nice text</span> string about nothing in particular.</p>
<h2>word_wrap()</h2>
<p>Wraps text at the specified <strong>character</strong> count while maintaining complete words. Example:</p>
<code>$string = "Here is a simple string of text that will help us demonstrate this function.";<br />
<br />
echo word_wrap($string, 25);<br />
<br />
// Would produce:<br />
<br />
Here is a simple string<br />
of text that will help<br />
us demonstrate this<br />
function</code>
<h2>ellipsize()</h2>
<p>This function will strip tags from a string, split it at a defined maximum length, and insert an ellipsis.</p>
<p>The first parameter is the string to ellipsize, the second is the number of characters in the final string. The third parameter is where in the string the ellipsis should appear from 0 - 1, left to right. For example. a value of 1 will place the ellipsis at the right of the string, .5 in the middle, and 0 at the left.</p>
<p>An optional forth parameter is the kind of ellipsis. By default, <samp>&hellip;</samp> will be inserted.</p>
<code>$str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg';<br />
<br />
echo ellipsize($str, 32, .5);</code>
Produces:
<code>this_string_is_e…ak_my_design.jpg</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="string_helper.html">String Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="typography_helper.html">Typography Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/text_helper.html | HTML | mit | 8,031 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>URL Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
URL Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>URL Helper</h1>
<p>The URL Helper file contains functions that assist in working with URLs.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('url');</code>
<p>The following functions are available:</p>
<h2>site_url()</h2>
<p>Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your
site <dfn>index_page</dfn> in your config file) will be added to the URL, as will any URI segments you pass to the function, and the <dfn>url_suffix</dfn> as set in your config file.</p>
<p>You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable
in the event your URL changes.</p>
<p>Segments can be optionally passed to the function as a string or an array. Here is a string example:</p>
<code>echo site_url("news/local/123");</code>
<p>The above example would return something like: http://example.com/index.php/news/local/123</p>
<p>Here is an example of segments passed as an array:</p>
<code>
$segments = array('news', 'local', '123');<br />
<br />
echo site_url($segments);</code>
<h2>base_url()</h2>
<p>Returns your site base URL, as specified in your config file. Example:</p>
<code>echo base_url();</code>
<p>This function returns the same thing as site_url, without the <dfn>index_page</dfn> or <dfn>url_suffix</dfn> being appended.</p>
<p>Also like site_url, you can supply segments as a string or an array. Here is a string example:</p>
<code>echo base_url("blog/post/123");</code>
<p>The above example would return something like: http://example.com/blog/post/123</p>
<p>This is useful because unlike site_url(), you can supply a string to a file, such as an image or stylesheet. For example:</p>
<code>echo base_url("images/icons/edit.png");</code>
<p>This would give you something like: http://example.com/images/icons/edit.png</p>
<h2>current_url()</h2>
<p>Returns the full URL (including segments) of the page being currently viewed.</p>
<h2>uri_string()</h2>
<p>Returns the URI segments of any page that contains this function. For example, if your URL was this:</p>
<code>http://some-site.com/blog/comments/123</code>
<p>The function would return:</p>
<code>/blog/comments/123</code>
<h2>index_page()</h2>
<p>Returns your site "index" page, as specified in your config file. Example:</p>
<code>echo index_page();</code>
<h2>anchor()</h2>
<p>Creates a standard HTML anchor link based on your local site URL:</p>
<code><a href="http://example.com">Click Here</a></code>
<p>The tag has three optional parameters:</p>
<code>anchor(<var>uri segments</var>, <var>text</var>, <var>attributes</var>)</code>
<p>The first parameter can contain any segments you wish appended to the URL. As with the <dfn>site_url()</dfn> function above,
segments can be a string or an array.</p>
<p><strong>Note:</strong> If you are building links that are internal to your application do not include the base URL (http://...). This
will be added automatically from the information specified in your config file. Include only the URI segments you wish appended to the URL.</p>
<p>The second segment is the text you would like the link to say. If you leave it blank, the URL will be used.</p>
<p>The third parameter can contain a list of attributes you would like added to the link. The attributes can be a simple string or an associative array.</p>
<p>Here are some examples:</p>
<code>echo anchor('news/local/123', 'My News', 'title="News title"');</code>
<p>Would produce: <a href="http://example.com/index.php/news/local/123" title="News title">My News</a></p>
<code>echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));</code>
<p>Would produce: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a></p>
<h2>anchor_popup()</h2>
<p>Nearly identical to the <dfn>anchor()</dfn> function except that it opens the URL in a new window.
You can specify JavaScript window attributes in the third parameter to control how the window is opened. If
the third parameter is not set it will simply open a new window with your own browser settings. Here is an example
with attributes:</p>
<code>
$atts = array(<br />
'width' => '800',<br />
'height' => '600',<br />
'scrollbars' => 'yes',<br />
'status' => 'yes',<br />
'resizable' => 'yes',<br />
'screenx' => '0',<br />
'screeny' => '0'<br />
);<br />
<br />
echo anchor_popup('news/local/123', 'Click Me!', $atts);</code>
<p>Note: The above attributes are the function defaults so you only need to set the ones that are different from what you need.
If you want the function to use all of its defaults simply pass an empty array in the third parameter:</p>
<code>echo anchor_popup('news/local/123', 'Click Me!', array());</code>
<h2>mailto()</h2>
<p>Creates a standard HTML email link. Usage example:</p>
<code>echo mailto('me@my-site.com', 'Click Here to Contact Me');</code>
<p>As with the <dfn>anchor()</dfn> tab above, you can set attributes using the third parameter.</p>
<h2>safe_mailto()</h2>
<p>Identical to the above function except it writes an obfuscated version of the mailto tag using ordinal numbers
written with JavaScript to help prevent the email address from being harvested by spam bots.</p>
<h2>auto_link()</h2>
<p>Automatically turns URLs and email addresses contained in a string into links. Example:</p>
<code>$string = auto_link($string);</code>
<p>The second parameter determines whether URLs and emails are converted or just one or the other. Default behavior is both
if the parameter is not specified. Email links are encoded as safe_mailto() as shown above.</p>
<p>Converts only URLs:</p>
<code>$string = auto_link($string, 'url');</code>
<p>Converts only Email addresses:</p>
<code>$string = auto_link($string, 'email');</code>
<p>The third parameter determines whether links are shown in a new window. The value can be TRUE or FALSE (boolean):</p>
<code>$string = auto_link($string, 'both', TRUE);</code>
<h2>url_title()</h2>
<p>Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog
in which you'd like to use the title of your entries in the URL. Example:</p>
<code>$title = "What's wrong with CSS?";<br />
<br />
$url_title = url_title($title);<br />
<br />
// Produces: Whats-wrong-with-CSS
</code>
<p>The second parameter determines the word delimiter. By default dashes are used.</p>
<code>$title = "What's wrong with CSS?";<br />
<br />
$url_title = url_title($title, '_');<br />
<br />
// Produces: Whats_wrong_with_CSS
</code>
<p>The third parameter determines whether or not lowercase characters are forced. By default they are not. Options are boolean <dfn>TRUE</dfn>/<dfn>FALSE</dfn>:</p>
<code>$title = "What's wrong with CSS?";<br />
<br />
$url_title = url_title($title, '_', TRUE);<br />
<br />
// Produces: whats_wrong_with_css
</code>
<h3>prep_url()</h3>
<p>This function will add <kbd>http://</kbd> in the event that a scheme is missing from a URL. Pass the URL string to the function like this:</p>
<code>
$url = "example.com";<br /><br />
$url = prep_url($url);</code>
<h2>redirect()</h2>
<p>Does a "header redirect" to the URI specified. If you specify the full site URL that link will be build, but for local links simply providing the URI segments
to the controller you want to direct to will create the link. The function will build the URL based on your config file values.</p>
<p>The optional second parameter allows you to choose between the "location"
method (default) or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is <em>only</em> available with 'location' redirects, and not 'refresh'. Examples:</p>
<code>if ($logged_in == FALSE)<br />
{<br />
redirect('/login/form/', 'refresh');<br />
}<br />
<br />
// with 301 redirect<br />
redirect('/article/13', 'location', 301);</code>
<p class="important"><strong>Note:</strong> In order for this function to work it must be used before anything is outputted
to the browser since it utilizes server headers.<br />
<strong>Note:</strong> For very fine grained control over headers, you should use the <a href="../libraries/output.html">Output Library</a>'s set_header() function.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="typography_helper.html">Typography Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="xml_helper.html">XML Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/url_helper.html | HTML | mit | 12,491 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Number Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Number Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Number Helper</h1>
<p>The Number Helper file contains functions that help you work with numeric data.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('number');</code>
<p>The following functions are available:</p>
<h2>byte_format()</h2>
<p>Formats a numbers as bytes, based on size, and adds the appropriate suffix. Examples:</p>
<code>
echo byte_format(456); // Returns 456 Bytes<br />
echo byte_format(4567); // Returns 4.5 KB<br />
echo byte_format(45678); // Returns 44.6 KB<br />
echo byte_format(456789); // Returns 447.8 KB<br />
echo byte_format(3456789); // Returns 3.3 MB<br />
echo byte_format(12345678912345); // Returns 1.8 GB<br />
echo byte_format(123456789123456789); // Returns 11,228.3 TB
</code>
<p>An optional second parameter allows you to set the precision of the result.</p>
<code>
echo byte_format(45678, 2); // Returns 44.61 KB
</code>
<p class="important">
<strong>Note:</strong>
The text generated by this function is found in the following language file: language/<your_lang>/number_lang.php
</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="inflector_helper.html">Inflector Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="path_helper.html">Path Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/number_helper.html | HTML | mit | 4,144 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
File Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>File Helper</h1>
<p>The File Helper file contains functions that assist in working with files.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('file');</code>
<p>The following functions are available:</p>
<h2>read_file('<var>path</var>')</h2>
<p>Returns the data contained in the file specified in the path. Example:</p>
<code>$string = read_file('./path/to/file.php');</code>
<p>The path can be a relative or full server path. Returns FALSE (boolean) on failure.</p>
<p class="important"><strong>Note:</strong> The path is relative to your main site index.php file, NOT your controller or view files.
CodeIgniter uses a front controller so paths are always relative to the main site index.</p>
<p>If your server is running an open_basedir restriction this function
might not work if you are trying to access a file above the calling script.</p>
<h2>write_file('<var>path</var>', <kbd>$data</kbd>)</h2>
<p>Writes data to the file specified in the path. If the file does not exist the function will create it. Example:</p>
<code>
$data = 'Some file data';<br />
<br />
if ( ! write_file('./path/to/file.php', $data))<br />
{<br />
echo 'Unable to write the file';<br />
}<br />
else<br />
{<br />
echo 'File written!';<br />
}</code>
<p>You can optionally set the write mode via the third parameter:</p>
<code>write_file('./path/to/file.php', $data, <var>'r+'</var>);</code>
<p>The default mode is <kbd>wb</kbd>. Please see the <a href="http://php.net/fopen">PHP user guide</a> for mode options.</p>
<p>Note: In order for this function to write data to a file its file permissions must be set such that it is writable (666, 777, etc.).
If the file does not already exist, the directory containing it must be writable.</p>
<p class="important"><strong>Note:</strong> The path is relative to your main site index.php file, NOT your controller or view files.
CodeIgniter uses a front controller so paths are always relative to the main site index.</p>
<h2>delete_files('<var>path</var>')</h2>
<p>Deletes ALL files contained in the supplied path. Example:</p>
<code>delete_files('./path/to/directory/');</code>
<p>If the second parameter is set to <kbd>true</kbd>, any directories contained within the supplied root path will be deleted as well. Example:</p>
<code>delete_files('./path/to/directory/', TRUE);</code>
<p class="important"><strong>Note:</strong> The files must be writable or owned by the system in order to be deleted.</p>
<h2>get_filenames('<var>path/to/directory/</var>')</h2>
<p>Takes a server path as input and returns an array containing the names of all files contained within it. The file path
can optionally be added to the file names by setting the second parameter to TRUE.</p>
<h2>get_dir_file_info('<var>path/to/directory/</var>', <kbd>$top_level_only</kbd> = TRUE)</h2>
<p>Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions. Sub-folders contained within the specified path are only read if forced
by sending the second parameter, <kbd>$top_level_only</kbd> to <samp>FALSE</samp>, as this can be an intensive operation.</p>
<h2>get_file_info('<var>path/to/file</var>', <kbd>$file_information</kbd>)</h2>
<p>Given a file and path, returns the name, path, size, date modified. Second parameter allows you to explicitly declare what information you want returned; options are: name, server_path, size, date, readable, writable, executable, fileperms. Returns FALSE if the file cannot be found.</p>
<p class="important"><strong>Note:</strong> The "writable" uses the PHP function is_writable() which is known to have issues on the IIS webserver. Consider using fileperms instead, which returns information from PHP's fileperms() function.</p>
<h2>get_mime_by_extension('<var>file</var>')</h2>
<p>Translates a file extension into a mime type based on config/mimes.php. Returns FALSE if it can't determine the type, or open the mime config file.</p>
<p>
<code>$file = "somefile.png";<br />
echo $file . ' is has a mime type of ' . get_mime_by_extension($file);</code>
</p>
<p class="critical"><strong>Note:</strong> This is not an accurate way of determining file mime types, and is here strictly as a convenience. It should not be used for security.</p>
<h2>symbolic_permissions(<kbd>$perms</kbd>)</h2>
<p>Takes numeric permissions (such as is returned by <kbd>fileperms()</kbd> and returns standard symbolic notation of file permissions.</p>
<code>echo symbolic_permissions(fileperms('./index.php'));<br />
<br />
// -rw-r--r--</code>
<h2>octal_permissions(<kbd>$perms</kbd>)</h2>
<p>Takes numeric permissions (such as is returned by <kbd>fileperms()</kbd> and returns a three character octal notation of file permissions.</p>
<code>echo octal_permissions(fileperms('./index.php'));<br />
<br />
// 644</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="email_helper.html">Email Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="form_helper.html">Form Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/file_helper.html | HTML | mit | 7,996 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>String Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
String Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>String Helper</h1>
<p>The String Helper file contains functions that assist in working with strings.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('string');</code>
<p>The following functions are available:</p>
<h2>random_string()</h2>
<p>Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.</p>
<p>The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:</p>
alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
<ul>
<li><strong>alpha</strong>: A string with lower and uppercase letters only.</li>
<li><strong>alnum</strong>: Alpha-numeric string with lower and uppercase characters.</li>
<li><strong>numeric</strong>: Numeric string.</li>
<li><strong>nozero</strong>: Numeric string with no zeros.</li>
<li><strong>unique</strong>: Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type.
Returns a fixed length 32 character string.</li>
<li><strong>sha1</strong>: An encrypted random number based on <kbd>do_hash()</kbd> from the <a href="security_helper.html">security helper</a>.</li>
</ul>
<p>Usage example:</p>
<code>echo random_string('alnum', 16);</code>
<h2>increment_string()</h2>
<p>Increments a string by appending a number to it or increasing the number. Useful for creating "copies" or a file or duplicating database content which has unique titles or slugs.</p>
<p>Usage example:</p>
<code>echo increment_string('file', '_'); // "file_1"<br/>
echo increment_string('file', '-', 2); // "file-2"<br/>
echo increment_string('file-4'); // "file-5"<br/></code>
<h2>alternator()</h2>
<p>Allows two or more items to be alternated between, when cycling through a loop. Example:</p>
<code>for ($i = 0; $i < 10; $i++)<br />
{<br />
echo alternator('string one', 'string two');<br />
}<br />
</code>
<p>You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.</p>
<code>for ($i = 0; $i < 10; $i++)<br />
{<br />
echo alternator('one', 'two', 'three', 'four', 'five');<br />
}<br />
</code>
<p><strong>Note:</strong> To use multiple separate calls to this function simply call the function with no arguments to re-initialize.</p>
<h2>repeater()</h2>
<p>Generates repeating copies of the data you submit. Example:</p>
<code>$string = "\n";<br />
echo repeater($string, 30);</code>
<p>The above would generate 30 newlines.</p>
<h2>reduce_double_slashes()</h2>
<p>Converts double slashes in a string to a single slash, except those found in http://. Example: </p>
<code>$string = "http://example.com//index.php";<br />
echo reduce_double_slashes($string); // results in "http://example.com/index.php"</code>
<h2>trim_slashes()</h2>
<p>Removes any leading/trailing slashes from a string. Example:<br />
<br />
<code>$string = "/this/that/theother/";<br />
echo trim_slashes($string); // results in this/that/theother</code></p>
<h2>reduce_multiples()</h2>
<p>Reduces multiple instances of a particular character occuring directly after each other. Example:</p>
<code>
$string="Fred, Bill,, Joe, Jimmy";<br />
$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"
</code>
<p>The function accepts the following parameters:
<code>reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)</code>
The first parameter contains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced.
The third parameter is FALSE by default; if set to TRUE it will remove occurences of the character at the beginning and the end of the string. Example:
<code>
$string=",Fred, Bill,, Joe, Jimmy,";<br />
$string=reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy"
</code>
</p>
<h2>quotes_to_entities()</h2>
<p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p>
<code>$string="Joe's \"dinner\"";<br />
$string=quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;"
</code>
<h2>strip_quotes()</h2>
<p>Removes single and double quotes from a string. Example:</p>
<code>$string="Joe's \"dinner\"";<br />
$string=strip_quotes($string); //results in "Joes dinner"
</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="smiley_helper.html">Smiley Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="text_helper.html">Text Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/string_helper.html | HTML | mit | 7,635 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Download Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Download Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Download Helper</h1>
<p>The Download Helper lets you download data to your desktop.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('download');</code>
<p>The following functions are available:</p>
<h2>force_download('<var>filename</var>', '<var>data</var>')</h2>
<p>Generates server headers which force data to be downloaded to your desktop. Useful with file downloads.
The first parameter is the <strong>name you want the downloaded file to be named</strong>, the second parameter is the file data.
Example:</p>
<code>
$data = 'Here is some text!';<br />
$name = 'mytext.txt';<br />
<br />
force_download($name, $data);
</code>
<p>If you want to download an existing file from your server you'll need to read the file into a string:</p>
<code>
$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents<br />
$name = 'myphoto.jpg';<br />
<br />
force_download($name, $data);
</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="directory_helper.html">Directory Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="email_helper.html">Email Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/download_helper.html | HTML | mit | 4,028 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XML Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
XML Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>XML Helper</h1>
<p>The XML Helper file contains functions that assist in working with XML data.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('xml');</code>
<p>The following functions are available:</p>
<h2>xml_convert('<var>string</var>')</h2>
<p>Takes a string as input and converts the following reserved XML characters to entities:</p>
<p>
Ampersands: &<br />
Less then and greater than characters: < ><br />
Single and double quotes: ' "<br />
Dashes: -</p>
<p>This function ignores ampersands if they are part of existing character entities. Example:</p>
<code>$string = xml_convert($string);</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="url_helper.html">URL Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/xml_helper.html | HTML | mit | 3,624 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Typography Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Typography Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Typography Helper</h1>
<p>The Typography Helper file contains functions that help your format text in semantically relevant ways.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('typography');</code>
<p>The following functions are available:</p>
<h2>auto_typography()</h2>
<p>Formats text so that it is semantically and typographically correct HTML. Please see the <a href="../libraries/typography.html">Typography Class</a> for more info.</p>
<p>Usage example:</p>
<code>$string = auto_typography($string);</code>
<p><strong>Note:</strong> Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted.
If you choose to use this function you may want to consider
<a href="../general/caching.html">caching</a> your pages.</p>
<h2>nl2br_except_pre()</h2>
<p>Converts newlines to <br /> tags unless they appear within <pre> tags.
This function is identical to the native PHP <dfn>nl2br()</dfn> function, except that it ignores <pre> tags.</p>
<p>Usage example:</p>
<code>$string = nl2br_except_pre($string);</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="text_helper.html">Text Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="url_helper.html">URL Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/typography_helper.html | HTML | mit | 4,199 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Inflector Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Inflector Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Inflector Helper</h1>
<p>The Inflector Helper file contains functions that permits you to change words to plural, singular, camel case, etc.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('inflector');</code>
<p>The following functions are available:</p>
<h2>singular()</h2>
<p>Changes a plural word to singular. Example:</p>
<code>
$word = "dogs";<br />
echo singular($word); // Returns "dog"
</code>
<h2>plural()</h2>
<p>Changes a singular word to plural. Example:</p>
<code>
$word = "dog";<br />
echo plural($word); // Returns "dogs"
</code>
<p>To force a word to end with "es" use a second "true" argument. </p>
<code> $word = "pass";<br />
echo plural($word, TRUE); // Returns "passes" </code>
<h2>camelize()</h2>
<p>Changes a string of words separated by spaces or underscores to camel case. Example:</p>
<code>
$word = "my_dog_spot";<br />
echo camelize($word); // Returns "myDogSpot"
</code>
<h2>underscore()</h2>
<p>Takes multiple words separated by spaces and underscores them. Example:</p>
<code>
$word = "my dog spot";<br />
echo underscore($word); // Returns "my_dog_spot"
</code>
<h2>humanize()</h2>
<p>Takes multiple words separated by underscores and adds spaces between them. Each word is capitalized. Example:</p>
<code>
$word = "my_dog_spot";<br />
echo humanize($word); // Returns "My Dog Spot"
</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="html_helper.html"> HTML Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="number_helper.html">Number Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/inflector_helper.html | HTML | mit | 4,512 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Form Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Form Helper</h1>
<p>The Form Helper file contains functions that assist in working with forms.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('form');</code>
<p>The following functions are available:</p>
<h2>form_open()</h2>
<p>Creates an opening form tag with a base URL <strong>built from your config preferences</strong>. It will optionally let you
add form attributes and hidden input fields, and will always add the attribute <kbd>accept-charset</kbd> based on the charset value in your config file.</p>
<p>The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable
in the event your URLs ever change.</p>
<p>Here's a simple example:</p>
<code>echo form_open('email/send');</code>
<p>The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:</p>
<code><form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" /></code>
<h4>Adding Attributes</h4>
<p>Attributes can be added by passing an associative array to the second parameter, like this:</p>
<code>
$attributes = array('class' => 'email', 'id' => 'myform');<br />
<br />
echo form_open('email/send', $attributes);</code>
<p>The above example would create a form similar to this:</p>
<code><form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" class="email" id="myform" /></code>
<h4>Adding Hidden Input Fields</h4>
<p>Hidden fields can be added by passing an associative array to the third parameter, like this:</p>
<code>
$hidden = array('username' => 'Joe', 'member_id' => '234');<br />
<br />
echo form_open('email/send', '', $hidden);</code>
<p>The above example would create a form similar to this:</p>
<code><form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send"><br />
<input type="hidden" name="username" value="Joe" /><br />
<input type="hidden" name="member_id" value="234" /></code>
<h2>form_open_multipart()</h2>
<p>This function is absolutely identical to the <dfn>form_open()</dfn> tag above except that it adds a multipart attribute,
which is necessary if you would like to use the form to upload files with.</p>
<h2>form_hidden()</h2>
<p>Lets you generate hidden input fields. You can either submit a name/value string to create one field:</p>
<code>form_hidden('username', 'johndoe');<br />
<br />
// Would produce:<br /><br />
<input type="hidden" name="username" value="johndoe" /></code>
<p>Or you can submit an associative array to create multiple fields:</p>
<code>$data = array(<br />
'name' => 'John Doe',<br />
'email' => 'john@example.com',<br />
'url' => 'http://example.com'<br />
);<br />
<br />
echo form_hidden($data);<br />
<br />
// Would produce:<br /><br />
<input type="hidden" name="name" value="John Doe" /><br />
<input type="hidden" name="email" value="john@example.com" /><br />
<input type="hidden" name="url" value="http://example.com" /></code>
<h2>form_input()</h2>
<p>Lets you generate a standard text input field. You can minimally pass the field name and value in the first
and second parameter:</p>
<code>echo form_input('username', 'johndoe');</code>
<p>Or you can pass an associative array containing any data you wish your form to contain:</p>
<code>$data = array(<br />
'name' => 'username',<br />
'id' => 'username',<br />
'value' => 'johndoe',<br />
'maxlength' => '100',<br />
'size' => '50',<br />
'style' => 'width:50%',<br />
);<br />
<br />
echo form_input($data);<br />
<br />
// Would produce:<br /><br />
<input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" /></code>
<p>If you would like your form to contain some additional data, like Javascript, you can pass it as a string in the
third parameter:</p>
<code>$js = 'onClick="some_function()"';<br />
<br />
echo form_input('username', 'johndoe', $js);</code>
<h2>form_password()</h2>
<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
except that is sets it as a "password" type.</p>
<h2>form_upload()</h2>
<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
except that is sets it as a "file" type, allowing it to be used to upload files.</p>
<h2>form_textarea()</h2>
<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
except that it generates a "textarea" type. Note: Instead of the "maxlength" and "size" attributes in the above
example, you will instead specify "rows" and "cols".</p>
<h2>form_dropdown()</h2>
<p>Lets you create a standard drop-down field. The first parameter will contain the name of the field,
the second parameter will contain an associative array of options, and the third parameter will contain the
value you wish to be selected. You can also pass an array of multiple items through the third parameter, and CodeIgniter will create a multiple select for you. Example:</p>
<code>$options = array(<br />
'small' => 'Small Shirt',<br />
'med' => 'Medium Shirt',<br />
'large' => 'Large Shirt',<br />
'xlarge' => 'Extra Large Shirt',<br />
);<br />
<br />
$shirts_on_sale = array('small', 'large');<br />
<br />
echo form_dropdown('shirts', $options, 'large');<br />
<br />
// Would produce:<br />
<br />
<select name="shirts"><br />
<option value="small">Small Shirt</option><br />
<option value="med">Medium Shirt</option><br />
<option value="large" selected="selected">Large Shirt</option><br />
<option value="xlarge">Extra Large Shirt</option><br />
</select><br />
<br />
echo form_dropdown('shirts', $options, $shirts_on_sale);<br />
<br />
// Would produce:<br />
<br />
<select name="shirts" multiple="multiple"><br />
<option value="small" selected="selected">Small Shirt</option><br />
<option value="med">Medium Shirt</option><br />
<option value="large" selected="selected">Large Shirt</option><br />
<option value="xlarge">Extra Large Shirt</option><br />
</select></code>
<p>If you would like the opening <select> to contain additional data, like an <kbd>id</kbd> attribute or JavaScript, you can pass it as a string in the
fourth parameter:</p>
<code>$js = 'id="shirts" onChange="some_function();"';<br />
<br />
echo form_dropdown('shirts', $options, 'large', $js);</code>
<p>If the array passed as $options is a multidimensional array, form_dropdown() will produce an <optgroup> with the array key as the label.</p>
<h2>form_multiselect()</h2>
<p>Lets you create a standard multiselect field. The first parameter will contain the name of the field,
the second parameter will contain an associative array of options, and the third parameter will contain the
value or values you wish to be selected. The parameter usage is identical to using <kbd>form_dropdown()</kbd> above,
except of course that the name of the field will need to use POST array syntax, e.g. <samp>foo[]</samp>.</p>
<h2>form_fieldset()</h2>
<p>Lets you generate fieldset/legend fields.</p>
<code>echo form_fieldset('Address Information');<br />
echo "<p>fieldset content here</p>\n";<br />
echo form_fieldset_close();
<br />
<br />
// Produces<br />
<fieldset>
<br />
<legend>Address Information</legend>
<br />
<p>form content here</p>
<br />
</fieldset></code>
<p>Similar to other functions, you can submit an associative array in the second parameter if you prefer to set additional attributes. </p>
<p><code>$attributes = array('id' => 'address_info', 'class' => 'address_info');<br />
echo form_fieldset('Address Information', $attributes);<br />
echo "<p>fieldset content here</p>\n";<br />
echo form_fieldset_close(); <br />
<br />
// Produces<br />
<fieldset id="address_info" class="address_info"> <br />
<legend>Address Information</legend> <br />
<p>form content here</p> <br />
</fieldset></code></p>
<h2>form_fieldset_close()</h2>
<p>Produces a closing </fieldset> tag. The only advantage to using this function is it permits you to pass data to it
which will be added below the tag. For example:</p>
<code>$string = "</div></div>";<br />
<br />
echo form_fieldset_close($string);<br />
<br />
// Would produce:<br />
</fieldset><br />
</div></div></code>
<h2>form_checkbox()</h2>
<p>Lets you generate a checkbox field. Simple example:</p>
<code>echo form_checkbox('newsletter', 'accept', TRUE);<br />
<br />
// Would produce:<br />
<br />
<input type="checkbox" name="newsletter" value="accept" checked="checked" /></code>
<p>The third parameter contains a boolean TRUE/FALSE to determine whether the box should be checked or not.</p>
<p>Similar to the other form functions in this helper, you can also pass an array of attributes to the function:</p>
<code>$data = array(<br />
'name' => 'newsletter',<br />
'id' => 'newsletter',<br />
'value' => 'accept',<br />
'checked' => TRUE,<br />
'style' => 'margin:10px',<br />
);<br />
<br />
echo form_checkbox($data);<br />
<br />
// Would produce:<br /><br />
<input type="checkbox" name="newsletter" id="newsletter" value="accept" checked="checked" style="margin:10px" /></code>
<p>As with other functions, if you would like the tag to contain additional data, like JavaScript, you can pass it as a string in the
fourth parameter:</p>
<code>$js = 'onClick="some_function()"';<br />
<br />
echo form_checkbox('newsletter', 'accept', TRUE, $js)</code>
<h2>form_radio()</h2>
<p>This function is identical in all respects to the <dfn>form_checkbox()</dfn> function above except that is sets it as a "radio" type.</p>
<h2>form_submit()</h2>
<p>Lets you generate a standard submit button. Simple example:</p>
<code>echo form_submit('mysubmit', 'Submit Post!');<br />
<br />
// Would produce:<br />
<br />
<input type="submit" name="mysubmit" value="Submit Post!" /></code>
<p>Similar to other functions, you can submit an associative array in the first parameter if you prefer to set your own attributes.
The third parameter lets you add extra data to your form, like JavaScript.</p>
<h2>form_label()</h2>
<p>Lets you generate a <label>. Simple example:</p>
<code>echo form_label('What is your Name', 'username');<br />
<br />
// Would produce:
<br />
<label for="username">What is your Name</label></code>
<p>Similar to other functions, you can submit an associative array in the third parameter if you prefer to set additional attributes. </p>
<p><code>$attributes = array(<br />
'class' => 'mycustomclass',<br />
'style' => 'color: #000;',<br />
);<br />
echo form_label('What is your Name', 'username', $attributes);<br />
<br />
// Would produce: <br />
<label for="username" class="mycustomclass" style="color: #000;">What is your Name</label></code></p>
<h2>form_reset()</h2>
<p>Lets you generate a standard reset button. Use is identical to <dfn>form_submit()</dfn>.</p>
<h2>form_button()</h2>
<p>Lets you generate a standard button element. You can minimally pass the button name and content in the first and second parameter:</p>
<code>
echo form_button('name','content');<br />
<br />
// Would produce<br />
<button name="name" type="button">Content</button>
</code>
Or you can pass an associative array containing any data you wish your form to contain:
<code>
$data = array(<br />
'name' => 'button',<br />
'id' => 'button',<br />
'value' => 'true',<br />
'type' => 'reset',<br />
'content' => 'Reset'<br />
);<br />
<br />
echo form_button($data);<br />
<br />
// Would produce:<br />
<button name="button" id="button" value="true" type="reset">Reset</button>
</code>
If you would like your form to contain some additional data, like JavaScript, you can pass it as a string in the third parameter:
<code>
$js = 'onClick="some_function()"';<br /><br />
echo form_button('mybutton', 'Click Me', $js);
</code>
<h2>form_close()</h2>
<p>Produces a closing </form> tag. The only advantage to using this function is it permits you to pass data to it
which will be added below the tag. For example:</p>
<code>$string = "</div></div>";<br />
<br />
echo form_close($string);<br />
<br />
// Would produce:<br />
<br />
</form><br />
</div></div></code>
<h2>form_prep()</h2>
<p>Allows you to safely use HTML and characters such as quotes within form elements without breaking out of the form. Consider this example:</p>
<code>$string = 'Here is a string containing <strong>"quoted"</strong> text.';<br />
<br />
<input type="text" name="myform" value="<var>$string</var>" /></code>
<p>Since the above string contains a set of quotes it will cause the form to break.
The form_prep function converts HTML so that it can be used safely:</p>
<code><input type="text" name="myform" value="<var><?php echo form_prep($string); ?></var>" /></code>
<p class="important"><strong>Note:</strong> If you use any of the form helper functions listed in this page the form
values will be prepped automatically, so there is no need to call this function. Use it only if you are
creating your own form elements.</p>
<h2>set_value()</h2>
<p>Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function.
The second (optional) parameter allows you to set a default value for the form. Example:</p>
<code><input type="text" name="quantity" value="<dfn><?php echo set_value('quantity', '0'); ?></dfn>" size="50" /></code>
<p>The above form will show "0" when loaded for the first time.</p>
<h2>set_select()</h2>
<p>If you use a <dfn><select></dfn> menu, this function permits you to display the menu item that was selected. The first parameter
must contain the name of the select menu, the second parameter must contain the value of
each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).</p>
<p>Example:</p>
<code>
<select name="myselect"><br />
<option value="one" <dfn><?php echo set_select('myselect', 'one', TRUE); ?></dfn> >One</option><br />
<option value="two" <dfn><?php echo set_select('myselect', 'two'); ?></dfn> >Two</option><br />
<option value="three" <dfn><?php echo set_select('myselect', 'three'); ?></dfn> >Three</option><br />
</select>
</code>
<h2>set_checkbox()</h2>
<p>Permits you to display a checkbox in the state it was submitted. The first parameter
must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE). Example:</p>
<code><input type="checkbox" name="mycheck" value="1" <dfn><?php echo set_checkbox('mycheck', '1'); ?></dfn> /><br />
<input type="checkbox" name="mycheck" value="2" <dfn><?php echo set_checkbox('mycheck', '2'); ?></dfn> /></code>
<h2>set_radio()</h2>
<p>Permits you to display radio buttons in the state they were submitted. This function is identical to the <strong>set_checkbox()</strong> function above.</p>
<code><input type="radio" name="myradio" value="1" <dfn><?php echo set_radio('myradio', '1', TRUE); ?></dfn> /><br />
<input type="radio" name="myradio" value="2" <dfn><?php echo set_radio('myradio', '2'); ?></dfn> /></code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="file_helper.html">File Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="html_helper.html">HTML Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/form_helper.html | HTML | mit | 21,252 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CAPTCHA Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
CAPTCHA Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>CAPTCHA Helper</h1>
<p>The CAPTCHA Helper file contains functions that assist in creating CAPTCHA images.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('captcha');</code>
<p>The following functions are available:</p>
<h2>create_captcha(<var>$data</var>)</h2>
<p>Takes an array of information to generate the CAPTCHA as input and creates the image to your specifications, returning an array of associative data about the image.</p>
<code>[array]<br />
(<br />
'image' => IMAGE TAG<br />
'time' => TIMESTAMP (in microtime)<br />
'word' => CAPTCHA WORD<br />
)</code>
<p>The "image" is the actual image tag:
<code><img src="http://example.com/captcha/12345.jpg" width="140" height="50" /></code></p>
<p>The "time" is the micro timestamp used as the image name without the file
extension. It will be a number like this: 1139612155.3422</p>
<p>The "word" is the word that appears in the captcha image, which if not
supplied to the function, will be a random string.</p>
<h3>Using the CAPTCHA helper</h3>
<p>Once loaded you can generate a captcha like this:</p>
<code>$vals = array(<br />
'word' => 'Random word',<br />
'img_path' => './captcha/',<br />
'img_url' => 'http://example.com/captcha/',<br />
'font_path' => './path/to/fonts/texb.ttf',<br />
'img_width' => '150',<br />
'img_height' => 30,<br />
'expiration' => 7200<br />
);<br />
<br />
$cap = create_captcha($vals);<br />
echo $cap['image'];</code>
<ul>
<li>The captcha function requires the GD image library.</li>
<li>Only the img_path and img_url are required.</li>
<li>If a "word" is not supplied, the function will generate a random
ASCII string. You might put together your own word library that
you can draw randomly from.</li>
<li>If you do not specify a path to a TRUE TYPE font, the native ugly GD
font will be used.</li>
<li>The "captcha" folder must be writable (666, or 777)</li>
<li>The "expiration" (in seconds) signifies how long an image will
remain in the captcha folder before it will be deleted. The default
is two hours.</li>
</ul>
<h3>Adding a Database</h3>
<p>In order for the captcha function to prevent someone from submitting, you will need
to add the information returned from <kbd>create_captcha()</kbd> function to your database.
Then, when the data from the form is submitted by the user you will need to verify
that the data exists in the database and has not expired.</p>
<p>Here is a table prototype:</p>
<code>CREATE TABLE captcha (<br />
captcha_id bigint(13) unsigned NOT NULL auto_increment,<br />
captcha_time int(10) unsigned NOT NULL,<br />
ip_address varchar(16) default '0' NOT NULL,<br />
word varchar(20) NOT NULL,<br />
PRIMARY KEY `captcha_id` (`captcha_id`),<br />
KEY `word` (`word`)<br />
);</code>
<p>Here is an example of usage with a database. On the page where the CAPTCHA will be shown you'll have something like this:</p>
<code>$this->load->helper('captcha');<br />
$vals = array(<br />
'img_path' => './captcha/',<br />
'img_url' => 'http://example.com/captcha/'<br />
);<br />
<br />
$cap = create_captcha($vals);<br />
<br />
$data = array(<br />
'captcha_time' => $cap['time'],<br />
'ip_address' => $this->input->ip_address(),<br />
'word' => $cap['word']<br />
);<br />
<br />
$query = $this->db->insert_string('captcha', $data);<br />
$this->db->query($query);<br />
<br />
echo 'Submit the word you see below:';<br />
echo $cap['image'];<br />
echo '<input type="text" name="captcha" value="" />';</code>
<p>Then, on the page that accepts the submission you'll have something like this:</p>
<code>// First, delete old captchas<br />
$expiration = time()-7200; // Two hour limit<br />
$this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration); <br />
<br />
// Then see if a captcha exists:<br />
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?";<br />
$binds = array($_POST['captcha'], $this->input->ip_address(), $expiration);<br />
$query = $this->db->query($sql, $binds);<br />
$row = $query->row();<br />
<br />
if ($row->count == 0)<br />
{<br />
echo "You must submit the word that appears in the image";<br />
}</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="array_helper.html">Array Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="cookie_helper.html">Cookie Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html>
| 069h-course-management | trunk/ci/user_guide/helpers/captcha_helper.html | HTML | mit | 8,075 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Array Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Array Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Array Helper</h1>
<p>The Array Helper file contains functions that assist in working with arrays.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('array');</code>
<p>The following functions are available:</p>
<h2>element()</h2>
<p>Lets you fetch an item from an array. The function tests whether the array index is set and whether it has a value. If
a value exists it is returned. If a value does not exist it returns FALSE, or whatever you've specified as the default value via the third parameter. Example:</p>
<code>
$array = array('color' => 'red', 'shape' => 'round', 'size' => '');<br />
<br />
// returns "red"<br />
echo element('color', $array);<br />
<br />
// returns NULL<br />
echo element('size', $array, NULL);
</code>
<h2>random_element()</h2>
<p>Takes an array as input and returns a random element from it. Usage example:</p>
<code>$quotes = array(<br />
"I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",<br />
"Don't stay in bed, unless you can make money in bed. - George Burns",<br />
"We didn't lose the game; we just ran out of time. - Vince Lombardi",<br />
"If everything seems under control, you're not going fast enough. - Mario Andretti",<br />
"Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",<br />
"Chance favors the prepared mind - Louis Pasteur"<br />
);<br />
<br />
echo random_element($quotes);</code>
<h2>elements()</h2>
<p>Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist
it is set to FALSE, or whatever you've specified as the default value via the third parameter. Example:</p>
<code>
$array = array(<br />
'color' => 'red',<br />
'shape' => 'round',<br />
'radius' => '10',<br />
'diameter' => '20'<br />
);<br />
<br />
$my_shape = elements(array('color', 'shape', 'height'), $array);<br />
</code>
<p>The above will return the following array:</p>
<code>
array(<br />
'color' => 'red',<br />
'shape' => 'round',<br />
'height' => FALSE<br />
);
</code>
<p>You can set the third parameter to any default value you like:</p>
<code>
$my_shape = elements(array('color', 'shape', 'height'), $array, NULL);<br />
</code>
<p>The above will return the following array:</p>
<code>
array(<br />
'color' => 'red',<br />
'shape' => 'round',<br />
'height' => NULL<br />
);
</code>
<p>This is useful when sending the <kbd>$_POST</kbd> array to one of your Models. This prevents users from
sending additional POST data to be entered into your tables:</p>
<code>
$this->load->model('post_model');<br />
<br />
$this->post_model->update(elements(array('id', 'title', 'content'), $_POST));
</code>
<p>This ensures that only the id, title and content fields are sent to be updated.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="../libraries/javascript.html">Javascript Class</a> ·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="captcha_helper.html">CAPTCHA Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/array_helper.html | HTML | mit | 6,657 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
HTML Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>HTML Helper</h1>
<p>The HTML Helper file contains functions that assist in working with HTML.</p>
<ul>
<li><a href="#br">br()</a></li>
<li><a href="#heading">heading()</a></li>
<li><a href="#img">img()</a></li>
<li><a href="#link_tag">link_tag()</a></li>
<li><a href="#nbs">nbs()</a></li>
<li><a href="#ol_and_ul">ol() and ul()</a></li>
<li><a href="#meta">meta()</a></li>
<li><a href="#doctype">doctype()</a></li>
</ul>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('html');</code>
<p>The following functions are available:</p>
<h2><a name="br"></a>br()</h2>
<p>Generates line break tags (<br />) based on the number you submit. Example:</p>
<code>echo br(3);</code>
<p>The above would produce: <br /><br /><br /></p>
<h2><a name="heading"></a>heading()</h2>
<p>Lets you create HTML <h1> tags. The first parameter will contain the data, the
second the size of the heading. Example:</p>
<code>echo heading('Welcome!', 3);</code>
<p>The above would produce: <h3>Welcome!</h3></p>
<p>Additionally, in order to add attributes to the heading tag such as HTML classes, ids or inline styles, a third parameter is available.</p>
<code>echo heading('Welcome!', 3, 'class="pink"')</code>
<p>The above code produces: <h3 class="pink">Welcome!<<h3></p>
<h2><a name="img"></a>img()</h2>
<p>Lets you create HTML <img /> tags. The first parameter contains the image source. Example:</p>
<code>echo img('images/picture.jpg');<br />
// gives <img src="http://site.com/images/picture.jpg" /></code>
<p>There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config['index_page'] added to the address it creates. Presumably, this would be if you were using a media controller.</p>
<p><code>echo img('images/picture.jpg', TRUE);<br />
// gives <img src="http://site.com/index.php/images/picture.jpg" alt="" /></code></p>
<p>Additionally, an associative array can be passed to the img() function for complete control over all attributes and values. If an alt attribute is not provided, CodeIgniter will generate an empty string.</p>
<p><code> $image_properties = array(<br />
'src' => 'images/picture.jpg',<br />
'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',<br />
'class' => 'post_images',<br />
'width' => '200',<br />
'height' => '200',<br />
'title' => 'That was quite a night',<br />
'rel' => 'lightbox',<br />
);<br />
<br />
img($image_properties);<br />
// <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" /></code></p>
<h2><a name="link_tag"></a>link_tag()</h2>
<p>Lets you create HTML <link /> tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.<code>
echo link_tag('css/mystyles.css');<br />
// gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" /></code></p>
<p>Further examples:</p>
<code>
echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');<br />
// <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
<br />
<br />
echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
// <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" /> </code>
<p>Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.</p>
<p><code>
$link = array(<br />
'href' => 'css/printer.css',<br />
'rel' => 'stylesheet',<br />
'type' => 'text/css',<br />
'media' => 'print'<br />
);<br />
<br />
echo link_tag($link);<br />
// <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" /></code></p>
<h2><a name="nbs"></a>nbs()</h2>
<p>Generates non-breaking spaces (&nbsp;) based on the number you submit. Example:</p>
<code>echo nbs(3);</code>
<p>The above would produce: &nbsp;&nbsp;&nbsp;</p>
<h2><a name="ol_and_ul"></a>ol() and ul()</h2>
<p>Permits you to generate ordered or unordered HTML lists from simple or multi-dimensional arrays. Example:</p>
<code>
$this->load->helper('html');<br />
<br />
$list = array(<br />
'red', <br />
'blue', <br />
'green',<br />
'yellow'<br />
);<br />
<br />
$attributes = array(<br />
'class' => 'boldlist',<br />
'id' => 'mylist'<br />
);<br />
<br />
echo ul($list, $attributes);<br />
</code>
<p>The above code will produce this:</p>
<code>
<ul class="boldlist" id="mylist"><br />
<li>red</li><br />
<li>blue</li><br />
<li>green</li><br />
<li>yellow</li><br />
</ul>
</code>
<p>Here is a more complex example, using a multi-dimensional array:</p>
<code>
$this->load->helper('html');<br />
<br />
$attributes = array(<br />
'class' => 'boldlist',<br />
'id' => 'mylist'<br />
);<br />
<br />
$list = array(<br />
'colors' => array(<br />
'red',<br />
'blue',<br />
'green'<br />
),<br />
'shapes' => array(<br />
'round', <br />
'square',<br />
'circles' => array(<br />
'ellipse', <br />
'oval', <br />
'sphere'<br />
)<br />
),<br />
'moods' => array(<br />
'happy', <br />
'upset' => array(<br />
'defeated' => array(<br />
'dejected',<br />
'disheartened',<br />
'depressed'<br />
),<br />
'annoyed',<br />
'cross',<br />
'angry'<br />
)<br />
)<br />
);<br />
<br />
<br />
echo ul($list, $attributes);</code>
<p>The above code will produce this:</p>
<code>
<ul class="boldlist" id="mylist"><br />
<li>colors<br />
<ul><br />
<li>red</li><br />
<li>blue</li><br />
<li>green</li><br />
</ul><br />
</li><br />
<li>shapes<br />
<ul><br />
<li>round</li><br />
<li>suare</li><br />
<li>circles<br />
<ul><br />
<li>elipse</li><br />
<li>oval</li><br />
<li>sphere</li><br />
</ul><br />
</li><br />
</ul><br />
</li><br />
<li>moods<br />
<ul><br />
<li>happy</li><br />
<li>upset<br />
<ul><br />
<li>defeated<br />
<ul><br />
<li>dejected</li><br />
<li>disheartened</li><br />
<li>depressed</li><br />
</ul><br />
</li><br />
<li>annoyed</li><br />
<li>cross</li><br />
<li>angry</li><br />
</ul><br />
</li><br />
</ul><br />
</li><br />
</ul>
</code>
<h2><a name="meta"></a>meta()</h2>
<p>Helps you generate meta tags. You can pass strings to the function, or simple arrays, or multidimensional ones. Examples:</p>
<code>
echo meta('description', 'My Great site');<br />
// Generates: <meta name="description" content="My Great Site" /><br />
<br /><br />
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); // Note the third parameter. Can be "equiv" or "name"<br />
// Generates: <meta http-equiv="Content-type" content="text/html; charset=utf-8" /><br />
<br /><br />
echo meta(array('name' => 'robots', 'content' => 'no-cache'));<br />
// Generates: <meta name="robots" content="no-cache" /><br />
<br /><br />
$meta = array(<br />
array('name' => 'robots', 'content' => 'no-cache'),<br />
array('name' => 'description', 'content' => 'My Great Site'),<br />
array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),<br />
array('name' => 'robots', 'content' => 'no-cache'),<br />
array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')<br />
);<br />
<br />
echo meta($meta);
<br />
// Generates: <br />
// <meta name="robots" content="no-cache" /><br />
// <meta name="description" content="My Great Site" /><br />
// <meta name="keywords" content="love, passion, intrigue, deception" /><br />
// <meta name="robots" content="no-cache" /><br />
// <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</code>
<h2><a name="doctype"></a>doctype()</h2>
<p>Helps you generate document type declarations, or DTD's. XHTML 1.0 Strict is used by default, but many doctypes are available.</p>
<code>
echo doctype();<br />
// <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<br />
echo doctype('html4-trans');<br />
// <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
</code>
<p>The following is a list of doctype choices. These are configurable, and pulled from <samp>application/config/doctypes.php</samp></p>
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
<tr>
<th>Doctype</th>
<th>Option</th>
<th>Result</th>
</tr>
<tr>
<td class="td">XHTML 1.1</td>
<td class="td">doctype('xhtml11')</td>
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"></td>
</tr>
<tr>
<td class="td">XHTML 1.0 Strict</td>
<td class="td">doctype('xhtml1-strict')</td>
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></td>
</tr>
<tr>
<td class="td">XHTML 1.0 Transitional</td>
<td class="td">doctype('xhtml1-trans')</td>
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></td>
</tr>
<tr>
<td class="td">XHTML 1.0 Frameset</td>
<td class="td">doctype('xhtml1-frame')</td>
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"></td>
</tr>
<tr>
<td class="td">HTML 5</td>
<td class="td">doctype('html5')</td>
<td class="td"><!DOCTYPE html></td>
</tr>
<tr>
<td class="td">HTML 4 Strict</td>
<td class="td">doctype('html4-strict')</td>
<td class="td"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"></td>
</tr>
<tr>
<td class="td">HTML 4 Transitional</td>
<td class="td">doctype('html4-trans')</td>
<td class="td"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></td>
</tr>
<tr>
<td class="td">HTML 4 Frameset</td>
<td class="td">doctype('html4-frame')</td>
<td class="td"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"></td>
</tr>
</table>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="form_helper.html">Form Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="path_helper.html"> Path Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/html_helper.html | HTML | mit | 24,831 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cookie Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Cookie Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Cookie Helper</h1>
<p>The Cookie Helper file contains functions that assist in working with cookies.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('cookie');</code>
<p>The following functions are available:</p>
<h2>set_cookie()</h2>
<p>This helper function gives you view file friendly syntax to set browser cookies. Refer to the <a href="../libraries/input.html">Input class</a> for a description of use, as this function is an alias to $this->input->set_cookie().</p>
<h2>get_cookie()</h2>
<p>This helper function gives you view file friendly syntax to get browser cookies. Refer to the <a href="../libraries/input.html">Input class</a> for a description of use, as this function is an alias to $this->input->cookie().</p>
<h2>delete_cookie()</h2>
<p>Lets you delete a cookie. Unless you've set a custom path or other values, only the name of the cookie is needed:</p>
<code>delete_cookie("name");</code>
<p>This function is otherwise identical to <dfn>set_cookie()</dfn>, except that it does not have the value and expiration parameters. You can submit an array
of values in the first parameter or you can set discrete parameters.</p>
<code>delete_cookie($name, $domain, $path, $prefix)</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="captcha_helper.html">CAPTCHA Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="date_helper.html">Date Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/cookie_helper.html | HTML | mit | 4,320 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Smiley Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Smiley Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Smiley Helper</h1>
<p>The Smiley Helper file contains functions that let you manage smileys (emoticons).</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('smiley');</code>
<h2>Overview</h2>
<p>The Smiley helper has a renderer that takes plain text simileys, like <dfn>:-)</dfn> and turns
them into a image representation, like <img src="../images/smile.gif" width="19" height="19" border="0" alt="smile!" /></p>
<p>It also lets you display a set of smiley images that when clicked will be inserted into a form field.
For example, if you have a blog that allows user commenting you can show the smileys next to the comment form.
Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.</p>
<h2>Clickable Smileys Tutorial</h2>
<p>Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example
requires that you first download and install the smiley images, then create a controller and the View as described.</p>
<p class="important"><strong>Important:</strong> Before you begin, please <a href="http://codeigniter.com/download_files/smileys.zip">download the smiley images</a> and put them in
a publicly accessible place on your server. This helper also assumes you have the smiley replacement array located at
<dfn>application/config/smileys.php</dfn></p>
<h3>The Controller</h3>
<p>In your <dfn>application/controllers/</dfn> folder, create a file called <kbd>smileys.php</kbd> and place the code below in it.</p>
<p><strong>Important:</strong> Change the URL in the <dfn>get_clickable_smileys()</dfn> function below so that it points to
your <dfn>smiley</dfn> folder.</p>
<p>You'll notice that in addition to the smiley helper we are using the <a href="../libraries/table.html">Table Class</a>.</p>
<textarea class="textarea" style="width:100%" cols="50" rows="25">
<?php
class Smileys extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->helper('smiley');
$this->load->library('table');
$image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments');
$col_array = $this->table->make_columns($image_array, 8);
$data['smiley_table'] = $this->table->generate($col_array);
$this->load->view('smiley_view', $data);
}
}
?>
</textarea>
<p>In your <dfn>application/views/</dfn> folder, create a file called <kbd>smiley_view.php</kbd> and place this code in it:</p>
<textarea class="textarea" style="width:100%" cols="50" rows="20">
<html>
<head>
<title>Smileys</title>
<?php echo smiley_js(); ?>
</head>
<body>
<form name="blog">
<textarea name="comments" id="comments" cols="40" rows="4"></textarea>
</form>
<p>Click to insert a smiley!</p>
<?php echo $smiley_table; ?>
</body>
</html>
</textarea>
<p>When you have created the above controller and view, load it by visiting <dfn>http://www.example.com/index.php/smileys/</dfn></p>
<h3>Field Aliases</h3>
<p>When making changes to a view it can be inconvenient to have the field id in the controller. To work around this,
you can give your smiley links a generic name that will be tied to a specific id in your view.</p>
<code>$image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias");</code>
<p>To map the alias to the field id, pass them both into the smiley_js function:</p>
<code>$image_array = smiley_js("comment_textarea_alias", "comments");</code>
<h1>Function Reference</h1>
<h2>get_clickable_smileys()</h2>
<p>Returns an array containing your smiley images wrapped in a clickable link. You must supply the URL to your smiley folder
and a field id or field alias.</p>
<code>$image_array = get_smiley_links("http://example.com/images/smileys/", "comment");</code>
<p class="important">Note: Usage of this function without the second parameter, in combination with js_insert_smiley has been deprecated.</p>
<h2>smiley_js()</h2>
<p>Generates the JavaScript that allows the images to be clicked and inserted into a form field.
If you supplied an alias instead of an id when generating your smiley links, you need to pass the
alias and corresponding form id into the function.
This function is designed to be placed into the <head> area of your web page.</p>
<code><?php echo smiley_js(); ?></code>
<p class="important">Note: This function replaces js_insert_smiley, which has been deprecated.</p>
<h2>parse_smileys()</h2>
<p>Takes a string of text as input and replaces any contained plain text smileys into the image
equivalent. The first parameter must contain your string, the second must contain the URL to your smiley folder:</p>
<code>
$str = 'Here are some simileys: :-) ;-)';
$str = parse_smileys($str, "http://example.com/images/smileys/");
echo $str;
</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="security_helper.html">Security Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="string_helper.html">String Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/smiley_helper.html | HTML | mit | 7,995 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Directory Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Directory Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Directory Helper</h1>
<p>The Directory Helper file contains functions that assist in working with directories.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('directory');</code>
<p>The following functions are available:</p>
<h2>directory_map('<var>source directory</var>')</h2>
<p>This function reads the directory path specified in the first parameter
and builds an array representation of it and all its contained files. Example:</p>
<code>$map = directory_map('./mydirectory/');</code>
<p class="important"><strong>Note:</strong> Paths are almost always relative to your main index.php file.</p>
<p>Sub-folders contained within the directory will be mapped as well. If you wish to control the recursion depth,
you can do so using the second parameter (integer). A depth of 1 will only map the top level directory:</p>
<code>$map = directory_map('./mydirectory/', 1);</code>
<p>By default, hidden files will not be included in the returned array. To override this behavior,
you may set a third parameter to <var>true</var> (boolean):</p>
<code>$map = directory_map('./mydirectory/', FALSE, TRUE);</code>
<p>Each folder name will be an array index, while its contained files will be numerically indexed.
Here is an example of a typical array:</p>
<code>Array<br />
(<br />
[libraries] => Array<br />
(<br />
[0] => benchmark.html<br />
[1] => config.html<br />
[database] => Array<br />
(<br />
[0] => active_record.html<br />
[1] => binds.html<br />
[2] => configuration.html<br />
[3] => connecting.html<br />
[4] => examples.html<br />
[5] => fields.html<br />
[6] => index.html<br />
[7] => queries.html<br />
)<br />
[2] => email.html<br />
[3] => file_uploading.html<br />
[4] => image_lib.html<br />
[5] => input.html<br />
[6] => language.html<br />
[7] => loader.html<br />
[8] => pagination.html<br />
[9] => uri.html<br />
)</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="date_helper.html">Date Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="download_helper.html">Download Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/directory_helper.html | HTML | mit | 6,192 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Language Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Language Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Language Helper</h1>
<p>The Language Helper file contains functions that assist in working with language files.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('language');</code>
<p>The following functions are available:</p>
<h2>lang('<var>language line</var>', '<var>element id</var>')</h2>
<p>This function returns a line of text from a loaded language file with simplified syntax
that may be more desirable for view files than calling <kbd>$this->lang->line()</kbd>.
The optional second parameter will also output a form label for you. Example:</p>
<code>echo lang('<samp>language_key</samp>', '<samp>form_item_id</samp>');<br />
// becomes <label for="form_item_id">language_key</label></code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="date_helper.html">Date Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="download_helper.html">Download Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/language_helper.html | HTML | mit | 3,838 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Security Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Security Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Security Helper</h1>
<p>The Security Helper file contains security related functions.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('security');</code>
<p>The following functions are available:</p>
<h2>xss_clean()</h2>
<p>Provides Cross Site Script Hack filtering. This function is an alias to the one in the
<a href="../libraries/input.html">Input class</a>. More info can be found there.</p>
<h2>sanitize_filename()</h2>
<p>Provides protection against directory traversal. This function is an alias to the one in the
<a href="../libraries/security.html">Security class</a>. More info can be found there.</p>
<h2>do_hash()</h2>
<p>Permits you to create SHA1 or MD5 one way hashes suitable for encrypting passwords. Will create SHA1 by default. Examples:</p>
<code>
$str = do_hash($str); // SHA1<br />
<br />
$str = do_hash($str, 'md5'); // MD5
</code>
<p class="important"><strong>Note:</strong> This function was formerly named <kbd>dohash()</kbd>, which has been deprecated in favour of <kbd>do_hash()</kbd>.</p>
<h2>strip_image_tags()</h2>
<p>This is a security function that will strip image tags from a string. It leaves the image URL as plain text.</p>
<code>$string = strip_image_tags($string);</code>
<h2>encode_php_tags()</h2>
<p>This is a security function that converts PHP tags to entities. Note: If you use the XSS filtering function it does this automatically.</p>
<code>$string = encode_php_tags($string);</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="path_helper.html"> Path Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="smiley_helper.html">Smiley Helper</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/security_helper.html | HTML | mit | 4,573 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Date Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Date Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Date Helper</h1>
<p>The Date Helper file contains functions that help you work with dates.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('date');</code>
<p>The following functions are available:</p>
<h2>now()</h2>
<p>Returns the current time as a Unix timestamp, referenced either to your server's local time or GMT, based on the "time reference"
setting in your config file. If you do not intend to set your master time reference to GMT (which you'll typically do if you
run a site that lets each user set their own timezone settings) there is no benefit to using this function over PHP's time() function.
</p>
<h2>mdate()</h2>
<p>This function is identical to PHPs <a href="http://www.php.net/date">date()</a> function, except that it lets you
use MySQL style date codes, where each code letter is preceded with a percent sign: %Y %m %d etc.</p>
<p>The benefit of doing dates this way is that you don't have to worry about escaping any characters that
are not date codes, as you would normally have to do with the date() function. Example:</p>
<code>$datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";<br />
$time = time();<br />
<br />
echo mdate($datestring, $time);</code>
<p>If a timestamp is not included in the second parameter the current time will be used.</p>
<h2>standard_date()</h2>
<p>Lets you generate a date string in one of several standardized formats. Example:</p>
<code>
$format = 'DATE_RFC822';<br />
$time = time();<br />
<br />
echo standard_date($format, $time);
</code>
<p>The first parameter must contain the format, the second parameter must contain the date as a Unix timestamp.</p>
<p>Supported formats:</p>
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
<tr>
<th>Constant</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>DATE_ATOM</td>
<td>Atom</td>
<td>2005-08-15T16:13:03+0000</td>
</tr>
<tr>
<td>DATE_COOKIE</td>
<td>HTTP Cookies</td>
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_ISO8601</td>
<td>ISO-8601</td>
<td>2005-08-14T16:13:03+00:00</td>
</tr>
<tr>
<td>DATE_RFC822</td>
<td>RFC 822</td>
<td>Sun, 14 Aug 05 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_RFC850</td>
<td>RFC 850</td>
<td>Sunday, 14-Aug-05 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_RFC1036</td>
<td>RFC 1036</td>
<td>Sunday, 14-Aug-05 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_RFC1123</td>
<td>RFC 1123</td>
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_RFC2822</td>
<td>RFC 2822</td>
<td>Sun, 14 Aug 2005 16:13:03 +0000</td>
</tr>
<tr>
<td>DATE_RSS</td>
<td>RSS</td>
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_W3C</td>
<td>World Wide Web Consortium</td>
<td>2005-08-14T16:13:03+0000</td>
</tr>
</table>
<h2>local_to_gmt()</h2>
<p>Takes a Unix timestamp as input and returns it as GMT. Example:</p>
<code>$now = time();<br />
<br />
$gmt = local_to_gmt($now);</code>
<h2>gmt_to_local()</h2>
<p>Takes a Unix timestamp (referenced to GMT) as input, and converts it to a localized timestamp based on the
timezone and Daylight Saving time submitted. Example:</p>
<code>
$timestamp = '1140153693';<br />
$timezone = 'UM8';<br />
$daylight_saving = TRUE;<br />
<br />
echo gmt_to_local($timestamp, $timezone, $daylight_saving);</code>
<p><strong>Note:</strong> For a list of timezones see the reference at the bottom of this page.</p>
<h2>mysql_to_unix()</h2>
<p>Takes a MySQL Timestamp as input and returns it as Unix. Example:</p>
<code>$mysql = '20061124092345';<br />
<br />
$unix = mysql_to_unix($mysql);</code>
<h2>unix_to_human()</h2>
<p>Takes a Unix timestamp as input and returns it in a human readable format with this prototype:</p>
<code>YYYY-MM-DD HH:MM:SS AM/PM</code>
<p>This can be useful if you need to display a date in a form field for submission.</p>
<p>The time can be formatted with or without seconds, and it can be set to European or US format. If only
the timestamp is submitted it will return the time without seconds formatted for the U.S. Examples:</p>
<code>$now = time();<br />
<br />
echo unix_to_human($now); // U.S. time, no seconds<br />
<br />
echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds<br />
<br />
echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds</code>
<h2>human_to_unix()</h2>
<p>The opposite of the above function. Takes a "human" time as input and returns it as Unix. This function is
useful if you accept "human" formatted dates submitted via a form. Returns FALSE (boolean) if
the date string passed to it is not formatted as indicated above. Example:</p>
<code>$now = time();<br />
<br />
$human = unix_to_human($now);<br />
<br />
$unix = human_to_unix($human);</code>
<h2>timespan()</h2>
<p>Formats a unix timestamp so that is appears similar to this:</p>
<code>1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes</code>
<p>The first parameter must contain a Unix timestamp. The second parameter must contain a
timestamp that is greater that the first timestamp. If the second parameter empty, the current time will be used. The most common purpose
for this function is to show how much time has elapsed from some point in time in the past to now. Example:</p>
<code>$post_date = '1079621429';<br />
$now = time();<br />
<br />
echo timespan($post_date, $now);</code>
<p class="important"><strong>Note:</strong> The text generated by this function is found in the following language file: language/<your_lang>/date_lang.php</p>
<h2>days_in_month()</h2>
<p>Returns the number of days in a given month/year. Takes leap years into account. Example:</p>
<code>echo days_in_month(06, 2005);</code>
<p>If the second parameter is empty, the current year will be used.</p>
<h2>timezones()</h2>
<p> Takes a timezone reference (for a list of valid timezones, see the "Timezone Reference" below) and returns the number of hours offset from UTC.</p>
<p><code>echo timezones('UM5');</code></p>
<p>This function is useful when used with timezone_menu(). </p>
<h2>timezone_menu()</h2>
<p>Generates a pull-down menu of timezones, like this one:</p>
<form action="#">
<select name="timezones">
<option value='UM12'>(UTC - 12:00) Enitwetok, Kwajalien</option>
<option value='UM11'>(UTC - 11:00) Nome, Midway Island, Samoa</option>
<option value='UM10'>(UTC - 10:00) Hawaii</option>
<option value='UM9'>(UTC - 9:00) Alaska</option>
<option value='UM8'>(UTC - 8:00) Pacific Time</option>
<option value='UM7'>(UTC - 7:00) Mountain Time</option>
<option value='UM6'>(UTC - 6:00) Central Time, Mexico City</option>
<option value='UM5'>(UTC - 5:00) Eastern Time, Bogota, Lima, Quito</option>
<option value='UM4'>(UTC - 4:00) Atlantic Time, Caracas, La Paz</option>
<option value='UM25'>(UTC - 3:30) Newfoundland</option>
<option value='UM3'>(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.</option>
<option value='UM2'>(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena</option>
<option value='UM1'>(UTC - 1:00) Azores, Cape Verde Islands</option>
<option value='UTC' selected='selected'>(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia</option>
<option value='UP1'>(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome</option>
<option value='UP2'>(UTC + 2:00) Kaliningrad, South Africa, Warsaw</option>
<option value='UP3'>(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi</option>
<option value='UP25'>(UTC + 3:30) Tehran</option>
<option value='UP4'>(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi</option>
<option value='UP35'>(UTC + 4:30) Kabul</option>
<option value='UP5'>(UTC + 5:00) Islamabad, Karachi, Tashkent</option>
<option value='UP45'>(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi</option>
<option value='UP6'>(UTC + 6:00) Almaty, Colomba, Dhaka</option>
<option value='UP7'>(UTC + 7:00) Bangkok, Hanoi, Jakarta</option>
<option value='UP8'>(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei</option>
<option value='UP9'>(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk</option>
<option value='UP85'>(UTC + 9:30) Adelaide, Darwin</option>
<option value='UP10'>(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok</option>
<option value='UP11'>(UTC + 11:00) Magadan, New Caledonia, Solomon Islands</option>
<option value='UP12'>(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island</option>
</select>
</form>
<p>This menu is useful if you run a membership site in which your users are allowed to set their local timezone value.</p>
<p>The first parameter lets you set the "selected" state of the menu. For example, to set Pacific time as the default you will do this:</p>
<code>echo timezone_menu('UM8');</code>
<p>Please see the timezone reference below to see the values of this menu.</p>
<p>The second parameter lets you set a CSS class name for the menu.</p>
<p class="important"><strong>Note:</strong> The text contained in the menu is found in the following language file: language/<your_lang>/date_lang.php</p>
<h2>Timezone Reference</h2>
<p>The following table indicates each timezone and its location.</p>
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
<tr>
<th>Time Zone</th>
<th>Location</th>
</tr><tr>
<td class="td">UM12</td><td class="td">(UTC - 12:00) Enitwetok, Kwajalien</td>
</tr><tr>
<td class="td">UM11</td><td class="td">(UTC - 11:00) Nome, Midway Island, Samoa</td>
</tr><tr>
<td class="td">UM10</td><td class="td">(UTC - 10:00) Hawaii</td>
</tr><tr>
<td class="td">UM9</td><td class="td">(UTC - 9:00) Alaska</td>
</tr><tr>
<td class="td">UM8</td><td class="td">(UTC - 8:00) Pacific Time</td>
</tr><tr>
<td class="td">UM7</td><td class="td">(UTC - 7:00) Mountain Time</td>
</tr><tr>
<td class="td">UM6</td><td class="td">(UTC - 6:00) Central Time, Mexico City</td>
</tr><tr>
<td class="td">UM5</td><td class="td">(UTC - 5:00) Eastern Time, Bogota, Lima, Quito</td>
</tr><tr>
<td class="td">UM4</td><td class="td">(UTC - 4:00) Atlantic Time, Caracas, La Paz</td>
</tr><tr>
<td class="td">UM25</td><td class="td">(UTC - 3:30) Newfoundland</td>
</tr><tr>
<td class="td">UM3</td><td class="td">(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.</td>
</tr><tr>
<td class="td">UM2</td><td class="td">(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena</td>
</tr><tr>
<td class="td">UM1</td><td class="td">(UTC - 1:00) Azores, Cape Verde Islands</td>
</tr><tr>
<td class="td">UTC</td><td class="td">(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia</td>
</tr><tr>
<td class="td">UP1</td><td class="td">(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome</td>
</tr><tr>
<td class="td">UP2</td><td class="td">(UTC + 2:00) Kaliningrad, South Africa, Warsaw</td>
</tr><tr>
<td class="td">UP3</td><td class="td">(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi</td>
</tr><tr>
<td class="td">UP25</td><td class="td">(UTC + 3:30) Tehran</td>
</tr><tr>
<td class="td">UP4</td><td class="td">(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi</td>
</tr><tr>
<td class="td">UP35</td><td class="td">(UTC + 4:30) Kabul</td>
</tr><tr>
<td class="td">UP5</td><td class="td">(UTC + 5:00) Islamabad, Karachi, Tashkent</td>
</tr><tr>
<td class="td">UP45</td><td class="td">(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi</td>
</tr><tr>
<td class="td">UP6</td><td class="td">(UTC + 6:00) Almaty, Colomba, Dhaka</td>
</tr><tr>
<td class="td">UP7</td><td class="td">(UTC + 7:00) Bangkok, Hanoi, Jakarta</td>
</tr><tr>
<td class="td">UP8</td><td class="td">(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei</td>
</tr><tr>
<td class="td">UP9</td><td class="td">(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk</td>
</tr><tr>
<td class="td">UP85</td><td class="td">(UTC + 9:30) Adelaide, Darwin</td>
</tr><tr>
<td class="td">UP10</td><td class="td">(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok</td>
</tr><tr>
<td class="td">UP11</td><td class="td">(UTC + 11:00) Magadan, New Caledonia, Solomon Islands</td>
</tr><tr>
<td class="td">UP12</td><td class="td">(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island</td>
</tr>
</table>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="cookie_helper.html">Cookie Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="directory_helper.html">Directory Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/date_helper.html | HTML | mit | 15,244 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Path Helper : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Path Helper
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Path Helper</h1>
<p>The Path Helper file contains functions that permits you to work with file paths on the server.</p>
<h2>Loading this Helper</h2>
<p>This helper is loaded using the following code:</p>
<code>$this->load->helper('path');</code>
<p>The following functions are available:</p>
<h2>set_realpath()</h2>
<p>Checks to see if the path exists. This function will return a server path without symbolic links or relative directory structures. An optional second argument will cause an error to be triggered if the path cannot be resolved.</p>
<code>$directory = '/etc/passwd';<br />
echo set_realpath($directory);<br />
// returns "/etc/passwd"<br />
<br />
$non_existent_directory = '/path/to/nowhere';<br />
echo set_realpath($non_existent_directory, TRUE);<br />
// returns an <strong>error</strong>, as the path could not be resolved
<br /><br />
echo set_realpath($non_existent_directory, FALSE);<br />
// returns "/path/to/nowhere"
</code>
<h2> </h2>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="number_helper.html">Number Helper</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="security_helper.html">Security Helper</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/helpers/path_helper.html | HTML | mit | 4,037 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Connecting to your Database : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
<a href="index.html">Database Library</a> ›
Connecting
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Connecting to your Database</h1>
<p>There are two ways to connect to a database:</p>
<h2>Automatically Connecting</h2>
<p>The "auto connect" feature will load and instantiate the database class with every page load.
To enable "auto connecting", add the word <var>database</var> to the library array, as indicated in the following file:</p>
<p><kbd>application/config/autoload.php</kbd></p>
<h2>Manually Connecting</h2>
<p>If only some of your pages require database connectivity you can manually connect to your database by adding this
line of code in any function where it is needed, or in your class constructor to make the database
available globally in that class.</p>
<code>$this->load->database();</code>
<p class="important">If the above function does <strong>not</strong> contain any information in the first parameter it will connect
to the group specified in your database config file. For most people, this is the preferred method of use.</p>
<h3>Available Parameters</h3>
<ol>
<li>The database connection values, passed either as an array or a DSN string.</li>
<li>TRUE/FALSE (boolean). Whether to return the connection ID (see Connecting to Multiple Databases below).</li>
<li>TRUE/FALSE (boolean). Whether to enable the Active Record class. Set to TRUE by default.</li>
</ol>
<h3>Manually Connecting to a Database</h3>
<p>The first parameter of this function can <strong>optionally</strong> be used to specify a particular database group
from your config file, or you can even submit connection values for a database that is not specified in your config file.
Examples:</p>
<p>To choose a specific group from your config file you can do this:</p>
<code>$this->load->database('<samp>group_name</samp>');</code>
<p>Where <samp>group_name</samp> is the name of the connection group from your config file.</p>
<p>To connect manually to a desired database you can pass an array of values:</p>
<code>$config['hostname'] = "localhost";<br />
$config['username'] = "myusername";<br />
$config['password'] = "mypassword";<br />
$config['database'] = "mydatabase";<br />
$config['dbdriver'] = "mysql";<br />
$config['dbprefix'] = "";<br />
$config['pconnect'] = FALSE;<br />
$config['db_debug'] = TRUE;<br />
$config['cache_on'] = FALSE;<br />
$config['cachedir'] = "";<br />
$config['char_set'] = "utf8";<br />
$config['dbcollat'] = "utf8_general_ci";<br />
<br />
$this->load->database(<samp>$config</samp>);</code>
<p>For information on each of these values please see the <a href="configuration.html">configuration page</a>.</p>
<p>Or you can submit your database values as a Data Source Name. DSNs must have this prototype:</p>
<code>$dsn = 'dbdriver://username:password@hostname/database';<br />
<br />
$this->load->database(<samp>$dsn</samp>);</code>
<p>To override default config values when connecting with a DSN string, add the config variables as a query string.</p>
<code>$dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=/path/to/cache';<br />
<br />
$this->load->database(<samp>$dsn</samp>);</code>
<h2>Connecting to Multiple Databases</h2>
<p>If you need to connect to more than one database simultaneously you can do so as follows:</p>
<code>$DB1 = $this->load->database('group_one', TRUE);<br />
$DB2 = $this->load->database('group_two', TRUE);
</code>
<p>Note: Change the words "group_one" and "group_two" to the specific group names you are connecting to (or
you can pass the connection values as indicated above).</p>
<p>By setting the second parameter to TRUE (boolean) the function will return the database object.</p>
<div class="important">
<p>When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide. In other words, rather than issuing commands with:</p>
<p>$this->db->query();<br />$this->db->result();<br /> etc...</p>
<p>You will instead use:</p>
<p>$DB1->query();<br />$DB1->result();<br /> etc...</p>
</div>
<h2>Reconnecting / Keeping the Connection Alive</h2>
<p>If the database server's idle timeout is exceeded while you're doing some heavy PHP lifting (processing an image, for instance), you should consider pinging the server by using the <dfn>reconnect()</dfn> method before sending further queries, which can gracefully keep the connection alive or re-establish it.</p>
<code>$this->db->reconnect();</code>
<h2>Manually closing the Connection</h2>
<p>While CodeIgniter intelligently takes care of closing your database connections, you can explicitly close the connection.</p>
<code>$this->db->close();</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="configuration.html">Database Configuration</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="queries.html">Queries</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/database/connecting.html | HTML | mit | 7,756 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Database Class : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
Database Library
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>The Database Class</h1>
<p>CodeIgniter comes with a full-featured and very fast abstracted database class that supports both traditional
structures and Active Record patterns. The database functions offer clear, simple syntax.</p>
<ul>
<li><a href="examples.html">Quick Start: Usage Examples</a></li>
<li><a href="configuration.html">Database Configuration</a></li>
<li><a href="connecting.html">Connecting to a Database</a></li>
<li><a href="queries.html">Running Queries</a></li>
<li><a href="results.html">Generating Query Results</a></li>
<li><a href="helpers.html">Query Helper Functions</a></li>
<li><a href="active_record.html">Active Record Class</a></li>
<li><a href="transactions.html">Transactions</a></li>
<li><a href="table_data.html">Table MetaData</a></li>
<li><a href="fields.html">Field MetaData</a></li>
<li><a href="call_function.html">Custom Function Calls</a></li>
<li><a href="caching.html">Query Caching</a></li>
<li><a href="forge.html">Database manipulation with Database Forge</a></li>
<li><a href="utilities.html">Database Utilities Class</a></li>
</ul>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="../libraries/caching.html">Caching Class</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="examples.html">Quick Start: Usage Examples</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/database/index.html | HTML | mit | 4,178 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Database Quick Start : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
<a href="index.html">Database Library</a> ›
Database Example Code
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Database Quick Start: Example Code</h1>
<p>The following page contains example code showing how the database class is used. For complete details please
read the individual pages describing each function.</p>
<h2>Initializing the Database Class</h2>
<p>The following code loads and initializes the database class based on your <a href="configuration.html">configuration</a> settings:</p>
<code>$this->load->database();</code>
<p>Once loaded the class is ready to be used as described below.</p>
<p>Note: If all your pages require database access you can connect automatically. See the <a href="connecting.html">connecting</a> page for details.</p>
<h2>Standard Query With Multiple Results (Object Version)</h2>
<code>$query = $this->db->query('SELECT name, title, email FROM my_table');<br />
<br />
foreach ($query->result() as $row)<br />
{<br />
echo $row->title;<br />
echo $row->name;<br />
echo $row->email;<br />
}<br />
<br />
echo 'Total Results: ' . $query->num_rows();
</code>
<p>The above <dfn>result()</dfn> function returns an array of <strong>objects</strong>. Example: $row->title</p>
<h2>Standard Query With Multiple Results (Array Version)</h2>
<code>$query = $this->db->query('SELECT name, title, email FROM my_table');<br />
<br />
foreach ($query->result_array() as $row)<br />
{<br />
echo $row['title'];<br />
echo $row['name'];<br />
echo $row['email'];<br />
}</code>
<p>The above <dfn>result_array()</dfn> function returns an array of standard array indexes. Example: $row['title']</p>
<h2>Testing for Results</h2>
<p>If you run queries that might <strong>not</strong> produce a result, you are encouraged to test for a result first
using the <dfn>num_rows()</dfn> function:</p>
<code>
$query = $this->db->query("YOUR QUERY");<br />
<br />
if ($query->num_rows() > 0)<br />
{<br />
foreach ($query->result() as $row)<br />
{<br />
echo $row->title;<br />
echo $row->name;<br />
echo $row->body;<br />
}<br />
}
</code>
<h2>Standard Query With Single Result</h2>
<code>$query = $this->db->query('SELECT name FROM my_table LIMIT 1');<br />
<br />
$row = $query->row();<br />
echo $row->name;<br />
</code>
<p>The above <dfn>row()</dfn> function returns an <strong>object</strong>. Example: $row->name</p>
<h2>Standard Query With Single Result (Array version)</h2>
<code>$query = $this->db->query('SELECT name FROM my_table LIMIT 1');<br />
<br />
$row = $query->row_array();<br />
echo $row['name'];<br />
</code>
<p>The above <dfn>row_array()</dfn> function returns an <strong>array</strong>. Example: $row['name']</p>
<h2>Standard Insert</h2>
<code>
$sql = "INSERT INTO mytable (title, name) <br />
VALUES (".$this->db->escape($title).", ".$this->db->escape($name).")";<br />
<br />
$this->db->query($sql);<br />
<br />
echo $this->db->affected_rows();
</code>
<h2>Active Record Query</h2>
<p>The <a href="active_record.html">Active Record Pattern</a> gives you a simplified means of retrieving data:</p>
<code>
$query = $this->db->get('table_name');<br />
<br />
foreach ($query->result() as $row)<br />
{<br />
echo $row->title;<br />
}</code>
<p>The above <dfn>get()</dfn> function retrieves all the results from the supplied table.
The <a href="active_record.html">Active Record</a> class contains a full compliment of functions
for working with data.</p>
<h2>Active Record Insert</h2>
<code>
$data = array(<br />
'title' => $title,<br />
'name' => $name,<br />
'date' => $date<br />
);<br />
<br />
$this->db->insert('mytable', $data);
<br /><br />
// Produces: INSERT INTO mytable (title, name, date) VALUES ('{$title}', '{$name}', '{$date}')</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="index.html">Database Class</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="configuration.html">Database Configuration</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/database/examples.html | HTML | mit | 7,475 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Database Caching Class : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
<a href="index.html">Database Library</a> ›
Database Caching Class
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Database Caching Class</h1>
<p>The Database Caching Class permits you to cache your queries as text files for reduced database load.</p>
<p class="important"><strong>Important:</strong> This class is initialized automatically by the database driver
when caching is enabled. Do NOT load this class manually.<br /><br />
<strong>Also note:</strong> Not all query result functions are available when you use caching. Please read this page carefully.</p>
<h2>Enabling Caching</h2>
<p>Caching is enabled in three steps:</p>
<ul>
<li>Create a writable directory on your server where the cache files can be stored.</li>
<li>Set the path to your cache folder in your <dfn>application/config/database.php</dfn> file.</li>
<li>Enable the caching feature, either globally by setting the preference in your <dfn>application/config/database.php</dfn> file, or manually as described below.</li>
</ul>
<p>Once enabled, caching will happen automatically whenever a page is loaded that contains database queries.</p>
<h2>How Does Caching Work?</h2>
<p>CodeIgniter's query caching system happens dynamically when your pages are viewed.
When caching is enabled, the first time a web page is loaded, the query result object will
be serialized and stored in a text file on your server. The next time the page is loaded the cache file will be used instead of
accessing your database. Your database usage can effectively be reduced to zero for any pages that have been cached.</p>
<p>Only <dfn>read-type</dfn> (SELECT) queries can be cached, since these are the only type of queries that produce a result.
<dfn>Write-type</dfn> (INSERT, UPDATE, etc.) queries, since they don't generate a result, will not be cached by the system.</p>
<p>Cache files DO NOT expire. Any queries that have been cached will remain cached until you delete them. The caching system
permits you clear caches associated with individual pages, or you can delete the entire collection of cache files.
Typically you'll want to use the housekeeping functions described below to delete cache files after certain
events take place, like when you've added new information to your database.</p>
<h2>Will Caching Improve Your Site's Performance?</h2>
<p>Getting a performance gain as a result of caching depends on many factors.
If you have a highly optimized database under very little load, you probably won't see a performance boost.
If your database is under heavy use you probably will see an improved response, assuming your file-system is not
overly taxed. Remember that caching simply changes how your information is retrieved, shifting it from being a database
operation to a file-system one.</p>
<p>In some clustered server environments, for example, caching may be detrimental since file-system operations are so intense.
On single servers in shared environments, caching will probably be beneficial. Unfortunately there is no
single answer to the question of whether you should cache your database. It really depends on your situation.</p>
<h2>How are Cache Files Stored?</h2>
<p>CodeIgniter places the result of EACH query into its own cache file. Sets of cache files are further organized into
sub-folders corresponding to your controller functions. To be precise, the sub-folders are named identically to the
first two segments of your URI (the controller class name and function name).</p>
<p>For example, let's say you have a controller called <dfn>blog</dfn> with a function called <dfn>comments</dfn> that
contains three queries. The caching system will create a cache folder
called <kbd>blog+comments</kbd>, into which it will write three cache files.</p>
<p>If you use dynamic queries that change based on information in your URI (when using pagination, for example), each instance of
the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have
queries.</p>
<h2>Managing your Cache Files</h2>
<p>Since cache files do not expire, you'll need to build deletion routines into your application. For example, let's say you have a blog
that allows user commenting. Whenever a new comment is submitted you'll want to delete the cache files associated with the
controller function that serves up your comments. You'll find two delete functions described below that help you
clear data.</p>
<h2>Not All Database Functions Work with Caching</h2>
<p>Lastly, we need to point out that the result object that is cached is a simplified version of the full result object. For that reason,
some of the query result functions are not available for use.</p>
<p>The following functions <kbd>ARE NOT</kbd> available when using a cached result object:</p>
<ul>
<li>num_fields()</li>
<li>field_names()</li>
<li>field_data()</li>
<li>free_result()</li>
</ul>
<p>Also, the two database resources (result_id and conn_id) are not available when caching, since result resources only
pertain to run-time operations.</p>
<br />
<h1>Function Reference</h1>
<h2>$this->db->cache_on() / $this->db->cache_off()</h2>
<p>Manually enables/disables caching. This can be useful if you want to
keep certain queries from being cached. Example:</p>
<code>
// Turn caching on<br />
$this->db->cache_on();<br />
$query = $this->db->query("SELECT * FROM mytable");<br />
<br />
// Turn caching off for this one query<br />
$this->db->cache_off();<br />
$query = $this->db->query("SELECT * FROM members WHERE member_id = '$current_user'");<br />
<br />
// Turn caching back on<br />
$this->db->cache_on();<br />
$query = $this->db->query("SELECT * FROM another_table");
</code>
<h2>$this->db->cache_delete()</h2>
<p>Deletes the cache files associated with a particular page. This is useful if you need to clear caching after you update your database.</p>
<p>The caching system saves your cache files to folders that correspond to the URI of the page you are viewing. For example, if you are viewing
a page at <dfn>example.com/index.php/blog/comments</dfn>, the caching system will put all cache files associated with it in a folder
called <dfn>blog+comments</dfn>. To delete those particular cache files you will use:</p>
<code>$this->db->cache_delete('blog', 'comments');</code>
<p>If you do not use any parameters the current URI will be used when determining what should be cleared.</p>
<h2>$this->db->cache_delete_all()</h2>
<p>Clears all existing cache files. Example:</p>
<code>$this->db->cache_delete_all();</code>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="call_function.html">Custom Function Calls</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="forge.html">Database manipulation with Database Forge</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/database/caching.html | HTML | mit | 9,651 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Database Configuration : CodeIgniter User Guide</title>
<style type='text/css' media='all'>@import url('../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="../nav/nav.js"></script>
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
<script type="text/javascript" src="../nav/moo.fx.js"></script>
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='author' content='ExpressionEngine Dev Team' />
<meta name='description' content='CodeIgniter User Guide' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
<a href="../index.html">User Guide Home</a> ›
<a href="index.html">Database Library</a> ›
Configuration
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Database Configuration</h1>
<p>CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.).
The config file is located at <samp>application/config/database.php</samp>. You can also set database connection values for specific <a href="../libraries/config.html">environments</a> by placing <strong>database.php</strong> it the respective environment config folder.</p>
<p>The config settings are stored in a multi-dimensional array with this prototype:</p>
<code>$db['default']['hostname'] = "localhost";<br />
$db['default']['username'] = "root";<br />
$db['default']['password'] = "";<br />
$db['default']['database'] = "database_name";<br />
$db['default']['dbdriver'] = "mysql";<br />
$db['default']['dbprefix'] = "";<br />
$db['default']['pconnect'] = TRUE;<br />
$db['default']['db_debug'] = FALSE;<br />
$db['default']['cache_on'] = FALSE;<br />
$db['default']['cachedir'] = "";<br />
$db['default']['char_set'] = "utf8";<br />
$db['default']['dbcollat'] = "utf8_general_ci";<br />
$db['default']['swap_pre'] = "";<br />
$db['default']['autoinit'] = TRUE;<br />
$db['default']['stricton'] = FALSE;</code>
<p>The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store
multiple sets of connection values. If, for example, you run multiple environments (development, production, test, etc.)
under a single installation, you can set up a connection group for each, then switch between groups as needed.
For example, to set up a "test" environment you would do this:</p>
<code>$db['test']['hostname'] = "localhost";<br />
$db['test']['username'] = "root";<br />
$db['test']['password'] = "";<br />
$db['test']['database'] = "database_name";<br />
$db['test']['dbdriver'] = "mysql";<br />
$db['test']['dbprefix'] = "";<br />
$db['test']['pconnect'] = TRUE;<br />
$db['test']['db_debug'] = FALSE;<br />
$db['test']['cache_on'] = FALSE;<br />
$db['test']['cachedir'] = "";<br />
$db['test']['char_set'] = "utf8";<br />
$db['test']['dbcollat'] = "utf8_general_ci";<br />
$db['test']['swap_pre'] = "";<br />
$db['test']['autoinit'] = TRUE;<br />
$db['test']['stricton'] = FALSE;</code>
<p>Then, to globally tell the system to use that group you would set this variable located in the config file:</p>
<code>$active_group = "test";</code>
<p>Note: The name "test" is arbitrary. It can be anything you want. By default we've used the word "default"
for the primary connection, but it too can be renamed to something more relevant to your project.</p>
<h3>Active Record</h3>
<p>The <a href="active_record.html">Active Record Class</a> is globally enabled or disabled by setting the $active_record variable in the database configuration file to TRUE/FALSE (boolean). If you are not using the active record class, setting it to FALSE will utilize fewer resources when the database classes are initialized.</p>
<code>$active_record = TRUE;</code>
<p class="important"><strong>Note:</strong> that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.</p>
<h3>Explanation of Values:</h3>
<ul>
<li><strong>hostname</strong> - The hostname of your database server. Often this is "localhost".</li>
<li><strong>username</strong> - The username used to connect to the database.</li>
<li><strong>password</strong> - The password used to connect to the database.</li>
<li><strong>database</strong> - The name of the database you want to connect to.</li>
<li><strong>dbdriver</strong> - The database type. ie: mysql, postgres, odbc, etc. Must be specified in lower case.</li>
<li><strong>dbprefix</strong> - An optional table prefix which will added to the table name when running <a href="active_record.html">Active Record</a> queries. This permits multiple CodeIgniter installations to share one database.</li>
<li><strong>pconnect</strong> - TRUE/FALSE (boolean) - Whether to use a persistent connection.</li>
<li><strong>db_debug</strong> - TRUE/FALSE (boolean) - Whether database errors should be displayed.</li>
<li><strong>cache_on</strong> - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also <a href="caching.html">Database Caching Class</a>.</li>
<li><strong>cachedir</strong> - The absolute server path to your database query cache directory.</li>
<li><strong>char_set</strong> - The character set used in communicating with the database.</li>
<li><strong>dbcollat</strong> - The character collation used in communicating with the database. <p class="important"><strong>Note:</strong> For MySQL and MySQLi databases, this setting is only used as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 (and in table creation queries made with DB Forge). There is an incompatibility in PHP with mysql_real_escape_string() which can make your site vulnerable to SQL injection if you are using a multi-byte character set and are running versions lower than these. Sites using Latin-1 or UTF-8 database character set and collation are unaffected.</p></li>
<li><strong>swap_pre</strong> - A default table prefix that should be swapped with <var>dbprefix</var>. This is useful for distributed applications where you might run manually written queries, and need the prefix to still be customizable by the end user.</li>
<li><strong>autoinit</strong> - Whether or not to automatically connect to the database when the library loads. If set to false, the connection will take place prior to executing the first query.</li>
<li><strong>stricton</strong> - TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application.</li>
<li><strong>port</strong> - The database port number. To use this value you have to add a line to the database config array.<code>$db['default']['port'] = 5432;</code>
</ul>
<p class="important"><strong>Note:</strong> Depending on what database platform you are using (MySQL, Postgres, etc.)
not all values will be needed. For example, when using SQLite you will not need to supply a username or password, and
the database name will be the path to your database file. The information above assumes you are using MySQL.</p>
</div>
<!-- END CONTENT -->
<div id="footer">
<p>
Previous Topic: <a href="examples.html">Quick Start: Usage Examples</a>
·
<a href="#top">Top of Page</a> ·
<a href="../index.html">User Guide Home</a> ·
Next Topic: <a href="connecting.html">Connecting to your Database</a>
</p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p>
</div>
</body>
</html> | 069h-course-management | trunk/ci/user_guide/database/configuration.html | HTML | mit | 9,379 |