From 0ea392937fd9e0a135e16cc7a645e4068f456f5d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 18:48:46 +0200 Subject: Improve the Zip library --- system/libraries/Zip.php | 70 +++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 52f1bc3d0..3c66c6b3a 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -1,13 +1,13 @@ -now); - - $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; - $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; + + $time = array( + 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2, + 'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'] + ); return $time; } @@ -117,7 +119,7 @@ class CI_Zip { * @param string the directory name * @return void */ - function _add_dir($dir, $file_mtime, $file_mdate) + private function _add_dir($dir, $file_mtime, $file_mdate) { $dir = str_replace("\\", "/", $dir); @@ -170,21 +172,19 @@ class CI_Zip { * @param string * @return void */ - function add_data($filepath, $data = NULL) + public function add_data($filepath, $data = NULL) { if (is_array($filepath)) { foreach ($filepath as $path => $data) { $file_data = $this->_get_mod_time($path); - $this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']); } } else { $file_data = $this->_get_mod_time($filepath); - $this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']); } } @@ -199,7 +199,7 @@ class CI_Zip { * @param string the data to be encoded * @return void */ - function _add_data($filepath, $data, $file_mtime, $file_mdate) + private function _add_data($filepath, $data, $file_mtime, $file_mdate) { $filepath = str_replace("\\", "/", $filepath); @@ -251,7 +251,7 @@ class CI_Zip { * @access public * @return bool */ - function read_file($path, $preserve_filepath = FALSE) + public function read_file($path, $preserve_filepath = FALSE) { if ( ! file_exists($path)) { @@ -286,7 +286,7 @@ class CI_Zip { * @param string path to source * @return bool */ - function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) + public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { if ( ! $fp = @opendir($path)) { @@ -301,7 +301,7 @@ class CI_Zip { while (FALSE !== ($file = readdir($fp))) { - if (substr($file, 0, 1) == '.') + if ($file[0] === '.') { continue; } @@ -337,7 +337,7 @@ class CI_Zip { * @access public * @return binary string */ - function get_zip() + public function get_zip() { // Is there any data to return? if ($this->entries == 0) @@ -345,15 +345,13 @@ class CI_Zip { return FALSE; } - $zip_data = $this->zipdata; - $zip_data .= $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00"; - $zip_data .= pack('v', $this->entries); // total # of entries "on this disk" - $zip_data .= pack('v', $this->entries); // total # of entries overall - $zip_data .= pack('V', strlen($this->directory)); // size of central dir - $zip_data .= pack('V', strlen($this->zipdata)); // offset to start of central dir - $zip_data .= "\x00\x00"; // .zip file comment length - - return $zip_data; + return $this->zipdata + . $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" + . pack('v', $this->entries) // total # of entries "on this disk" + . pack('v', $this->entries) // total # of entries overall + . pack('V', strlen($this->directory)) // size of central dir + . pack('V', strlen($this->zipdata)) // offset to start of central dir + . "\x00\x00"; // .zip file comment length } // -------------------------------------------------------------------- @@ -367,7 +365,7 @@ class CI_Zip { * @param string the file name * @return bool */ - function archive($filepath) + public function archive($filepath) { if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE))) { @@ -392,7 +390,7 @@ class CI_Zip { * @param string the data to be encoded * @return bool */ - function download($filename = 'backup.zip') + public function download($filename = 'backup.zip') { if ( ! preg_match("|.+?\.zip$|", $filename)) { @@ -420,7 +418,7 @@ class CI_Zip { * @access public * @return void */ - function clear_data() + public function clear_data() { $this->zipdata = ''; $this->directory = ''; @@ -432,4 +430,4 @@ class CI_Zip { } /* End of file Zip.php */ -/* Location: ./system/libraries/Zip.php */ \ No newline at end of file +/* Location: ./system/libraries/Zip.php */ -- cgit v1.2.3-24-g4f1b From b9535c80cc389952912f456f2c68665398b71494 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:21:17 +0200 Subject: Update with suggestions from gaker & dixy --- system/libraries/Zip.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 3c66c6b3a..7a97914c0 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -97,7 +97,7 @@ class CI_Zip { * @param string path to file * @return array filemtime/filemdate */ - private function _get_mod_time($dir) + protected function _get_mod_time($dir) { // filemtime() may return false, but raises an error for non-existing files $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); @@ -115,11 +115,11 @@ class CI_Zip { /** * Add Directory * - * @access private + * @access protected * @param string the directory name * @return void */ - private function _add_dir($dir, $file_mtime, $file_mdate) + protected function _add_dir($dir, $file_mtime, $file_mdate) { $dir = str_replace("\\", "/", $dir); @@ -194,12 +194,12 @@ class CI_Zip { /** * Add Data to Zip * - * @access private + * @access protected * @param string the file name/path * @param string the data to be encoded * @return void */ - private function _add_data($filepath, $data, $file_mtime, $file_mdate) + protected function _add_data($filepath, $data, $file_mtime, $file_mdate) { $filepath = str_replace("\\", "/", $filepath); @@ -288,6 +288,8 @@ class CI_Zip { */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { + $path = rtrim($path, '/\\').DIRECTORY_SEPARATOR; + if ( ! $fp = @opendir($path)) { return FALSE; @@ -425,6 +427,7 @@ class CI_Zip { $this->entries = 0; $this->file_num = 0; $this->offset = 0; + return $this; } } -- cgit v1.2.3-24-g4f1b From b1f3f57c65083904fe899753043419a25b073898 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:38:39 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Zip.php | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 7a97914c0..d60b99462 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -68,7 +68,6 @@ class CI_Zip { * * Lets you add a virtual directory into which you can place files. * - * @access public * @param mixed the directory name. Can be string or array * @return void */ @@ -115,7 +114,6 @@ class CI_Zip { /** * Add Directory * - * @access protected * @param string the directory name * @return void */ @@ -167,7 +165,6 @@ class CI_Zip { * in the filename it will be placed within a directory. Make * sure you use add_dir() first to create the folder. * - * @access public * @param mixed * @param string * @return void @@ -194,7 +191,6 @@ class CI_Zip { /** * Add Data to Zip * - * @access protected * @param string the file name/path * @param string the data to be encoded * @return void @@ -248,7 +244,6 @@ class CI_Zip { /** * Read the contents of a file and add it to the zip * - * @access public * @return bool */ public function read_file($path, $preserve_filepath = FALSE) @@ -282,7 +277,6 @@ class CI_Zip { * sub-folders) and creates a zip based on it. Whatever directory structure * is in the original file path will be recreated in the zip file. * - * @access public * @param string path to source * @return bool */ @@ -336,7 +330,6 @@ class CI_Zip { /** * Get the Zip file * - * @access public * @return binary string */ public function get_zip() @@ -363,7 +356,6 @@ class CI_Zip { * * Lets you write a file * - * @access public * @param string the file name * @return bool */ @@ -387,7 +379,6 @@ class CI_Zip { /** * Download * - * @access public * @param string the file name * @param string the data to be encoded * @return bool @@ -417,7 +408,6 @@ class CI_Zip { * Lets you clear current zip data. Useful if you need to create * multiple zips with different data. * - * @access public * @return void */ public function clear_data() -- cgit v1.2.3-24-g4f1b From cfbd15b6d052c1cb93fb5fa08e35fa7d3c6c7751 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 8 Jan 2012 06:41:41 +0200 Subject: Some more misc. stuff --- system/libraries/Zip.php | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index d60b99462..2ed79f0e3 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -51,13 +51,9 @@ class CI_Zip { public $offset = 0; public $now; - /** - * Constructor - */ public function __construct() { - log_message('debug', "Zip Compression Class Initialized"); - + log_message('debug', 'Zip Compression Class Initialized'); $this->now = time(); } @@ -75,13 +71,12 @@ class CI_Zip { { foreach ((array)$directory as $dir) { - if ( ! preg_match("|.+/$|", $dir)) + if ( ! preg_match('|.+/$|', $dir)) { $dir .= '/'; } $dir_time = $this->_get_mod_time($dir); - $this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']); } } @@ -101,12 +96,10 @@ class CI_Zip { // filemtime() may return false, but raises an error for non-existing files $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); - $time = array( + return array( 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2, 'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'] ); - - return $time; } // -------------------------------------------------------------------- @@ -197,13 +190,11 @@ class CI_Zip { */ protected function _add_data($filepath, $data, $file_mtime, $file_mdate) { - $filepath = str_replace("\\", "/", $filepath); + $filepath = str_replace('\\', '/', $filepath); $uncompressed_size = strlen($data); $crc32 = crc32($data); - - $gzdata = gzcompress($data); - $gzdata = substr($gzdata, 2, -4); + $gzdata = substr(gzcompress($data), 2, -4); $compressed_size = strlen($gzdata); $this->zipdata .= @@ -255,16 +246,16 @@ class CI_Zip { if (FALSE !== ($data = file_get_contents($path))) { - $name = str_replace("\\", "/", $path); - + $name = str_replace('\\', '/', $path); if ($preserve_filepath === FALSE) { - $name = preg_replace("|.*/(.+)|", "\\1", $name); + $name = preg_replace('|.*/(.+)|', '\\1', $name); } $this->add_data($name, $data); return TRUE; } + return FALSE; } @@ -282,7 +273,7 @@ class CI_Zip { */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { - $path = rtrim($path, '/\\').DIRECTORY_SEPARATOR; + $path = rtrim($path, '/\\').'/'; if ( ! $fp = @opendir($path)) { @@ -304,14 +295,13 @@ class CI_Zip { if (@is_dir($path.$file)) { - $this->read_dir($path.$file."/", $preserve_filepath, $root_path); + $this->read_dir($path.$file.'/', $preserve_filepath, $root_path); } else { if (FALSE !== ($data = file_get_contents($path.$file))) { - $name = str_replace("\\", "/", $path); - + $name = str_replace('\\', '/', $path); if ($preserve_filepath === FALSE) { $name = str_replace($root_path, '', $name); @@ -335,7 +325,7 @@ class CI_Zip { public function get_zip() { // Is there any data to return? - if ($this->entries == 0) + if ($this->entries === 0) { return FALSE; } @@ -392,9 +382,7 @@ class CI_Zip { $CI =& get_instance(); $CI->load->helper('download'); - $get_zip = $this->get_zip(); - $zip_content =& $get_zip; force_download($filename, $zip_content); -- cgit v1.2.3-24-g4f1b From e34f1a75ca78825bcf96c4344e01de412f6113bf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 10 Jan 2012 22:41:52 +0200 Subject: Some quotes --- system/libraries/Zip.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 2ed79f0e3..dbcdb2d97 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -112,7 +112,7 @@ class CI_Zip { */ protected function _add_dir($dir, $file_mtime, $file_mdate) { - $dir = str_replace("\\", "/", $dir); + $dir = str_replace('\\', '/', $dir); $this->zipdata .= "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00" @@ -375,7 +375,7 @@ class CI_Zip { */ public function download($filename = 'backup.zip') { - if ( ! preg_match("|.+?\.zip$|", $filename)) + if ( ! preg_match('|.+?\.zip$|', $filename)) { $filename .= '.zip'; } -- cgit v1.2.3-24-g4f1b From 901573ce19e905ce28a3f3345c33dedf9c703cd4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 11 Jan 2012 01:40:48 +0200 Subject: Fix issue 863 --- system/libraries/Form_validation.php | 122 +++++++++++------------------------ 1 file changed, 38 insertions(+), 84 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..78b1ae016 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Form Validation Class * @@ -48,9 +46,6 @@ class CI_Form_validation { protected $error_string = ''; protected $_safe_form_data = FALSE; - /** - * Constructor - */ public function __construct($rules = array()) { $this->CI =& get_instance(); @@ -67,7 +62,7 @@ class CI_Form_validation { mb_internal_encoding($this->CI->config->item('charset')); } - log_message('debug', "Form Validation Class Initialized"); + log_message('debug', 'Form Validation Class Initialized'); } // -------------------------------------------------------------------- @@ -179,7 +174,6 @@ class CI_Form_validation { } $this->_error_messages = array_merge($this->_error_messages, $lang); - return $this; } @@ -198,7 +192,6 @@ class CI_Form_validation { { $this->_error_prefix = $prefix; $this->_error_suffix = $suffix; - return $this; } @@ -313,10 +306,10 @@ class CI_Form_validation { $this->set_rules($this->_config_rules); } - // We're we able to set the rules correctly? + // Were we able to set the rules correctly? if (count($this->_field_data) === 0) { - log_message('debug', "Unable to find validation rules"); + log_message('debug', 'Unable to find validation rules'); return FALSE; } } @@ -330,17 +323,13 @@ class CI_Form_validation { { // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. // Depending on whether the field name is an array or a string will determine where we get it from. - if ($row['is_array'] === TRUE) { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); } - else + elseif (isset($_POST[$field]) AND $_POST[$field] != '') { - if (isset($_POST[$field]) AND $_POST[$field] != "") - { - $this->_field_data[$field]['postdata'] = $_POST[$field]; - } + $this->_field_data[$field]['postdata'] = $_POST[$field]; } $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); @@ -348,7 +337,6 @@ class CI_Form_validation { // Did we end up with any errors? $total_errors = count($this->_error_array); - if ($total_errors > 0) { $this->_safe_form_data = TRUE; @@ -462,14 +450,12 @@ class CI_Form_validation { return; } - // -------------------------------------------------------------------- - // If the field is blank, but NOT required, no further tests are necessary $callback = FALSE; if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) + if (preg_match('/(callback_\w+(\[.*?\])?)/', implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); @@ -480,8 +466,6 @@ class CI_Form_validation { } } - // -------------------------------------------------------------------- - // Isset Test. Typically this rule will only apply to checkboxes. if (is_null($postdata) AND $callback === FALSE) { @@ -543,11 +527,9 @@ class CI_Form_validation { $postdata = $this->_field_data[$row['field']]['postdata']; } - // -------------------------------------------------------------------- - // Is the rule a callback? $callback = FALSE; - if (substr($rule, 0, 9) == 'callback_') + if (strpos($rule, 'callback_') === 0) { $rule = substr($rule, 9); $callback = TRUE; @@ -556,7 +538,7 @@ class CI_Form_validation { // Strip the parameter (if exists) from the rule // Rules can contain a parameter: max_length[5] $param = FALSE; - if (preg_match("/(.*?)\[(.*)\]/", $rule, $match)) + if (preg_match('/(.*?)\[(.*)\]/', $rule, $match)) { $rule = $match[1]; $param = $match[2]; @@ -567,11 +549,14 @@ class CI_Form_validation { { if ( ! method_exists($this->CI, $rule)) { - continue; + log_message('debug', 'Unable to find callback validation rule: '.$rule); + $result = FALSE; + } + else + { + // Run the function and grab the result + $result = $this->CI->$rule($postdata, $param); } - - // Run the function and grab the result - $result = $this->CI->$rule($postdata, $param); // Re-assign the result to the master data array if ($_in_array === TRUE) @@ -610,13 +595,14 @@ class CI_Form_validation { } else { - log_message('debug', "Unable to find validation rule: ".$rule); + log_message('debug', 'Unable to find validation rule: '.$rule); + $result = FALSE; } - - continue; } - - $result = $this->$rule($postdata, $param); + else + { + $result = $this->$rule($postdata, $param); + } if ($_in_array === TRUE) { @@ -628,7 +614,7 @@ class CI_Form_validation { } } - // Did the rule test negatively? If so, grab the error. + // Did the rule test negatively? If so, grab the error. if ($result === FALSE) { if ( ! isset($this->_error_messages[$rule])) @@ -644,7 +630,7 @@ class CI_Form_validation { } // Is the parameter we are inserting into the error message the name - // of another field? If so we need to grab its "field label" + // of another field? If so we need to grab its "field label" if (isset($this->_field_data[$param], $this->_field_data[$param]['label'])) { $param = $this->_translate_fieldname($this->_field_data[$param]['label']); @@ -678,7 +664,7 @@ class CI_Form_validation { { // Do we need to translate the field name? // We look for the prefix lang: to determine this - if (substr($fieldname, 0, 5) === 'lang:') + if (strpos($fieldname, 'lang:') === 0) { // Grab the variable $line = substr($fieldname, 5); @@ -738,15 +724,10 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' selected="selected"'; - } - return ''; + return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; - if (is_array($field)) { if ( ! in_array($value, $field)) @@ -754,12 +735,9 @@ class CI_Form_validation { return ''; } } - else + elseif (($field == '' OR $value == '') OR ($field != $value)) { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } + return ''; } return ' selected="selected"'; @@ -781,15 +759,10 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' checked="checked"'; - } - return ''; + return ($default === TRUE AND count($this->_field_data) === 0) ? ' checked="checked"' : ''; } $field = $this->_field_data[$field]['postdata']; - if (is_array($field)) { if ( ! in_array($value, $field)) @@ -797,12 +770,9 @@ class CI_Form_validation { return ''; } } - else + elseif (($field == '' OR $value == '') OR ($field != $value)) { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } + return ''; } return ' checked="checked"'; @@ -869,9 +839,7 @@ class CI_Form_validation { return FALSE; } - $field = $_POST[$field]; - - return ($str === $field); + return ($str === $_POST[$field]); } // -------------------------------------------------------------------- @@ -908,7 +876,7 @@ class CI_Form_validation { */ public function min_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -932,7 +900,7 @@ class CI_Form_validation { */ public function max_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -956,7 +924,7 @@ class CI_Form_validation { */ public function exact_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -1076,19 +1044,6 @@ class CI_Form_validation { // -------------------------------------------------------------------- - /** - * Is Numeric - * - * @param string - * @return bool - */ - public function is_numeric($str) - { - return is_numeric($str); - } - - // -------------------------------------------------------------------- - /** * Integer * @@ -1217,7 +1172,7 @@ class CI_Form_validation { return $data; } - return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); + return str_replace(array("'", '"', '<', '>'), array(''', '"', '<', '>'), stripslashes($data)); } // -------------------------------------------------------------------- @@ -1230,14 +1185,14 @@ class CI_Form_validation { */ public function prep_url($str = '') { - if ($str == 'http://' OR $str == '') + if ($str === 'http://' OR $str == '') { return ''; } - if (substr($str, 0, 7) !== 'http://' && substr($str, 0, 8) !== 'https://') + if (strpos($str, 'http://') !== 0 && strpos($str, 'https://') !== 0) { - $str = 'http://'.$str; + return 'http://'.$str; } return $str; @@ -1283,7 +1238,6 @@ class CI_Form_validation { } } -// END Form Validation Class /* End of file Form_validation.php */ /* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From cde43687ef19aa23ee6796925270961b760369f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Jan 2012 20:16:35 +0200 Subject: Allow native PHP functions used as rules to accept an additional parameter --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 78b1ae016..9aa07a1a8 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -582,7 +582,7 @@ class CI_Form_validation { // Users can use any native PHP function call that has one param. if (function_exists($rule)) { - $result = $rule($postdata); + $result = ($param !== FALSE) ? $rule($postdata, $param) : $rule($postdata); if ($_in_array === TRUE) { -- cgit v1.2.3-24-g4f1b From 6de924ce72797a1a8d8d8104f767f42c24e929c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:18:18 +0200 Subject: Replace AND with && --- system/libraries/Form_validation.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 9aa07a1a8..34b7b646d 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it @@ -297,7 +297,7 @@ class CI_Form_validation { // Is there a validation rule for the particular URI being accessed? $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group; - if ($uri != '' AND isset($this->_config_rules[$uri])) + if ($uri != '' && isset($this->_config_rules[$uri])) { $this->set_rules($this->_config_rules[$uri]); } @@ -327,7 +327,7 @@ class CI_Form_validation { { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); } - elseif (isset($_POST[$field]) AND $_POST[$field] != '') + elseif (isset($_POST[$field]) && $_POST[$field] != '') { $this->_field_data[$field]['postdata'] = $_POST[$field]; } @@ -373,7 +373,7 @@ class CI_Form_validation { /** * Re-populate the _POST array with our finalized and processed data * - * @return null + * @return void */ protected function _reset_post_array() { @@ -452,7 +452,7 @@ class CI_Form_validation { // If the field is blank, but NOT required, no further tests are necessary $callback = FALSE; - if ( ! in_array('required', $rules) AND is_null($postdata)) + if ( ! in_array('required', $rules) && is_null($postdata)) { // Before we bail out, does the rule contain a callback? if (preg_match('/(callback_\w+(\[.*?\])?)/', implode(' ', $rules), $match)) @@ -467,7 +467,7 @@ class CI_Form_validation { } // Isset Test. Typically this rule will only apply to checkboxes. - if (is_null($postdata) AND $callback === FALSE) + if (is_null($postdata) && $callback === FALSE) { if (in_array('isset', $rules, TRUE) OR in_array('required', $rules)) { @@ -510,7 +510,7 @@ class CI_Form_validation { // We set the $postdata variable with the current data in our master array so that // each cycle of the loop is dealing with the processed data from the last cycle - if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata'])) + if ($row['is_array'] == TRUE && is_array($this->_field_data[$row['field']]['postdata'])) { // We shouldn't need this safety, but just in case there isn't an array index // associated with this cycle we'll bail out @@ -569,7 +569,7 @@ class CI_Form_validation { } // If the field isn't required and we just processed a callback we'll move on... - if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE) + if ( ! in_array('required', $rules, TRUE) && $result !== FALSE) { continue; } @@ -724,7 +724,7 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -759,7 +759,7 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { - return ($default === TRUE AND count($this->_field_data) === 0) ? ' checked="checked"' : ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' checked="checked"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -1125,7 +1125,7 @@ class CI_Form_validation { */ public function is_natural_no_zero($str) { - return ($str != 0 AND preg_match('/^[0-9]+$/', $str)); + return ($str != 0 && preg_match('/^[0-9]+$/', $str)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 16d806605993305efe9c264b3ae8383ec92ae5ae Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:26:49 +0200 Subject: Some more cleaning --- system/libraries/Zip.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index dbcdb2d97..85a0b5ce9 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Zip Compression Class * @@ -265,7 +263,7 @@ class CI_Zip { * Read a directory and add it to the zip. * * This function recursively reads a folder and everything it contains (including - * sub-folders) and creates a zip based on it. Whatever directory structure + * sub-folders) and creates a zip based on it. Whatever directory structure * is in the original file path will be recreated in the zip file. * * @param string path to source @@ -297,18 +295,14 @@ class CI_Zip { { $this->read_dir($path.$file.'/', $preserve_filepath, $root_path); } - else + elseif (FALSE !== ($data = file_get_contents($path.$file))) { - if (FALSE !== ($data = file_get_contents($path.$file))) + $name = str_replace('\\', '/', $path); + if ($preserve_filepath === FALSE) { - $name = str_replace('\\', '/', $path); - if ($preserve_filepath === FALSE) - { - $name = str_replace($root_path, '', $name); - } - - $this->add_data($name.$file, $data); + $name = str_replace($root_path, '', $name); } + $this->add_data($name.$file, $data); } } @@ -320,7 +314,7 @@ class CI_Zip { /** * Get the Zip file * - * @return binary string + * @return string (binary encoded) */ public function get_zip() { @@ -393,10 +387,10 @@ class CI_Zip { /** * Initialize Data * - * Lets you clear current zip data. Useful if you need to create + * Lets you clear current zip data. Useful if you need to create * multiple zips with different data. * - * @return void + * @return object */ public function clear_data() { -- cgit v1.2.3-24-g4f1b From 1841e6b472820deb2dfe4d43c675211eeabbd057 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:30:01 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 85a0b5ce9..e7c55de1b 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it -- cgit v1.2.3-24-g4f1b From b998f3e820c724f16f3b700f094c875af1d28c0f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:31:26 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 34b7b646d..20f1faf27 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it -- cgit v1.2.3-24-g4f1b From 6c308b7482375baa4982cce26219cecd20bafdc0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 2 Feb 2012 22:03:53 +0200 Subject: Fix some comment blocks --- system/libraries/Zip.php | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index e7c55de1b..174d18a67 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -67,7 +67,7 @@ class CI_Zip { */ public function add_dir($directory) { - foreach ((array)$directory as $dir) + foreach ( (array) $directory as $dir) { if ( ! preg_match('|.+/$|', $dir)) { @@ -82,17 +82,17 @@ class CI_Zip { // -------------------------------------------------------------------- /** - * Get file/directory modification time + * Get file/directory modification time * - * If this is a newly created file/dir, we will set the time to 'now' + * If this is a newly created file/dir, we will set the time to 'now' * - * @param string path to file - * @return array filemtime/filemdate + * @param string path to file + * @return array filemtime/filemdate */ protected function _get_mod_time($dir) { // filemtime() may return false, but raises an error for non-existing files - $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now); + $date = file_exists($dir) ? filemtime($dir) : getdate($this->now); return array( 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2, @@ -106,6 +106,8 @@ class CI_Zip { * Add Directory * * @param string the directory name + * @param int + * @param int * @return void */ protected function _add_dir($dir, $file_mtime, $file_mdate) @@ -184,6 +186,8 @@ class CI_Zip { * * @param string the file name/path * @param string the data to be encoded + * @param int + * @param int * @return void */ protected function _add_data($filepath, $data, $file_mtime, $file_mdate) @@ -233,6 +237,8 @@ class CI_Zip { /** * Read the contents of a file and add it to the zip * + * @param string + * @param bool * @return bool */ public function read_file($path, $preserve_filepath = FALSE) @@ -267,12 +273,13 @@ class CI_Zip { * is in the original file path will be recreated in the zip file. * * @param string path to source + * @param bool + * @param bool * @return bool */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { $path = rtrim($path, '/\\').'/'; - if ( ! $fp = @opendir($path)) { return FALSE; @@ -306,6 +313,8 @@ class CI_Zip { } } + closedir($fp); + return TRUE; } @@ -314,7 +323,7 @@ class CI_Zip { /** * Get the Zip file * - * @return string (binary encoded) + * @return string (binary encoded) */ public function get_zip() { @@ -325,12 +334,12 @@ class CI_Zip { } return $this->zipdata - . $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" - . pack('v', $this->entries) // total # of entries "on this disk" - . pack('v', $this->entries) // total # of entries overall - . pack('V', strlen($this->directory)) // size of central dir - . pack('V', strlen($this->zipdata)) // offset to start of central dir - . "\x00\x00"; // .zip file comment length + .$this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" + .pack('v', $this->entries) // total # of entries "on this disk" + .pack('v', $this->entries) // total # of entries overall + .pack('V', strlen($this->directory)) // size of central dir + .pack('V', strlen($this->zipdata)) // offset to start of central dir + ."\x00\x00"; // .zip file comment length } // -------------------------------------------------------------------- @@ -364,7 +373,6 @@ class CI_Zip { * Download * * @param string the file name - * @param string the data to be encoded * @return bool */ public function download($filename = 'backup.zip') -- cgit v1.2.3-24-g4f1b From c15e17c3fe6110a4e08a56cde3514c02359fe080 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Thu, 23 Feb 2012 14:56:18 -0500 Subject: added all_flashdata function to Session.php --- system/libraries/Session.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 66b39a6a2..a594d24ef 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -468,6 +468,29 @@ class CI_Session { { return $this->userdata; } + + // -------------------------------------------------------------------------- + + /** + * Fetch all flashdata + * + * @return array + */ + public function all_flashdata() + { + $out = array(); + + // loop through all userdata + foreach ($this->all_userdata() as $key => $val) + { + // if it contains flashdata, add it + if (strpos($key, 'flash:old:') !== FALSE) + { + $out[$key] = $val; + } + } + return $out; + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 46e3a9a365e6bae7954f5118db1409faa5f5decd Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 09:38:35 -0500 Subject: added config check, changelog entry, and user guide update. --- system/libraries/Table.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb154e50f..de5a6ba3a 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -49,9 +49,23 @@ class CI_Table { public $empty_cells = ''; public $function = FALSE; - public function __construct() + // -------------------------------------------------------------------------- + + /** + * Set the template from the table config file if it exists + * + * @param array $config (default: array()) + * @return void + */ + public function __construct($config = array()) { log_message('debug', "Table Class Initialized"); + + // initialize config + foreach ($config as $key => $val) + { + $this->template[$key] = $val; + } } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 326a5e75db1e03e453f488f2d612b0f421806129 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:06:28 -0500 Subject: added config process method checking for delimiter values, updated changelog and user guide. --- system/libraries/Form_validation.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..93ec8b34a 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -55,6 +55,9 @@ class CI_Form_validation { { $this->CI =& get_instance(); + // applies delimiters set in config file. + $this->_config_delimiters(); + // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -69,6 +72,27 @@ class CI_Form_validation { log_message('debug', "Form Validation Class Initialized"); } + + // -------------------------------------------------------------------- + + /** + * if prefixes/suffixes set in config, assign and unset. + * + * @return void + */ + private function _config_delimiters() + { + if (isset($rules['error_prefix'])) + { + $this->_error_prefix = $rules['error_prefix']); + unset $rules['error_prefix']); + } + if (isset($rules['error_suffix'])) + { + $this->_error_suffix = $rules['error_suffix']); + unset $rules['error_suffix']); + } + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 1ccdb9a8e3a34153d3c9a1075b44e84dd39aa25c Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:32:19 -0500 Subject: changed _config_delimiters() to protected. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 93ec8b34a..25ccb4c69 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -80,7 +80,7 @@ class CI_Form_validation { * * @return void */ - private function _config_delimiters() + protected function _config_delimiters() { if (isset($rules['error_prefix'])) { -- cgit v1.2.3-24-g4f1b From 9af3337175b82c66e7f43d2ad782e2e1d79dac5e Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:37:56 -0500 Subject: fixed some mismatched brackets. --- system/libraries/Form_validation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 25ccb4c69..bfe64fac9 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -84,13 +84,13 @@ class CI_Form_validation { { if (isset($rules['error_prefix'])) { - $this->_error_prefix = $rules['error_prefix']); - unset $rules['error_prefix']); + $this->_error_prefix = $rules['error_prefix']; + unset($rules['error_prefix']); } if (isset($rules['error_suffix'])) { - $this->_error_suffix = $rules['error_suffix']); - unset $rules['error_suffix']); + $this->_error_suffix = $rules['error_suffix']; + unset($rules['error_suffix']); } } -- cgit v1.2.3-24-g4f1b From aa20f5b70f6da196d1a66d5dc17b05a037708e1a Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:43:16 -0500 Subject: using tabs as @item seperators in docblocks. --- system/libraries/Table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index de5a6ba3a..947aedd8f 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -54,8 +54,8 @@ class CI_Table { /** * Set the template from the table config file if it exists * - * @param array $config (default: array()) - * @return void + * @param array $config (default: array()) + * @return void */ public function __construct($config = array()) { -- cgit v1.2.3-24-g4f1b From a90b1f2f89a41b2fe061f5fdd3f84f08b961a887 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:44:19 -0500 Subject: tab separator in _config_delimiters dockblock. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bfe64fac9..79414656f 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -78,7 +78,7 @@ class CI_Form_validation { /** * if prefixes/suffixes set in config, assign and unset. * - * @return void + * @return void */ protected function _config_delimiters() { -- cgit v1.2.3-24-g4f1b From c91a66cd7c770f8060cbe366491c1f4de9147da4 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:46:00 -0500 Subject: tab separation in docblock. --- system/libraries/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index a594d24ef..c14b11fa3 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -474,7 +474,7 @@ class CI_Session { /** * Fetch all flashdata * - * @return array + * @return array */ public function all_flashdata() { -- cgit v1.2.3-24-g4f1b From 0b5a4867af78838f3c7e2726e469f904e15976f1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Feb 2012 23:44:00 +0200 Subject: Minor clean-up --- system/libraries/Zip.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 174d18a67..f2f5f2e5d 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -155,7 +155,7 @@ class CI_Zip { * Add Data to Zip * * Lets you add files to the archive. If the path is included - * in the filename it will be placed within a directory. Make + * in the filename it will be placed within a directory. Make * sure you use add_dir() first to create the folder. * * @param mixed @@ -314,7 +314,6 @@ class CI_Zip { } closedir($fp); - return TRUE; } @@ -373,7 +372,7 @@ class CI_Zip { * Download * * @param string the file name - * @return bool + * @return void */ public function download($filename = 'backup.zip') { -- cgit v1.2.3-24-g4f1b From 03a57655f3cdc6c0b9f717f4466a4547247729d3 Mon Sep 17 00:00:00 2001 From: Mike Davies Date: Wed, 29 Feb 2012 17:52:36 -0500 Subject: Added support for Wincache when running CI on Windows boxes Wincache is directly analogous to APC, except with less problems on a Windows environment. Performance wise they are almost identical (for user mode caching at least). Need to have the Wincache PHP module downloaded from http://www.iis.net/download/wincacheforphp. --- system/libraries/Cache/Cache.php | 2 +- system/libraries/Cache/drivers/Cache_wincache.php | 155 ++++++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 system/libraries/Cache/drivers/Cache_wincache.php (limited to 'system/libraries') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 2e78a6660..e9cc1101c 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -39,7 +39,7 @@ class CI_Cache extends CI_Driver_Library { protected $valid_drivers = array( - 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy' + 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_wincache' ); protected $_cache_path = NULL; // Path of cache files (if file-based cache) diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php new file mode 100644 index 000000000..a1b1bb3de --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -0,0 +1,155 @@ + $ttl - $age, + 'hitcount' => $hitcount, + 'age' => $age, + 'ttl' => $ttl + ); + } + return false; + } + + // ------------------------------------------------------------------------ + + /** + * is_supported() + * + * Check to see if WinCache is available on this system, bail if it isn't. + */ + public function is_supported() + { + if ( ! extension_loaded('wincache') ) + { + log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); + return FALSE; + } + + return TRUE; + } + + // ------------------------------------------------------------------------ + + +} +// End Class + +/* End of file Cache_wincache.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ -- cgit v1.2.3-24-g4f1b From 100934cf6d8d3bc3bcff7c7a16d0d2c29bf2f6a9 Mon Sep 17 00:00:00 2001 From: Mike Davies Date: Fri, 2 Mar 2012 19:18:22 -0500 Subject: Updated tabs, reinserted license, and fixed logic on get() --- system/libraries/Cache/drivers/Cache_wincache.php | 62 ++++++++++++++--------- 1 file changed, 37 insertions(+), 25 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index a1b1bb3de..8164b5a7b 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -4,13 +4,25 @@ * * An open source application development framework for PHP 5.1.6 or newer * + * NOTICE OF LICENSE + * + * Licensed under the Open Software License version 3.0 + * + * This source file is subject to the Open Software License (OSL 3.0) that is + * bundled with this package in the files license.txt / license.rst. It is + * also available through the world wide web at this URL: + * http://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to obtain it + * through the world wide web, please send an email to + * licensing@ellislab.com so we can send you a copy immediately. + * * @package CodeIgniter - * @author Mike Murkovic - * @copyright - * @license http://codeigniter.com/user_guide/license.html + * @author EllisLab Dev Team + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ @@ -41,11 +53,11 @@ class CI_Cache_wincache extends CI_Driver { */ public function get($id) { - if ($data = wincache_ucache_get($id)) - { - return $data; - } - return FALSE; + $success = FALSE; + $data = wincache_ucache_get($id, $success); + + //Success returned by reference from wincache_ucache_get + return ($success) ? $data : FALSE; } // ------------------------------------------------------------------------ @@ -111,20 +123,20 @@ class CI_Cache_wincache extends CI_Driver { */ public function get_metadata($id) { - if ($stored = wincache_ucache_info(false, $id)) - { - $age = $stored['ucache_entries'][1]['age_seconds']; - $ttl = $stored['ucache_entries'][1]['ttl_seconds']; - $hitcount = $stored['ucache_entries'][1]['hitcount']; - - return array( - 'expire' => $ttl - $age, - 'hitcount' => $hitcount, - 'age' => $age, - 'ttl' => $ttl - ); - } - return false; + if ($stored = wincache_ucache_info(false, $id)) + { + $age = $stored['ucache_entries'][1]['age_seconds']; + $ttl = $stored['ucache_entries'][1]['ttl_seconds']; + $hitcount = $stored['ucache_entries'][1]['hitcount']; + + return array( + 'expire' => $ttl - $age, + 'hitcount' => $hitcount, + 'age' => $age, + 'ttl' => $ttl + ); + } + return false; } // ------------------------------------------------------------------------ @@ -138,8 +150,8 @@ class CI_Cache_wincache extends CI_Driver { { if ( ! extension_loaded('wincache') ) { - log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); - return FALSE; + log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); + return FALSE; } return TRUE; -- cgit v1.2.3-24-g4f1b From fd15423734b23ce1f10a24b6fc57f6b16a3b361b Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Wed, 7 Mar 2012 19:58:58 -0500 Subject: Fixed bug with rules not being passed to _config_delimiters or back into $this->_config_rules. --- system/libraries/Form_validation.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f2f3712d9..f3535b225 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -54,7 +54,7 @@ class CI_Form_validation { $this->CI =& get_instance(); // applies delimiters set in config file. - $this->_config_delimiters(); + $rules = $this->_config_delimiters($rules); // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -76,9 +76,10 @@ class CI_Form_validation { /** * if prefixes/suffixes set in config, assign and unset. * - * @return void + * @param array + * @return array */ - protected function _config_delimiters() + protected function _config_delimiters($rules) { if (isset($rules['error_prefix'])) { @@ -90,6 +91,7 @@ class CI_Form_validation { $this->_error_suffix = $rules['error_suffix']; unset($rules['error_suffix']); } + return $rules; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 7f42d060fb828bfb0bd857ad1a17b91070e52628 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Thu, 8 Mar 2012 09:00:57 -0500 Subject: moved delimiter assigning to constructor, removed extra function. --- system/libraries/Form_validation.php | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f3535b225..3e16d69ed 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -54,7 +54,16 @@ class CI_Form_validation { $this->CI =& get_instance(); // applies delimiters set in config file. - $rules = $this->_config_delimiters($rules); + if (isset($rules['error_prefix'])) + { + $this->_error_prefix = $rules['error_prefix']; + unset($rules['error_prefix']); + } + if (isset($rules['error_suffix'])) + { + $this->_error_suffix = $rules['error_suffix']; + unset($rules['error_suffix']); + } // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -70,29 +79,6 @@ class CI_Form_validation { log_message('debug', "Form Validation Class Initialized"); } - - // -------------------------------------------------------------------- - - /** - * if prefixes/suffixes set in config, assign and unset. - * - * @param array - * @return array - */ - protected function _config_delimiters($rules) - { - if (isset($rules['error_prefix'])) - { - $this->_error_prefix = $rules['error_prefix']; - unset($rules['error_prefix']); - } - if (isset($rules['error_suffix'])) - { - $this->_error_suffix = $rules['error_suffix']; - unset($rules['error_suffix']); - } - return $rules; - } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/libraries/Cache/Cache.php | 2 +- system/libraries/Cache/drivers/Cache_apc.php | 2 +- system/libraries/Cache/drivers/Cache_dummy.php | 2 +- system/libraries/Cache/drivers/Cache_file.php | 2 +- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- system/libraries/Calendar.php | 2 +- system/libraries/Cart.php | 2 +- system/libraries/Driver.php | 2 +- system/libraries/Email.php | 2 +- system/libraries/Encrypt.php | 2 +- system/libraries/Form_validation.php | 2 +- system/libraries/Ftp.php | 2 +- system/libraries/Image_lib.php | 2 +- system/libraries/Javascript.php | 2 +- system/libraries/Log.php | 2 +- system/libraries/Migration.php | 2 +- system/libraries/Pagination.php | 2 +- system/libraries/Parser.php | 2 +- system/libraries/Profiler.php | 2 +- system/libraries/Session.php | 2 +- system/libraries/Table.php | 2 +- system/libraries/Trackback.php | 2 +- system/libraries/Typography.php | 2 +- system/libraries/Unit_test.php | 2 +- system/libraries/Upload.php | 2 +- system/libraries/User_agent.php | 2 +- system/libraries/Xmlrpc.php | 2 +- system/libraries/Xmlrpcs.php | 2 +- system/libraries/Zip.php | 2 +- system/libraries/javascript/Jquery.php | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 2e78a6660..60998e3b8 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index a3dd46978..c387a30fc 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index fcd55da39..c9767e401 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index a960730d7..c0be0def4 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index ffe6f2ff7..b8f2d7e4c 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index a05a7babf..6c04de8a2 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 10b5362a5..60a1e52fe 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 4e8944311..9a073b336 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 8d839d0c9..f30fe40b6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 0b0618991..b29eb470e 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index cdb3d3d62..8153af706 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index ab395b0a0..4d96c00cc 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 9826eabdd..86b77bf07 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 33df6007a..9ba93000b 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 944173fdd..955277acc 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index d07097223..c045ac0e2 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 35ac541e8..86b8d79fa 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 321248277..290e17fc0 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 04216be5d..d84e5d3fc 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 104b88810..0b9d45b2a 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb154e50f..8651b9e69 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 79a009133..3bea5f9b8 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 46c73ef8b..65e30b089 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 38d767c69..2eb8df356 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 89575c849..42664a587 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index cd644c00d..9109edd0f 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 730a0fc49..32e2e523b 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 355d43f29..fc41444bc 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 50e84920e..e33eb4e5a 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 03574c66e..f30d7c639 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 8749bc7e836c196dfef37d3b7b5a67736a15092c Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 11 Mar 2012 05:43:45 +0700 Subject: Fix incomplete and skipped test --- system/libraries/Table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb154e50f..8f6ac8d45 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -102,7 +102,7 @@ class CI_Table { */ public function make_columns($array = array(), $col_limit = 0) { - if ( ! is_array($array) OR count($array) === 0) + if ( ! is_array($array) OR count($array) === 0 OR ! is_int($col_limit)) { return FALSE; } @@ -395,7 +395,7 @@ class CI_Table { // First generate the headings from the table column names if (count($this->heading) === 0) { - if ( ! method_exists($query, 'list_fields')) + if ( ! is_callable(array($query, 'list_fields'))) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 5fbaf27ac9da632b520457e91d9088e9aab6df89 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Mon, 12 Mar 2012 10:19:46 -0400 Subject: Changed space to tab in docblock. --- system/libraries/Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 947aedd8f..649d50875 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -54,7 +54,7 @@ class CI_Table { /** * Set the template from the table config file if it exists * - * @param array $config (default: array()) + * @param array $config (default: array()) * @return void */ public function __construct($config = array()) -- cgit v1.2.3-24-g4f1b From 802953234f0b7669333807aaa3f2318778cde187 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 16:29:16 +0200 Subject: Just some cleanup in the Table class --- system/libraries/Table.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index ceda6f323..99d001ce5 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * HTML Table Generating Class * @@ -49,18 +47,16 @@ class CI_Table { public $empty_cells = ''; public $function = FALSE; - // -------------------------------------------------------------------------- - /** * Set the template from the table config file if it exists - * + * * @param array $config (default: array()) * @return void */ public function __construct($config = array()) { - log_message('debug', "Table Class Initialized"); - + log_message('debug', 'Table Class Initialized'); + // initialize config foreach ($config as $key => $val) { -- cgit v1.2.3-24-g4f1b From 5b9fd2deb29968fd5f7b039868d95ce9c1392de5 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Mon, 12 Mar 2012 20:26:59 +0400 Subject: Replace function_exists() checks with MB_ENABLED constant --- system/libraries/Form_validation.php | 8 ++++---- system/libraries/Trackback.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 826d94fb0..9491f354c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -72,7 +72,7 @@ class CI_Form_validation { $this->CI->load->helper('form'); // Set the character encoding in MB. - if (function_exists('mb_internal_encoding')) + if (MB_ENABLED === TRUE) { mb_internal_encoding($this->CI->config->item('charset')); } @@ -950,7 +950,7 @@ class CI_Form_validation { return FALSE; } - if (function_exists('mb_strlen')) + if (MB_ENABLED === TRUE) { return ! (mb_strlen($str) < $val); } @@ -974,7 +974,7 @@ class CI_Form_validation { return FALSE; } - if (function_exists('mb_strlen')) + if (MB_ENABLED === TRUE) { return ! (mb_strlen($str) > $val); } @@ -998,7 +998,7 @@ class CI_Form_validation { return FALSE; } - if (function_exists('mb_strlen')) + if (MB_ENABLED === TRUE) { return (mb_strlen($str) == $val); } diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 3bea5f9b8..be1de6f3f 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -141,7 +141,7 @@ class CI_Trackback { $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset'])); - if ($val != 'url' && function_exists('mb_convert_encoding')) + if ($val != 'url' && MB_ENABLED === TRUE) { $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']); } -- cgit v1.2.3-24-g4f1b From 6b535f51fcb94e0a645fda0d0356f4748076877e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Mar 2012 22:19:13 +0200 Subject: Fix some spaces and alignments in the new Wincache driver --- system/libraries/Cache/Cache.php | 21 ++++---- system/libraries/Cache/drivers/Cache_wincache.php | 60 +++++++++++------------ 2 files changed, 38 insertions(+), 43 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index b89e5ab6f..7642a5270 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -39,20 +39,17 @@ class CI_Cache extends CI_Driver_Library { protected $valid_drivers = array( - 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_wincache' - ); - - protected $_cache_path = NULL; // Path of cache files (if file-based cache) - protected $_adapter = 'dummy'; + 'cache_apc', + 'cache_file', + 'cache_memcached', + 'cache_dummy', + 'cache_wincache' + ); + + 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)) diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index 8164b5a7b..df619d4e6 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 2.0 + * @since Version 3.0 * @filesource */ @@ -37,52 +37,51 @@ * @subpackage Libraries * @category Core * @author Mike Murkovic - * @link + * @link */ class CI_Cache_wincache extends CI_Driver { /** - * Get + * Get * - * Look for a value in the cache. If it exists, return the data + * 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 + * @param string + * @return mixed value that is stored/FALSE on failure */ public function get($id) { $success = FALSE; $data = wincache_ucache_get($id, $success); - - //Success returned by reference from wincache_ucache_get + + // Success returned by reference from wincache_ucache_get() return ($success) ? $data : 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 + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { return wincache_ucache_set($id, $data, $ttl); } - + // ------------------------------------------------------------------------ /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @param boolean true on success/false on failure + * @param mixed unique identifier of the item in the cache + * @param bool true on success/false on failure */ public function delete($id) { @@ -94,7 +93,7 @@ class CI_Cache_wincache extends CI_Driver { /** * Clean the cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -106,11 +105,11 @@ class CI_Cache_wincache extends CI_Driver { /** * Cache Info * - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ public function cache_info() { - return wincache_ucache_info(true); + return wincache_ucache_info(TRUE); } // ------------------------------------------------------------------------ @@ -118,12 +117,12 @@ class CI_Cache_wincache extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed array on success/false on failure + * @param mixed key to get cache metadata on + * @return mixed array on success/false on failure */ public function get_metadata($id) { - if ($stored = wincache_ucache_info(false, $id)) + if ($stored = wincache_ucache_info(FALSE, $id)) { $age = $stored['ucache_entries'][1]['age_seconds']; $ttl = $stored['ucache_entries'][1]['ttl_seconds']; @@ -136,7 +135,8 @@ class CI_Cache_wincache extends CI_Driver { 'ttl' => $ttl ); } - return false; + + return FALSE; } // ------------------------------------------------------------------------ @@ -145,23 +145,21 @@ class CI_Cache_wincache extends CI_Driver { * is_supported() * * Check to see if WinCache is available on this system, bail if it isn't. + * + * @return bool */ public function is_supported() { - if ( ! extension_loaded('wincache') ) + if ( ! extension_loaded('wincache')) { log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); return FALSE; } - + return TRUE; } - // ------------------------------------------------------------------------ - - } -// End Class /* End of file Cache_wincache.php */ /* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ -- cgit v1.2.3-24-g4f1b From 5688d58688318cecaf9decdde014635f3a27760f Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Tue, 13 Mar 2012 19:29:29 +0100 Subject: Add support for buffer string email attachment. --- system/libraries/Email.php | 58 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f30fe40b6..aec4957de 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,6 +83,8 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); + protected $_attach_source = array(); + protected $_attach_content = array(); protected $_protocols = array('mail', 'sendmail', 'smtp'); protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) protected $_bit_depths = array('7bit', '8bit'); @@ -171,6 +173,8 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); + $this->_attach_source = array(); + $this->_attach_content = array(); } return $this; @@ -411,6 +415,23 @@ class CI_Email { $this->_attach_name[] = array($filename, $newname); $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_source[] = 'file'; + return $this; + } + + /** + * Assign string attachments + * + * @param string + * @return object + */ + public function string_attach($str, $filename, $mime, $disposition = 'attachment') + { + $this->_attach_name[] = $filename; + $this->_attach_type[] = $mime; + $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_source[] = 'string'; + $this->_attach_content[] = $str; return $this; } @@ -1048,29 +1069,38 @@ class CI_Email { $filename = $this->_attach_name[$i][0]; $basename = (is_null($this->_attach_name[$i][1])) ? basename($filename) : $this->_attach_name[$i][1]; $ctype = $this->_attach_type[$i]; + $file_content = ''; - if ( ! file_exists($filename)) + if($this->_attach_source[$i] == 'file') { - $this->_set_error_message('lang:email_attachment_missing', $filename); - return FALSE; - } + if ( ! file_exists($filename)) + { + $this->_set_error_message('lang:email_attachment_missing', $filename); + return FALSE; + } + $file = filesize($filename) +1; + + if ( ! $fp = fopen($filename, FOPEN_READ)) + { + $this->_set_error_message('lang:email_attachment_unreadable', $filename); + return FALSE; + } + + $file_content = fread($fp, $file); + fclose($fp); + } + else + { + $file_content =& $this->_attach_content[$i]; + } $attachment[$z++] = "--".$this->_atc_boundary.$this->newline . "Content-type: ".$ctype."; " . "name=\"".$basename."\"".$this->newline . "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline . "Content-Transfer-Encoding: base64".$this->newline; - $file = filesize($filename) +1; - - if ( ! $fp = fopen($filename, FOPEN_READ)) - { - $this->_set_error_message('lang:email_attachment_unreadable', $filename); - return FALSE; - } - - $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file))); - fclose($fp); + $attachment[$z++] = chunk_split(base64_encode($file_content)); } $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--"; -- cgit v1.2.3-24-g4f1b From c2acb23b5148182893583b495f451c7a28950c23 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Wed, 14 Mar 2012 21:24:00 +0400 Subject: Fix comment typo in Form_validation.php --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 9491f354c..3e0c72e84 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -101,7 +101,7 @@ class CI_Form_validation { return $this; } - // If an array was passed via the first parameter instead of indidual string + // If an array was passed via the first parameter instead of individual string // values we cycle through it and recursively call this function. if (is_array($field)) { -- cgit v1.2.3-24-g4f1b From 5a98a3dda56f6167f8241a7bc7d1c8784d98ccf9 Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Thu, 15 Mar 2012 12:00:44 +0100 Subject: Email class: move string_attach() to attach() and add documentation --- system/libraries/Email.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index aec4957de..df03eaaf6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,7 +83,6 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); - protected $_attach_source = array(); protected $_attach_content = array(); protected $_protocols = array('mail', 'sendmail', 'smtp'); protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) @@ -173,7 +172,6 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); - $this->_attach_source = array(); $this->_attach_content = array(); } @@ -410,27 +408,11 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $disposition = '', $newname = NULL) + public function attach($filename, $str = '', $mime = '', $disposition = '', $newname = NULL) { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); + $this->_attach_type[] = ($mime === '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_source[] = 'file'; - return $this; - } - - /** - * Assign string attachments - * - * @param string - * @return object - */ - public function string_attach($str, $filename, $mime, $disposition = 'attachment') - { - $this->_attach_name[] = $filename; - $this->_attach_type[] = $mime; - $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_source[] = 'string'; $this->_attach_content[] = $str; return $this; } @@ -1071,7 +1053,7 @@ class CI_Email { $ctype = $this->_attach_type[$i]; $file_content = ''; - if($this->_attach_source[$i] == 'file') + if ($this->_attach_content[$i] === '') { if ( ! file_exists($filename)) { -- cgit v1.2.3-24-g4f1b From df59c687a2243142e6da9d7b904523a1b91ca09b Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Thu, 15 Mar 2012 16:03:58 +0100 Subject: Email class: adjust documentation and make the code backward compatible --- system/libraries/Email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index df03eaaf6..7320ea566 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -408,10 +408,10 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $str = '', $mime = '', $disposition = '', $newname = NULL) + public function attach($filename, $disposition = '', $str = '', $mime = '', $newname = NULL) { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = ($mime === '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; + $this->_attach_type[] = ($mime == '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters $this->_attach_content[] = $str; return $this; -- cgit v1.2.3-24-g4f1b From 4ad0fd86e8dc6dba74305dbb0c88c593b46a19a2 Mon Sep 17 00:00:00 2001 From: freewil Date: Tue, 13 Mar 2012 22:37:42 -0400 Subject: add support for httponly cookies --- system/libraries/Session.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 0b9d45b2a..0c8d46591 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -48,6 +48,7 @@ class CI_Session { public $cookie_path = ''; public $cookie_domain = ''; public $cookie_secure = FALSE; + public $cookie_httponly = FALSE; public $sess_time_to_update = 300; public $encryption_key = ''; public $flashdata_key = 'flash'; @@ -72,7 +73,7 @@ class CI_Session { // Set all the session preferences, which can either be set // manually via the $params array above or via the config file - foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) + foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) { $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); } @@ -666,13 +667,14 @@ class CI_Session { // Set the cookie setcookie( - $this->sess_cookie_name, - $cookie_data, - $expire, - $this->cookie_path, - $this->cookie_domain, - $this->cookie_secure - ); + $this->sess_cookie_name, + $cookie_data, + $expire, + $this->cookie_path, + $this->cookie_domain, + $this->cookie_secure, + $this->cookie_httponly + ); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0336dc228c84695ec75fc8dccedac354d1556de9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:34:28 +0200 Subject: Remove EOF newline --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index aa838eeca..c9810fab9 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -412,4 +412,4 @@ class CI_Zip { } /* End of file Zip.php */ -/* Location: ./system/libraries/Zip.php */ +/* Location: ./system/libraries/Zip.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b455294bc404e41a65f8c9260837e76ee1cc9bda Mon Sep 17 00:00:00 2001 From: leandronf Date: Wed, 21 Mar 2012 23:54:26 -0300 Subject: (DSN) Delivery status notification feature --- system/libraries/Email.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f30fe40b6..d870f9782 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,6 +59,7 @@ class CI_Email { public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. + var $dsn = FALSE"; // Delivery Status Notification public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch @@ -1567,9 +1568,11 @@ class CI_Email { $resp = 250; break; case 'to' : - - $this->_send_data('RCPT TO:<'.$data.'>'); - + + if($this->dsn) + $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + else + $this->_send_data('RCPT TO:<'.$data.'>'); $resp = 250; break; case 'data' : -- cgit v1.2.3-24-g4f1b From 7686c1208cf1b0d9e1f4e522fff8a4b4646b7a2d Mon Sep 17 00:00:00 2001 From: leandronf Date: Thu, 22 Mar 2012 08:07:31 -0300 Subject: Update system/libraries/Email.php --- system/libraries/Email.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index d870f9782..8f383c939 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,7 +59,7 @@ class CI_Email { public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. - var $dsn = FALSE"; // Delivery Status Notification + public $dsn = FALSE; // Delivery Status Notification public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch @@ -1569,10 +1569,14 @@ class CI_Email { break; case 'to' : - if($this->dsn) + if ($this->dsn) + { $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + } else + { $this->_send_data('RCPT TO:<'.$data.'>'); + } $resp = 250; break; case 'data' : -- cgit v1.2.3-24-g4f1b From c3b36f4c6b8e8b15c96d6653ebdf07c76eb57d9e Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Mon, 26 Mar 2012 10:27:17 +0200 Subject: Centralize handling of attach() function for both real file and buffer string. Update documentation. --- system/libraries/Email.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 7320ea566..7429035f8 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,7 +83,6 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); - protected $_attach_content = array(); protected $_protocols = array('mail', 'sendmail', 'smtp'); protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) protected $_bit_depths = array('7bit', '8bit'); @@ -172,7 +171,6 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); - $this->_attach_content = array(); } return $this; @@ -408,12 +406,11 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $disposition = '', $str = '', $mime = '', $newname = NULL) + public function attach($filename, $disposition = '', $newname = NULL, $mime = '') { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = ($mime == '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_content[] = $str; + $this->_attach_type[] = $mime; return $this; } @@ -1053,7 +1050,7 @@ class CI_Email { $ctype = $this->_attach_type[$i]; $file_content = ''; - if ($this->_attach_content[$i] === '') + if ($this->_attach_type[$i] == '') { if ( ! file_exists($filename)) { @@ -1069,6 +1066,7 @@ class CI_Email { return FALSE; } + $ctype = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); $file_content = fread($fp, $file); fclose($fp); } -- cgit v1.2.3-24-g4f1b From e684bdac2d6282e3b9a5c57e1006d5ed1664f647 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 13:47:29 +0300 Subject: Clear some spaces and fix some inconsistencies in the Zip library and system/helpers/ files --- system/libraries/Zip.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index e33eb4e5a..12f3a5e59 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -1,13 +1,13 @@ -now); - + $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; -- cgit v1.2.3-24-g4f1b From c4d979c45297ecc021e385a96dc3bae04a4cdbc4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:53:00 +0300 Subject: Switch private methods to protected and cleanup the Ftp library --- system/libraries/Ftp.php | 109 ++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 68 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 4d96c00cc..8aa1650d2 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * FTP Class * @@ -42,16 +40,11 @@ class CI_FTP { public $username = ''; public $password = ''; public $port = 21; - public $passive = TRUE; + public $passive = TRUE; public $debug = FALSE; - public $conn_id = FALSE; + public $conn_id = FALSE; - /** - * Constructor - Sets Preferences - * - * The constructor can be passed an array of config values - */ public function __construct($config = array()) { if (count($config) > 0) @@ -59,7 +52,7 @@ class CI_FTP { $this->initialize($config); } - log_message('debug', "FTP Class Initialized"); + log_message('debug', 'FTP Class Initialized'); } // -------------------------------------------------------------------- @@ -67,7 +60,6 @@ class CI_FTP { /** * Initialize preferences * - * @access public * @param array * @return void */ @@ -90,7 +82,6 @@ class CI_FTP { /** * FTP Connect * - * @access public * @param array the connection values * @return bool */ @@ -133,10 +124,9 @@ class CI_FTP { /** * FTP Login * - * @access private * @return bool */ - private function _login() + protected function _login() { return @ftp_login($this->conn_id, $this->username, $this->password); } @@ -146,10 +136,9 @@ class CI_FTP { /** * Validates the connection ID * - * @access private * @return bool */ - private function _is_conn() + protected function _is_conn() { if ( ! is_resource($this->conn_id)) { @@ -164,17 +153,15 @@ class CI_FTP { // -------------------------------------------------------------------- - /** * Change directory * * The second parameter lets us momentarily turn off debugging so that * this function can be used to test for the existence of a folder - * without throwing an error. There's no FTP equivalent to is_dir() + * without throwing an error. There's no FTP equivalent to is_dir() * so we do it by trying to change to a particular directory. * Internally, this parameter is only used by the "mirror" function below. * - * @access public * @param string * @param bool * @return bool @@ -190,7 +177,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE AND $supress_debug == FALSE) + if ($this->debug == TRUE && $supress_debug == FALSE) { $this->_error('ftp_unable_to_changedir'); } @@ -205,8 +192,8 @@ class CI_FTP { /** * Create a directory * - * @access public * @param string + * @param int * @return bool */ public function mkdir($path = '', $permissions = NULL) @@ -230,7 +217,7 @@ class CI_FTP { // Set file permissions if needed if ( ! is_null($permissions)) { - $this->chmod($path, (int)$permissions); + $this->chmod($path, (int) $permissions); } return TRUE; @@ -241,10 +228,10 @@ class CI_FTP { /** * Upload a file to the server * - * @access public * @param string * @param string * @param string + * @param int * @return bool */ public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL) @@ -284,7 +271,7 @@ class CI_FTP { // Set file permissions if needed if ( ! is_null($permissions)) { - $this->chmod($rempath, (int)$permissions); + $this->chmod($rempath, (int) $permissions); } return TRUE; @@ -295,7 +282,6 @@ class CI_FTP { /** * Download a file from a remote server to the local server * - * @access public * @param string * @param string * @param string @@ -337,7 +323,6 @@ class CI_FTP { /** * Rename (or move) a file * - * @access public * @param string * @param string * @param bool @@ -369,7 +354,6 @@ class CI_FTP { /** * Move a file * - * @access public * @param string * @param string * @return bool @@ -384,7 +368,6 @@ class CI_FTP { /** * Rename (or move) a file * - * @access public * @param string * @return bool */ @@ -415,7 +398,6 @@ class CI_FTP { * Delete a folder and recursively delete everything (including sub-folders) * containted within it. * - * @access public * @param string * @return bool */ @@ -427,11 +409,11 @@ class CI_FTP { } // Add a trailing slash to the file path if needed - $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath); + $filepath = preg_replace('/(.+?)\/*$/', '\\1/', $filepath); $list = $this->list_files($filepath); - if ($list !== FALSE AND count($list) > 0) + if ($list !== FALSE && count($list) > 0) { foreach ($list as $item) { @@ -463,7 +445,6 @@ class CI_FTP { /** * Set file permissions * - * @access public * @param string the file path * @param string the permissions * @return bool @@ -494,7 +475,6 @@ class CI_FTP { /** * FTP List files in the specified directory * - * @access public * @return array */ public function list_files($path = '.') @@ -512,11 +492,11 @@ class CI_FTP { /** * Read a directory and recreate it remotely * - * This function recursively reads a folder and everything it contains (including - * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure - * of the original file path will be recreated on the server. + * This function recursively reads a folder and everything it contains + * (including sub-folders) and creates a mirror via FTP based on it. + * Whatever the directory structure of the original file path will be + * recreated on the server. * - * @access public * @param string path to source with trailing slash * @param string path to destination - include the base folder with trailing slash * @return bool @@ -532,7 +512,7 @@ class CI_FTP { if ($fp = @opendir($locpath)) { // Attempt to open the remote file path and try to create it, if it doesn't exist - if ( ! $this->changedir($rempath, TRUE) AND ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))) + if ( ! $this->changedir($rempath, TRUE) && ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))) { return FALSE; } @@ -542,9 +522,9 @@ class CI_FTP { { if (@is_dir($locpath.$file) && $file[0] !== '.') { - $this->mirror($locpath.$file."/", $rempath.$file."/"); + $this->mirror($locpath.$file.'/', $rempath.$file.'/'); } - elseif ($file[0] !== ".") + elseif ($file[0] !== '.') { // Get the file extension so we can se the upload type $ext = $this->_getext($file); @@ -565,11 +545,10 @@ class CI_FTP { /** * Extract the file extension * - * @access private * @param string * @return string */ - private function _getext($filename) + protected function _getext($filename) { if (FALSE === strpos($filename, '.')) { @@ -580,36 +559,34 @@ class CI_FTP { return end($x); } - // -------------------------------------------------------------------- /** * Set the upload type * - * @access private * @param string * @return string */ - private function _settype($ext) + protected function _settype($ext) { $text_types = array( - 'txt', - 'text', - 'php', - 'phps', - 'php4', - 'js', - 'css', - 'htm', - 'html', - 'phtml', - 'shtml', - 'log', - 'xml' - ); - - - return (in_array($ext, $text_types)) ? 'ascii' : 'binary'; + 'txt', + 'text', + 'php', + 'phps', + 'php4', + 'js', + 'css', + 'htm', + 'html', + 'phtml', + 'shtml', + 'log', + 'xml' + ); + + + return in_array($ext, $text_types) ? 'ascii' : 'binary'; } // ------------------------------------------------------------------------ @@ -617,7 +594,6 @@ class CI_FTP { /** * Close the connection * - * @access public * @return bool */ public function close() @@ -635,20 +611,17 @@ class CI_FTP { /** * Display error message * - * @access private * @param string * @return void */ - private function _error($line) + protected function _error($line) { $CI =& get_instance(); $CI->lang->load('ftp'); show_error($CI->lang->line($line)); } - } -// END FTP Class /* End of file Ftp.php */ -/* Location: ./system/libraries/Ftp.php */ +/* Location: ./system/libraries/Ftp.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6f042ccc261645530e897bb8c390eae0640bacb0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:58:33 +0300 Subject: Switch private methods and properties to protected and cleanup the Cart library --- system/libraries/Cart.php | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 60a1e52fe..305960f5f 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Shopping Cart Class * @@ -41,12 +39,11 @@ class CI_Cart { // These are the regular expression rules that we use to validate the product ID and product name public $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods public $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods - public $product_name_safe = true; // only allow safe product names - - // Private variables. Do not change! - private $CI; - private $_cart_contents = array(); + public $product_name_safe = TRUE; // only allow safe product names + // Protected variables. Do not change! + protected $CI; + protected $_cart_contents = array(); /** * Shopping Class Constructor @@ -72,7 +69,7 @@ class CI_Cart { $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0); } - log_message('debug', "Cart Class Initialized"); + log_message('debug', 'Cart Class Initialized'); } // -------------------------------------------------------------------- @@ -80,7 +77,6 @@ class CI_Cart { /** * Insert items into the cart and save it to the session table * - * @access public * @param array * @return bool */ @@ -110,7 +106,7 @@ class CI_Cart { { foreach ($items as $val) { - if (is_array($val) AND isset($val['id'])) + if (is_array($val) && isset($val['id'])) { if ($this->_insert($val)) { @@ -135,7 +131,6 @@ class CI_Cart { /** * Insert * - * @access private * @param array * @return bool */ @@ -213,7 +208,7 @@ class CI_Cart { // Internally, we need to treat identical submissions, but with different options, as a unique product. // Our solution is to convert the options array to a string and MD5 it along with the product ID. // This becomes the unique "row ID" - if (isset($items['options']) AND count($items['options']) > 0) + if (isset($items['options']) && count($items['options']) > 0) { $rowid = md5($items['id'].implode('', $items['options'])); } @@ -249,7 +244,6 @@ class CI_Cart { * changes to the quantity before checkout. That array must contain the * product ID and quantity for each item. * - * @access public * @param array * @param string * @return bool @@ -308,11 +302,10 @@ class CI_Cart { * changes to the quantity before checkout. That array must contain the * product ID and quantity for each item. * - * @access private * @param array * @return bool */ - private function _update($items = array()) + protected function _update($items = array()) { // Without these array indexes there is nothing we can do if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']])) @@ -348,10 +341,9 @@ class CI_Cart { /** * Save the cart array to the session DB * - * @access private * @return bool */ - private function _save_cart() + protected function _save_cart() { // Lets add up the individual prices and set the cart sub-total $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0; @@ -390,8 +382,7 @@ class CI_Cart { /** * Cart Total * - * @access public - * @return integer + * @return int */ public function total() { @@ -405,8 +396,7 @@ class CI_Cart { * * Removes an item from the cart * - * @access public - * @return boolean + * @return bool */ public function remove($rowid) { @@ -423,8 +413,7 @@ class CI_Cart { * * Returns the total item count * - * @access public - * @return integer + * @return int */ public function total_items() { @@ -438,7 +427,6 @@ class CI_Cart { * * Returns the entire cart array * - * @access public * @return array */ public function contents($newest_first = FALSE) @@ -461,7 +449,6 @@ class CI_Cart { * Returns TRUE if the rowid passed to this function correlates to an item * that has options associated with it. * - * @access public * @return bool */ public function has_options($rowid = '') @@ -476,7 +463,7 @@ class CI_Cart { * * Returns the an array of options, for a particular product row ID * - * @access public + * @param int * @return array */ public function product_options($rowid = '') @@ -491,7 +478,7 @@ class CI_Cart { * * Returns the supplied number with commas and a decimal point. * - * @access public + * @param float * @return string */ public function format_number($n = '') @@ -514,7 +501,6 @@ class CI_Cart { * * Empties the cart and kills the session * - * @access public * @return void */ public function destroy() @@ -523,9 +509,7 @@ class CI_Cart { $this->CI->session->unset_userdata('cart_contents'); } - } -// END Cart Class /* End of file Cart.php */ -/* Location: ./system/libraries/Cart.php */ +/* Location: ./system/libraries/Cart.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 74476e1c4371bb7dc8c9727898026687d875284f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:03:40 +0300 Subject: Switch private methods and properties to protected and cleanup the Parser library --- system/libraries/Cart.php | 2 +- system/libraries/Parser.php | 47 ++++++++++++++++----------------------------- 2 files changed, 18 insertions(+), 31 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 305960f5f..ca7be555e 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -134,7 +134,7 @@ class CI_Cart { * @param array * @return bool */ - private function _insert($items = array()) + protected function _insert($items = array()) { // Was any cart data passed? No? Bah... if ( ! is_array($items) OR count($items) === 0) diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 290e17fc0..d1b5b764b 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Parser Class * @@ -41,15 +39,14 @@ class CI_Parser { public $l_delim = '{'; public $r_delim = '}'; public $object; - private $CI; + protected $CI; /** - * Parse a template + * Parse a template * * Parses pseudo-variables contained in the specified template view, * replacing them with the data in the second param * - * @access public * @param string * @param array * @param bool @@ -66,12 +63,11 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a String + * Parse a String * * Parses pseudo-variables contained in the specified string, * replacing them with the data in the second param * - * @access public * @param string * @param array * @param bool @@ -85,18 +81,17 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a template + * Parse a template * * Parses pseudo-variables contained in the specified template, * replacing them with the data in the second param * - * @access private * @param string * @param array * @param bool * @return string */ - private function _parse($template, $data, $return = FALSE) + protected function _parse($template, $data, $return = FALSE) { if ($template == '') { @@ -126,9 +121,8 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Set the left/right variable delimiters + * Set the left/right variable delimiters * - * @access public * @param string * @param string * @return void @@ -142,15 +136,14 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a single key/value + * Parse a single key/value * - * @access private * @param string * @param string * @param string * @return string */ - private function _parse_single($key, $val, $string) + protected function _parse_single($key, $val, $string) { return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string); } @@ -158,17 +151,16 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Parse a tag pair + * Parse a tag pair * - * Parses tag pairs: {some_tag} string... {/some_tag} + * Parses tag pairs: {some_tag} string... {/some_tag} * - * @access private * @param string * @param array * @param string * @return string */ - private function _parse_pair($variable, $data, $string) + protected function _parse_pair($variable, $data, $string) { if (FALSE === ($match = $this->_match_pair($string, $variable))) { @@ -200,25 +192,20 @@ class CI_Parser { // -------------------------------------------------------------------- /** - * Matches a variable pair + * Matches a variable pair * - * @access private * @param string * @param string * @return mixed */ - private function _match_pair($string, $variable) + protected function _match_pair($string, $variable) { - if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match)) - { - return FALSE; - } - - return $match; + return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s', + $string, $match) + ? $match : FALSE; } } -// END Parser Class /* End of file Parser.php */ -/* Location: ./system/libraries/Parser.php */ +/* Location: ./system/libraries/Parser.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b24b033a9c285c98802fbd7bf16d486e355e2f97 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:34:39 +0300 Subject: Switch private methods and properties to protected and cleanup the Cache library and drivers --- system/libraries/Cache/Cache.php | 109 +++++++++------------ system/libraries/Cache/drivers/Cache_apc.php | 43 ++++---- system/libraries/Cache/drivers/Cache_dummy.php | 37 +++---- system/libraries/Cache/drivers/Cache_file.php | 42 ++++---- system/libraries/Cache/drivers/Cache_memcached.php | 57 +++++------ system/libraries/Cache/drivers/Cache_wincache.php | 7 +- 6 files changed, 125 insertions(+), 170 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 7642a5270..f98241617 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Caching Class * @@ -50,11 +48,37 @@ class CI_Cache extends CI_Driver_Library { protected $_adapter = 'dummy'; protected $_backup_driver; + /** + * Constructor + * + * Initialize class properties based on the configuration array. + * + * @param array + * @return void + */ public function __construct($config = array()) { - if ( ! empty($config)) + $default_config = array( + 'adapter', + 'memcached' + ); + + foreach ($default_config as $key) { - $this->_initialize($config); + 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']; + } } } @@ -63,11 +87,11 @@ class CI_Cache extends CI_Driver_Library { /** * Get * - * Look for a value in the cache. If it exists, return the data + * 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 + * @param string + * @return mixed value that is stored/FALSE on failure */ public function get($id) { @@ -79,11 +103,10 @@ class CI_Cache extends CI_Driver_Library { /** * 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 + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -95,8 +118,8 @@ class CI_Cache extends CI_Driver_Library { /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @return boolean true on success/false on failure + * @param mixed unique identifier of the item in the cache + * @return bool true on success/false on failure */ public function delete($id) { @@ -108,7 +131,7 @@ class CI_Cache extends CI_Driver_Library { /** * Clean the cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -120,8 +143,8 @@ class CI_Cache extends CI_Driver_Library { /** * Cache Info * - * @param string user/filehits - * @return mixed array on success, false on failure + * @param string user/filehits + * @return mixed array on success, false on failure */ public function cache_info($type = 'user') { @@ -133,8 +156,8 @@ class CI_Cache extends CI_Driver_Library { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed return value from child method + * @param mixed key to get cache metadata on + * @return mixed return value from child method */ public function get_metadata($id) { @@ -143,47 +166,11 @@ class CI_Cache extends CI_Driver_Library { // ------------------------------------------------------------------------ - /** - * 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 + * @param string The driver to test. + * @return array */ public function is_supported($driver) { @@ -202,8 +189,8 @@ class CI_Cache extends CI_Driver_Library { /** * __get() * - * @param child - * @return object + * @param child + * @return object */ public function __get($child) { @@ -217,9 +204,7 @@ class CI_Cache extends CI_Driver_Library { return $obj; } - // ------------------------------------------------------------------------ } -// End Class /* End of file Cache.php */ -/* Location: ./system/libraries/Cache/Cache.php */ +/* Location: ./system/libraries/Cache/Cache.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index c387a30fc..59ab67533 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter APC Caching Class * @@ -36,23 +34,22 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_apc extends CI_Driver { /** * Get * - * Look for a value in the cache. If it exists, return the data + * 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 + * @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; + return is_array($data) ? $data[0] : FALSE; } // ------------------------------------------------------------------------ @@ -60,11 +57,11 @@ class CI_Cache_apc extends CI_Driver { /** * Cache Save * - * @param string Unique Key - * @param mixed Data to store - * @param int Length of time (in seconds) to cache the data + * @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 + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -77,8 +74,8 @@ class CI_Cache_apc extends CI_Driver { /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @param boolean true on success/false on failure + * @param mixed unique identifier of the item in the cache + * @param bool true on success/false on failure */ public function delete($id) { @@ -90,7 +87,7 @@ class CI_Cache_apc extends CI_Driver { /** * Clean the cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -102,8 +99,8 @@ class CI_Cache_apc extends CI_Driver { /** * Cache Info * - * @param string user/filehits - * @return mixed array on success, false on failure + * @param string user/filehits + * @return mixed array on success, false on failure */ public function cache_info($type = NULL) { @@ -115,8 +112,8 @@ class CI_Cache_apc extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed array on success/false on failure + * @param mixed key to get cache metadata on + * @return mixed array on success/false on failure */ public function get_metadata($id) { @@ -142,10 +139,12 @@ class CI_Cache_apc extends CI_Driver { * is_supported() * * Check to see if APC is available on this system, bail if it isn't. + * + * @return bool */ public function is_supported() { - if ( ! extension_loaded('apc') OR ini_get('apc.enabled') != "1") + if ( ! extension_loaded('apc') OR ! (bool) @ini_get('apc.enabled')) { log_message('error', 'The APC PHP extension must be loaded to use APC Cache.'); return FALSE; @@ -154,11 +153,7 @@ class CI_Cache_apc extends CI_Driver { return TRUE; } - // ------------------------------------------------------------------------ - - } -// End Class /* End of file Cache_apc.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index c9767e401..e8b791c5b 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Dummy Caching Class * @@ -36,7 +34,6 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_dummy extends CI_Driver { /** @@ -44,8 +41,8 @@ class CI_Cache_dummy extends CI_Driver { * * Since this is the dummy class, it's always going to return FALSE. * - * @param string - * @return Boolean FALSE + * @param string + * @return bool FALSE */ public function get($id) { @@ -57,11 +54,10 @@ class CI_Cache_dummy extends CI_Driver { /** * 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 + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * @return bool TRUE, Simulating success */ public function save($id, $data, $ttl = 60) { @@ -73,8 +69,8 @@ class CI_Cache_dummy extends CI_Driver { /** * Delete from Cache * - * @param mixed unique identifier of the item in the cache - * @param boolean TRUE, simulating success + * @param mixed unique identifier of the item in the cache + * @param bool TRUE, simulating success */ public function delete($id) { @@ -86,7 +82,7 @@ class CI_Cache_dummy extends CI_Driver { /** * Clean the cache * - * @return boolean TRUE, simulating success + * @return bool TRUE, simulating success */ public function clean() { @@ -98,8 +94,8 @@ class CI_Cache_dummy extends CI_Driver { /** * Cache Info * - * @param string user/filehits - * @return boolean FALSE + * @param string user/filehits + * @return bool FALSE */ public function cache_info($type = NULL) { @@ -111,8 +107,8 @@ class CI_Cache_dummy extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return boolean FALSE + * @param mixed key to get cache metadata on + * @return bool FALSE */ public function get_metadata($id) { @@ -125,17 +121,14 @@ class CI_Cache_dummy extends CI_Driver { * Is this caching driver supported on the system? * Of course this one is. * - * @return TRUE; + * @return bool TRUE */ public function is_supported() { return TRUE; } - // ------------------------------------------------------------------------ - } -// End Class /* End of file Cache_dummy.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index c0be0def4..dd27aa90e 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Memcached Caching Class * @@ -36,14 +34,10 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_file extends CI_Driver { protected $_cache_path; - /** - * Constructor - */ public function __construct() { $CI =& get_instance(); @@ -57,8 +51,8 @@ class CI_Cache_file extends CI_Driver { /** * Fetch from cache * - * @param mixed unique key id - * @return mixed data on success/false on failure + * @param mixed unique key id + * @return mixed data on success/false on failure */ public function get($id) { @@ -83,11 +77,11 @@ class CI_Cache_file extends CI_Driver { /** * 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 + * @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 bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -111,12 +105,12 @@ class CI_Cache_file extends CI_Driver { /** * Delete from Cache * - * @param mixed unique identifier of item in cache - * @return boolean true on success/false on failure + * @param mixed unique identifier of item in cache + * @return bool true on success/false on failure */ public function delete($id) { - return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE; + return file_exists($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE; } // ------------------------------------------------------------------------ @@ -124,7 +118,7 @@ class CI_Cache_file extends CI_Driver { /** * Clean the Cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -138,8 +132,8 @@ class CI_Cache_file extends CI_Driver { * * Not supported by file-based caching * - * @param string user/filehits - * @return mixed FALSE + * @param string user/filehits + * @return mixed FALSE */ public function cache_info($type = NULL) { @@ -151,8 +145,8 @@ class CI_Cache_file extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed FALSE on failure, array on success. + * @param mixed key to get cache metadata on + * @return mixed FALSE on failure, array on success. */ public function get_metadata($id) { @@ -188,16 +182,14 @@ class CI_Cache_file extends CI_Driver { * * In the file driver, check to see that the cache directory is indeed writable * - * @return boolean + * @return bool */ 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 */ +/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index b8f2d7e4c..1028c8fd5 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Memcached Caching Class * @@ -36,12 +34,11 @@ * @author EllisLab Dev Team * @link */ - class CI_Cache_memcached extends CI_Driver { - private $_memcached; // Holds the memcached object + protected $_memcached; // Holds the memcached object - protected $_memcache_conf = array( + protected $_memcache_conf = array( 'default' => array( 'default_host' => '127.0.0.1', 'default_port' => 11211, @@ -49,19 +46,17 @@ class CI_Cache_memcached extends CI_Driver { ) ); - // ------------------------------------------------------------------------ - /** * Fetch from cache * - * @param mixed unique key id - * @return mixed data on success/false on failure + * @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; + return is_array($data) ? $data[0] : FALSE; } // ------------------------------------------------------------------------ @@ -69,18 +64,18 @@ class CI_Cache_memcached extends CI_Driver { /** * Save * - * @param string unique identifier - * @param mixed data being cached - * @param int time to live - * @return boolean true on success, false on failure + * @param string unique identifier + * @param mixed data being cached + * @param int time to live + * @return bool true on success, false on failure */ public function save($id, $data, $ttl = 60) { - if (get_class($this->_memcached) == 'Memcached') + if (get_class($this->_memcached) === 'Memcached') { return $this->_memcached->set($id, array($data, time(), $ttl), $ttl); } - else if (get_class($this->_memcached) == 'Memcache') + elseif (get_class($this->_memcached) === 'Memcache') { return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl); } @@ -93,8 +88,8 @@ class CI_Cache_memcached extends CI_Driver { /** * Delete from Cache * - * @param mixed key to be deleted. - * @return boolean true on success, false on failure + * @param mixed key to be deleted. + * @return bool true on success, false on failure */ public function delete($id) { @@ -106,7 +101,7 @@ class CI_Cache_memcached extends CI_Driver { /** * Clean the Cache * - * @return boolean false on failure/true on success + * @return bool false on failure/true on success */ public function clean() { @@ -118,10 +113,9 @@ class CI_Cache_memcached extends CI_Driver { /** * Cache Info * - * @param null type not supported in memcached - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ - public function cache_info($type = NULL) + public function cache_info() { return $this->_memcached->getStats(); } @@ -131,8 +125,8 @@ class CI_Cache_memcached extends CI_Driver { /** * Get Cache Metadata * - * @param mixed key to get cache metadata on - * @return mixed FALSE on failure, array on success. + * @param mixed key to get cache metadata on + * @return mixed FALSE on failure, array on success. */ public function get_metadata($id) { @@ -156,8 +150,10 @@ class CI_Cache_memcached extends CI_Driver { /** * Setup memcached. + * + * @return bool */ - private function _setup_memcached() + protected function _setup_memcached() { // Try to load memcached server info from the config file. $CI =& get_instance(); @@ -179,14 +175,13 @@ class CI_Cache_memcached extends CI_Driver { { $this->_memcached = new Memcached(); } - else if (class_exists('Memcache')) + elseif (class_exists('Memcache')) { $this->_memcached = new Memcache(); } else { log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); - return FALSE; } @@ -237,23 +232,21 @@ class CI_Cache_memcached extends CI_Driver { * * Returns FALSE if memcached is not supported on the system. * If it is, we setup the memcached object & return TRUE + * + * @return bool */ public function is_supported() { if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) { log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); - return FALSE; } return $this->_setup_memcached(); } - // ------------------------------------------------------------------------ - } -// End Class /* End of file Cache_memcached.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index df619d4e6..b32e66a46 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Wincache Caching Class * @@ -39,7 +37,6 @@ * @author Mike Murkovic * @link */ - class CI_Cache_wincache extends CI_Driver { /** @@ -68,7 +65,7 @@ class CI_Cache_wincache extends CI_Driver { * @param string Unique Key * @param mixed Data to store * @param int Length of time (in seconds) to cache the data - * @return bool true on success/false on failure + * @return bool true on success/false on failure */ public function save($id, $data, $ttl = 60) { @@ -162,4 +159,4 @@ class CI_Cache_wincache extends CI_Driver { } /* End of file Cache_wincache.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6dbabb565e1411a2c62fa86d46b0b2bbb98ab9b0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:41:48 +0300 Subject: Switch a private property to protected and cleanup the Calendar library --- system/libraries/Calendar.php | 61 ++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 6c04de8a2..b6f145d95 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Calendar Class * @@ -40,7 +38,7 @@ */ class CI_Calendar { - private $CI; + protected $CI; public $lang; public $local_time; public $template = ''; @@ -54,6 +52,9 @@ class CI_Calendar { * Constructor * * Loads the calendar language file and sets the default time reference + * + * @param array + * @return void */ public function __construct($config = array()) { @@ -71,7 +72,7 @@ class CI_Calendar { $this->initialize($config); } - log_message('debug', "Calendar Class Initialized"); + log_message('debug', 'Calendar Class Initialized'); } // -------------------------------------------------------------------- @@ -81,7 +82,6 @@ class CI_Calendar { * * Accepts an associative array as input, containing display preferences * - * @access public * @param array config preferences * @return void */ @@ -101,9 +101,8 @@ class CI_Calendar { /** * Generate the calendar * - * @access public - * @param integer the year - * @param integer the month + * @param int the year + * @param int the month * @param array the data to be shown in the calendar cells * @return string */ @@ -147,7 +146,7 @@ class CI_Calendar { // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); $date = getdate($local_date); - $day = $start_day + 1 - $date["wday"]; + $day = $start_day + 1 - $date['wday']; while ($day > 1) { @@ -160,7 +159,7 @@ class CI_Calendar { $cur_month = date('m', $this->local_time); $cur_day = date('j', $this->local_time); - $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; + $is_current_month = ($cur_year == $year && $cur_month == $month); // Generate the template data array $this->parse_template(); @@ -172,7 +171,7 @@ class CI_Calendar { if ($this->show_next_prev == TRUE) { // Add a trailing slash to the URL if needed - $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url); + $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; @@ -213,21 +212,21 @@ class CI_Calendar { for ($i = 0; $i < 7; $i++) { - $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; - if ($day > 0 AND $day <= $total_days) + if ($day > 0 && $day <= $total_days) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } @@ -238,7 +237,7 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; $day++; } @@ -258,8 +257,7 @@ class CI_Calendar { * Generates a textual month name based on the numeric * month provided. * - * @access public - * @param integer the month + * @param int the month * @return string */ public function get_month_name($month) @@ -289,9 +287,8 @@ class CI_Calendar { * Get Day Names * * Returns an array of day names (Sunday, Monday, etc.) based - * on the type. Options: long, short, abrev + * on the type. Options: long, short, abrev * - * @access public * @param string * @return array */ @@ -333,9 +330,8 @@ class CI_Calendar { * For example, if you submit 13 as the month, the year will * increment and the month will become January. * - * @access public - * @param integer the month - * @param integer the year + * @param int the month + * @param int the year * @return array */ public function adjust_date($month, $year) @@ -370,10 +366,9 @@ class CI_Calendar { /** * Total days in a given month * - * @access public - * @param integer the month - * @param integer the year - * @return integer + * @param int the month + * @param int the year + * @return int */ public function get_total_days($month, $year) { @@ -387,7 +382,7 @@ class CI_Calendar { // Is the year a leap year? if ($month == 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0)) + if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) { return 29; } @@ -403,8 +398,7 @@ class CI_Calendar { * * This is used in the event that the user has not created their own template * - * @access public - * @return array + * @return array */ public function default_template() { @@ -441,7 +435,6 @@ class CI_Calendar { * Harvests the data within the template {pseudo-variables} * used to display the calendar * - * @access public * @return void */ public function parse_template() @@ -457,7 +450,7 @@ class CI_Calendar { foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val) { - if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) + if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) { $this->temp[$val] = $match[1]; } @@ -470,7 +463,5 @@ class CI_Calendar { } -// END CI_Calendar class - /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ +/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 5227837eca102b5aa2c14daa4201ffcb0a79f246 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 16:02:30 +0300 Subject: Remove access description lines and cleanup the Xmlrpcs library --- system/libraries/Xmlrpcs.php | 64 ++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 44 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index fc41444bc..6d270c2ea 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -54,10 +54,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc public $controller_obj; public $object = FALSE; - /** - * Constructor - */ - public function __construct($config=array()) + public function __construct($config = array()) { parent::__construct(); $this->set_system_methods(); @@ -67,7 +64,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $this->methods = array_merge($this->methods, $config['functions']); } - log_message('debug', "XML-RPC Server Class Initialized"); + log_message('debug', 'XML-RPC Server Class Initialized'); } // -------------------------------------------------------------------- @@ -75,7 +72,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Initialize Prefs and Serve * - * @access public * @param mixed * @return void */ @@ -107,7 +103,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Setting of System Methods * - * @access public * @return void */ public function set_system_methods() @@ -137,7 +132,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Main Server Function * - * @access public * @return void */ public function serve() @@ -145,8 +139,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc $r = $this->parseRequest(); $payload = 'xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response(); - header("Content-Type: text/xml"); - header("Content-Length: ".strlen($payload)); + header('Content-Type: text/xml'); + header('Content-Length: '.strlen($payload)); exit($payload); } @@ -155,7 +149,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Add Method to Class * - * @access public * @param string method name * @param string function * @param string signature @@ -176,7 +169,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Parse Server Request * - * @access public * @param string data * @return object xmlrpc response */ @@ -198,7 +190,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- $parser = xml_parser_create($this->xmlrpc_defencoding); - $parser_object = new XML_RPC_Message("filler"); + $parser_object = new XML_RPC_Message('filler'); $parser_object->xh[$parser] = array( 'isf' => 0, @@ -215,7 +207,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc xml_set_character_data_handler($parser, 'character_data'); //xml_set_default_handler($parser, 'default_handler'); - //------------------------------------- // PARSE + PROCESS XML DATA //------------------------------------- @@ -245,7 +236,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { if ($this->debug === TRUE) { - $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n"; + $plist .= $i.' - '.print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE).";\n"; } $m->addParam($parser_object->xh[$parser]['params'][$i]); @@ -276,7 +267,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Executes the Method * - * @access protected * @param object * @return mixed */ @@ -305,7 +295,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // Check for Method (and Object) //------------------------------------- - $method_parts = explode(".", $this->methods[$methName]['function']); + $method_parts = explode('.', $this->methods[$methName]['function']); $objectCall = (isset($method_parts[1]) && $method_parts[1] != ''); if ($system_call === TRUE) @@ -315,14 +305,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } } - else + elseif (($objectCall && ! is_callable(array($method_parts[0], $method_parts[1]))) + OR ( ! $objectCall && ! is_callable($this->methods[$methName]['function'])) + ) { - if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1]))) - OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function'])) - ) - { - return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); - } + return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } //------------------------------------- @@ -351,7 +338,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['incorrect_params'], $this->xmlrpcstr['incorrect_params'] . - ": Wanted {$wanted}, got {$pt} at param {$pno})"); + ': Wanted '.$wanted.', got '.$pt.' at param '.$pno.')'); } } } @@ -393,7 +380,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: List Methods * - * @access public * @param mixed * @return object */ @@ -409,7 +395,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc foreach ($this->system_methods as $key => $value) { - $output[]= new XML_RPC_Values($key, 'string'); + $output[] = new XML_RPC_Values($key, 'string'); } $v->addArray($output); @@ -421,7 +407,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: Return Signature for Method * - * @access public * @param mixed * @return object */ @@ -447,18 +432,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc } $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')); + + return new XML_RPC_Response(new XML_RPC_Values($sigs, 'array')); } + + return 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; + + return new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } // -------------------------------------------------------------------- @@ -466,7 +447,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: Doc String for Method * - * @access public * @param mixed * @return object */ @@ -492,7 +472,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Server Function: Multi-call * - * @access public * @param mixed * @return object */ @@ -536,7 +515,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Multi-call Function: Error Handling * - * @access public * @param mixed * @return object */ @@ -556,7 +534,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Multi-call Function: Processes method * - * @access public * @param mixed * @return object */ @@ -610,7 +587,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc } } -// END XML_RPC_Server class /* End of file Xmlrpcs.php */ -/* Location: ./system/libraries/Xmlrpcs.php */ +/* Location: ./system/libraries/Xmlrpcs.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From d69082b8af130ac74806203140a391fc8ca18b82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 16:14:26 +0300 Subject: Remove access description lines and cleanup the Typography library --- system/libraries/Typography.php | 53 ++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 65e30b089..21bbad038 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -25,13 +25,11 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Typography Class * - * - * @access protected + * @package CodeIgniter + * @subpackage Libraries * @category Helpers * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/typography.html @@ -67,7 +65,6 @@ class CI_Typography { * - Converts double dashes into em-dashes. * - Converts two spaces into entities * - * @access public * @param string * @param bool whether to reduce more then two consecutive newlines to two * @return string @@ -94,15 +91,12 @@ class CI_Typography { // HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed $html_comments = array(); - if (strpos($str, '", - "'", - "<", - ">", - '"', - '&', - '$', - '=', - ';', - '?', - '/', - "%20", - "%22", - "%3c", // < - "%253c", // < - "%3e", // > - "%0e", // > - "%28", // ( - "%29", // ) - "%2528", // ( - "%26", // & - "%24", // $ - "%3f", // ? - "%3b", // ; - "%3d" // = - ); - - $filename = str_replace($bad, '', $filename); - - return stripslashes($filename); + '', + "'", '"', + '<', '>', + '&', '$', + '=', + ';', + '?', + '/', + '%20', + '%22', + '%3c', // < + '%253c', // < + '%3e', // > + '%0e', // > + '%28', // ( + '%29', // ) + '%2528', // ( + '%26', // & + '%24', // $ + '%3f', // ? + '%3b', // ; + '%3d' // = + ); + + return stripslashes(str_replace($bad, '', $filename)); } // -------------------------------------------------------------------- @@ -847,7 +817,7 @@ class CI_Upload { $current = ini_get('memory_limit') * 1024 * 1024; // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output - // into scientific notation. number_format() ensures this number is an integer + // into scientific notation. number_format() ensures this number is an integer // http://bugs.php.net/bug.php?id=43053 $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', ''); @@ -857,8 +827,8 @@ class CI_Upload { // If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but // IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone - // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this - // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of + // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this + // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of // processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an // attempted XSS attack. @@ -932,7 +902,7 @@ class CI_Upload { */ public function display_errors($open = '

', $close = '

') { - return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; + return (count($this->error_msg) > 0) ? $open.implode($close.$open, $this->error_msg).$close : ''; } // -------------------------------------------------------------------- @@ -940,7 +910,7 @@ class CI_Upload { /** * List of Mime Types * - * This is a list of mime types. We use it to validate + * This is a list of mime types. We use it to validate * the "allowed types" set by the developer * * @param string @@ -952,7 +922,7 @@ class CI_Upload { if (count($this->mimes) == 0) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } @@ -966,10 +936,9 @@ class CI_Upload { } $this->mimes = $mimes; - unset($mimes); } - return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime]; + return isset($this->mimes[$mime]) ? $this->mimes[$mime] : FALSE; } // -------------------------------------------------------------------- @@ -1006,9 +975,7 @@ class CI_Upload { } } - $filename .= '.'.$ext; - - return $filename; + return $filename.'.'.$ext; } // -------------------------------------------------------------------- @@ -1129,10 +1096,7 @@ class CI_Upload { $this->file_type = $file['type']; } - // -------------------------------------------------------------------- - } -// END Upload Class /* End of file Upload.php */ -/* Location: ./system/libraries/Upload.php */ +/* Location: ./system/libraries/Upload.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 8486e9cbdd28e80b41e517afe786e9b0c917af8a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 20:24:12 +0300 Subject: Renamed (with an underscore prefix) and switched from private to protected properties in the Driver library --- system/libraries/Driver.php | 52 ++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 9a073b336..f409f47d4 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Driver Library Class * @@ -84,8 +82,8 @@ class CI_Driver_Library { // 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); + log_message('error', 'Unable to load the requested driver: '.$child_class); + show_error('Unable to load the requested driver: '.$child_class); } } @@ -96,15 +94,11 @@ class CI_Driver_Library { } // The requested driver isn't valid! - log_message('error', "Invalid driver requested: ".$child_class); - show_error("Invalid driver requested: ".$child_class); + log_message('error', 'Invalid driver requested: '.$child_class); + show_error('Invalid driver requested: '.$child_class); } - // -------------------------------------------------------------------- - } -// END CI_Driver_Library CLASS - /** * CodeIgniter Driver Class @@ -120,12 +114,12 @@ class CI_Driver_Library { */ class CI_Driver { - protected $parent; + protected $_parent; - private $methods = array(); - private $properties = array(); + protected $_methods = array(); + protected $_properties = array(); - private static $reflections = array(); + protected static $_reflections = array(); /** * Decorate @@ -137,14 +131,14 @@ class CI_Driver { */ public function decorate($parent) { - $this->parent = $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])) + if ( ! isset(self::$_reflections[$class_name])) { $r = new ReflectionObject($parent); @@ -152,7 +146,7 @@ class CI_Driver { { if ($method->isPublic()) { - $this->methods[] = $method->getName(); + $this->_methods[] = $method->getName(); } } @@ -160,15 +154,15 @@ class CI_Driver { { if ($prop->isPublic()) { - $this->properties[] = $prop->getName(); + $this->_properties[] = $prop->getName(); } } - self::$reflections[$class_name] = array($this->methods, $this->properties); + self::$_reflections[$class_name] = array($this->_methods, $this->_properties); } else { - list($this->methods, $this->properties) = self::$reflections[$class_name]; + list($this->_methods, $this->_properties) = self::$_reflections[$class_name]; } } @@ -179,16 +173,15 @@ class CI_Driver { * * 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)) + if (in_array($method, $this->_methods)) { - return call_user_func_array(array($this->parent, $method), $args); + return call_user_func_array(array($this->_parent, $method), $args); } $trace = debug_backtrace(); @@ -208,9 +201,9 @@ class CI_Driver { */ public function __get($var) { - if (in_array($var, $this->properties)) + if (in_array($var, $this->_properties)) { - return $this->parent->$var; + return $this->_parent->$var; } } @@ -227,16 +220,13 @@ class CI_Driver { */ public function __set($var, $val) { - if (in_array($var, $this->properties)) + if (in_array($var, $this->_properties)) { - $this->parent->$var = $val; + $this->_parent->$var = $val; } } - // -------------------------------------------------------------------- - } -// END CI_Driver CLASS /* End of file Driver.php */ -/* Location: ./system/libraries/Driver.php */ +/* Location: ./system/libraries/Driver.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 8f50b6b36cb743be8b70809279e501c20b8e38e2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Mar 2012 14:12:09 +0300 Subject: Some minor style changes in the XMLRPC class --- system/libraries/Xmlrpc.php | 57 +++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 32e2e523b..b6e6c810d 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -136,10 +136,9 @@ class CI_Xmlrpc { $this->initialize($config); - log_message('debug', "XML-RPC Class Initialized"); + log_message('debug', 'XML-RPC Class Initialized'); } - //------------------------------------- // Initialize Prefs //------------------------------------- @@ -163,7 +162,7 @@ class CI_Xmlrpc { // Take URL and parse it //------------------------------------- - public function server($url, $port=80) + public function server($url, $port = 80) { if (strpos($url, 'http') !== 0) { @@ -172,9 +171,9 @@ class CI_Xmlrpc { $parts = parse_url($url); - $path = ( ! isset($parts['path'])) ? '/' : $parts['path']; + $path = isset($parts['path']) ? $parts['path'] : '/'; - if (isset($parts['query']) && $parts['query'] != '') + if ( ! empty($parts['query'])) { $path .= '?'.$parts['query']; } @@ -244,7 +243,7 @@ class CI_Xmlrpc { { if (is_array($value) && array_key_exists(0, $value)) { - if ( ! isset($value[1]) OR ( ! isset($this->xmlrpcTypes[$value[1]]))) + if ( ! isset($value[1], $this->xmlrpcTypes[$value[1]])) { $temp = new XML_RPC_Values($value[0], (is_array($value[0]) ? 'array' : 'string')); } @@ -337,7 +336,6 @@ class CI_Xmlrpc { } // END XML_RPC Class - /** * XML-RPC Client class * @@ -355,7 +353,7 @@ class XML_RPC_Client extends CI_Xmlrpc public $timeout = 5; public $no_multicall = FALSE; - public function __construct($path, $server, $port=80) + public function __construct($path, $server, $port = 80) { parent::__construct(); @@ -383,7 +381,7 @@ class XML_RPC_Client extends CI_Xmlrpc if ( ! is_resource($fp)) { error_log($this->xmlrpcstr['http_error']); - $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']); + $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']); return $r; } @@ -394,12 +392,12 @@ class XML_RPC_Client extends CI_Xmlrpc } $r = "\r\n"; - $op = "POST {$this->path} HTTP/1.0$r" - . "Host: {$this->server}$r" - . "Content-Type: text/xml$r" - . "User-Agent: {$this->xmlrpcName}$r" - . "Content-Length: ".strlen($msg->payload)."$r$r" - . $msg->payload; + $op = 'POST '.$this->path.' HTTP/1.0'.$r + .'Host: '.$this->server.$r + .'Content-Type: text/xml'.$r + .'User-Agent: '.$this->xmlrpcName.$r + .'Content-Length: '.strlen($msg->payload).$r.$r + .$msg->payload; if ( ! fputs($fp, $op, strlen($op))) @@ -446,10 +444,10 @@ class XML_RPC_Response $this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8'); } } - else if ( ! is_object($val)) + elseif ( ! is_object($val)) { // programmer error, not an object - error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value."); + error_log("Invalid type '".gettype($val)."' (value: ".$val.') passed to XML_RPC_Response. Defaulting to empty value.'); $this->val = new XML_RPC_Values(); } else @@ -532,8 +530,6 @@ class XML_RPC_Response return $result; } - - //------------------------------------- // XML-RPC Object to PHP Types //------------------------------------- @@ -571,7 +567,6 @@ class XML_RPC_Response } } - //------------------------------------- // ISO-8601 time to server or UTC time //------------------------------------- @@ -605,7 +600,7 @@ class XML_RPC_Message extends CI_Xmlrpc public $params = array(); public $xh = array(); - public function __construct($method, $pars=0) + public function __construct($method, $pars = 0) { parent::__construct(); @@ -681,7 +676,7 @@ class XML_RPC_Message extends CI_Xmlrpc if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr= substr($data, 0, strpos($data, "\n")-1); - $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')'); + $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' (' . $errstr . ')'); return $r; } @@ -706,7 +701,6 @@ class XML_RPC_Message extends CI_Xmlrpc xml_set_character_data_handler($parser, 'character_data'); //xml_set_default_handler($parser, 'default_handler'); - //------------------------------------- // GET HEADERS //------------------------------------- @@ -765,14 +759,14 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "
";
+			echo '
';
 
 			if (count($this->xh[$parser]['headers'] > 0))
 			{
 				echo "---HEADERS---\n";
 				foreach ($this->xh[$parser]['headers'] as $header)
 				{
-					echo "$header\n";
+					echo $header."\n";
 				}
 				echo "---END HEADERS---\n\n";
 			}
@@ -850,7 +844,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 			if ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
 			{
 				$this->xh[$the_parser]['isf'] = 2;
-				$this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
+				$this->xh[$the_parser]['isf_reason'] = 'XML-RPC element $name cannot be child of '.$this->xh[$the_parser]['stack'][0];
 				return;
 			}
 		}
@@ -861,8 +855,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 			case 'ARRAY':
 				// Creates array for child elements
 
-				$cur_val = array('value' => array(),
-								 'type'	 => $name);
+				$cur_val = array('value' => array(), 'type' => $name);
 
 				array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
 			break;
@@ -925,7 +918,6 @@ class XML_RPC_Message extends CI_Xmlrpc
 	}
 	// END
 
-
 	//-------------------------------------
 	//  End Element Handler
 	//-------------------------------------
@@ -996,7 +988,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 					}
 					else
 					{
-						$this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
+						$this->xh[$the_parser]['value'] = (float) $this->xh[$the_parser]['ac'];
 					}
 				}
 				else
@@ -1145,7 +1137,6 @@ class XML_RPC_Message extends CI_Xmlrpc
 		return $parameters;
 	}
 
-
 	public function decode_message($param)
 	{
 		$kind = $param->kindOf();
@@ -1237,7 +1228,7 @@ class XML_RPC_Values extends CI_Xmlrpc
 
 		if ($type == $this->xmlrpcBoolean)
 		{
-			$val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == true && strcasecmp($val, 'false'))) ? 1 : 0;
+			$val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == TRUE && strcasecmp($val, 'false'))) ? 1 : 0;
 		}
 
 		if ($this->mytype == 2)
@@ -1383,4 +1374,4 @@ class XML_RPC_Values extends CI_Xmlrpc
 // END XML_RPC_Values Class
 
 /* End of file Xmlrpc.php */
-/* Location: ./system/libraries/Xmlrpc.php */
+/* Location: ./system/libraries/Xmlrpc.php */
\ No newline at end of file
-- 
cgit v1.2.3-24-g4f1b


From f1bbb17cd8c12680a3f95b1dbdc8979246796684 Mon Sep 17 00:00:00 2001
From: Ryan Neufeld 
Date: Thu, 29 Mar 2012 08:24:01 -0700
Subject: Fix for Issue 88. _default_options does not exist in the
 Cache_memcahe driver

---
 system/libraries/Cache/drivers/Cache_memcached.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 1028c8fd5..4cd5f3d6f 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -189,17 +189,17 @@ class CI_Cache_memcached extends CI_Driver {
 		{
 			if ( ! array_key_exists('hostname', $cache_server))
 			{
-				$cache_server['hostname'] = $this->_default_options['default_host'];
+				$cache_server['hostname'] = $this->_memcache_conf['default']['default_host'];
 			}
 
 			if ( ! array_key_exists('port', $cache_server))
 			{
-				$cache_server['port'] = $this->_default_options['default_port'];
+				$cache_server['port'] = $this->_memcache_conf['default']['default_port'];
 			}
 
 			if ( ! array_key_exists('weight', $cache_server))
 			{
-				$cache_server['weight'] = $this->_default_options['default_weight'];
+				$cache_server['weight'] = $this->_memcache_conf['default']['default_weight'];
 			}
 
 			if (get_class($this->_memcached) == 'Memcache')
-- 
cgit v1.2.3-24-g4f1b


From 443bbd96382552e8a7aea0f9dc7f1c90efc9b4e8 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Tue, 3 Apr 2012 15:49:11 +0300
Subject: Minor cleanup and style fixes in the Log and Javascript libraries

---
 system/libraries/Javascript.php | 41 +++++++++++++++--------------------------
 system/libraries/Log.php        | 17 ++++++-----------
 2 files changed, 21 insertions(+), 37 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 9ba93000b..baa044117 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * Javascript Class
  *
@@ -46,7 +44,7 @@ class CI_Javascript {
 
 		foreach ($defaults as $key => $val)
 		{
-			if (isset($params[$key]) && $params[$key] !== "")
+			if (isset($params[$key]) && $params[$key] !== '')
 			{
 				$defaults[$key] = $params[$key];
 			}
@@ -61,7 +59,7 @@ class CI_Javascript {
 		// make js to refer to current library
 		$this->js =& $this->CI->$js_library_driver;
 
-		log_message('debug', "Javascript Class Initialized and loaded.  Driver used: $js_library_driver");
+		log_message('debug', 'Javascript Class Initialized and loaded. Driver used: '.$js_library_driver);
 	}
 
 	// --------------------------------------------------------------------
@@ -375,7 +373,6 @@ class CI_Javascript {
 	// Effects
 	// --------------------------------------------------------------------
 
-
 	/**
 	 * Add Class
 	 *
@@ -618,12 +615,9 @@ class CI_Javascript {
 		{
 			$this->_javascript_location = $external_file;
 		}
-		else
+		elseif ($this->CI->config->item('javascript_location') != '')
 		{
-			if ($this->CI->config->item('javascript_location') != '')
-			{
-				$this->_javascript_location = $this->CI->config->item('javascript_location');
-			}
+			$this->_javascript_location = $this->CI->config->item('javascript_location');
 		}
 
 		if ($relative === TRUE OR strncmp($external_file, 'http://', 7) === 0 OR strncmp($external_file, 'https://', 8) === 0)
@@ -656,7 +650,7 @@ class CI_Javascript {
 	public function inline($script, $cdata = TRUE)
 	{
 		return $this->_open_script()
-			. ($cdata ? "\n// \n" : "\n{$script}\n")
+			. ($cdata ? "\n// \n" : "\n".$script."\n")
 			. $this->_close_script();
 	}
 
@@ -673,7 +667,7 @@ class CI_Javascript {
 	protected function _open_script($src = '')
 	{
 		return '$extra";
+		return ''.$extra;
 	}
 
-
-	// --------------------------------------------------------------------
 	// --------------------------------------------------------------------
 	// AJAX-Y STUFF - still a testbed
 	// --------------------------------------------------------------------
-	// --------------------------------------------------------------------
 
 	/**
 	 * Update
@@ -751,9 +742,9 @@ class CI_Javascript {
 		$json = array();
 		$_is_assoc = TRUE;
 
-		if ( ! is_array($json_result) AND empty($json_result))
+		if ( ! is_array($json_result) && empty($json_result))
 		{
-			show_error("Generate JSON Failed - Illegal key, value pair.");
+			show_error('Generate JSON Failed - Illegal key, value pair.');
 		}
 		elseif ($match_array_type)
 		{
@@ -774,7 +765,7 @@ class CI_Javascript {
 
 		$json = implode(',', $json);
 
-		return $_is_assoc ? "{".$json."}" : "[".$json."]";
+		return $_is_assoc ? '{'.$json.'}' : '['.$json.']';
 
 	}
 
@@ -785,8 +776,8 @@ class CI_Javascript {
 	 *
 	 * Checks for an associative array
 	 *
-	 * @param	type
-	 * @return	type
+	 * @param	array
+	 * @return	bool
 	 */
 	protected function _is_associative_array($arr)
 	{
@@ -808,8 +799,8 @@ class CI_Javascript {
 	 *
 	 * Ensures a standard json value and escapes values
 	 *
-	 * @param	type
-	 * @return	type
+	 * @param	mixed
+	 * @return	string
 	 */
 	protected function _prep_args($result, $is_key = FALSE)
 	{
@@ -831,9 +822,7 @@ class CI_Javascript {
 		}
 	}
 
-	// --------------------------------------------------------------------
 }
-// END Javascript Class
 
 /* End of file Javascript.php */
-/* Location: ./system/libraries/Javascript.php */
+/* Location: ./system/libraries/Javascript.php */
\ No newline at end of file
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 955277acc..66f9ebff9 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * Logging Class
  *
@@ -43,12 +41,9 @@ class CI_Log {
 	protected $_threshold_max	= 0;
 	protected $_threshold_array	= array();
 	protected $_date_fmt		= 'Y-m-d H:i:s';
-	protected $_enabled			= TRUE;
-	protected $_levels			= array('ERROR' => 1, 'DEBUG' => 2,  'INFO' => 3, 'ALL' => 4);
+	protected $_enabled		= TRUE;
+	protected $_levels		= array('ERROR' => 1, 'DEBUG' => 2,  'INFO' => 3, 'ALL' => 4);
 
-	/**
-	 * Constructor
-	 */
 	public function __construct()
 	{
 		$config =& get_config();
@@ -98,7 +93,7 @@ class CI_Log {
 		$level = strtoupper($level);
 
 		if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
-			AND ! isset($this->_threshold_array[$this->_levels[$level]]))
+			&& ! isset($this->_threshold_array[$this->_levels[$level]]))
 		{
 			return FALSE;
 		}
@@ -125,15 +120,15 @@ class CI_Log {
 		flock($fp, LOCK_UN);
 		fclose($fp);
 
-		if (isset($newfile) AND $newfile === TRUE)
+		if (isset($newfile) && $newfile === TRUE)
 		{
 			@chmod($filepath, FILE_WRITE_MODE);
 		}
+
 		return TRUE;
 	}
 
 }
-// END Log Class
 
 /* End of file Log.php */
-/* Location: ./system/libraries/Log.php */
+/* Location: ./system/libraries/Log.php */
\ No newline at end of file
-- 
cgit v1.2.3-24-g4f1b


From 1b815532378bd444347d1bc741771e13108147b6 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Tue, 3 Apr 2012 16:06:03 +0300
Subject: Minor cleanup and style fixes in the Unit_test and Image_lib
 libraries

---
 system/libraries/Image_lib.php  |  4 ++--
 system/libraries/Javascript.php |  4 ++--
 system/libraries/Unit_test.php  | 28 ++++++++++++----------------
 3 files changed, 16 insertions(+), 20 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 86b77bf07..1ab8b23e0 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -251,7 +251,7 @@ class CI_Image_lib {
 		}
 		else
 		{
-			if (strpos($this->new_image, '/') === FALSE AND strpos($this->new_image, '\\') === FALSE)
+			if (strpos($this->new_image, '/') === FALSE && strpos($this->new_image, '\\') === FALSE)
 			{
 				$full_dest_path = str_replace('\\', '/', realpath($this->new_image));
 			}
@@ -1462,4 +1462,4 @@ class CI_Image_lib {
 }
 
 /* End of file Image_lib.php */
-/* Location: ./system/libraries/Image_lib.php */
+/* Location: ./system/libraries/Image_lib.php */
\ No newline at end of file
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index baa044117..629a3adfe 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -105,7 +105,7 @@ class CI_Javascript {
 	 *
 	 * @param	string	The element to attach the event to
 	 * @param	string	The code to execute
-	 * @param	boolean	whether or not to return false
+	 * @param	bool	whether or not to return false
 	 * @return	string
 	 */
 	public function click($element = 'this', $js = '', $ret_false = TRUE)
@@ -644,7 +644,7 @@ class CI_Javascript {
 	 * Outputs a