Skip to content

Instantly share code, notes, and snippets.

@narfbg
narfbg / hkdf.php
Created February 3, 2014 22:09
Experimental HKDF implementation for CodeIgniter's encryption class
/**
* HKDF
*
* @link https://tools.ietf.org/rfc/rfc5869.txt
* @param $key Input key
* @param $digest A SHA-2 hashing algorithm
* @param $salt Optional salt
* @param $length Output length (defaults to the selected digest size)
* @param $info Optional context/application-specific info
* @return string A pseudo-random key
@narfbg
narfbg / Email.php
Created October 15, 2012 08:38
CodeIgniter Email.php with patch from gist 3870694 applied
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
* Licensed under the Open Software License version 3.0
*
@narfbg
narfbg / ci_upload_initialize.diff
Created February 20, 2014 11:34
Simplify CI_Upload::initialize() defaults reset
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 983d832..686f27d 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -301,41 +301,16 @@ class CI_Upload {
*/
public function initialize($config = array())
{
- $defaults = array(
- 'max_size' => 0,
@narfbg
narfbg / xmlrpc-fix-2737.diff
Created January 9, 2014 11:06
Fix for issue #2737
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 2fd1259..2a38dfd 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -1113,15 +1113,15 @@ class XML_RPC_Message extends CI_Xmlrpc
//-------------------------------------
$parser = xml_parser_create($this->xmlrpc_defencoding);
-
- $this->xh[$parser] = array(
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 1d41a19..c543e15 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2556,6 +2556,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
{
return;
}
+ elseif (in_array('select', $this->qb_cache_exists, TRUE))
+ {
@narfbg
narfbg / 2698.diff
Created October 28, 2013 11:19
A simpler alternative to CodeIgniter#2698
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index a36501e..95c3af3 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2551,11 +2551,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$qb_variable = 'qb_'.$val;
$qb_cache_var = 'qb_cache_'.$val;
- if (count($this->$qb_cache_var) === 0)
+ if (count($this->$qb_cache_var) > 0)
@narfbg
narfbg / gist:5412104
Last active December 16, 2015 09:19
Possible fix for CI issue 2406
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 292621b..569490e 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2554,7 +2554,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
{
continue;
}
- $this->$qb_variable = array_merge($this->$qb_variable, array_diff($this->$qb_cache_var, $this->$qb_variable));
+ $this->$qb_variable = array_merge($this->$qb_variable, array_udiff($this->$qb_cache_var, $this->$qb_variable, '_ci_array_diff'));
@narfbg
narfbg / issue-658-fix.diff
Created October 26, 2012 09:48
Fix for CodeIgniter issue #658
diff --git a/system/core/Router.php b/system/core/Router.php
index 5bc0530..db73cb2 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -368,7 +368,7 @@ class CI_Router {
foreach ($this->routes as $key => $val)
{
// Convert wild-cards to RegEx
- $key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key);
+ $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);
@narfbg
narfbg / prep_q_encoding.diff
Created October 11, 2012 07:06
RC Fix issues #1409 & #1498 (broken multibyte email headers)
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 698cb76..764d16d 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -98,7 +98,7 @@ class CI_Email {
*/
public function __construct($config = array())
{
- $this->charset = strtoupper(config_item('charset'));
+ $this->charset = config_item('charset');
@narfbg
narfbg / proxies-fix.diff
Created August 15, 2012 12:08
Subnetted proxies fix
diff --git a/system/core/Input.php b/system/core/Input.php
index 968a42a..c3d8980 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -328,34 +328,42 @@ class CI_Input {
return $this->ip_address;
}
- if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR'))
+ $proxies = config_item('proxy_ips');