summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-08 09:21:12 +0200
committeradmin <devnull@localhost>2006-10-08 09:21:12 +0200
commit10c3f41cbe5bd3bb66fd106cc9fb171ffcc7364b (patch)
tree7477d21d33dd07221425685756561c3bbd386217 /system/libraries
parent86d4e993d9ea21f28124b80f3d0c161aea681cb6 (diff)
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Calendar.php11
-rw-r--r--system/libraries/Encrypt.php32
-rw-r--r--system/libraries/Image_lib.php1
-rw-r--r--system/libraries/Input.php64
-rw-r--r--system/libraries/Loader.php45
-rw-r--r--system/libraries/Log.php3
-rw-r--r--system/libraries/Pagination.php21
-rw-r--r--system/libraries/Router.php4
-rw-r--r--system/libraries/Unit.php2
-rw-r--r--system/libraries/Upload.php30
-rw-r--r--system/libraries/Validation.php14
-rw-r--r--system/libraries/Zip.php3
12 files changed, 142 insertions, 88 deletions
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 3cbbbfe6d..23a6bf791 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -48,6 +48,7 @@ class CI_Calendar {
function CI_Calendar()
{
$this->CI =& get_instance();
+
if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
{
$this->CI->lang->load('calendar');
@@ -56,7 +57,6 @@ class CI_Calendar {
$this->local_time = time();
log_message('debug', "Calendar Class Initialized");
}
- // END CI_Calendar()
// --------------------------------------------------------------------
@@ -79,7 +79,6 @@ class CI_Calendar {
}
}
}
- // END initialize()
// --------------------------------------------------------------------
@@ -241,7 +240,6 @@ class CI_Calendar {
return $out;
}
- // END generate()
// --------------------------------------------------------------------
@@ -275,7 +273,6 @@ class CI_Calendar {
return $this->CI->lang->line($month);
}
- // END get_month_name()
// --------------------------------------------------------------------
@@ -315,7 +312,6 @@ class CI_Calendar {
return $days;
}
- // END get_day_names()
// --------------------------------------------------------------------
@@ -357,7 +353,6 @@ class CI_Calendar {
return $date;
}
- // END adjust_date()
// --------------------------------------------------------------------
@@ -378,6 +373,7 @@ class CI_Calendar {
return 0;
}
+ // Is the year a leap year?
if ($month == 2)
{
if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
@@ -388,7 +384,6 @@ class CI_Calendar {
return $days_in_month[$month - 1];
}
- // END get_total_days()
// --------------------------------------------------------------------
@@ -426,7 +421,6 @@ class CI_Calendar {
'table_close' => '</table>'
);
}
- // END default_template()
// --------------------------------------------------------------------
@@ -465,7 +459,6 @@ class CI_Calendar {
}
}
}
- // END parse_template()
}
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 2a1de6f37..50b3fab39 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -27,6 +27,7 @@
* @link http://www.codeigniter.com/user_guide/libraries/encryption.html
*/
class CI_Encrypt {
+
var $encryption_key = '';
var $_hash_type = 'sha1';
var $_mcrypt_exists = FALSE;
@@ -246,10 +247,9 @@ class CI_Encrypt {
*/
function mcrypt_encode($data, $key)
{
- $this->_get_mcrypt();
- $init_size = mcrypt_get_iv_size($this->_mcrypt_cipher, $this->_mcrypt_mode);
+ $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
- return mcrypt_encrypt($this->_mcrypt_cipher, $key, $data, $this->_mcrypt_mode, $init_vect);
+ return mcrypt_encrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect);
}
// --------------------------------------------------------------------
@@ -264,10 +264,9 @@ class CI_Encrypt {
*/
function mcrypt_decode($data, $key)
{
- $this->_get_mcrypt();
- $init_size = mcrypt_get_iv_size($this->_mcrypt_cipher, $this->_mcrypt_mode);
+ $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
- return rtrim(mcrypt_decrypt($this->_mcrypt_cipher, $key, $data, $this->_mcrypt_mode, $init_vect), "\0");
+ return rtrim(mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
}
// --------------------------------------------------------------------
@@ -301,22 +300,37 @@ class CI_Encrypt {
// --------------------------------------------------------------------
/**
- * Get Mcrypt value
+ * Get Mcrypt Cypher Value
*
* @access private
- * @param string
* @return string
*/
- function _get_mcrypt()
+ function _get_cypher()
{
if ($this->_mcrypt_cipher == '')
{
$this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
}
+
+ return $this->_mcrypt_cipher;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mcrypt MOde Value
+ *
+ * @access private
+ * @return string
+ */
+ function _get_mode()
+ {
if ($this->_mcrypt_mode == '')
{
$this->_mcrypt_mode = MCRYPT_MODE_ECB;
}
+
+ return $this->_mcrypt_mode;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 79b2f9c1c..16583c063 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -148,6 +148,7 @@ class CI_Image_lib {
$this->set_error('imglib_source_image_required');
return FALSE;
}
+
/*
* Is getimagesize() Available?
*
diff --git a/system/libraries/Input.php b/system/libraries/Input.php
index 98c2cbd55..0d3c87b49 100644
--- a/system/libraries/Input.php
+++ b/system/libraries/Input.php
@@ -179,6 +179,7 @@ class CI_Input {
*
* @access public
* @param string
+ * @param bool
* @return string
*/
function post($index = '', $xss_clean = FALSE)
@@ -213,6 +214,7 @@ class CI_Input {
*
* @access public
* @param string
+ * @param bool
* @return string
*/
function cookie($index = '', $xss_clean = FALSE)
@@ -244,6 +246,31 @@ class CI_Input {
return $_COOKIE[$index];
}
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the SERVER array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function server($index = '', $xss_clean = FALSE)
+ {
+ if ( ! isset($_SERVER[$index]))
+ {
+ return FALSE;
+ }
+
+ if ($xss_clean === TRUE)
+ {
+ return $this->xss_clean($_SERVER[$index]);
+ }
+
+ return $_SERVER[$index];
+ }
// --------------------------------------------------------------------
@@ -259,15 +286,28 @@ class CI_Input {
{
return $this->ip_address;
}
-
- $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
- $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
- $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
-
- if ($cip && $rip) $this->ip_address = $cip;
- elseif ($rip) $this->ip_address = $rip;
- elseif ($cip) $this->ip_address = $cip;
- elseif ($fip) $this->ip_address = $fip;
+
+ if ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
+ {
+ $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
+ }
+ elseif ($this->server('REMOTE_ADDR'))
+ {
+ $this->ip_address = $_SERVER['REMOTE_ADDR'];
+ }
+ elseif ($this->server('HTTP_CLIENT_IP'))
+ {
+ $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
+ }
+ elseif ($this->server('HTTP_X_FORWARDED_FOR'))
+ {
+ $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
+ }
+
+ if ($this->ip_address === FALSE)
+ {
+ return $this->ip_address = '0.0.0.0';
+ }
if (strstr($this->ip_address, ','))
{
@@ -279,11 +319,7 @@ class CI_Input {
{
$this->ip_address = '0.0.0.0';
}
-
- unset($cip);
- unset($rip);
- unset($fip);
-
+
return $this->ip_address;
}
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 90dc0f140..05ee93959 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -611,16 +611,7 @@ class CI_Loader {
if (substr($class, 0, 3) == 'my_')
{
$class = preg_replace("/my_(.+)/", "\\1", $class);
- $extend = TRUE;
- }
- else
- {
- $extend = FALSE;
- }
-
- // Are we extending one of the base classes?
- if ($extend == TRUE)
- {
+
// Load the requested library from the main system/libraries folder
if (file_exists(BASEPATH.'libraries/'.ucfirst($class).EXT))
{
@@ -638,22 +629,20 @@ class CI_Loader {
return $this->_ci_init_class($filename, 'MY_', $params);
}
- else
- {
- // Lets search for the requested library file and load it.
- // For backward compatibility we'll test for filenames that are
- // both uppercase and lower.
- foreach (array(ucfirst($class), $class) as $filename)
+
+ // Lets search for the requested library file and load it.
+ // For backward compatibility we'll test for filenames that are
+ // both uppercase and lower.
+ foreach (array(ucfirst($class), $class) as $filename)
+ {
+ for ($i = 1; $i < 3; $i++)
{
- for ($i = 1; $i < 3; $i++)
+ $path = ($i % 2) ? APPPATH : BASEPATH;
+
+ if (file_exists($path.'libraries/'.$filename.EXT))
{
- $path = ($i % 2) ? APPPATH : BASEPATH;
-
- if (file_exists($path.'libraries/'.$filename.EXT))
- {
- include_once($path.'libraries/'.$filename.EXT);
- return $this->_ci_init_class($filename, '', $params);
- }
+ include_once($path.'libraries/'.$filename.EXT);
+ return $this->_ci_init_class($filename, '', $params);
}
}
}
@@ -686,7 +675,7 @@ class CI_Loader {
if ($prefix == '')
{
- $name = ( ! class_exists($class)) ? 'CI_'.$class : $class;
+ $name = (class_exists('CI_'.$class)) ? 'CI_'.$class : $class;
}
else
{
@@ -756,24 +745,28 @@ class CI_Loader {
// 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 the model class.
if (in_array('model', $autoload['libraries']))
{
$this->model();
$autoload['libraries'] = array_diff($autoload['libraries'], array('model'));
}
-
+
+ // Load scaffolding
if (in_array('scaffolding', $autoload['libraries']))
{
$this->scaffolding();
$autoload['libraries'] = array_diff($autoload['libraries'], array('scaffolding'));
}
+ // Load all other libraries
foreach ($autoload['libraries'] as $item)
{
$this->library($item);
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 392742584..eff7cb7fc 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -61,7 +61,6 @@ class CI_Log {
$this->_date_fmt = $config['log_date_format'];
}
}
- // END CI_Log()
// --------------------------------------------------------------------
@@ -113,7 +112,7 @@ class CI_Log {
@chmod($filepath, 0666);
return TRUE;
}
- // END write_log()
+
}
// END Log Class
?> \ No newline at end of file
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index efbe6c27f..b29571eee 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -105,16 +105,21 @@ class CI_Pagination {
{
return '';
}
-
+
// Calculate the total number of pages
- $num_pages = intval($this->total_rows / $this->per_page);
+ $num_pages = ceil($this->total_rows / $this->per_page);
+
+ /*
+ // Calculate the total number of pages
+ $num_pages = intval($this->total_rows / $this->per_page);
+
+ // Use modulus to see if our division has a remainder. If so, add one to our page number.
+ if ($this->total_rows % $this->per_page)
+ {
+ $num_pages++;
+ }
+ */
- // Use modulus to see if our division has a remainder.If so, add one to our page number.
- if ($this->total_rows % $this->per_page)
- {
- $num_pages++;
- }
-
// Is there only one page? Hm... nothing more to do here then.
if ($num_pages == 1)
{
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 7a4fd3899..27e3c27cc 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -66,7 +66,6 @@ class CI_Router {
*/
function _set_route_mapping()
{
-
// Are query strings enabled in the config file?
// If so, we're done since segment based URIs are not used with query strings.
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
@@ -120,8 +119,7 @@ class CI_Router {
{
$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.
foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
diff --git a/system/libraries/Unit.php b/system/libraries/Unit.php
index 6573f4269..439424fbb 100644
--- a/system/libraries/Unit.php
+++ b/system/libraries/Unit.php
@@ -55,7 +55,7 @@ class CI_Unit {
function run($test, $expected = TRUE, $test_name = 'undefined')
{
if ($this->active == FALSE)
- return;
+ return FALSE;
if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
{
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 13fa8acdf..5bb506cdb 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -248,20 +248,20 @@ class CI_Upload {
function data()
{
return array (
- 'file_name' => $this->file_name,
- 'file_type' => $this->file_type,
- 'file_path' => $this->file_path,
- 'full_path' => $this->file_path.$this->file_name,
- 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
- 'orig_name' => $this->orig_name,
- 'file_ext' => $this->file_ext,
- 'file_size' => $this->file_size,
- 'is_image' => $this->is_image(),
- 'image_width' => $this->image_width,
- 'image_height' => $this->image_height,
- 'image_type' => $this->image_type,
- 'image_size_str' => $this->image_size_str,
- );
+ 'file_name' => $this->file_name,
+ 'file_type' => $this->file_type,
+ 'file_path' => $this->file_path,
+ 'full_path' => $this->file_path.$this->file_name,
+ 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
+ 'orig_name' => $this->orig_name,
+ 'file_ext' => $this->file_ext,
+ 'file_size' => $this->file_size,
+ 'is_image' => $this->is_image(),
+ 'image_width' => $this->image_width,
+ 'image_height' => $this->image_height,
+ 'image_type' => $this->image_type,
+ 'image_size_str' => $this->image_size_str,
+ );
}
// --------------------------------------------------------------------
@@ -554,7 +554,7 @@ class CI_Upload {
// --------------------------------------------------------------------
/**
- * VAlidate Upload Path
+ * Validate Upload Path
*
* Verifies that it is a valid upload path with proper permissions.
*
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index 5322be0e9..07ca35a33 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -478,7 +478,21 @@ class CI_Validation {
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
+
+ // --------------------------------------------------------------------
+ /**
+ * Validate IP Address
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function valid_ip($ip)
+ {
+ return ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) ? FALSE : TRUE;
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 218388314..e13c713fe 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -41,7 +41,8 @@ class CI_Zip {
{
log_message('debug', "Zip Compression Class Initialized");
}
-
+
+ // --------------------------------------------------------------------
/**
* Add Directory