From 35be644f6c912f6cdbe9392557ac38a9fbbc0416 Mon Sep 17 00:00:00 2001 From: Stéphane Goetz Date: Mon, 24 Oct 2011 23:10:07 +0300 Subject: Added a "break 2;", When overriding the cache file in an other folder, it would try to load all files corresponding to this name and create an error because of a double file loading --- system/libraries/Driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 8df137e74..30204d075 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -76,7 +76,7 @@ class CI_Driver_Library { if (file_exists($filepath)) { include_once $filepath; - break; + break 2; } } } -- cgit v1.2.3-24-g4f1b From 8bd8f687827454f83a5512b96bb0f632178a08a6 Mon Sep 17 00:00:00 2001 From: dixy Date: Mon, 19 Dec 2011 22:26:12 +0100 Subject: Prev link and 1 link don't have the same url with use_page_numbers=TRUE --- system/libraries/Pagination.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index eea953ae4..cc73e0d2f 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -236,13 +236,13 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page; - if (($i == 0 OR ($this->use_page_numbers && $i == 1)) AND $this->first_url != '') + if ($i == $base_page AND $this->first_url != '') { $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.''.$this->prev_tag_close; } else { - $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix; + $i = ($i == $base_page) ? '' : $this->prefix.$i.$this->suffix; $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.''.$this->prev_tag_close; } -- cgit v1.2.3-24-g4f1b From a92b903c0e6c2faa2a9480e23e2d3e4b6308878f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 19:05:58 +0200 Subject: Improve the Image manipulation library --- system/libraries/Image_lib.php | 150 ++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 92 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 20ca1f055..70a127987 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1,4 +1,4 @@ -y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis; // Watermark-related Stuff... - if ($this->wm_font_color != '') + if ($this->wm_font_color != '' AND strlen($this->wm_font_color) === 6) { - if (strlen($this->wm_font_color) == 6) - { - $this->wm_font_color = '#'.$this->wm_font_color; - } + $this->wm_font_color = '#'.$this->wm_font_color; } - if ($this->wm_shadow_color != '') + if ($this->wm_shadow_color != '' AND strlen($this->wm_shadow_color) === 6) { - if (strlen($this->wm_shadow_color) == 6) - { - $this->wm_shadow_color = '#'.$this->wm_shadow_color; - } + $this->wm_shadow_color = '#'.$this->wm_shadow_color; } if ($this->wm_overlay_path != '') @@ -381,13 +375,7 @@ class CI_Image_lib { */ public function resize() { - $protocol = 'image_process_'.$this->image_library; - - if (preg_match('/gd2$/i', $protocol)) - { - $protocol = 'image_process_gd'; - } - + $protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; return $this->$protocol('resize'); } @@ -404,13 +392,7 @@ class CI_Image_lib { */ public function crop() { - $protocol = 'image_process_'.$this->image_library; - - if (preg_match('/gd2$/i', $protocol)) - { - $protocol = 'image_process_gd'; - } - + $protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; return $this->$protocol('crop'); } @@ -453,7 +435,6 @@ class CI_Image_lib { if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm') { $protocol = 'image_process_'.$this->image_library; - return $this->$protocol('rotate'); } @@ -484,20 +465,14 @@ class CI_Image_lib { // If the target width/height match the source, AND if the new file name is not equal to the old file name // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off. - if ($this->dynamic_output === FALSE) + if ($this->dynamic_output === FALSE AND $this->orig_width == $this->width AND $this->orig_height == $this->height) { - if ($this->orig_width == $this->width AND $this->orig_height == $this->height) + if ($this->source_image != $this->new_image AND @copy($this->full_src_path, $this->full_dst_path)) { - if ($this->source_image != $this->new_image) - { - if (@copy($this->full_src_path, $this->full_dst_path)) - { - @chmod($this->full_dst_path, FILE_WRITE_MODE); - } - } - - return TRUE; + @chmod($this->full_dst_path, FILE_WRITE_MODE); } + + return TRUE; } // Let's set up our values based on the action @@ -601,9 +576,7 @@ class CI_Image_lib { if ( ! preg_match("/convert$/i", $this->library_path)) { - $this->library_path = rtrim($this->library_path, '/').'/'; - - $this->library_path .= 'convert'; + $this->library_path = rtrim($this->library_path, '/').'/convert'; } // Execute the command @@ -808,11 +781,8 @@ class CI_Image_lib { if ($this->rotation_angle == 'hor') { - for ($i = 0; $i < $height; $i++) + for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1) { - $left = 0; - $right = $width-1; - while ($left < $right) { $cl = imagecolorat($src_img, $left, $i); @@ -828,11 +798,8 @@ class CI_Image_lib { } else { - for ($i = 0; $i < $width; $i++) + for ($i = 0; $i < $width; $i++, $top = 0, $bot = $height-1) { - $top = 0; - $bot = $height-1; - while ($top < $bot) { $ct = imagecolorat($src_img, $i, $top); @@ -993,12 +960,9 @@ class CI_Image_lib { { $this->image_display_gd($src_img); } - else + elseif ( ! $this->image_save_gd($src_img)) { - if ( ! $this->image_save_gd($src_img)) - { - return FALSE; - } + return FALSE; } imagedestroy($src_img); @@ -1065,7 +1029,9 @@ class CI_Image_lib { if ($this->wm_use_truetype == TRUE) { if ($this->wm_font_size == '') - $this->wm_font_size = '17'; + { + $this->wm_font_size = 17; + } $fontwidth = $this->wm_font_size-($this->wm_font_size/4); $fontheight = $this->wm_font_size; @@ -1090,11 +1056,11 @@ class CI_Image_lib { switch ($this->wm_vrt_alignment) { - case "T" : + case 'T': break; - case "M": $y_axis += ($this->orig_height/2)+($fontheight/2); + case 'M': $y_axis += ($this->orig_height/2)+($fontheight/2); break; - case "B": $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2)); + case 'B': $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2)); break; } @@ -1104,32 +1070,34 @@ class CI_Image_lib { // Set horizontal alignment switch ($this->wm_hor_alignment) { - case "L": + case 'L': break; - case "R": - if ($this->wm_use_drop_shadow) - $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text)); - $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text)); + case 'R': + if ($this->wm_use_drop_shadow) + { + $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text)); + $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text)); + } break; - case "C": - if ($this->wm_use_drop_shadow) - $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); - $x_axis += floor(($this->orig_width -$fontwidth*strlen($this->wm_text))/2); + case 'C': + if ($this->wm_use_drop_shadow) + { + $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); + $x_axis += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); + } break; } // Add the text to the source image - if ($this->wm_use_truetype) + if ($this->wm_use_truetype AND $this->wm_use_drop_shadow) { - if ($this->wm_use_drop_shadow) - imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); - imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); + imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); + imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); } - else + elseif ($this->wm_use_drop_shadow) { - if ($this->wm_use_drop_shadow) - imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); - imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); + imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); + imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } // Output the final image @@ -1369,26 +1337,24 @@ class CI_Image_lib { } $vals = getimagesize($path); - $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); - - $mime = (isset($types[$vals['2']])) ? 'image/'.$types[$vals['2']] : 'image/jpg'; + $mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg'; if ($return == TRUE) { - $v['width'] = $vals['0']; - $v['height'] = $vals['1']; - $v['image_type'] = $vals['2']; - $v['size_str'] = $vals['3']; - $v['mime_type'] = $mime; - - return $v; + return array( + 'width' => $vals[0], + 'height' => $vals[1], + 'image_type' => $vals[2], + 'size_str' => $vals[3], + 'mime_type' => $mime + ); } - $this->orig_width = $vals['0']; - $this->orig_height = $vals['1']; - $this->image_type = $vals['2']; - $this->size_str = $vals['3']; + $this->orig_width = $vals[0]; + $this->orig_height = $vals[1]; + $this->image_type = $vals[2]; + $this->size_str = $vals[3]; $this->mime_type = $mime; return TRUE; @@ -1482,10 +1448,10 @@ class CI_Image_lib { { if ( ! extension_loaded('gd')) { - if ( ! dl('gd.so')) - { - return FALSE; - } + /* As it is stated in the PHP manual, dl() is not always available + * and even if so - it could generate an E_WARNING message on failure + */ + return (function_exists('dl') AND @dl('gd.so')); } return TRUE; -- cgit v1.2.3-24-g4f1b From a30faf95d1d833f716dd1e181cef5b33b02ef8b9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 18:15:34 +0200 Subject: Improve the Xmlrpc library --- system/libraries/Xmlrpc.php | 408 +++++++++++++++++++------------------------- 1 file changed, 180 insertions(+), 228 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7b1e3fa6e..ebb04601b 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1,13 +1,13 @@ -xmlrpcName = $this->xmlrpcName; + $this->xmlrpcName = $this->xmlrpcName; $this->xmlrpc_backslash = chr(92).chr(92); // Types for info sent back and forth @@ -101,23 +101,23 @@ class CI_Xmlrpc { // Array of Valid Parents for Various XML-RPC elements $this->valid_parents = array('BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'FAULT' => array('METHODRESPONSE'), - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') - ); + 'I4' => array('VALUE'), + 'INT' => array('VALUE'), + 'STRING' => array('VALUE'), + 'DOUBLE' => array('VALUE'), + 'DATETIME.ISO8601' => array('VALUE'), + 'BASE64' => array('VALUE'), + 'ARRAY' => array('VALUE'), + 'STRUCT' => array('VALUE'), + 'PARAM' => array('PARAMS'), + 'METHODNAME' => array('METHODCALL'), + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), + 'MEMBER' => array('STRUCT'), + 'NAME' => array('MEMBER'), + 'DATA' => array('ARRAY'), + 'FAULT' => array('METHODRESPONSE'), + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') + ); // XML-RPC Responses @@ -128,7 +128,7 @@ class CI_Xmlrpc { $this->xmlrpcerr['incorrect_params'] = '3'; $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method'; $this->xmlrpcerr['introspect_unknown'] = '4'; - $this->xmlrpcstr['introspect_unknown'] = "Cannot inspect signature for request: method unknown"; + $this->xmlrpcstr['introspect_unknown'] = 'Cannot inspect signature for request: method unknown'; $this->xmlrpcerr['http_error'] = '5'; $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server."; $this->xmlrpcerr['no_data'] = '6'; @@ -144,7 +144,7 @@ class CI_Xmlrpc { // Initialize Prefs //------------------------------------- - function initialize($config = array()) + public function initialize($config = array()) { if (count($config) > 0) { @@ -163,9 +163,9 @@ class CI_Xmlrpc { // Take URL and parse it //------------------------------------- - function server($url, $port=80) + public function server($url, $port=80) { - if (substr($url, 0, 4) != "http") + if (strpos($url, 'http') !== 0) { $url = "http://".$url; } @@ -187,7 +187,7 @@ class CI_Xmlrpc { // Set Timeout //------------------------------------- - function timeout($seconds=5) + public function timeout($seconds = 5) { if ( ! is_null($this->client) && is_int($seconds)) { @@ -200,7 +200,7 @@ class CI_Xmlrpc { // Set Methods //------------------------------------- - function method($function) + public function method($function) { $this->method = $function; } @@ -210,7 +210,7 @@ class CI_Xmlrpc { // Take Array of Data and Create Objects //------------------------------------- - function request($incoming) + public function request($incoming) { if ( ! is_array($incoming)) { @@ -231,42 +231,34 @@ class CI_Xmlrpc { // Set Debug //------------------------------------- - function set_debug($flag = TRUE) + public function set_debug($flag = TRUE) { - $this->debug = ($flag == TRUE) ? TRUE : FALSE; + $this->debug = ($flag == TRUE); } //------------------------------------- // Values Parsing //------------------------------------- - function values_parsing($value, $return = FALSE) + public function values_parsing($value, $return = FALSE) { if (is_array($value) && array_key_exists(0, $value)) { - if ( ! isset($value['1']) OR ( ! isset($this->xmlrpcTypes[$value['1']]))) + if ( ! isset($value[1]) OR ( ! isset($this->xmlrpcTypes[$value[1]]))) { - if (is_array($value[0])) - { - $temp = new XML_RPC_Values($value['0'], 'array'); - } - else - { - $temp = new XML_RPC_Values($value['0'], 'string'); - } + $temp = new XML_RPC_Values($value[0], (is_array($value[0]) ? 'array' : 'string')); } - elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array')) + else { - while (list($k) = each($value['0'])) + if (is_array($value[0]) && ($value[1] == 'struct' OR $value[1] == 'array')) { - $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE); + while (list($k) = each($value[0])) + { + $value[0][$k] = $this->values_parsing($value[0][$k], TRUE); + } } - $temp = new XML_RPC_Values($value['0'], $value['1']); - } - else - { - $temp = new XML_RPC_Values($value['0'], $value['1']); + $temp = new XML_RPC_Values($value[0], $value[1]); } } else @@ -283,24 +275,18 @@ class CI_Xmlrpc { // Sends XML-RPC Request //------------------------------------- - function send_request() + public function send_request() { $this->message = new XML_RPC_Message($this->method,$this->data); $this->message->debug = $this->debug; - if ( ! $this->result = $this->client->send($this->message)) - { - $this->error = $this->result->errstr; - return FALSE; - } - elseif ( ! is_object($this->result->val)) + if ( ! $this->result = $this->client->send($this->message) OR ! is_object($this->result->val)) { $this->error = $this->result->errstr; return FALSE; } $this->response = $this->result->decode(); - return TRUE; } // END @@ -309,7 +295,7 @@ class CI_Xmlrpc { // Returns Error //------------------------------------- - function display_error() + public function display_error() { return $this->error; } @@ -319,7 +305,7 @@ class CI_Xmlrpc { // Returns Remote Server Response //------------------------------------- - function display_response() + public function display_response() { return $this->response; } @@ -329,9 +315,9 @@ class CI_Xmlrpc { // Sends an Error Message for Server Request //------------------------------------- - function send_error_message($number, $message) + public function send_error_message($number, $message) { - return new XML_RPC_Response('0',$number, $message); + return new XML_RPC_Response(0, $number, $message); } // END @@ -340,14 +326,11 @@ class CI_Xmlrpc { // Send Response for Server Request //------------------------------------- - function send_response($response) + public function send_response($response) { // $response should be array of values, which will be parsed // based on their data and type into a valid group of XML-RPC values - - $response = $this->values_parsing($response); - - return new XML_RPC_Response($response); + return new XML_RPC_Response($this->values_parsing($response)); } // END @@ -364,13 +347,13 @@ class CI_Xmlrpc { */ class XML_RPC_Client extends CI_Xmlrpc { - var $path = ''; - var $server = ''; - var $port = 80; - var $errno = ''; - var $errstring = ''; - var $timeout = 5; - var $no_multicall = FALSE; + public $path = ''; + public $server = ''; + public $port = 80; + public $errno = ''; + public $errstring = ''; + public $timeout = 5; + public $no_multicall = FALSE; public function __construct($path, $server, $port=80) { @@ -381,7 +364,7 @@ class XML_RPC_Client extends CI_Xmlrpc $this->path = $path; } - function send($msg) + public function send($msg) { if (is_array($msg)) { @@ -393,7 +376,7 @@ class XML_RPC_Client extends CI_Xmlrpc return $this->sendPayload($msg); } - function sendPayload($msg) + public function sendPayload($msg) { $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout); @@ -411,12 +394,12 @@ class XML_RPC_Client extends CI_Xmlrpc } $r = "\r\n"; - $op = "POST {$this->path} HTTP/1.0$r"; - $op .= "Host: {$this->server}$r"; - $op .= "Content-Type: text/xml$r"; - $op .= "User-Agent: {$this->xmlrpcName}$r"; - $op .= "Content-Length: ".strlen($msg->payload). "$r$r"; - $op .= $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))) @@ -430,8 +413,8 @@ class XML_RPC_Client extends CI_Xmlrpc return $resp; } -} // end class XML_RPC_Client - +} +// end class XML_RPC_Client /** * XML-RPC Response class @@ -442,11 +425,11 @@ class XML_RPC_Client extends CI_Xmlrpc */ class XML_RPC_Response { - var $val = 0; - var $errno = 0; - var $errstr = ''; - var $headers = array(); - var $xss_clean = TRUE; + public $val = 0; + public $errno = 0; + public $errstr = ''; + public $headers = array(); + public $xss_clean = TRUE; public function __construct($val, $code = 0, $fstr = '') { @@ -468,27 +451,26 @@ class XML_RPC_Response } } - function faultCode() + public function faultCode() { return $this->errno; } - function faultString() + public function faultString() { return $this->errstr; } - function value() + public function value() { return $this->val; } - function prepare_response() + public function prepare_response() { - $result = "\n"; - if ($this->errno) - { - $result .= ' + return "\n" + . ($this->errno + ? ' @@ -501,23 +483,16 @@ class XML_RPC_Response -'; - } - else - { - $result .= "\n\n" . - $this->val->serialize_class() . - "\n"; - } - $result .= "\n"; - return $result; +' + : "\n\n".$this->val->serialize_class()."\n") + . "\n"; } - function decode($array=FALSE) + public function decode($array = FALSE) { $CI =& get_instance(); - - if ($array !== FALSE && is_array($array)) + + if (is_array($array)) { while (list($key) = each($array)) { @@ -556,7 +531,7 @@ class XML_RPC_Response // XML-RPC Object to PHP Types //------------------------------------- - function xmlrpc_decoder($xmlrpc_val) + public function xmlrpc_decoder($xmlrpc_val) { $kind = $xmlrpc_val->kindOf(); @@ -568,11 +543,9 @@ class XML_RPC_Response { reset($xmlrpc_val->me); list($a,$b) = each($xmlrpc_val->me); - $size = count($b); - $arr = array(); - for ($i = 0; $i < $size; $i++) + for ($i = 0, $size = count($b); $i < $size; $i++) { $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]); } @@ -596,7 +569,7 @@ class XML_RPC_Response // ISO-8601 time to server or UTC time //------------------------------------- - function iso8601_decode($time, $utc=0) + public function iso8601_decode($time, $utc = 0) { // return a timet in the localtime, or UTC $t = 0; @@ -608,9 +581,8 @@ class XML_RPC_Response return $t; } -} // End Response Class - - +} +// End Response Class /** * XML-RPC Message class @@ -621,10 +593,10 @@ class XML_RPC_Response */ class XML_RPC_Message extends CI_Xmlrpc { - var $payload; - var $method_name; - var $params = array(); - var $xh = array(); + public $payload; + public $method_name; + public $params = array(); + public $xh = array(); public function __construct($method, $pars=0) { @@ -633,7 +605,7 @@ class XML_RPC_Message extends CI_Xmlrpc $this->method_name = $method; if (is_array($pars) && count($pars) > 0) { - for ($i=0; $iparams[] = $pars[$i]; @@ -645,13 +617,13 @@ class XML_RPC_Message extends CI_Xmlrpc // Create Payload to Send //------------------------------------- - function createPayload() + public function createPayload() { - $this->payload = "\r\n\r\n"; - $this->payload .= '' . $this->method_name . "\r\n"; - $this->payload .= "\r\n"; + $this->payload = "\r\n\r\n" + . ''.$this->method_name."\r\n" + . "\r\n"; - for ($i=0; $iparams); $i++) + for ($i = 0, $c = count($this->params); $i < $c; $i++) { // $p = XML_RPC_Values $p = $this->params[$i]; @@ -665,7 +637,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Parse External XML-RPC Server's Response //------------------------------------- - function parseResponse($fp) + public function parseResponse($fp) { $data = ''; @@ -680,16 +652,14 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "
";
-			echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
-			echo "
"; + echo "
---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n
"; } //------------------------------------- // Check for data //------------------------------------- - if ($data == "") + if ($data === '') { error_log($this->xmlrpcstr['no_data']); $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); @@ -701,7 +671,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Check for HTTP 200 Response //------------------------------------- - if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) + 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 . ')'); @@ -714,13 +684,14 @@ class XML_RPC_Message extends CI_Xmlrpc $parser = xml_parser_create($this->xmlrpc_defencoding); - $this->xh[$parser] = array(); - $this->xh[$parser]['isf'] = 0; - $this->xh[$parser]['ac'] = ''; - $this->xh[$parser]['headers'] = array(); - $this->xh[$parser]['stack'] = array(); - $this->xh[$parser]['valuestack'] = array(); - $this->xh[$parser]['isf_reason'] = 0; + $this->xh[$parser] = array( + 'isf' => 0, + 'ac' => '', + 'headers' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'isf_reason' => 0 + ); xml_set_object($parser, $this); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); @@ -769,9 +740,7 @@ class XML_RPC_Message extends CI_Xmlrpc { if ($this->debug === TRUE) { - echo "---Invalid Return---\n"; - echo $this->xh[$parser]['isf_reason']; - echo "---Invalid Return---\n\n"; + echo "---Invalid Return---\n".$this->xh[$parser]['isf_reason']."---Invalid Return---\n\n"; } $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); @@ -801,9 +770,7 @@ class XML_RPC_Message extends CI_Xmlrpc echo "---END HEADERS---\n\n"; } - echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n"; - - echo "---PARSED---\n" ; + echo "---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n---PARSED---\n"; var_dump($this->xh[$parser]['value']); echo "\n---END PARSED---"; } @@ -813,7 +780,6 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- $v = $this->xh[$parser]['value']; - if ($this->xh[$parser]['isf']) { $errno_v = $v->me['struct']['faultCode']; @@ -855,7 +821,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Start Element Handler //------------------------------------- - function open_tag($the_parser, $name, $attrs) + public function open_tag($the_parser, $name, $attrs) { // If invalid nesting, then return if ($this->xh[$the_parser]['isf'] > 1) return; @@ -957,7 +923,7 @@ class XML_RPC_Message extends CI_Xmlrpc // End Element Handler //------------------------------------- - function closing_tag($the_parser, $name) + public function closing_tag($the_parser, $name) { if ($this->xh[$the_parser]['isf'] > 1) return; @@ -1101,7 +1067,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Parses Character Data //------------------------------------- - function character_data($the_parser, $data) + public function character_data($the_parser, $data) { if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already @@ -1123,13 +1089,16 @@ class XML_RPC_Message extends CI_Xmlrpc } - function addParam($par) { $this->params[]=$par; } + public function addParam($par) + { + $this->params[] = $par; + } - function output_parameters($array=FALSE) + public function output_parameters($array = FALSE) { $CI =& get_instance(); - - if ($array !== FALSE && is_array($array)) + + if (is_array($array)) { while (list($key) = each($array)) { @@ -1151,7 +1120,7 @@ class XML_RPC_Message extends CI_Xmlrpc { $parameters = array(); - for ($i = 0; $i < count($this->params); $i++) + for ($i = 0, $c = count($this->params); $i < $c; $i++) { $a_param = $this->decode_message($this->params[$i]); @@ -1170,7 +1139,7 @@ class XML_RPC_Message extends CI_Xmlrpc } - function decode_message($param) + public function decode_message($param) { $kind = $param->kindOf(); @@ -1185,7 +1154,7 @@ class XML_RPC_Message extends CI_Xmlrpc $arr = array(); - for($i = 0; $i < count($b); $i++) + for($i = 0, $c = count($b); $i < $c; $i++) { $arr[] = $this->decode_message($param->me['array'][$i]); } @@ -1207,9 +1176,8 @@ class XML_RPC_Message extends CI_Xmlrpc } } -} // End XML_RPC_Messages class - - +} +// End XML_RPC_Messages class /** * XML-RPC Values class @@ -1220,10 +1188,10 @@ class XML_RPC_Message extends CI_Xmlrpc */ class XML_RPC_Values extends CI_Xmlrpc { - var $me = array(); - var $mytype = 0; + public $me = array(); + public $mytype = 0; - public function __construct($val=-1, $type='') + public function __construct($val = -1, $type = '') { parent::__construct(); @@ -1246,7 +1214,7 @@ class XML_RPC_Values extends CI_Xmlrpc } } - function addScalar($val, $type='string') + public function addScalar($val, $type = 'string') { $typeof = $this->xmlrpcTypes[$type]; @@ -1264,14 +1232,7 @@ class XML_RPC_Values extends CI_Xmlrpc if ($type == $this->xmlrpcBoolean) { - if (strcasecmp($val,'true')==0 OR $val==1 OR ($val==true && strcasecmp($val,'false'))) - { - $val = 1; - } - else - { - $val=0; - } + $val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == true && strcasecmp($val, 'false'))) ? 1 : 0; } if ($this->mytype == 2) @@ -1290,7 +1251,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function addArray($vals) + public function addArray($vals) { if ($this->mytype != 0) { @@ -1303,7 +1264,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function addStruct($vals) + public function addStruct($vals) { if ($this->mytype != 0) { @@ -1315,7 +1276,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function kindOf() + public function kindOf() { switch($this->mytype) { @@ -1333,7 +1294,7 @@ class XML_RPC_Values extends CI_Xmlrpc } } - function serializedata($typ, $val) + public function serializedata($typ, $val) { $rs = ''; @@ -1345,20 +1306,18 @@ class XML_RPC_Values extends CI_Xmlrpc reset($val); while (list($key2, $val2) = each($val)) { - $rs .= "\n{$key2}\n"; - $rs .= $this->serializeval($val2); - $rs .= "\n"; + $rs .= "\n{$key2}\n".$this->serializeval($val2)."\n"; } $rs .= ''; break; case 2: // array $rs .= "\n\n"; - for($i=0; $i < count($val); $i++) + for($i = 0, $c = count($val); $i < $c; $i++) { $rs .= $this->serializeval($val[$i]); } - $rs.="\n\n"; + $rs .= "\n\n"; break; case 1: // others @@ -1383,22 +1342,21 @@ class XML_RPC_Values extends CI_Xmlrpc return $rs; } - function serialize_class() + public function serialize_class() { return $this->serializeval($this); } - function serializeval($o) + public function serializeval($o) { $ar = $o->me; reset($ar); list($typ, $val) = each($ar); - $rs = "\n".$this->serializedata($typ, $val)."\n"; - return $rs; + return "\n".$this->serializedata($typ, $val)."\n"; } - function scalarval() + public function scalarval() { reset($this->me); list($a,$b) = each($this->me); @@ -1412,24 +1370,18 @@ class XML_RPC_Values extends CI_Xmlrpc // Useful for sending time in XML-RPC - function iso8601_encode($time, $utc=0) + public function iso8601_encode($time, $utc=0) { if ($utc == 1) { - $t = strftime("%Y%m%dT%H:%i:%s", $time); + return strftime("%Y%m%dT%H:%i:%s", $time); } - else - { - if (function_exists('gmstrftime')) - $t = gmstrftime("%Y%m%dT%H:%i:%s", $time); - else - $t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z')); - } - return $t; + + return (function_exists('gmstrftime')) ? gmstrftime('%Y%m%dT%H:%i:%s', $time) : strftime('%Y%m%dT%H:%i:%s', $time - date('Z')); } } // END XML_RPC_Values Class /* End of file Xmlrpc.php */ -/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file +/* Location: ./system/libraries/Xmlrpc.php */ -- cgit v1.2.3-24-g4f1b From 5342e8b0d8e4c0b585a4757d60f0fd7127704755 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:57:52 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Image_lib.php | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 70a127987..2737503a8 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -111,7 +111,6 @@ class CI_Image_lib { * * Resets values in case this class is used in a loop * - * @access public * @return void */ public function clear() @@ -154,7 +153,6 @@ class CI_Image_lib { /** * initialize image preferences * - * @access public * @param array * @return bool */ @@ -370,7 +368,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the proper * resize function based on the protocol specified * - * @access public * @return bool */ public function resize() @@ -387,7 +384,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the proper * cropping function based on the protocol specified * - * @access public * @return bool */ public function crop() @@ -404,7 +400,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the proper * rotation function based on the protocol specified * - * @access public * @return bool */ public function rotate() @@ -455,7 +450,6 @@ class CI_Image_lib { * * This function will resize or crop * - * @access public * @param string * @return bool */ @@ -561,7 +555,6 @@ class CI_Image_lib { * * This function will resize, crop or rotate * - * @access public * @param string * @return bool */ @@ -629,7 +622,6 @@ class CI_Image_lib { * * This function will resize, crop or rotate * - * @access public * @param string * @return bool */ @@ -713,7 +705,6 @@ class CI_Image_lib { /** * Image Rotate Using GD * - * @access public * @return bool */ public function image_rotate_gd() @@ -766,7 +757,6 @@ class CI_Image_lib { * * This function will flip horizontal or vertical * - * @access public * @return bool */ public function image_mirror_gd() @@ -845,7 +835,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the type * of watermarking based on the specified preference. * - * @access public * @param string * @return bool */ @@ -866,7 +855,6 @@ class CI_Image_lib { /** * Watermark - Graphic Version * - * @access public * @return bool */ public function overlay_watermark() @@ -976,7 +964,6 @@ class CI_Image_lib { /** * Watermark - Text Version * - * @access public * @return bool */ public function text_watermark() @@ -1123,7 +1110,6 @@ class CI_Image_lib { * This simply creates an image resource handle * based on the type of image being processed * - * @access public * @param string * @return resource */ @@ -1180,7 +1166,6 @@ class CI_Image_lib { * Takes an image resource as input and writes the file * to the specified destination * - * @access public * @param resource * @return bool */ @@ -1241,7 +1226,6 @@ class CI_Image_lib { /** * Dynamically outputs an image * - * @access public * @param resource * @return void */ @@ -1277,7 +1261,6 @@ class CI_Image_lib { * This function lets us re-proportion the width/height * if users choose to maintain the aspect ratio when resizing. * - * @access public * @return void */ public function image_reproportion() @@ -1318,7 +1301,6 @@ class CI_Image_lib { * * A helper function that gets info about the file * - * @access public * @param string * @return mixed */ @@ -1376,7 +1358,6 @@ class CI_Image_lib { * 'new_height' => '' * ); * - * @access public * @param array * @return array */ @@ -1424,7 +1405,6 @@ class CI_Image_lib { * $array['ext'] = '.jpg'; * $array['name'] = 'my.cool'; * - * @access public * @param array * @return array */ @@ -1441,7 +1421,6 @@ class CI_Image_lib { /** * Is GD Installed? * - * @access public * @return bool */ public function gd_loaded() @@ -1462,7 +1441,6 @@ class CI_Image_lib { /** * Get GD version * - * @access public * @return mixed */ public function gd_version() @@ -1483,7 +1461,6 @@ class CI_Image_lib { /** * Set error message * - * @access public * @param string * @return void */ @@ -1515,7 +1492,6 @@ class CI_Image_lib { /** * Show error messages * - * @access public * @param string * @return string */ -- cgit v1.2.3-24-g4f1b From 6209015edde25e8ca82a8e8f5eb5a5eda2750e7b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 12:49:27 +0200 Subject: Some more optimizations --- system/libraries/Xmlrpc.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index ebb04601b..2804e6685 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -542,7 +542,7 @@ class XML_RPC_Response elseif ($kind == 'array') { reset($xmlrpc_val->me); - list($a,$b) = each($xmlrpc_val->me); + list(, $b) = each($xmlrpc_val->me); $arr = array(); for ($i = 0, $size = count($b); $i < $size; $i++) @@ -1150,7 +1150,7 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ($kind == 'array') { reset($param->me); - list($a,$b) = each($param->me); + list(, $b) = each($param->me); $arr = array(); @@ -1359,7 +1359,7 @@ class XML_RPC_Values extends CI_Xmlrpc public function scalarval() { reset($this->me); - list($a,$b) = each($this->me); + list(, $b) = each($this->me); return $b; } @@ -1370,14 +1370,9 @@ class XML_RPC_Values extends CI_Xmlrpc // Useful for sending time in XML-RPC - public function iso8601_encode($time, $utc=0) + public function iso8601_encode($time, $utc = 0) { - if ($utc == 1) - { - return strftime("%Y%m%dT%H:%i:%s", $time); - } - - return (function_exists('gmstrftime')) ? gmstrftime('%Y%m%dT%H:%i:%s', $time) : strftime('%Y%m%dT%H:%i:%s', $time - date('Z')); + return ($utc) ? strftime('%Y%m%dT%H:%i:%s', $time) : gmstrftime('%Y%m%dT%H:%i:%s', $time); } } -- cgit v1.2.3-24-g4f1b From 64dbdfb60e0556177061db2eecdf899111ae4ac9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 14:14:07 +0200 Subject: Added support for 3-length hex color values format and a number of validation improvements --- system/libraries/Image_lib.php | 87 ++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 38 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 2737503a8..d4fb51923 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -67,8 +67,8 @@ class CI_Image_lib { public $wm_padding = 0; // Padding around text public $wm_hor_offset = 0; // Lets you push text to the right public $wm_vrt_offset = 0; // Lets you push text down - public $wm_font_color = '#ffffff'; // Text color - public $wm_shadow_color = ''; // Dropshadow color + protected $wm_font_color = '#ffffff'; // Text color + protected $wm_shadow_color = ''; // Dropshadow color public $wm_shadow_distance = 2; // Dropshadow distance public $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image @@ -85,7 +85,7 @@ class CI_Image_lib { public $create_fnc = 'imagecreatetruecolor'; public $copy_fnc = 'imagecopyresampled'; public $error_msg = array(); - public $wm_use_drop_shadow = FALSE; + protected $wm_use_drop_shadow = FALSE; public $wm_use_truetype = FALSE; /** @@ -165,7 +165,30 @@ class CI_Image_lib { { foreach ($props as $key => $val) { - $this->$key = $val; + if (property_exists($this, $key)) + { + if (in_array($key, array('wm_font_color', 'wm_shadow_color'))) + { + if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) + { + if (strlen($matches[1]) === 6) + { + $val = '#'.$val; + } + else + { + $val = str_split($val, 1); + $val = '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2]; + } + } + else + { + continue; + } + } + + $this->$key = $val; + } } } @@ -332,16 +355,6 @@ class CI_Image_lib { $this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis; // Watermark-related Stuff... - if ($this->wm_font_color != '' AND strlen($this->wm_font_color) === 6) - { - $this->wm_font_color = '#'.$this->wm_font_color; - } - - if ($this->wm_shadow_color != '' AND strlen($this->wm_shadow_color) === 6) - { - $this->wm_shadow_color = '#'.$this->wm_shadow_color; - } - if ($this->wm_overlay_path != '') { $this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path)); @@ -351,6 +364,10 @@ class CI_Image_lib { { $this->wm_use_drop_shadow = TRUE; } + elseif ($this->wm_use_drop_shadow == TRUE AND $this->wm_shadow_color == '') + { + $this->wm_use_drop_shadow = FALSE; + } if ($this->wm_font_path != '') { @@ -982,21 +999,6 @@ class CI_Image_lib { // Fetch source image properties $this->get_image_properties(); - // Set RGB values for text and shadow - $this->wm_font_color = str_replace('#', '', $this->wm_font_color); - $this->wm_shadow_color = str_replace('#', '', $this->wm_shadow_color); - - $R1 = hexdec(substr($this->wm_font_color, 0, 2)); - $G1 = hexdec(substr($this->wm_font_color, 2, 2)); - $B1 = hexdec(substr($this->wm_font_color, 4, 2)); - - $R2 = hexdec(substr($this->wm_shadow_color, 0, 2)); - $G2 = hexdec(substr($this->wm_shadow_color, 2, 2)); - $B2 = hexdec(substr($this->wm_shadow_color, 4, 2)); - - $txt_color = imagecolorclosest($src_img, $R1, $G1, $B1); - $drp_color = imagecolorclosest($src_img, $R2, $G2, $B2); - // Reverse the vertical offset // When the image is positioned at the bottom // we don't want the vertical offset to push it @@ -1075,16 +1077,25 @@ class CI_Image_lib { break; } - // Add the text to the source image - if ($this->wm_use_truetype AND $this->wm_use_drop_shadow) - { - imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); - imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); - } - elseif ($this->wm_use_drop_shadow) + if ($this->wm_use_drop_shadow) { - imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); - imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); + // Set RGB values for text and shadow + $txt_color = str_split(substr($this->wm_font_color, 1, 6)); + $txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2])); + $drp_color = str_split(substr($this->wm_shadow_color, 1, 6)); + $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[2]), hexdec($drp_color[3])); + + // Add the text to the source image + if ($this->wm_use_truetype) + { + imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); + imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); + } + else + { + imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); + imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); + } } // Output the final image -- cgit v1.2.3-24-g4f1b From a948f07bde83e149d9fc75e9aaf7260efba39b55 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 14:22:50 +0200 Subject: Remove a str_split() from the previous commit - we can access string characters like we do in an indexed array anyways --- system/libraries/Image_lib.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index d4fb51923..72621c9b4 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -171,15 +171,7 @@ class CI_Image_lib { { if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { - if (strlen($matches[1]) === 6) - { - $val = '#'.$val; - } - else - { - $val = str_split($val, 1); - $val = '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2]; - } + $val = (strlen($matches[1]) === 6) ? '#'.$val : '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2]; } else { -- cgit v1.2.3-24-g4f1b From 1d97f291fa1988794b0e6ac2b90a0b1f8c83df25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 14:24:59 +0200 Subject: Another fix on a previous commit from this request --- system/libraries/Image_lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 72621c9b4..609cb7f98 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -171,7 +171,8 @@ class CI_Image_lib { { if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { - $val = (strlen($matches[1]) === 6) ? '#'.$val : '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2]; + $val = (strlen($matches[1]) === 6) ? + '#'.$matches[1] : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2]; } else { -- cgit v1.2.3-24-g4f1b From 665af0cbb98372f8521298aafcde9e0c9023123e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 14:39:29 +0200 Subject: Some alignment for readability --- system/libraries/Image_lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 609cb7f98..7beac0ba0 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -171,8 +171,9 @@ class CI_Image_lib { { if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { - $val = (strlen($matches[1]) === 6) ? - '#'.$matches[1] : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2]; + $val = (strlen($matches[1]) === 6) + ? '#'.$matches[1] + : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2]; } else { -- cgit v1.2.3-24-g4f1b From adc1175f7af1a5fa3a833f72b6f24a82b59e69c1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 14:46:08 +0200 Subject: Replace some list(...) = each(...) expressions with current(), where only values are needed --- system/libraries/Xmlrpc.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 2804e6685..bb95ca145 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -542,7 +542,7 @@ class XML_RPC_Response elseif ($kind == 'array') { reset($xmlrpc_val->me); - list(, $b) = each($xmlrpc_val->me); + $b = current($xmlrpc_val->me); $arr = array(); for ($i = 0, $size = count($b); $i < $size; $i++) @@ -1150,8 +1150,7 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ($kind == 'array') { reset($param->me); - list(, $b) = each($param->me); - + $b = current($param->me); $arr = array(); for($i = 0, $c = count($b); $i < $c; $i++) @@ -1164,7 +1163,6 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ($kind == 'struct') { reset($param->me['struct']); - $arr = array(); while (list($key,$value) = each($param->me['struct'])) @@ -1359,8 +1357,7 @@ class XML_RPC_Values extends CI_Xmlrpc public function scalarval() { reset($this->me); - list(, $b) = each($this->me); - return $b; + return current($this->me); } -- cgit v1.2.3-24-g4f1b From d268eda6c2b502cc7fa352072482d1924e36127e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sat, 31 Dec 2011 16:20:11 +0000 Subject: Added SELECT version to migrations to make the query a billionth faster. --- system/libraries/Migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index eb5161d76..f89391c0d 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -322,7 +322,7 @@ class CI_Migration { */ protected function _get_version() { - $row = $this->db->get($this->_migration_table)->row(); + $row = $this->db->select('version')->get($this->_migration_table)->row(); return $row ? $row->version : 0; } -- cgit v1.2.3-24-g4f1b From 8323ae6cebde490bc29141d8dadbdbc07a1c6a4a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 31 Dec 2011 18:39:10 +0200 Subject: Fix a bug and put some comments describing changes from pull #818 --- system/libraries/Image_lib.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 7beac0ba0..c175c6740 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -169,8 +169,21 @@ class CI_Image_lib { { if (in_array($key, array('wm_font_color', 'wm_shadow_color'))) { - if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) + if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { + /* This particular line has caused a lengthy discussion + * (https://github.com/EllisLab/CodeIgniter/pull/818), so + * just to clarify: + * + * $matches[1] contains our hex color value, but it might be + * both in the full 6-length format or the shortened 3-length + * value. + * We'll later need the full version, so if we keep it if it's + * already there and if not - we'll convert to it. We can + * access string characters by their index as in an array, + * so we'll do that and use concatenation to form the final + * value: + */ $val = (strlen($matches[1]) === 6) ? '#'.$matches[1] : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2]; @@ -1073,10 +1086,15 @@ class CI_Image_lib { if ($this->wm_use_drop_shadow) { - // Set RGB values for text and shadow - $txt_color = str_split(substr($this->wm_font_color, 1, 6)); + /* Set RGB values for text and shadow + * + * First character is #, so we don't really need it. + * Get the rest of the string and split it into 2-length + * hex values: + */ + $txt_color = str_split(substr($this->wm_font_color, 1, 6), 2); $txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2])); - $drp_color = str_split(substr($this->wm_shadow_color, 1, 6)); + $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[2]), hexdec($drp_color[3])); // Add the text to the source image -- cgit v1.2.3-24-g4f1b From bb96c8b466cb618c5fd6f004234a137011a7e374 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 31 Dec 2011 18:48:39 +0200 Subject: Fix a comment typo --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index c175c6740..5f5b5f9d5 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -178,7 +178,7 @@ class CI_Image_lib { * $matches[1] contains our hex color value, but it might be * both in the full 6-length format or the shortened 3-length * value. - * We'll later need the full version, so if we keep it if it's + * We'll later need the full version, so we keep it if it's * already there and if not - we'll convert to it. We can * access string characters by their index as in an array, * so we'll do that and use concatenation to form the final -- cgit v1.2.3-24-g4f1b From cf2ba9ee5fc50b8411eba46ddd73c59b66524fea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 1 Jan 2012 21:57:13 +0200 Subject: Cut some comments --- system/libraries/Image_lib.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 5f5b5f9d5..fe9b8dc79 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -171,11 +171,7 @@ class CI_Image_lib { { if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches)) { - /* This particular line has caused a lengthy discussion - * (https://github.com/EllisLab/CodeIgniter/pull/818), so - * just to clarify: - * - * $matches[1] contains our hex color value, but it might be + /* $matches[1] contains our hex color value, but it might be * both in the full 6-length format or the shortened 3-length * value. * We'll later need the full version, so we keep it if it's -- cgit v1.2.3-24-g4f1b From 0defe5d33ee2633f377a109519ca818becc60f64 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 1 Jan 2012 18:46:41 -0600 Subject: Updating copyright date to 2012 --- 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 87253739c..2e78a6660 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @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 diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index 90b68688d..93993d07a 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @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 diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index ff787e90b..fcd55da39 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @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 diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 194279726..4a81b0422 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @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 diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 0037e6755..ffe6f2ff7 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @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 diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 605765bf6..a05a7babf 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 01a0cb8ce..ba8d69be2 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 183a95985..2112a7ee6 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 1066535c7..922107e9f 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 92b0b3c4a..e297576e6 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d83afdd25..2761d060b 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 99850a9e5..ab395b0a0 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index fe9b8dc79..c86224ffb 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index f872d672f..33df6007a 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 7f3a307f3..944173fdd 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index f89391c0d..d07097223 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 3.0 diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 008c15192..23ca549e2 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 39aa61e45..321248277 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 9cbd69bb2..89c616543 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 137b037b8..04103a4d9 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 1851bf3bc..fb154e50f 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.3.1 diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index b5e68507f..79a009133 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 651ba7bff..76f0d4fc5 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index fd3880d29..38d767c69 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.3.1 diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 826bcceb8..0c63886e7 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index c31ff2646..cd644c00d 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7b1e3fa6e..1bdc27512 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 893e51873..355d43f29 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 52f1bc3d0..50e84920e 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 888e89b1b..03574c66e 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From d09d650acf612652627d77efda3616e5bbc3871c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Jan 2012 06:38:33 +0200 Subject: Fix a comment and remove access description lines --- system/libraries/Form_validation.php | 46 ++++-------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 2761d060b..0a6a2af0d 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -78,7 +78,6 @@ class CI_Form_validation { * This function takes an array of field names and validation * rules as input, validates the info, and stores it * - * @access public * @param mixed * @param string * @return void @@ -168,7 +167,6 @@ class CI_Form_validation { * Lets users set their own error messages on the fly. Note: The key * name has to match the function name that it corresponds to. * - * @access public * @param string * @param string * @return string @@ -192,7 +190,6 @@ class CI_Form_validation { * * Permits a prefix/suffix to be added to each error message * - * @access public * @param string * @param string * @return void @@ -212,7 +209,6 @@ class CI_Form_validation { * * Gets the error message associated with a particular field * - * @access public * @param string the field name * @return void */ @@ -243,7 +239,6 @@ class CI_Form_validation { * * Returns the error messages as a string, wrapped in the error delimiters * - * @access public * @param string * @param string * @return str @@ -286,7 +281,6 @@ class CI_Form_validation { * * This function does all the work. * - * @access public * @return bool */ public function run($group = '') @@ -371,7 +365,6 @@ class CI_Form_validation { /** * Traverse a multidimensional $_POST array index until the data is found * - * @access protected * @param array * @param array * @param integer @@ -392,7 +385,6 @@ class CI_Form_validation { /** * Re-populate the _POST array with our finalized and processed data * - * @access protected * @return null */ protected function _reset_post_array() @@ -450,7 +442,6 @@ class CI_Form_validation { /** * Executes the Validation routines * - * @access protected * @param array * @param array * @param mixed @@ -680,7 +671,6 @@ class CI_Form_validation { /** * Translate a field name * - * @access protected * @param string the field name * @return string */ @@ -711,7 +701,6 @@ class CI_Form_validation { * Permits you to repopulate a form field with the value it was submitted * with, or, if that value doesn't exist, with the default * - * @access public * @param string the field name * @param string * @return void @@ -741,7 +730,6 @@ class CI_Form_validation { * Enables pull-down lists to be set to the value the user * selected in the event of an error * - * @access public * @param string * @param string * @return string @@ -785,7 +773,6 @@ class CI_Form_validation { * Enables radio buttons to be set to the value the user * selected in the event of an error * - * @access public * @param string * @param string * @return string @@ -829,7 +816,6 @@ class CI_Form_validation { * Enables checkboxes to be set to the value the user * selected in the event of an error * - * @access public * @param string * @param string * @return string @@ -845,7 +831,6 @@ class CI_Form_validation { /** * Required * - * @access public * @param string * @return bool */ @@ -859,7 +844,6 @@ class CI_Form_validation { /** * Performs a Regular Expression match test. * - * @access public * @param string * @param regex * @return bool @@ -874,7 +858,6 @@ class CI_Form_validation { /** * Match one field to another * - * @access public * @param string * @param field * @return bool @@ -894,9 +877,11 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** - * Match one field to another + * Is Unique + * + * Check if the input value doesn't already exist + * in the specified database field. * - * @access public * @param string * @param field * @return bool @@ -917,7 +902,6 @@ class CI_Form_validation { /** * Minimum Length * - * @access public * @param string * @param value * @return bool @@ -942,7 +926,6 @@ class CI_Form_validation { /** * Max Length * - * @access public * @param string * @param value * @return bool @@ -967,7 +950,6 @@ class CI_Form_validation { /** * Exact Length * - * @access public * @param string * @param value * @return bool @@ -992,7 +974,6 @@ class CI_Form_validation { /** * Valid Email * - * @access public * @param string * @return bool */ @@ -1006,7 +987,6 @@ class CI_Form_validation { /** * Valid Emails * - * @access public * @param string * @return bool */ @@ -1033,7 +1013,6 @@ class CI_Form_validation { /** * Validate IP Address * - * @access public * @param string * @return bool */ @@ -1047,7 +1026,6 @@ class CI_Form_validation { /** * Alpha * - * @access public * @param string * @return bool */ @@ -1061,7 +1039,6 @@ class CI_Form_validation { /** * Alpha-numeric * - * @access public * @param string * @return bool */ @@ -1075,7 +1052,6 @@ class CI_Form_validation { /** * Alpha-numeric with underscores and dashes * - * @access public * @param string * @return bool */ @@ -1089,7 +1065,6 @@ class CI_Form_validation { /** * Numeric * - * @access public * @param string * @return bool */ @@ -1104,7 +1079,6 @@ class CI_Form_validation { /** * Is Numeric * - * @access public * @param string * @return bool */ @@ -1118,7 +1092,6 @@ class CI_Form_validation { /** * Integer * - * @access public * @param string * @return bool */ @@ -1132,7 +1105,6 @@ class CI_Form_validation { /** * Decimal number * - * @access public * @param string * @return bool */ @@ -1146,7 +1118,6 @@ class CI_Form_validation { /** * Greather than * - * @access public * @param string * @return bool */ @@ -1164,7 +1135,6 @@ class CI_Form_validation { /** * Less than * - * @access public * @param string * @return bool */ @@ -1182,7 +1152,6 @@ class CI_Form_validation { /** * Is a Natural number (0,1,2,3, etc.) * - * @access public * @param string * @return bool */ @@ -1196,7 +1165,6 @@ class CI_Form_validation { /** * Is a Natural number, but not a zero (1,2,3, etc.) * - * @access public * @param string * @return bool */ @@ -1213,7 +1181,6 @@ class CI_Form_validation { * Tests a string for characters outside of the Base64 alphabet * as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045 * - * @access public * @param string * @return bool */ @@ -1230,7 +1197,6 @@ class CI_Form_validation { * This function allows HTML to be safely shown in a form. * Special characters are converted. * - * @access public * @param string * @return string */ @@ -1259,7 +1225,6 @@ class CI_Form_validation { /** * Prep URL * - * @access public * @param string * @return string */ @@ -1283,7 +1248,6 @@ class CI_Form_validation { /** * Strip Image Tags * - * @access public * @param string * @return string */ @@ -1297,7 +1261,6 @@ class CI_Form_validation { /** * XSS Clean * - * @access public * @param string * @return string */ @@ -1311,7 +1274,6 @@ class CI_Form_validation { /** * Convert PHP tags to entities * - * @access public * @param string * @return string */ -- cgit v1.2.3-24-g4f1b From b195637240bbbc7c3dc7ee0585f0e4cd39cb9d81 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Jan 2012 11:01:48 +0200 Subject: Replace htmlentities() with htmlspecialchars() to fix issue #561 --- system/libraries/Xmlrpc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index bb95ca145..a9f8d9c38 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -437,7 +437,14 @@ class XML_RPC_Response { // error $this->errno = $code; - $this->errstr = htmlentities($fstr); + if ( ! is_php('5.4')) + { + $this->errstr = htmlspecialchars($fstr, ENT_NOQUOTES, 'UTF-8'); + } + else + { + $this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8'); + } } else if ( ! is_object($val)) { -- cgit v1.2.3-24-g4f1b From 8d727f14446f31d919e808e3833d252ef12cf1ae Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Wed, 4 Jan 2012 00:06:36 -0500 Subject: Fixed prefix and suffix in pagination. Fixes #677 --- system/libraries/Pagination.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 23ca549e2..2fe4cf31b 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -142,6 +142,11 @@ class CI_Pagination { // Determine the current page number. $CI =& get_instance(); + if ($this->prefix != '' OR $this->suffix != '') + { + $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment)); + } + if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { if ($CI->input->get($this->query_string_segment) != $base_page) -- cgit v1.2.3-24-g4f1b From 3b376595183e0e0db5559ccbfc368c442408dca9 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Wed, 4 Jan 2012 00:28:27 -0500 Subject: Fixed paging with prefix and suffix for real page numbers. Refs #677 Fixes #52 --- system/libraries/Pagination.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 2fe4cf31b..e0cab2128 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -142,9 +142,10 @@ class CI_Pagination { // Determine the current page number. $CI =& get_instance(); + // See if we are using a prefix or suffix on links if ($this->prefix != '' OR $this->suffix != '') { - $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment)); + $this->cur_page = (int) str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment)); } if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) @@ -154,7 +155,7 @@ class CI_Pagination { $this->cur_page = (int) $CI->input->get($this->query_string_segment); } } - elseif ($CI->uri->segment($this->uri_segment) != $base_page) + elseif ( ! $this->cur_page AND $CI->uri->segment($this->uri_segment) != $base_page) { $this->cur_page = (int) $CI->uri->segment($this->uri_segment); } @@ -165,7 +166,7 @@ class CI_Pagination { $this->cur_page = $base_page; } - $this->num_links = (int)$this->num_links; + $this->num_links = (int) $this->num_links; if ($this->num_links < 1) { -- cgit v1.2.3-24-g4f1b From 1a9f52c8ec021f6169b977ee936bb8cf2b972230 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 01:06:34 +0200 Subject: Fixed a bug in CI_Image_lib::resize() --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index c86224ffb..39f9887f1 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -392,7 +392,7 @@ class CI_Image_lib { */ public function resize() { - $protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; + $protocol = ($this->image_library === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; return $this->$protocol('resize'); } -- cgit v1.2.3-24-g4f1b From 5a67e3d09fe934af6f1bd75bb4e3dac87eb1361f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 01:21:09 +0200 Subject: Fix the same expression in crop() --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 39f9887f1..dc7d362ce 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -408,7 +408,7 @@ class CI_Image_lib { */ public function crop() { - $protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; + $protocol = ($this->image_library === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; return $this->$protocol('crop'); } -- cgit v1.2.3-24-g4f1b