diff --git a/application/config/application.php b/application/config/application.php index dea0c54cf..02137e066 100644 --- a/application/config/application.php +++ b/application/config/application.php @@ -3,11 +3,11 @@ * Bonfire * * An open source project to allow developers to jumpstart their development of - * CodeIgniter applications + * CodeIgniter applications. * * @package Bonfire * @author Bonfire Dev Team - * @copyright Copyright (c) 2011 - 2014, Bonfire Dev Team + * @copyright Copyright (c) 2011 - 2015, Bonfire Dev Team * @license http://opensource.org/licenses/MIT The MIT License * @link http://cibonfire.com * @since Version 1.0 @@ -19,16 +19,15 @@ */ $config['site.default_user_timezone'] = 'UM8'; -//-------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Module Locations -//-------------------------------------------------------------------- -// These paths are checked in the order listed whenever a module is -// attempting to be located, whether it's loading a library, helper, -// or routes file. +//------------------------------------------------------------------------------ +// These paths are checked in the order listed when attempting to locate a module, +// whether loading a library, helper, or routes file. // $config['modules_locations'] = array( realpath(APPPATH) . '/modules/' => '../../application/modules/', - realpath(APPPATH . '../bonfire') . '/modules/' => '../../bonfire/modules/', + realpath(BFPATH) . '/modules/' => '../../bonfire/modules/', ); //------------------------------------------------------------------------------ diff --git a/application/config/autoload.php b/application/config/autoload.php index 562be354e..a75a6be84 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -1,5 +1,5 @@ 'ua'); */ - $autoload['libraries'] = array('database'); @@ -69,15 +68,15 @@ | ------------------------------------------------------------------- | Auto-load Drivers | ------------------------------------------------------------------- -| These classes are located in the system/libraries folder or in your -| application/libraries folder within their own subdirectory. They +| These classes are located in system/libraries/ or in your +| application/libraries/ directory, but are also placed inside their +| own subdirectory and they extend the CI_Driver_Library class. They | offer multiple interchangeable driver options. | | Prototype: | | $autoload['drivers'] = array('cache'); */ - $autoload['drivers'] = array(); /* @@ -88,7 +87,6 @@ | | $autoload['helper'] = array('url', 'file'); */ - $autoload['helper'] = array('url', 'language'); /* @@ -103,7 +101,6 @@ | config files. Otherwise, leave it blank. | */ - $autoload['config'] = array('application'); /* @@ -118,7 +115,6 @@ | "codeigniter_lang.php" would be referenced as array('codeigniter'); | */ - $autoload['language'] = array(); /* @@ -127,12 +123,11 @@ | ------------------------------------------------------------------- | Prototype: | -| $autoload['model'] = array('model1', 'model2'); +| $autoload['model'] = array('first_model', 'second_model'); | | You can also supply an alternative model name to be assigned | in the controller: | | $autoload['model'] = array('first_model' => 'first'); */ - $autoload['model'] = array(); diff --git a/application/config/config.php b/application/config/config.php index 42dfe396f..f4b55cc37 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -1,5 +1,5 @@ '', - 'hostname' => 'localhost', + 'hostname' => '127.0.0.1', 'username' => '', 'password' => '', 'database' => '', @@ -107,7 +107,6 @@ 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', - 'autoinit' => true, 'encrypt' => false, 'compress' => false, 'stricton' => true, diff --git a/application/config/events.php b/application/config/events.php index f1f6fd581..c11894eaa 100644 --- a/application/config/events.php +++ b/application/config/events.php @@ -1,4 +1,4 @@ - 's', '/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T', '/ț|ţ|ť|ŧ|т/' => 't', + '/Þ|þ/' => 'th', '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U', '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u', '/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y', diff --git a/application/config/hooks.php b/application/config/hooks.php index 8af6c5a31..918c8acdc 100644 --- a/application/config/hooks.php +++ b/application/config/hooks.php @@ -3,16 +3,16 @@ * Define "hooks" to extend CI without hacking the core files. Please see the * user guide for info: * - * @link https://ellislab.com/codeigniter/user-guide/general/hooks.html + * @link http://www.codeigniter.com/user_guide/general/hooks.html */ // Store the requested URL, which will sometimes be different from previous URL. $hook['pre_controller'][] = array( - 'class' => 'App_hooks', + 'class' => 'App_hooks', 'function' => 'saveRequested', - 'filename' => 'App_hooks.php', - 'filepath' => 'hooks', - 'params' => '' + 'filename' => 'App_hooks.php', + 'filepath' => 'hooks', + 'params' => '' ); // Check whether the Composer Autoloader should be used. @@ -26,20 +26,20 @@ // Allow performance of good redirects to previous pages. $hook['post_controller'][] = array( - 'class' => 'App_hooks', + 'class' => 'App_hooks', 'function' => 'prepRedirect', - 'filename' => 'App_hooks.php', - 'filepath' => 'hooks', - 'params' => '' + 'filename' => 'App_hooks.php', + 'filepath' => 'hooks', + 'params' => '' ); - + // Check whether the site is in maintenance mode. $hook['post_controller_constructor'][] = array( - 'class' => 'App_hooks', + 'class' => 'App_hooks', 'function' => 'checkSiteStatus', - 'filename' => 'App_hooks.php', - 'filepath' => 'hooks', - 'params' => '' + 'filename' => 'App_hooks.php', + 'filepath' => 'hooks', + 'params' => '' ); /* End of file /application/config/hooks.php */ diff --git a/application/config/migration.php b/application/config/migration.php index f47548157..c87bd484a 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -25,12 +25,12 @@ | Migration file names may be based on a sequential identifier or on | a timestamp. Options are: | -| 'sequential' = Default migration naming (001_add_blog.php) +| 'sequential' = Sequential migration naming (001_add_blog.php) | 'timestamp' = Timestamp migration naming (20121031104401_add_blog.php) | Use timestamp format YYYYMMDDHHIISS. | -| If this configuration value is missing the Migration library defaults -| to 'sequential' for backward compatibility. +| Note: If this configuration value is missing the Migration library +| defaults to 'sequential' for backward compatibility with CI2. | */ $config['migration_type'] = 'timestamp'; diff --git a/application/config/mimes.php b/application/config/mimes.php index c18312ff3..a35d48940 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -1,4 +1,6 @@ - 'application/x-pkcs7', 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'), '3g2' => 'video/3gpp2', - '3gp' => 'video/3gp', + '3gp' => array('video/3gp', 'video/3gpp'), 'mp4' => 'video/mp4', 'm4a' => 'audio/x-m4a', 'f4v' => 'video/mp4', @@ -151,6 +153,9 @@ 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'), 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'), 'vcf' => 'text/x-vcard', + 'srt' => array('text/srt', 'text/plain'), + 'vtt' => array('text/vtt', 'text/plain'), + 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon') ); if (defined('CI_VERSION') && substr(CI_VERSION, 0, 1) != '2') { diff --git a/application/config/smileys.php b/application/config/smileys.php index 1428d68bc..1eeba4776 100644 --- a/application/config/smileys.php +++ b/application/config/smileys.php @@ -13,7 +13,6 @@ | http://codeigniter.com/user_guide/helpers/smiley_helper.html | */ - $smileys = array( // smiley image name width height alt diff --git a/application/config/user_agents.php b/application/config/user_agents.php index 73592c2a4..ac277374d 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -10,49 +10,49 @@ | mobile device data. The array keys are used to identify the device | and the array values are used to set the actual name of the item. */ - $platforms = array ( - 'windows nt 6.3' => 'Windows 8.1', - 'windows nt 6.2' => 'Windows 8', - 'windows nt 6.1' => 'Windows 7', - 'windows nt 6.0' => 'Windows Vista', - 'windows nt 5.2' => 'Windows 2003', - 'windows nt 5.1' => 'Windows XP', - 'windows nt 5.0' => 'Windows 2000', - 'windows nt 4.0' => 'Windows NT 4.0', - 'winnt4.0' => 'Windows NT 4.0', - 'winnt 4.0' => 'Windows NT', - 'winnt' => 'Windows NT', - 'windows 98' => 'Windows 98', - 'win98' => 'Windows 98', - 'windows 95' => 'Windows 95', - 'win95' => 'Windows 95', - 'windows phone' => 'Windows Phone', - 'windows' => 'Unknown Windows OS', - 'android' => 'Android', - 'blackberry' => 'BlackBerry', - 'iphone' => 'iOS', - 'ipad' => 'iOS', - 'ipod' => 'iOS', - 'os x' => 'Mac OS X', - 'ppc mac' => 'Power PC Mac', - 'freebsd' => 'FreeBSD', - 'ppc' => 'Macintosh', - 'linux' => 'Linux', - 'debian' => 'Debian', - 'sunos' => 'Sun Solaris', - 'beos' => 'BeOS', - 'apachebench' => 'ApacheBench', - 'aix' => 'AIX', - 'irix' => 'Irix', - 'osf' => 'DEC OSF', - 'hp-ux' => 'HP-UX', - 'netbsd' => 'NetBSD', - 'bsdi' => 'BSDi', - 'openbsd' => 'OpenBSD', - 'gnu' => 'GNU/Linux', - 'unix' => 'Unknown Unix OS', - 'symbian' => 'Symbian OS', + 'windows nt 10.0' => 'Windows 10', + 'windows nt 6.3' => 'Windows 8.1', + 'windows nt 6.2' => 'Windows 8', + 'windows nt 6.1' => 'Windows 7', + 'windows nt 6.0' => 'Windows Vista', + 'windows nt 5.2' => 'Windows 2003', + 'windows nt 5.1' => 'Windows XP', + 'windows nt 5.0' => 'Windows 2000', + 'windows nt 4.0' => 'Windows NT 4.0', + 'winnt4.0' => 'Windows NT 4.0', + 'winnt 4.0' => 'Windows NT', + 'winnt' => 'Windows NT', + 'windows 98' => 'Windows 98', + 'win98' => 'Windows 98', + 'windows 95' => 'Windows 95', + 'win95' => 'Windows 95', + 'windows phone' => 'Windows Phone', + 'windows' => 'Unknown Windows OS', + 'android' => 'Android', + 'blackberry' => 'BlackBerry', + 'iphone' => 'iOS', + 'ipad' => 'iOS', + 'ipod' => 'iOS', + 'os x' => 'Mac OS X', + 'ppc mac' => 'Power PC Mac', + 'freebsd' => 'FreeBSD', + 'ppc' => 'Macintosh', + 'linux' => 'Linux', + 'debian' => 'Debian', + 'sunos' => 'Sun Solaris', + 'beos' => 'BeOS', + 'apachebench' => 'ApacheBench', + 'aix' => 'AIX', + 'irix' => 'Irix', + 'osf' => 'DEC OSF', + 'hp-ux' => 'HP-UX', + 'netbsd' => 'NetBSD', + 'bsdi' => 'BSDi', + 'openbsd' => 'OpenBSD', + 'gnu' => 'GNU/Linux', + 'unix' => 'Unknown Unix OS', + 'symbian' => 'Symbian OS', ); @@ -61,6 +61,7 @@ $browsers = array( 'OPR' => 'Opera', 'Flock' => 'Flock', + 'Edge' => 'Spartan', 'RockMelt' => 'RockMelt', 'Chrome' => 'Chrome', // Opera 10+ always reports Opera/9.80 and appends Version/ to the user agent string @@ -93,57 +94,57 @@ $mobiles = array( // legacy array, old values commented out 'mobileexplorer' => 'Mobile Explorer', - // 'openwave' => 'Open Wave', - // 'opera mini' => 'Opera Mini', - // 'operamini' => 'Opera Mini', - // 'elaine' => 'Palm', + // 'openwave' => 'Open Wave', + // 'opera mini' => 'Opera Mini', + // 'operamini' => 'Opera Mini', + // 'elaine' => 'Palm', 'palmsource' => 'Palm', - // 'digital paths' => 'Palm', - // 'avantgo' => 'Avantgo', - // 'xiino' => 'Xiino', + // 'digital paths' => 'Palm', + // 'avantgo' => 'Avantgo', + // 'xiino' => 'Xiino', 'palmscape' => 'Palmscape', - // 'nokia' => 'Nokia', - // 'ericsson' => 'Ericsson', - // 'blackberry' => 'BlackBerry', - // 'motorola' => 'Motorola', + // 'nokia' => 'Nokia', + // 'ericsson' => 'Ericsson', + // 'blackberry' => 'BlackBerry', + // 'motorola' => 'Motorola', // Phones and Manufacturers - 'motorola' => 'Motorola', - 'nokia' => 'Nokia', - 'palm' => 'Palm', - 'iphone' => 'Apple iPhone', - 'ipad' => 'iPad', - 'ipod' => 'Apple iPod Touch', - 'sony' => 'Sony Ericsson', - 'ericsson' => 'Sony Ericsson', - 'blackberry' => 'BlackBerry', - 'cocoon' => 'O2 Cocoon', - 'blazer' => 'Treo', - 'lg' => 'LG', - 'amoi' => 'Amoi', - 'xda' => 'XDA', - 'mda' => 'MDA', - 'vario' => 'Vario', - 'htc' => 'HTC', - 'samsung' => 'Samsung', - 'sharp' => 'Sharp', - 'sie-' => 'Siemens', - 'alcatel' => 'Alcatel', - 'benq' => 'BenQ', - 'ipaq' => 'HP iPaq', - 'mot-' => 'Motorola', - 'playstation portable' => 'PlayStation Portable', + 'motorola' => 'Motorola', + 'nokia' => 'Nokia', + 'palm' => 'Palm', + 'iphone' => 'Apple iPhone', + 'ipad' => 'iPad', + 'ipod' => 'Apple iPod Touch', + 'sony' => 'Sony Ericsson', + 'ericsson' => 'Sony Ericsson', + 'blackberry' => 'BlackBerry', + 'cocoon' => 'O2 Cocoon', + 'blazer' => 'Treo', + 'lg' => 'LG', + 'amoi' => 'Amoi', + 'xda' => 'XDA', + 'mda' => 'MDA', + 'vario' => 'Vario', + 'htc' => 'HTC', + 'samsung' => 'Samsung', + 'sharp' => 'Sharp', + 'sie-' => 'Siemens', + 'alcatel' => 'Alcatel', + 'benq' => 'BenQ', + 'ipaq' => 'HP iPaq', + 'mot-' => 'Motorola', + 'playstation portable' => 'PlayStation Portable', 'playstation 3' => 'PlayStation 3', 'playstation vita' => 'PlayStation Vita', - 'hiptop' => 'Danger Hiptop', - 'nec-' => 'NEC', - 'panasonic' => 'Panasonic', - 'philips' => 'Philips', - 'sagem' => 'Sagem', - 'sanyo' => 'Sanyo', - 'spv' => 'SPV', - 'zte' => 'ZTE', - 'sendo' => 'Sendo', + 'hiptop' => 'Danger Hiptop', + 'nec-' => 'NEC', + 'panasonic' => 'Panasonic', + 'philips' => 'Philips', + 'sagem' => 'Sagem', + 'sanyo' => 'Sanyo', + 'spv' => 'SPV', + 'zte' => 'ZTE', + 'sendo' => 'Sendo', 'nintendo dsi' => 'Nintendo DSi', 'nintendo ds' => 'Nintendo DS', 'nintendo 3ds' => 'Nintendo 3DS', @@ -152,42 +153,42 @@ 'openweb' => 'OpenWeb', // Operating Systems - 'android' => 'Android', - 'symbian' => 'Symbian', - 'SymbianOS' => 'SymbianOS', - 'elaine' => 'Palm', - 'series60' => 'Symbian S60', - 'windows ce' => 'Windows CE', + 'android' => 'Android', + 'symbian' => 'Symbian', + 'SymbianOS' => 'SymbianOS', + 'elaine' => 'Palm', + 'series60' => 'Symbian S60', + 'windows ce' => 'Windows CE', // Browsers - 'obigo' => 'Obigo', - 'netfront' => 'Netfront Browser', - 'openwave' => 'Openwave Browser', - 'mobilexplorer' => 'Mobile Explorer', - 'operamini' => 'Opera Mini', - 'opera mini' => 'Opera Mini', + 'obigo' => 'Obigo', + 'netfront' => 'Netfront Browser', + 'openwave' => 'Openwave Browser', + 'mobilexplorer' => 'Mobile Explorer', + 'operamini' => 'Opera Mini', + 'opera mini' => 'Opera Mini', 'opera mobi' => 'Opera Mobile', - 'fennec' => 'Firefox Mobile', + 'fennec' => 'Firefox Mobile', // Other - 'digital paths' => 'Digital Paths', - 'avantgo' => 'AvantGo', - 'xiino' => 'Xiino', - 'novarra' => 'Novarra Transcoder', - 'vodafone' => 'Vodafone', - 'docomo' => 'NTT DoCoMo', - 'o2' => 'O2', + 'digital paths' => 'Digital Paths', + 'avantgo' => 'AvantGo', + 'xiino' => 'Xiino', + 'novarra' => 'Novarra Transcoder', + 'vodafone' => 'Vodafone', + 'docomo' => 'NTT DoCoMo', + 'o2' => 'O2', // Fallback - 'mobile' => 'Generic Mobile', - 'wireless' => 'Generic Mobile', - 'j2me' => 'Generic Mobile', - 'midp' => 'Generic Mobile', - 'cldc' => 'Generic Mobile', - 'up.link' => 'Generic Mobile', - 'up.browser' => 'Generic Mobile', - 'smartphone' => 'Generic Mobile', - 'cellphone' => 'Generic Mobile', + 'mobile' => 'Generic Mobile', + 'wireless' => 'Generic Mobile', + 'j2me' => 'Generic Mobile', + 'midp' => 'Generic Mobile', + 'cldc' => 'Generic Mobile', + 'up.link' => 'Generic Mobile', + 'up.browser' => 'Generic Mobile', + 'smartphone' => 'Generic Mobile', + 'cellphone' => 'Generic Mobile', ); // There are hundreds of bots but these are the most common. diff --git a/application/third_party/MX/Loader.php b/application/third_party/MX/Loader.php index a1133528b..b219e96f7 100644 --- a/application/third_party/MX/Loader.php +++ b/application/third_party/MX/Loader.php @@ -171,7 +171,6 @@ public function library($library, $params = NULL, $object_name = NULL) if ($path === FALSE) { $this->_ci_load_library($library, $params, $object_name); - $_alias = $this->_ci_classes[$class]; } else { diff --git a/application/views/errors/cli/error_exception.php b/application/views/errors/cli/error_exception.php index 75d7f0fad..efa6a66d1 100644 --- a/application/views/errors/cli/error_exception.php +++ b/application/views/errors/cli/error_exception.php @@ -1,25 +1,21 @@ - + An uncaught Exception was encountered -Type: -Message: -Filename: getFile(); ?> +Type: +Message: +Filename: getFile(), "\n"; ?> Line Number: getLine(); ?> Backtrace: - getTrace() as $error): ?> - +getTrace() as $error): ?> + + File: + Line: + Function: + + - File: - Line: - Function: - - - - - \ No newline at end of file + diff --git a/application/views/errors/cli/error_php.php b/application/views/errors/cli/error_php.php index fec91e54f..8a24b6491 100644 --- a/application/views/errors/cli/error_php.php +++ b/application/views/errors/cli/error_php.php @@ -1,25 +1,21 @@ - + A PHP Error was encountered -Severity: -Message: -Filename: -Line Number: +Severity: +Message: +Filename: +Line Number: Backtrace: - - + + + File: + Line: + Function: + + - File: - Line: - Function: - - - - - \ No newline at end of file + diff --git a/bonfire/ci2/core/CodeIgniter.php b/bonfire/ci2/core/CodeIgniter.php index 652ad2c44..f59a86c0a 100644 --- a/bonfire/ci2/core/CodeIgniter.php +++ b/bonfire/ci2/core/CodeIgniter.php @@ -34,7 +34,7 @@ * @var string * */ - define('CI_VERSION', '2.2.3'); + define('CI_VERSION', '2.2.4'); /** * CodeIgniter Branch (Core = TRUE, Reactor = FALSE) diff --git a/bonfire/ci2/core/Loader.php b/bonfire/ci2/core/Loader.php new file mode 100644 index 000000000..d649416c0 --- /dev/null +++ b/bonfire/ci2/core/Loader.php @@ -0,0 +1,1262 @@ + 'unit', + 'user_agent' => 'agent'); + + /** + * Constructor + * + * Sets the path to the view files and gets the initial output buffering level + */ + public function __construct() + { + $this->_ci_ob_level = ob_get_level(); + $this->_ci_library_paths = array(APPPATH, BASEPATH); + $this->_ci_helper_paths = array(APPPATH, BASEPATH); + $this->_ci_model_paths = array(APPPATH); + $this->_ci_view_paths = array(APPPATH.'views/' => TRUE); + + log_message('debug', "Loader Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Initialize the Loader + * + * This method is called once in CI_Controller. + * + * @param array + * @return object + */ + public function initialize() + { + $this->_ci_classes = array(); + $this->_ci_loaded_files = array(); + $this->_ci_models = array(); + $this->_base_classes =& is_loaded(); + + $this->_ci_autoloader(); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Is Loaded + * + * A utility function to test if a class is in the self::$_ci_classes array. + * This function returns the object name if the class tested for is loaded, + * and returns FALSE if it isn't. + * + * It is mainly used in the form_helper -> _get_validation_object() + * + * @param string class being checked for + * @return mixed class object name on the CI SuperObject or FALSE + */ + public function is_loaded($class) + { + if (isset($this->_ci_classes[$class])) + { + return $this->_ci_classes[$class]; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Class Loader + * + * This function lets users load and instantiate classes. + * It is designed to be called from a user's app controllers. + * + * @param string the name of the class + * @param mixed the optional parameters + * @param string an optional object name + * @return void + */ + public function library($library = '', $params = NULL, $object_name = NULL) + { + if (is_array($library)) + { + foreach ($library as $class) + { + $this->library($class, $params); + } + + return; + } + + if ($library == '' OR isset($this->_base_classes[$library])) + { + return FALSE; + } + + if ( ! is_null($params) && ! is_array($params)) + { + $params = NULL; + } + + $this->_ci_load_class($library, $params, $object_name); + } + + // -------------------------------------------------------------------- + + /** + * Model Loader + * + * This function lets users load and instantiate models. + * + * @param string the name of the class + * @param string name for the model + * @param bool database connection + * @return void + */ + public function model($model, $name = '', $db_conn = FALSE) + { + if (is_array($model)) + { + foreach ($model as $babe) + { + $this->model($babe); + } + return; + } + + if ($model == '') + { + return; + } + + $path = ''; + + // Is the model in a sub-folder? If so, parse out the filename and path. + if (($last_slash = strrpos($model, '/')) !== FALSE) + { + // The path is in front of the last slash + $path = substr($model, 0, $last_slash + 1); + + // And the model name behind it + $model = substr($model, $last_slash + 1); + } + + if ($name == '') + { + $name = $model; + } + + if (in_array($name, $this->_ci_models, TRUE)) + { + return; + } + + $CI =& get_instance(); + if (isset($CI->$name)) + { + show_error('The model name you are loading is the name of a resource that is already being used: '.$name); + } + + $model = strtolower($model); + + foreach ($this->_ci_model_paths as $mod_path) + { + if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) + { + continue; + } + + if ($db_conn !== FALSE AND ! class_exists('CI_DB')) + { + if ($db_conn === TRUE) + { + $db_conn = ''; + } + + $CI->load->database($db_conn, FALSE, TRUE); + } + + if ( ! class_exists('CI_Model')) + { + load_class('Model', 'core'); + } + + require_once($mod_path.'models/'.$path.$model.'.php'); + + $model = ucfirst($model); + + $CI->$name = new $model(); + + $this->_ci_models[] = $name; + return; + } + + // couldn't find the model + show_error('Unable to locate the model you have specified: '.$model); + } + + // -------------------------------------------------------------------- + + /** + * Database Loader + * + * @param string the DB credentials + * @param bool whether to return the DB object + * @param bool whether to enable active record (this allows us to override the config setting) + * @return object + */ + public function database($params = '', $return = FALSE, $active_record = NULL) + { + // Grab the super object + $CI =& get_instance(); + + // Do we even need to load the database class? + if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db)) + { + return FALSE; + } + + require_once(BASEPATH.'database/DB.php'); + + if ($return === TRUE) + { + return DB($params, $active_record); + } + + // Initialize the db variable. Needed to prevent + // reference errors with some configurations + $CI->db = ''; + + // Load the DB class + $CI->db =& DB($params, $active_record); + } + + // -------------------------------------------------------------------- + + /** + * Load the Utilities Class + * + * @return string + */ + public function dbutil() + { + if ( ! class_exists('CI_DB')) + { + $this->database(); + } + + $CI =& get_instance(); + + // for backwards compatibility, load dbforge so we can extend dbutils off it + // this use is deprecated and strongly discouraged + $CI->load->dbforge(); + + require_once(BASEPATH.'database/DB_utility.php'); + require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php'); + $class = 'CI_DB_'.$CI->db->dbdriver.'_utility'; + + $CI->dbutil = new $class(); + } + + // -------------------------------------------------------------------- + + /** + * Load the Database Forge Class + * + * @return string + */ + public function dbforge() + { + if ( ! class_exists('CI_DB')) + { + $this->database(); + } + + $CI =& get_instance(); + + require_once(BASEPATH.'database/DB_forge.php'); + require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php'); + $class = 'CI_DB_'.$CI->db->dbdriver.'_forge'; + + $CI->dbforge = new $class(); + } + + // -------------------------------------------------------------------- + + /** + * Load View + * + * This function is used to load a "view" file. It has three parameters: + * + * 1. The name of the "view" file to be included. + * 2. An associative array of data to be extracted for use in the view. + * 3. TRUE/FALSE - whether to return the data or load it. In + * some cases it's advantageous to be able to return data so that + * a developer can process it in some way. + * + * @param string + * @param array + * @param bool + * @return void + */ + public function view($view, $vars = array(), $return = FALSE) + { + return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)); + } + + // -------------------------------------------------------------------- + + /** + * Load File + * + * This is a generic file loader + * + * @param string + * @param bool + * @return string + */ + public function file($path, $return = FALSE) + { + return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return)); + } + + // -------------------------------------------------------------------- + + /** + * Set Variables + * + * Once variables are set they become available within + * the controller class and its "view" files. + * + * @param array + * @param string + * @return void + */ + public function vars($vars = array(), $val = '') + { + if ($val != '' AND is_string($vars)) + { + $vars = array($vars => $val); + } + + $vars = $this->_ci_object_to_array($vars); + + if (is_array($vars) AND count($vars) > 0) + { + foreach ($vars as $key => $val) + { + $this->_ci_cached_vars[$key] = $val; + } + } + } + + // -------------------------------------------------------------------- + + /** + * Get Variable + * + * Check if a variable is set and retrieve it. + * + * @param array + * @return void + */ + public function get_var($key) + { + return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL; + } + + // -------------------------------------------------------------------- + + /** + * Load Helper + * + * This function loads the specified helper file. + * + * @param mixed + * @return void + */ + public function helper($helpers = array()) + { + foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper) + { + if (isset($this->_ci_helpers[$helper])) + { + continue; + } + + $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; + $bfHelper = BFPATH . "helpers/BF_{$helper}.php"; + + // Is this a helper extension request? + if (file_exists($ext_helper)) + { + $base_helper = BASEPATH.'helpers/'.$helper.'.php'; + + if ( ! file_exists($base_helper)) + { + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); + } + + include_once($ext_helper); + // Look for Bonfire helper extension. + if (file_exists($bfHelper)) + { + include_once($bfHelper); + } + include_once($base_helper); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + continue; + } + + // Look for Bonfire helper extension. + if (file_exists($bfHelper)) + { + include_once($bfHelper); + $this->_ci_helpers[$helper] = TRUE; + } + + // Try to load the helper + foreach ($this->_ci_helper_paths as $path) + { + if (file_exists($path.'helpers/'.$helper.'.php')) + { + include_once($path.'helpers/'.$helper.'.php'); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + break; + } + } + + // unable to load the helper + if ( ! isset($this->_ci_helpers[$helper])) + { + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); + } + } + } + + // -------------------------------------------------------------------- + + /** + * Load Helpers + * + * This is simply an alias to the above function in case the + * user has written the plural form of this function. + * + * @param array + * @return void + */ + public function helpers($helpers = array()) + { + $this->helper($helpers); + } + + // -------------------------------------------------------------------- + + /** + * Loads a language file + * + * @param array + * @param string + * @return void + */ + public function language($file = array(), $lang = '') + { + $CI =& get_instance(); + + if ( ! is_array($file)) + { + $file = array($file); + } + + foreach ($file as $langfile) + { + $CI->lang->load($langfile, $lang); + } + } + + // -------------------------------------------------------------------- + + /** + * Loads a config file + * + * @param string + * @param bool + * @param bool + * @return void + */ + public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) + { + $CI =& get_instance(); + $CI->config->load($file, $use_sections, $fail_gracefully); + } + + // -------------------------------------------------------------------- + + /** + * Driver + * + * Loads a driver library + * + * @param string the name of the class + * @param mixed the optional parameters + * @param string an optional object name + * @return void + */ + public function driver($library = '', $params = NULL, $object_name = NULL) + { + if ( ! class_exists('CI_Driver_Library')) + { + // we aren't instantiating an object here, that'll be done by the Library itself + require BASEPATH.'libraries/Driver.php'; + } + + if ($library == '') + { + return FALSE; + } + + // We can save the loader some time since Drivers will *always* be in a subfolder, + // and typically identically named to the library + if ( ! strpos($library, '/')) + { + $library = ucfirst($library).'/'.$library; + } + + return $this->library($library, $params, $object_name); + } + + // -------------------------------------------------------------------- + + /** + * Add Package Path + * + * Prepends a parent path to the library, model, helper, and config path arrays + * + * @param string + * @param boolean + * @return void + */ + public function add_package_path($path, $view_cascade=TRUE) + { + $path = rtrim($path, '/').'/'; + + array_unshift($this->_ci_library_paths, $path); + array_unshift($this->_ci_model_paths, $path); + array_unshift($this->_ci_helper_paths, $path); + + $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths; + + // Add config file path + $config =& $this->_ci_get_component('config'); + array_unshift($config->_config_paths, $path); + } + + // -------------------------------------------------------------------- + + /** + * Get Package Paths + * + * Return a list of all package paths, by default it will ignore BASEPATH. + * + * @param string + * @return void + */ + public function get_package_paths($include_base = FALSE) + { + return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths; + } + + // -------------------------------------------------------------------- + + /** + * Remove Package Path + * + * Remove a path from the library, model, and helper path arrays if it exists + * If no path is provided, the most recently added path is removed. + * + * @param type + * @param bool + * @return type + */ + public function remove_package_path($path = '', $remove_config_path = TRUE) + { + $config =& $this->_ci_get_component('config'); + + if ($path == '') + { + $void = array_shift($this->_ci_library_paths); + $void = array_shift($this->_ci_model_paths); + $void = array_shift($this->_ci_helper_paths); + $void = array_shift($this->_ci_view_paths); + $void = array_shift($config->_config_paths); + } + else + { + $path = rtrim($path, '/').'/'; + foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var) + { + if (($key = array_search($path, $this->{$var})) !== FALSE) + { + unset($this->{$var}[$key]); + } + } + + if (isset($this->_ci_view_paths[$path.'views/'])) + { + unset($this->_ci_view_paths[$path.'views/']); + } + + if (($key = array_search($path, $config->_config_paths)) !== FALSE) + { + unset($config->_config_paths[$key]); + } + } + + // make sure the application default paths are still in the array + $this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH))); + $this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH))); + $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH))); + $this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE)); + $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH))); + } + + // -------------------------------------------------------------------- + + /** + * Loader + * + * This function is used to load views and files. + * Variables are prefixed with _ci_ to avoid symbol collision with + * variables made available to view files + * + * @param array + * @return void + */ + protected function _ci_load($_ci_data) + { + // Set the default data variables + foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val) + { + $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val]; + } + + $file_exists = FALSE; + + // Set the path to the requested file + if ($_ci_path != '') + { + $_ci_x = explode('/', $_ci_path); + $_ci_file = end($_ci_x); + } + else + { + $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); + $_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view; + + foreach ($this->_ci_view_paths as $view_file => $cascade) + { + if (file_exists($view_file.$_ci_file)) + { + $_ci_path = $view_file.$_ci_file; + $file_exists = TRUE; + break; + } + + if ( ! $cascade) + { + break; + } + } + } + + if ( ! $file_exists && ! file_exists($_ci_path)) + { + show_error('Unable to load the requested file: '.$_ci_file); + } + + // This allows anything loaded using $this->load (views, files, etc.) + // to become accessible from within the Controller and Model functions. + + $_ci_CI =& get_instance(); + foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var) + { + if ( ! isset($this->$_ci_key)) + { + $this->$_ci_key =& $_ci_CI->$_ci_key; + } + } + + /* + * Extract and cache variables + * + * You can either set variables using the dedicated $this->load_vars() + * function or via the second parameter of this function. We'll merge + * the two types and cache them so that views that are embedded within + * other views can have access to these variables. + */ + if (is_array($_ci_vars)) + { + $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars); + } + extract($this->_ci_cached_vars); + + /* + * Buffer the output + * + * We buffer the output for two reasons: + * 1. Speed. You get a significant speed boost. + * 2. So that the final rendered template can be + * post-processed by the output class. Why do we + * need post processing? For one thing, in order to + * show the elapsed page load time. Unless we + * can intercept the content right before it's sent to + * the browser and then stop the timer it won't be accurate. + */ + ob_start(); + + // If the PHP installation does not support short tags we'll + // do a little string replacement, changing the short tags + // to standard PHP echo statements. + + if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE) + { + echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace(' $this->_ci_ob_level + 1) + { + ob_end_flush(); + } + else + { + $_ci_CI->output->append_output(ob_get_contents()); + @ob_end_clean(); + } + } + + // -------------------------------------------------------------------- + + /** + * Load class + * + * This function loads the requested class. + * + * @param string the item that is being loaded + * @param mixed any additional parameters + * @param string an optional object name + * @return void + */ + protected function _ci_load_class($class, $params = NULL, $object_name = NULL) + { + // Get the class name, and while we're at it trim any slashes. + // The directory path can be included as part of the class name, + // but we don't want a leading slash + $class = str_replace('.php', '', trim($class, '/')); + + // Was the path included with the class name? + // We look for a slash to determine this + $subdir = ''; + if (($last_slash = strrpos($class, '/')) !== FALSE) + { + // Extract the path + $subdir = substr($class, 0, $last_slash + 1); + + // Get the filename from the path + $class = substr($class, $last_slash + 1); + } + + // We'll test for both lowercase and capitalized versions of the file name + foreach (array(ucfirst($class), strtolower($class)) as $class) + { + $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; + + // Is this a class extension request? + if (file_exists($subclass)) + { + $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; + + if ( ! file_exists($baseclass)) + { + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); + } + + // Safety: Was the class already loaded by a previous call? + if (in_array($subclass, $this->_ci_loaded_files)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) + { + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + } + } + + $is_duplicate = TRUE; + log_message('debug', $class." class already loaded. Second attempt ignored."); + return; + } + + include_once($baseclass); + include_once($subclass); + $this->_ci_loaded_files[] = $subclass; + + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + } + + // Lets search for the requested library file and load it. + $is_duplicate = FALSE; + foreach ($this->_ci_library_paths as $path) + { + $filepath = $path.'libraries/'.$subdir.$class.'.php'; + + // Does the file exist? No? Bummer... + if ( ! file_exists($filepath)) + { + continue; + } + + // Safety: Was the class already loaded by a previous call? + if (in_array($filepath, $this->_ci_loaded_files)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) + { + return $this->_ci_init_class($class, '', $params, $object_name); + } + } + + $is_duplicate = TRUE; + log_message('debug', $class." class already loaded. Second attempt ignored."); + return; + } + + include_once($filepath); + $this->_ci_loaded_files[] = $filepath; + return $this->_ci_init_class($class, '', $params, $object_name); + } + + } // END FOREACH + + // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? + if ($subdir == '') + { + $path = strtolower($class).'/'.$class; + return $this->_ci_load_class($path, $params); + } + + // If we got this far we were unable to find the requested class. + // We do not issue errors if the load call failed due to a duplicate request + if ($is_duplicate == FALSE) + { + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); + } + } + + // -------------------------------------------------------------------- + + /** + * Instantiates a class + * + * @param string + * @param string + * @param bool + * @param string an optional object name + * @return null + */ + protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) + { + // Is there an associated config file for this class? Note: these should always be lowercase + if ($config === NULL) + { + // Fetch the config paths containing any package paths + $config_component = $this->_ci_get_component('config'); + + if (is_array($config_component->_config_paths)) + { + // Break on the first found file, thus package files + // are not overridden by default paths + foreach ($config_component->_config_paths as $path) + { + // We test for both uppercase and lowercase, for servers that + // are case-sensitive with regard to file names. Check for environment + // first, global next + if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) + { + include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); + break; + } + elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) + { + include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); + break; + } + elseif (file_exists($path .'config/'.strtolower($class).'.php')) + { + include($path .'config/'.strtolower($class).'.php'); + break; + } + elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php')) + { + include($path .'config/'.ucfirst(strtolower($class)).'.php'); + break; + } + } + } + } + + if ($prefix == '') + { + if (class_exists('CI_'.$class)) + { + $name = 'CI_'.$class; + } + elseif (class_exists(config_item('subclass_prefix').$class)) + { + $name = config_item('subclass_prefix').$class; + } + else + { + $name = $class; + } + } + else + { + $name = $prefix.$class; + } + + // Is the class name valid? + if ( ! class_exists($name)) + { + log_message('error', "Non-existent class: ".$name); + show_error("Non-existent class: ".$class); + } + + // Set the variable name we will assign the class to + // Was a custom class name supplied? If so we'll use it + $class = strtolower($class); + + if (is_null($object_name)) + { + $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class]; + } + else + { + $classvar = $object_name; + } + + // Save the class name and object name + $this->_ci_classes[$class] = $classvar; + + // Instantiate the class + $CI =& get_instance(); + if ($config !== NULL) + { + $CI->$classvar = new $name($config); + } + else + { + $CI->$classvar = new $name; + } + } + + // -------------------------------------------------------------------- + + /** + * Autoloader + * + * The config/autoload.php file contains an array that permits sub-systems, + * libraries, and helpers to be loaded automatically. + * + * @param array + * @return void + */ + private function _ci_autoloader() + { + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'); + } + else + { + include(APPPATH.'config/autoload.php'); + } + + if ( ! isset($autoload)) + { + return FALSE; + } + + // Autoload packages + if (isset($autoload['packages'])) + { + foreach ($autoload['packages'] as $package_path) + { + $this->add_package_path($package_path); + } + } + + // Load any custom config file + if (count($autoload['config']) > 0) + { + $CI =& get_instance(); + foreach ($autoload['config'] as $key => $val) + { + $CI->config->load($val); + } + } + + // Autoload helpers and languages + foreach (array('helper', 'language') as $type) + { + if (isset($autoload[$type]) AND count($autoload[$type]) > 0) + { + $this->$type($autoload[$type]); + } + } + + // A little tweak to remain backward compatible + // The $autoload['core'] item was deprecated + if ( ! isset($autoload['libraries']) AND isset($autoload['core'])) + { + $autoload['libraries'] = $autoload['core']; + } + + // Load libraries + if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0) + { + // Load the database driver. + if (in_array('database', $autoload['libraries'])) + { + $this->database(); + $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); + } + + // Load all other libraries + foreach ($autoload['libraries'] as $item) + { + $this->library($item); + } + } + + // Autoload models + if (isset($autoload['model'])) + { + $this->model($autoload['model']); + } + } + + // -------------------------------------------------------------------- + + /** + * Object to Array + * + * Takes an object as input and converts the class variables to array key/vals + * + * @param object + * @return array + */ + protected function _ci_object_to_array($object) + { + return (is_object($object)) ? get_object_vars($object) : $object; + } + + // -------------------------------------------------------------------- + + /** + * Get a reference to a specific library or model + * + * @param string + * @return bool + */ + protected function &_ci_get_component($component) + { + $CI =& get_instance(); + return $CI->$component; + } + + // -------------------------------------------------------------------- + + /** + * Prep filename + * + * This function preps the name of various items to make loading them more reliable. + * + * @param mixed + * @param string + * @return array + */ + protected function _ci_prep_filename($filename, $extension) + { + if ( ! is_array($filename)) + { + return array(strtolower(str_replace('.php', '', str_replace($extension, '', $filename)).$extension)); + } + else + { + foreach ($filename as $key => $val) + { + $filename[$key] = strtolower(str_replace('.php', '', str_replace($extension, '', $val)).$extension); + } + + return $filename; + } + } +} + +/* End of file Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file diff --git a/bonfire/ci2/database/DB_active_rec.php b/bonfire/ci2/database/DB_active_rec.php index 0ae21105c..2d01cf71c 100644 --- a/bonfire/ci2/database/DB_active_rec.php +++ b/bonfire/ci2/database/DB_active_rec.php @@ -895,7 +895,7 @@ public function limit($value, $offset = '') */ public function offset($offset) { - $this->ar_offset = $offset; + $this->ar_offset = (int) $offset; return $this; } diff --git a/bonfire/ci3/core/CodeIgniter.php b/bonfire/ci3/core/CodeIgniter.php index 4c07d2922..92d2fc7d0 100644 --- a/bonfire/ci3/core/CodeIgniter.php +++ b/bonfire/ci3/core/CodeIgniter.php @@ -55,7 +55,7 @@ * @var string * */ - define('CI_VERSION', '3.0.0'); + define('CI_VERSION', '3.0.1'); /* * ------------------------------------------------------ diff --git a/bonfire/ci3/core/Common.php b/bonfire/ci3/core/Common.php index 1332317e9..181071a6e 100644 --- a/bonfire/ci3/core/Common.php +++ b/bonfire/ci3/core/Common.php @@ -195,7 +195,7 @@ function &load_class($class, $directory = 'libraries', $param = NULL) // Did we find the class? if ($name === FALSE) { - // Note: We use exit() rather then show_error() in order to avoid a + // Note: We use exit() rather than show_error() in order to avoid a // self-referencing loop with the Exceptions class set_status_header(503); echo 'Unable to locate the specified class: '.$class.'.php'; @@ -520,6 +520,9 @@ function set_status_header($code = 200, $text = '') { is_int($code) OR $code = (int) $code; $stati = array( + 100 => 'Continue', + 101 => 'Switching Protocols', + 200 => 'OK', 201 => 'Created', 202 => 'Accepted', @@ -538,6 +541,7 @@ function set_status_header($code = 200, $text = '') 400 => 'Bad Request', 401 => 'Unauthorized', + 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', @@ -843,19 +847,9 @@ function function_usable($function_name) { if ( ! isset($_suhosin_func_blacklist)) { - if (extension_loaded('suhosin')) - { - $_suhosin_func_blacklist = explode(',', trim(ini_get('suhosin.executor.func.blacklist'))); - - if ( ! in_array('eval', $_suhosin_func_blacklist, TRUE) && ini_get('suhosin.executor.disable_eval')) - { - $_suhosin_func_blacklist[] = 'eval'; - } - } - else - { - $_suhosin_func_blacklist = array(); - } + $_suhosin_func_blacklist = extension_loaded('suhosin') + ? explode(',', trim(ini_get('suhosin.executor.func.blacklist'))) + : array(); } return ! in_array($function_name, $_suhosin_func_blacklist, TRUE); diff --git a/bonfire/ci3/core/Hooks.php b/bonfire/ci3/core/Hooks.php index 08479b133..3b4fb2250 100644 --- a/bonfire/ci3/core/Hooks.php +++ b/bonfire/ci3/core/Hooks.php @@ -46,7 +46,7 @@ * @subpackage Libraries * @category Libraries * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/encryption.html + * @link http://codeigniter.com/user_guide/general/hooks.html */ class CI_Hooks { diff --git a/bonfire/ci3/core/Input.php b/bonfire/ci3/core/Input.php index 12332cf51..e1319be8d 100644 --- a/bonfire/ci3/core/Input.php +++ b/bonfire/ci3/core/Input.php @@ -682,7 +682,7 @@ protected function _clean_input_data($str) /* We strip slashes if magic quotes is on to keep things consistent NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and - it will probably not exist in future versions at all. + it will probably not exist in future versions at all. */ if ( ! is_php('5.4') && get_magic_quotes_gpc()) { @@ -799,19 +799,27 @@ public function request_headers($xss_clean = FALSE) */ public function get_request_header($index, $xss_clean = FALSE) { - if (empty($this->headers)) + static $headers; + + if ( ! isset($headers)) { - $this->request_headers(); + empty($this->headers) OR $this->request_headers(); + foreach ($this->headers as $key => $value) + { + $headers[strtolower($key)] = $value; + } } - if ( ! isset($this->headers[$index])) + $index = strtolower($index); + + if ( ! isset($headers[$index])) { return NULL; } return ($xss_clean === TRUE) - ? $this->security->xss_clean($this->headers[$index]) - : $this->headers[$index]; + ? $this->security->xss_clean($headers[$index]) + : $headers[$index]; } // -------------------------------------------------------------------- @@ -836,7 +844,7 @@ public function is_ajax_request() * Test to see if a request was made from the command line. * * @deprecated 3.0.0 Use is_cli() instead - * @return bool + * @return bool */ public function is_cli_request() { diff --git a/bonfire/ci3/core/Loader.php b/bonfire/ci3/core/Loader.php index ffe683423..5f6dbdeee 100644 --- a/bonfire/ci3/core/Loader.php +++ b/bonfire/ci3/core/Loader.php @@ -272,7 +272,7 @@ public function model($model, $name = '', $db_conn = FALSE) $CI =& get_instance(); if (isset($CI->$name)) { - show_error('The model name you are loading is the name of a resource that is already being used: '.$name); + throw new RuntimeException('The model name you are loading is the name of a resource that is already being used: '.$name); } if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE)) @@ -291,23 +291,37 @@ public function model($model, $name = '', $db_conn = FALSE) } $model = ucfirst(strtolower($model)); - - foreach ($this->_ci_model_paths as $mod_path) + if ( ! class_exists($model)) { - if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) + foreach ($this->_ci_model_paths as $mod_path) { - continue; - } + if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) + { + continue; + } - require_once($mod_path.'models/'.$path.$model.'.php'); + require_once($mod_path.'models/'.$path.$model.'.php'); + if ( ! class_exists($model, FALSE)) + { + throw new RuntimeException($mod_path."models/".$path.$model.".php exists, but doesn't declare class ".$model); + } - $this->_ci_models[] = $name; - $CI->$name = new $model(); - return $this; + break; + } + + if ( ! class_exists($model, FALSE)) + { + throw new RuntimeException('Unable to locate the model you have specified: '.$model); + } + } + elseif ( ! is_subclass_of($model, 'CI_Model')) + { + throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model"); } - // couldn't find the model - show_error('Unable to locate the model you have specified: '.$model); + $this->_ci_models[] = $name; + $CI->$name = new $model(); + return $this; } // -------------------------------------------------------------------- @@ -500,7 +514,7 @@ public function vars($vars, $val = '') * * Clears the cached variables. * - * @return object + * @return CI_Loader */ public function clear_vars() { @@ -566,6 +580,14 @@ public function helper($helpers = array()) } } + // Look for Bonfire helper extension. + if (file_exists(BFPATH . "helpers/BF_{$helper}.php")) + { + include_once(BFPATH . "helpers/BF_{$helper}.php"); + $ext_loaded = TRUE; + } + + // If we have loaded extensions - check if the base one is here if ($ext_loaded === TRUE) { @@ -905,7 +927,7 @@ protected function _ci_load($_ci_data) // If the PHP installation does not support short tags we'll // do a little string replacement, changing the short tags // to standard PHP echo statements. - if ( ! is_php('5.4') && ! ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE && function_usable('eval')) + if ( ! is_php('5.4') && ! ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE) { echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('_ci_library_paths; - array_pop($paths); // BASEPATH - array_pop($paths); // APPPATH (needs to be the first path checked) - array_unshift($paths, APPPATH); - - foreach ($paths as $path) - { - if (file_exists($path = $path.'libraries/'.$file_path.$library_name.'.php')) - { - // Override - include_once($path); - if (class_exists($prefix.$library_name, FALSE)) - { - return $this->_ci_init_library($library_name, $prefix, $params, $object_name); - } - else - { - log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name); - } - } - } + $paths = $this->_ci_library_paths; + array_pop($paths); // BASEPATH + array_pop($paths); // APPPATH (needs to be the first path checked) + array_unshift($paths, APPPATH); + + foreach ($paths as $path) + { + if (file_exists($path = $path.'libraries/'.$file_path.$library_name.'.php')) + { + // Override + include_once($path); + if (class_exists($prefix.$library_name, FALSE)) + { + return $this->_ci_init_library($library_name, $prefix, $params, $object_name); + } + else + { + log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name); + } + } + } include_once(BASEPATH.'libraries/'.$file_path.$library_name.'.php'); // Check for extensions $subclass = config_item('subclass_prefix').$library_name; - foreach ($paths as $path) - { - if (file_exists($path = $path.'libraries/'.$file_path.$subclass.'.php')) - { - include_once($path); - if (class_exists($subclass, FALSE)) - { - $prefix = config_item('subclass_prefix'); - break; - } - else - { - log_message('debug', $path.' exists, but does not declare '.$subclass); - } - } - } + foreach ($paths as $path) + { + if (file_exists($path = $path.'libraries/'.$file_path.$subclass.'.php')) + { + include_once($path); + if (class_exists($subclass, FALSE)) + { + $prefix = config_item('subclass_prefix'); + break; + } + else + { + log_message('debug', $path.' exists, but does not declare '.$subclass); + } + } + } return $this->_ci_init_library($library_name, $prefix, $params, $object_name); } @@ -1307,10 +1329,7 @@ protected function _ci_autoloader() } // Load all other libraries - foreach ($autoload['libraries'] as $item) - { - $this->library($item); - } + $this->library($autoload['libraries']); } // Autoload models diff --git a/bonfire/ci3/core/Output.php b/bonfire/ci3/core/Output.php index 02f66936c..76c1329d2 100644 --- a/bonfire/ci3/core/Output.php +++ b/bonfire/ci3/core/Output.php @@ -556,9 +556,16 @@ public function _write_cache($output) .$CI->config->item('index_page') .$CI->uri->uri_string(); - if ($CI->config->item('cache_query_string') && ! empty($_SERVER['QUERY_STRING'])) + if (($cache_query_string = $CI->config->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING'])) { - $uri .= '?'.$_SERVER['QUERY_STRING']; + if (is_array($cache_query_string)) + { + $uri .= '?'.http_build_query(array_intersect_key($_GET, array_flip($cache_query_string))); + } + else + { + $uri .= '?'.$_SERVER['QUERY_STRING']; + } } $cache_path .= md5($uri); @@ -646,9 +653,16 @@ public function _display_cache(&$CFG, &$URI) // Build the file path. The file name is an MD5 hash of the full URI $uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string; - if ($CFG->item('cache_query_string') && ! empty($_SERVER['QUERY_STRING'])) + if (($cache_query_string = $CFG->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING'])) { - $uri .= '?'.$_SERVER['QUERY_STRING']; + if (is_array($cache_query_string)) + { + $uri .= '?'.http_build_query(array_intersect_key($_GET, array_flip($cache_query_string))); + } + else + { + $uri .= '?'.$_SERVER['QUERY_STRING']; + } } $filepath = $cache_path.md5($uri); @@ -674,7 +688,7 @@ public function _display_cache(&$CFG, &$URI) $cache_info = unserialize($match[1]); $expire = $cache_info['expire']; - $last_modified = filemtime($cache_path); + $last_modified = filemtime($filepath); // Has the file expired? if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path)) @@ -729,13 +743,20 @@ public function delete_cache($uri = '') { $uri = $CI->uri->uri_string(); - if ($CI->config->item('cache_query_string') && ! empty($_SERVER['QUERY_STRING'])) + if (($cache_query_string = $CI->config->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING'])) { - $uri .= '?'.$_SERVER['QUERY_STRING']; + if (is_array($cache_query_string)) + { + $uri .= '?'.http_build_query(array_intersect_key($_GET, array_flip($cache_query_string))); + } + else + { + $uri .= '?'.$_SERVER['QUERY_STRING']; + } } } - $cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').$uri); + $cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').ltrim($uri, '/')); if ( ! @unlink($cache_path)) { diff --git a/bonfire/ci3/core/Router.php b/bonfire/ci3/core/Router.php index eb3da2285..0c793e418 100644 --- a/bonfire/ci3/core/Router.php +++ b/bonfire/ci3/core/Router.php @@ -83,7 +83,7 @@ class CI_Router { * * @var string */ - public $directory = ''; + public $directory; /** * Default controller (and method if specific) @@ -105,7 +105,7 @@ class CI_Router { /** * Enable query strings flag * - * Determines wether to use GET parameters or segment URIs + * Determines whether to use GET parameters or segment URIs * * @var bool */ @@ -126,25 +126,16 @@ public function __construct($routing = NULL) $this->uri =& load_class('URI', 'core'); $this->enable_query_strings = ( ! is_cli() && $this->config->item('enable_query_strings') === TRUE); + + // If a directory override is configured, it has to be set before any dynamic routing logic + is_array($routing) && isset($routing['directory']) && $this->set_directory($routing['directory']); $this->_set_routing(); // Set any routing overrides that may exist in the main index file if (is_array($routing)) { - if (isset($routing['directory'])) - { - $this->set_directory($routing['directory']); - } - - if ( ! empty($routing['controller'])) - { - $this->set_class($routing['controller']); - } - - if ( ! empty($routing['function'])) - { - $this->set_method($routing['function']); - } + empty($routing['controller']) OR $this->set_class($routing['controller']); + empty($routing['function']) OR $this->set_method($routing['function']); } log_message('info', 'Router Class Initialized'); @@ -167,12 +158,17 @@ protected function _set_routing() // If this feature is enabled, we will gather the directory/class/method a little differently if ($this->enable_query_strings) { - $_d = $this->config->item('directory_trigger'); - $_d = isset($_GET[$_d]) ? trim($_GET[$_d], " \t\n\r\0\x0B/") : ''; - if ($_d !== '') + // If the directory is set at this time, it means an override exists, so skip the checks + if ( ! isset($this->directory)) { - $this->uri->filter_uri($_d); - $this->set_directory($_d); + $_d = $this->config->item('directory_trigger'); + $_d = isset($_GET[$_d]) ? trim($_GET[$_d], " \t\n\r\0\x0B/") : ''; + + if ($_d !== '') + { + $this->uri->filter_uri($_d); + $this->set_directory($_d); + } } $_c = trim($this->config->item('controller_trigger')); @@ -333,6 +329,8 @@ protected function _set_default_controller() protected function _validate_request($segments) { $c = count($segments); + $directory_override = isset($this->directory); + // Loop through our segments and return as soon as a controller // is found or when such a directory doesn't exist while ($c-- > 0) @@ -340,7 +338,10 @@ protected function _validate_request($segments) $test = $this->directory .ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]); - if ( ! file_exists(APPPATH.'controllers/'.$test.'.php') && is_dir(APPPATH.'controllers/'.$this->directory.$segments[0])) + if ( ! file_exists(APPPATH.'controllers/'.$test.'.php') + && $directory_override === FALSE + && is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]) + ) { $this->set_directory(array_shift($segments), TRUE); continue; @@ -374,16 +375,19 @@ protected function _parse_routes() // Is there a literal match? If so we're done if (isset($this->routes[$uri])) { - // Check default routes format - if (is_string($this->routes[$uri])) + // Is it an HTTP verb-based route? + if (is_array($this->routes[$uri])) { - $this->_set_request(explode('/', $this->routes[$uri])); - return; + $route = array_change_key_case($this->routes[$uri], CASE_LOWER); + if (isset($route[$http_verb])) + { + $this->_set_request(explode('/', $route[$http_verb])); + return; + } } - // Is there a matching http verb? - elseif (is_array($this->routes[$uri]) && isset($this->routes[$uri][$http_verb])) + else { - $this->_set_request(explode('/', $this->routes[$uri][$http_verb])); + $this->_set_request(explode('/', $this->routes[$uri])); return; } } @@ -391,9 +395,10 @@ protected function _parse_routes() // Loop through the route array looking for wildcards foreach ($this->routes as $key => $val) { - // Check if route format is using http verb + // Check if route format is using HTTP verbs if (is_array($val)) { + $val = array_change_key_case($val, CASE_LOWER); if (isset($val[$http_verb])) { $val = $val[$http_verb]; @@ -493,7 +498,7 @@ public function fetch_method() * Set directory name * * @param string $dir Directory name - * @param bool $appent Whether we're appending rather then setting the full value + * @param bool $append Whether we're appending rather than setting the full value * @return void */ public function set_directory($dir, $append = FALSE) diff --git a/bonfire/ci3/core/Security.php b/bonfire/ci3/core/Security.php index b58b08b04..7c5199255 100644 --- a/bonfire/ci3/core/Security.php +++ b/bonfire/ci3/core/Security.php @@ -275,7 +275,7 @@ public function csrf_set_cookie() $secure_cookie, config_item('cookie_httponly') ); - log_message('info', 'CRSF cookie sent'); + log_message('info', 'CSRF cookie sent'); return $this; } @@ -772,7 +772,7 @@ protected function _compact_exploded_words($matches) */ protected function _remove_evil_attributes($str, $is_image) { - $evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction', 'form', 'xlink:href', 'FSCommand', 'seekSegmentTime'); + $evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction', 'form', 'xlink:href', 'FSCommand', 'seekSegmentTime'); if ($is_image === TRUE) { diff --git a/bonfire/ci3/core/URI.php b/bonfire/ci3/core/URI.php index 9e20b3a17..5b658f679 100644 --- a/bonfire/ci3/core/URI.php +++ b/bonfire/ci3/core/URI.php @@ -201,21 +201,23 @@ protected function _parse_request_uri() return ''; } - $uri = parse_url($_SERVER['REQUEST_URI']); + // parse_url() returns false if no host is present, but the path or query string + // contains a colon followed by a number + $uri = parse_url('http://dummy'.$_SERVER['REQUEST_URI']); $query = isset($uri['query']) ? $uri['query'] : ''; $uri = isset($uri['path']) ? $uri['path'] : ''; - if (isset($_SERVER['SCRIPT_NAME'][0])) - { - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) - { - $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); - } - elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) - { - $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); - } - } + if (isset($_SERVER['SCRIPT_NAME'][0])) + { + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + { + $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + } + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + { + $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + } + } // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. diff --git a/bonfire/ci3/core/compat/hash.php b/bonfire/ci3/core/compat/hash.php index 477535dca..15954559c 100644 --- a/bonfire/ci3/core/compat/hash.php +++ b/bonfire/ci3/core/compat/hash.php @@ -174,9 +174,56 @@ function hash_pbkdf2($algo, $password, $salt, $iterations, $length = 0, $raw_out } $hash_length = strlen(hash($algo, NULL, TRUE)); - if (empty($length)) + empty($length) && $length = $hash_length; + + // Pre-hash password inputs longer than the algorithm's block size + // (i.e. prepare HMAC key) to mitigate potential DoS attacks. + static $block_sizes; + empty($block_sizes) && $block_sizes = array( + 'gost' => 32, + 'haval128,3' => 128, + 'haval160,3' => 128, + 'haval192,3' => 128, + 'haval224,3' => 128, + 'haval256,3' => 128, + 'haval128,4' => 128, + 'haval160,4' => 128, + 'haval192,4' => 128, + 'haval224,4' => 128, + 'haval256,4' => 128, + 'haval128,5' => 128, + 'haval160,5' => 128, + 'haval192,5' => 128, + 'haval224,5' => 128, + 'haval256,5' => 128, + 'md2' => 16, + 'md4' => 64, + 'md5' => 64, + 'ripemd128' => 64, + 'ripemd160' => 64, + 'ripemd256' => 64, + 'ripemd320' => 64, + 'salsa10' => 64, + 'salsa20' => 64, + 'sha1' => 64, + 'sha224' => 64, + 'sha256' => 64, + 'sha384' => 128, + 'sha512' => 128, + 'snefru' => 32, + 'snefru256' => 32, + 'tiger128,3' => 64, + 'tiger160,3' => 64, + 'tiger192,3' => 64, + 'tiger128,4' => 64, + 'tiger160,4' => 64, + 'tiger192,4' => 64, + 'whirlpool' => 64 + ); + + if (isset($block_sizes[$algo]) && strlen($password) > $block_sizes[$algo]) { - $length = $hash_length; + $password = hash($algo, $password, TRUE); } $hash = ''; diff --git a/bonfire/ci3/database/DB_driver.php b/bonfire/ci3/database/DB_driver.php index 3d35c2d70..659664db9 100644 --- a/bonfire/ci3/database/DB_driver.php +++ b/bonfire/ci3/database/DB_driver.php @@ -451,7 +451,7 @@ public function initialize() * * This is just a dummy method that all drivers will override. * - * @return mixed + * @return mixed */ public function db_connect() { @@ -481,7 +481,7 @@ public function db_pconnect() * This is just a dummy method to allow drivers without such * functionality to not declare it, while others will override it. * - * @return void + * @return void */ public function reconnect() { @@ -495,7 +495,7 @@ public function reconnect() * This is just a dummy method to allow drivers without such * functionality to not declare it, while others will override it. * - * @return bool + * @return bool */ public function db_select() { @@ -647,7 +647,10 @@ public function query($sql, $binds = FALSE, $return_object = NULL) } // This will trigger a rollback if transactions are being used - $this->_trans_status = FALSE; + if ($this->_trans_depth !== 0) + { + $this->_trans_status = FALSE; + } // Grab the error now, as we might run some additional queries before displaying the error $error = $this->error(); @@ -1218,7 +1221,7 @@ public function table_exists($table_name) /** * Fetch Field Names * - * @param string the table name + * @param string $table Table name * @return array */ public function list_fields($table) @@ -1751,7 +1754,7 @@ public function protect_identifiers($item, $prefix_single = FALSE, $protect_iden // // Added exception for single quotes as well, we don't want to alter // literal strings. -- Narf - if (strpos($item, '(') !== FALSE OR strpos($item, "'") !== FALSE) + if (strcspn($item, "()'") !== strlen($item)) { return $item; } diff --git a/bonfire/ci3/database/DB_forge.php b/bonfire/ci3/database/DB_forge.php index f6ee2a63a..dde285598 100644 --- a/bonfire/ci3/database/DB_forge.php +++ b/bonfire/ci3/database/DB_forge.php @@ -143,7 +143,7 @@ abstract class CI_DB_forge { protected $_unsigned = TRUE; /** - * NULL value representatin in CREATE/ALTER TABLE statements + * NULL value representation in CREATE/ALTER TABLE statements * * @var string */ @@ -239,7 +239,7 @@ public function drop_database($db_name) */ public function add_key($key, $primary = FALSE) { - if ($primary === TRUE && is_array($key)) + if (is_array($key)) { foreach ($key as $one) { @@ -453,12 +453,7 @@ public function drop_table($table_name, $if_exists = FALSE) return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE; } - $query = $this->_drop_table($this->db->dbprefix.$table_name, $if_exists); - if ($query === FALSE) - { - return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; - } - elseif ($query === TRUE) + if (($query = $this->_drop_table($this->db->dbprefix.$table_name, $if_exists)) === TRUE) { return TRUE; } diff --git a/bonfire/ci3/database/DB_query_builder.php b/bonfire/ci3/database/DB_query_builder.php index 6816d319e..7f3334763 100644 --- a/bonfire/ci3/database/DB_query_builder.php +++ b/bonfire/ci3/database/DB_query_builder.php @@ -794,13 +794,23 @@ protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = $not = ($not) ? ' NOT' : ''; - $where_in = array(); - foreach ($values as $value) + if ($escape === TRUE) + { + $where_in = array(); + foreach ($values as $value) + { + $where_in[] = $this->escape($value); + } + } + else { - $where_in[] = $this->escape($value); + $where_in = array_values($values); } - $prefix = (count($this->qb_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type); + $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) + ? $this->_group_get_type('') + : $this->_group_get_type($type); + $where_in = array( 'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')', 'escape' => $escape @@ -918,13 +928,18 @@ protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $n } is_bool($escape) OR $escape = $this->_protect_identifiers; + // lowercase $side in case somebody writes e.g. 'BEFORE' instead of 'before' (doh) + $side = strtolower($side); foreach ($field as $k => $v) { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type); - $v = $this->escape_like_str($v); + if ($escape === TRUE) + { + $v = $this->escape_like_str($v); + } if ($side === 'none') { @@ -944,7 +959,7 @@ protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $n } // some platforms require an escape sequence definition for LIKE wildcards - if ($this->_like_escape_str !== '') + if ($escape === TRUE && $this->_like_escape_str !== '') { $like_statement .= sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -1292,7 +1307,7 @@ public function set($key, $value = '', $escape = NULL) * Compiles a SELECT query string and returns the sql. * * @param string the table name to select from (optional) - * @param bool TRUE: resets QB values; FALSE: leave QB vaules alone + * @param bool TRUE: resets QB values; FALSE: leave QB values alone * @return string */ public function get_compiled_select($table = '', $reset = TRUE) @@ -1353,7 +1368,7 @@ public function get($table = '', $limit = NULL, $offset = NULL) * returned by an Query Builder query. * * @param string - * @param bool the reset clause + * @param bool the reset clause * @return int */ public function count_all_results($table = '', $reset = TRUE) @@ -1368,10 +1383,10 @@ public function count_all_results($table = '', $reset = TRUE) ? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results") : $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows'))); - if ($reset === TRUE) - { - $this->_reset_select(); - } + if ($reset === TRUE) + { + $this->_reset_select(); + } if ($result->num_rows() === 0) { @@ -1734,7 +1749,7 @@ public function get_compiled_update($table = '', $reset = TRUE) return FALSE; } - $sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set); + $sql = $this->_update($this->qb_from[0], $this->qb_set); if ($reset === TRUE) { @@ -1782,7 +1797,7 @@ public function update($table = '', $set = NULL, $where = NULL, $limit = NULL) $this->limit($limit); } - $sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set); + $sql = $this->_update($this->qb_from[0], $this->qb_set); $this->_reset_write(); return $this->query($sql); } @@ -1799,7 +1814,7 @@ public function update($table = '', $set = NULL, $where = NULL, $limit = NULL) * @param string the table to update data on * @return bool */ - protected function _validate_update($table = '') + protected function _validate_update($table) { if (count($this->qb_set) === 0) { @@ -1808,7 +1823,7 @@ protected function _validate_update($table = '') if ($table !== '') { - $this->qb_from[0] = $table; + $this->qb_from = array($this->protect_identifiers($table, TRUE, NULL, FALSE)); } elseif ( ! isset($this->qb_from[0])) { @@ -2090,10 +2105,13 @@ public function delete($table = '', $where = '', $limit = NULL, $reset_data = TR } elseif (is_array($table)) { + empty($where) && $reset_data = FALSE; + foreach ($table as $single_table) { $this->delete($single_table, $where, $limit, $reset_data); } + return; } else @@ -2253,7 +2271,7 @@ protected function _compile_select($select_override = FALSE) else { // Cycle through the "select" portion of the query and prep each column name. - // The reason we protect identifiers here rather then in the select() function + // The reason we protect identifiers here rather than in the select() function // is because until the user calls the from() function we don't know if there are aliases foreach ($this->qb_select as $key => $val) { @@ -2324,7 +2342,7 @@ protected function _compile_wh($qb_key) // Split multiple conditions $conditions = preg_split( - '/(\s*AND\s+|\s*OR\s+)/i', + '/((^|\s+)AND\s+|(^|\s+)OR\s+)/i', $this->{$qb_key}[$i]['condition'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY diff --git a/bonfire/ci3/database/DB_utility.php b/bonfire/ci3/database/DB_utility.php index 57356ac53..78398ea83 100644 --- a/bonfire/ci3/database/DB_utility.php +++ b/bonfire/ci3/database/DB_utility.php @@ -249,7 +249,7 @@ public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosur $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + $out = substr($out, 0, -strlen($delim)).$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -258,7 +258,7 @@ public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosur { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + $out = substr($out, 0, -strlen($delim)).$newline; } return $out; diff --git a/bonfire/ci3/database/drivers/mysqli/mysqli_driver.php b/bonfire/ci3/database/drivers/mysqli/mysqli_driver.php index e953db052..dd3cc77c6 100644 --- a/bonfire/ci3/database/drivers/mysqli/mysqli_driver.php +++ b/bonfire/ci3/database/drivers/mysqli/mysqli_driver.php @@ -102,7 +102,6 @@ class CI_DB_mysqli_driver extends CI_DB { * * @param bool $persistent * @return object - * @todo SSL support */ public function db_connect($persistent = FALSE) { @@ -132,8 +131,52 @@ public function db_connect($persistent = FALSE) $mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode="STRICT_ALL_TABLES"'); } - return $mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags) - ? $mysqli : FALSE; + if (is_array($this->encrypt)) + { + $ssl = array(); + empty($this->encrypt['ssl_key']) OR $ssl['key'] = $this->encrypt['ssl_key']; + empty($this->encrypt['ssl_cert']) OR $ssl['cert'] = $this->encrypt['ssl_cert']; + empty($this->encrypt['ssl_ca']) OR $ssl['ca'] = $this->encrypt['ssl_ca']; + empty($this->encrypt['ssl_capath']) OR $ssl['capath'] = $this->encrypt['ssl_capath']; + empty($this->encrypt['ssl_cipher']) OR $ssl['cipher'] = $this->encrypt['ssl_cipher']; + + if ( ! empty($ssl)) + { + if ( ! empty($this->encrypt['ssl_verify']) && defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT')) + { + $mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, TRUE); + } + + $client_flags |= MYSQLI_CLIENT_SSL; + $mysqli->ssl_set( + isset($ssl['key']) ? $ssl['key'] : NULL, + isset($ssl['cert']) ? $ssl['cert'] : NULL, + isset($ssl['ca']) ? $ssl['ca'] : NULL, + isset($ssl['capath']) ? $ssl['capath'] : NULL, + isset($ssl['cipher']) ? $ssl['cipher'] : NULL + ); + } + } + + if ($mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags)) + { + // Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails + if ( + ($client_flags & MYSQLI_CLIENT_SSL) + && version_compare($mysqli->client_info, '5.7.3', '<=') + && empty($mysqli->query("SHOW STATUS LIKE 'ssl_cipher'")->fetch_object()->Value) + ) + { + $mysqli->close(); + $message = 'MySQLi was configured for an SSL connection, but got an unencrypted connection instead!'; + log_message('error', $message); + return ($this->db->db_debug) ? $this->db->display_error($message, '', TRUE) : FALSE; + } + + return $mysqli; + } + + return FALSE; } // -------------------------------------------------------------------- diff --git a/bonfire/ci3/database/drivers/oci8/oci8_driver.php b/bonfire/ci3/database/drivers/oci8/oci8_driver.php index 4010995a1..f2e40da9b 100644 --- a/bonfire/ci3/database/drivers/oci8/oci8_driver.php +++ b/bonfire/ci3/database/drivers/oci8/oci8_driver.php @@ -101,6 +101,14 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- + /** + * Reset $stmt_id flag + * + * Used by stored_procedure() to prevent _execute() from + * re-setting the statement ID. + */ + protected $_reset_stmt_id = TRUE; + /** * List of reserved identifiers * @@ -265,26 +273,13 @@ protected function _execute($sql) /* Oracle must parse the query before it is run. All of the actions with * the query are based on the statement id returned by oci_parse(). */ - $this->stmt_id = FALSE; - $this->_set_stmt_id($sql); - oci_set_prefetch($this->stmt_id, 1000); - return oci_execute($this->stmt_id, $this->commit_mode); - } - - // -------------------------------------------------------------------- - - /** - * Generate a statement ID - * - * @param string $sql an SQL query - * @return void - */ - protected function _set_stmt_id($sql) - { - if ( ! is_resource($this->stmt_id)) + if ($this->_reset_stmt_id === TRUE) { $this->stmt_id = oci_parse($this->conn_id, $sql); } + + oci_set_prefetch($this->stmt_id, 1000); + return oci_execute($this->stmt_id, $this->commit_mode); } // -------------------------------------------------------------------- @@ -311,22 +306,22 @@ public function get_cursor() * * params array keys * - * KEY OPTIONAL NOTES - * name no the name of the parameter should be in : format - * value no the value of the parameter. If this is an OUT or IN OUT parameter, - * this should be a reference to a variable - * type yes the type of the parameter - * length yes the max size of the parameter + * KEY OPTIONAL NOTES + * name no the name of the parameter should be in : format + * value no the value of the parameter. If this is an OUT or IN OUT parameter, + * this should be a reference to a variable + * type yes the type of the parameter + * length yes the max size of the parameter */ - public function stored_procedure($package, $procedure, $params) + public function stored_procedure($package, $procedure, array $params) { - if ($package === '' OR $procedure === '' OR ! is_array($params)) + if ($package === '' OR $procedure === '') { log_message('error', 'Invalid query: '.$package.'.'.$procedure); return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE; } - // build the query string + // Build the query string $sql = 'BEGIN '.$package.'.'.$procedure.'('; $have_cursor = FALSE; @@ -341,10 +336,12 @@ public function stored_procedure($package, $procedure, $params) } $sql = trim($sql, ',').'); END;'; - $this->stmt_id = FALSE; - $this->_set_stmt_id($sql); + $this->_reset_stmt_id = FALSE; + $this->stmt_id = oci_parse($this->conn_id, $sql); $this->_bind_params($params); - return $this->query($sql, FALSE, $have_cursor); + $result = $this->query($sql, FALSE, $have_cursor); + $this->_reset_stmt_id = TRUE; + return $result; } // -------------------------------------------------------------------- @@ -573,7 +570,7 @@ public function field_data($table) { $default = ''; } - $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + $retval[$i]->default = $default; } return $retval; diff --git a/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_mysql_driver.php index 67dc5f5ec..e9d25cebc 100644 --- a/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_mysql_driver.php +++ b/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_mysql_driver.php @@ -119,7 +119,6 @@ public function __construct($params) * * @param bool $persistent * @return object - * @todo SSL support */ public function db_connect($persistent = FALSE) { @@ -151,7 +150,59 @@ public function db_connect($persistent = FALSE) $this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE; } - return parent::db_connect($persistent); + // SSL support was added to PDO_MYSQL in PHP 5.3.7 + if (is_array($this->encrypt) && is_php('5.3.7')) + { + $ssl = array(); + empty($this->encrypt['ssl_key']) OR $ssl[PDO::MYSQL_ATTR_SSL_KEY] = $this->encrypt['ssl_key']; + empty($this->encrypt['ssl_cert']) OR $ssl[PDO::MYSQL_ATTR_SSL_CERT] = $this->encrypt['ssl_cert']; + empty($this->encrypt['ssl_ca']) OR $ssl[PDO::MYSQL_ATTR_SSL_CA] = $this->encrypt['ssl_ca']; + empty($this->encrypt['ssl_capath']) OR $ssl[PDO::MYSQL_ATTR_SSL_CAPATH] = $this->encrypt['ssl_capath']; + empty($this->encrypt['ssl_cipher']) OR $ssl[PDO::MYSQL_ATTR_SSL_CIPHER] = $this->encrypt['ssl_cipher']; + + // DO NOT use array_merge() here! + // It re-indexes numeric keys and the PDO_MYSQL_ATTR_SSL_* constants are integers. + empty($ssl) OR $this->options += $ssl; + } + + // Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails + if ( + ($pdo = parent::db_connect($persistent)) !== FALSE + && ! empty($ssl) + && version_compare($pdo->getAttribute(PDO::ATTR_CLIENT_VERSION), '5.7.3', '<=') + && empty($pdo->query("SHOW STATUS LIKE 'ssl_cipher'")->fetchObject()->Value) + ) + { + $message = 'PDO_MYSQL was configured for an SSL connection, but got an unencrypted connection instead!'; + log_message('error', $message); + return ($this->db->db_debug) ? $this->db->display_error($message, '', TRUE) : FALSE; + } + + return $pdo; + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @param string $database + * @return bool + */ + public function db_select($database = '') + { + if ($database === '') + { + $database = $this->database; + } + + if (FALSE !== $this->simple_query('USE '.$this->escape_identifiers($database))) + { + $this->database = $database; + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- diff --git a/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php b/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php index f07f49f84..409e6501b 100644 --- a/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php +++ b/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php @@ -121,17 +121,31 @@ protected function _list_tables($prefix_limit = FALSE) // -------------------------------------------------------------------- /** - * Show column query + * Fetch Field Names * - * Generates a platform-specific query string so that the column names can be fetched - * - * @param string $table - * @return string + * @param string $table Table name + * @return array */ - protected function _list_columns($table = '') + public function list_fields($table) { - // Not supported - return FALSE; + // Is there a cached result? + if (isset($this->data_cache['field_names'][$table])) + { + return $this->data_cache['field_names'][$table]; + } + + if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $this->data_cache['field_names'][$table] = array(); + foreach ($result->result_array() as $row) + { + $this->data_cache['field_names'][$table][] = $row['name']; + } + + return $this->data_cache['field_names'][$table]; } // -------------------------------------------------------------------- diff --git a/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php b/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php index 28faaddb7..15afbdef5 100644 --- a/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php +++ b/bonfire/ci3/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php @@ -89,6 +89,7 @@ public function __construct(&$db) if (version_compare($this->db->version(), '3.3', '<')) { $this->_create_table_if = FALSE; + $this->_drop_table_if = FALSE; } } diff --git a/bonfire/ci3/database/drivers/sqlite3/sqlite3_driver.php b/bonfire/ci3/database/drivers/sqlite3/sqlite3_driver.php index fdbe94939..31e37de91 100644 --- a/bonfire/ci3/database/drivers/sqlite3/sqlite3_driver.php +++ b/bonfire/ci3/database/drivers/sqlite3/sqlite3_driver.php @@ -247,17 +247,31 @@ protected function _list_tables($prefix_limit = FALSE) // -------------------------------------------------------------------- /** - * Show column query + * Fetch Field Names * - * Generates a platform-specific query string so that the column names can be fetched - * - * @param string $table - * @return string + * @param string $table Table name + * @return array */ - protected function _list_columns($table = '') + public function list_fields($table) { - // Not supported - return FALSE; + // Is there a cached result? + if (isset($this->data_cache['field_names'][$table])) + { + return $this->data_cache['field_names'][$table]; + } + + if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $this->data_cache['field_names'][$table] = array(); + foreach ($result->result_array() as $row) + { + $this->data_cache['field_names'][$table][] = $row['name']; + } + + return $this->data_cache['field_names'][$table]; } // -------------------------------------------------------------------- diff --git a/bonfire/ci3/database/drivers/sqlite3/sqlite3_forge.php b/bonfire/ci3/database/drivers/sqlite3/sqlite3_forge.php index 69f65b6f3..24690ba20 100644 --- a/bonfire/ci3/database/drivers/sqlite3/sqlite3_forge.php +++ b/bonfire/ci3/database/drivers/sqlite3/sqlite3_forge.php @@ -74,7 +74,8 @@ public function __construct(&$db) if (version_compare($this->db->version(), '3.3', '<')) { - $this->create_table_if = FALSE; + $this->_create_table_if = FALSE; + $this->_drop_table_if = FALSE; } } diff --git a/bonfire/ci3/helpers/array_helper.php b/bonfire/ci3/helpers/array_helper.php index e07b52bb5..2ce55b9c4 100644 --- a/bonfire/ci3/helpers/array_helper.php +++ b/bonfire/ci3/helpers/array_helper.php @@ -62,7 +62,7 @@ * @param mixed * @return mixed depends on what the array contains */ - function element($item, $array, $default = NULL) + function element($item, array $array, $default = NULL) { return array_key_exists($item, $array) ? $array[$item] : $default; } @@ -99,7 +99,7 @@ function random_element($array) * @param mixed * @return mixed depends on what the array contains */ - function elements($items, $array, $default = NULL) + function elements($items, array $array, $default = NULL) { $return = array(); diff --git a/bonfire/ci3/helpers/download_helper.php b/bonfire/ci3/helpers/download_helper.php index 95c94a1b8..73f6456c4 100644 --- a/bonfire/ci3/helpers/download_helper.php +++ b/bonfire/ci3/helpers/download_helper.php @@ -69,16 +69,14 @@ function force_download($filename = '', $data = '', $set_mime = FALSE) } elseif ($data === NULL) { - if (@is_file($filename) && ($filesize = @filesize($filename)) !== FALSE) - { - $filepath = $filename; - $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename)); - $filename = end($filename); - } - else + if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE) { return; } + + $filepath = $filename; + $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename)); + $filename = end($filename); } else { @@ -140,14 +138,7 @@ function force_download($filename = '', $data = '', $set_mime = FALSE) header('Expires: 0'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.$filesize); - - // Internet Explorer-specific headers - if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) - { - header('Cache-Control: no-cache, no-store, must-revalidate'); - } - - header('Pragma: no-cache'); + header('Cache-Control: private, no-transform, no-store, must-revalidate'); // If we have raw data - just dump it if ($data !== NULL) diff --git a/bonfire/ci3/helpers/file_helper.php b/bonfire/ci3/helpers/file_helper.php index 8b15e60a5..cd1c641ec 100644 --- a/bonfire/ci3/helpers/file_helper.php +++ b/bonfire/ci3/helpers/file_helper.php @@ -54,7 +54,7 @@ /** * Read File * - * Opens the file specfied in the path and returns it as a string. + * Opens the file specified in the path and returns it as a string. * * @todo Remove in version 3.1+. * @deprecated 3.0.0 It is now just an alias for PHP's native file_get_contents(). diff --git a/bonfire/ci3/helpers/form_helper.php b/bonfire/ci3/helpers/form_helper.php index 53ee8eb11..fd807769a 100644 --- a/bonfire/ci3/helpers/form_helper.php +++ b/bonfire/ci3/helpers/form_helper.php @@ -197,7 +197,7 @@ function form_hidden($name, $value = '', $recursing = FALSE) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_input($data = '', $value = '', $extra = '') @@ -208,7 +208,7 @@ function form_input($data = '', $value = '', $extra = '') 'value' => $value ); - return '\n"; + return '\n"; } } @@ -223,7 +223,7 @@ function form_input($data = '', $value = '', $extra = '') * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_password($data = '', $value = '', $extra = '') @@ -245,7 +245,7 @@ function form_password($data = '', $value = '', $extra = '') * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_upload($data = '', $value = '', $extra = '') @@ -253,7 +253,8 @@ function form_upload($data = '', $value = '', $extra = '') $defaults = array('type' => 'file', 'name' => ''); is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; - return '\n"; + + return '\n"; } } @@ -266,7 +267,7 @@ function form_upload($data = '', $value = '', $extra = '') * * @param mixed $data * @param string $value - * @param string $extra + * @param mixed $extra * @return string */ function form_textarea($data = '', $value = '', $extra = '') @@ -287,7 +288,9 @@ function form_textarea($data = '', $value = '', $extra = '') unset($data['value']); // textareas don't use the value attribute } - return '\n"; + return '\n"; } } @@ -301,12 +304,13 @@ function form_textarea($data = '', $value = '', $extra = '') * @param string * @param array * @param mixed - * @param string + * @param mixed * @return string */ function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '') { - if ( ! strpos($extra, 'multiple')) + $extra = _attributes_to_string($extra); + if (stripos($extra, 'multiple') === FALSE) { $extra .= ' multiple="multiple"'; } @@ -372,7 +376,7 @@ function form_dropdown($data = '', $options = array(), $selected = array(), $ext $extra = _attributes_to_string($extra); - $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; + $multiple = (count($selected) > 1 && stripos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; $form = '\n"; + return '\n"; } } @@ -464,13 +468,14 @@ function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') * @param mixed * @param string * @param bool - * @param string + * @param mixed * @return string */ function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') { is_array($data) OR $data = array('name' => $data); $data['type'] = 'radio'; + return form_checkbox($data, $value, $checked, $extra); } } @@ -484,7 +489,7 @@ function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_submit($data = '', $value = '', $extra = '') @@ -495,7 +500,7 @@ function form_submit($data = '', $value = '', $extra = '') 'value' => $value ); - return '\n"; + return '\n"; } } @@ -508,7 +513,7 @@ function form_submit($data = '', $value = '', $extra = '') * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_reset($data = '', $value = '', $extra = '') @@ -519,7 +524,7 @@ function form_reset($data = '', $value = '', $extra = '') 'value' => $value ); - return '\n"; + return '\n"; } } @@ -532,7 +537,7 @@ function form_reset($data = '', $value = '', $extra = '') * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_button($data = '', $content = '', $extra = '') @@ -548,7 +553,9 @@ function form_button($data = '', $content = '', $extra = '') unset($data['content']); // content is not an attribute } - return '\n"; + return '\n"; } } diff --git a/bonfire/ci3/helpers/inflector_helper.php b/bonfire/ci3/helpers/inflector_helper.php index d8ed45df9..f2890059f 100644 --- a/bonfire/ci3/helpers/inflector_helper.php +++ b/bonfire/ci3/helpers/inflector_helper.php @@ -133,6 +133,7 @@ function plural($str) } $plural_rules = array( + '/(quiz)$/' => '\1zes', // quizzes '/^(ox)$/' => '\1\2en', // ox '/([m|l])ouse$/' => '\1ice', // mouse, louse '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index diff --git a/bonfire/ci3/helpers/path_helper.php b/bonfire/ci3/helpers/path_helper.php index c23ec6435..c96d0b8b3 100644 --- a/bonfire/ci3/helpers/path_helper.php +++ b/bonfire/ci3/helpers/path_helper.php @@ -61,7 +61,7 @@ function set_realpath($path, $check_existance = FALSE) { // Security check to make sure the path is NOT a URL. No remote file inclusion! - if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i', $path)) + if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp)#i', $path) OR filter_var($path, FILTER_VALIDATE_IP) === $path ) { show_error('The path you submitted must be a local server path, not a URL'); } diff --git a/bonfire/ci3/helpers/string_helper.php b/bonfire/ci3/helpers/string_helper.php index 5860e15fb..637835160 100644 --- a/bonfire/ci3/helpers/string_helper.php +++ b/bonfire/ci3/helpers/string_helper.php @@ -253,7 +253,7 @@ function random_string($type = 'alnum', $len = 8) */ function increment_string($str, $separator = '_', $first = 1) { - preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); + preg_match('/(.+)'.preg_quote($separator, '/').'([0-9]+)$/', $str, $match); return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; } } diff --git a/bonfire/ci3/helpers/text_helper.php b/bonfire/ci3/helpers/text_helper.php index f2290c895..fb47036f2 100644 --- a/bonfire/ci3/helpers/text_helper.php +++ b/bonfire/ci3/helpers/text_helper.php @@ -254,7 +254,7 @@ function entities_to_ascii($str, $all = TRUE) * word you've submitted. * * @param string the text string - * @param string the array of censoered words + * @param string the array of censored words * @param string the optional replacement value * @return string */ diff --git a/bonfire/ci3/helpers/url_helper.php b/bonfire/ci3/helpers/url_helper.php index bf623b000..d65f92f1b 100644 --- a/bonfire/ci3/helpers/url_helper.php +++ b/bonfire/ci3/helpers/url_helper.php @@ -161,7 +161,7 @@ function anchor($uri = '', $title = '', $attributes = '') $site_url = is_array($uri) ? site_url($uri) - : preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri); + : (preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri)); if ($title === '') { @@ -474,7 +474,7 @@ function prep_url($str = '') * @param string $str Input string * @param string $separator Word separator * (usually '-' or '_') - * @param bool $lowercase Wether to transform the output string to lowercase + * @param bool $lowercase Whether to transform the output string to lowercase * @return string */ function url_title($str, $separator = '-', $lowercase = FALSE) @@ -492,7 +492,7 @@ function url_title($str, $separator = '-', $lowercase = FALSE) $trans = array( '&.+?;' => '', - '[^a-z0-9 _-]' => '', + '[^\w\d _-]' => '', '\s+' => $separator, '('.$q_separator.')+' => $separator ); @@ -500,7 +500,7 @@ function url_title($str, $separator = '-', $lowercase = FALSE) $str = strip_tags($str); foreach ($trans as $key => $val) { - $str = preg_replace('#'.$key.'#i', $val, $str); + $str = preg_replace('#'.$key.'#i'.(UTF8_ENABLED ? 'u' : ''), $val, $str); } if ($lowercase === TRUE) diff --git a/bonfire/ci3/libraries/Cache/Cache.php b/bonfire/ci3/libraries/Cache/Cache.php index 40ac70103..0c87a5628 100644 --- a/bonfire/ci3/libraries/Cache/Cache.php +++ b/bonfire/ci3/libraries/Cache/Cache.php @@ -100,28 +100,10 @@ class CI_Cache extends CI_Driver_Library { */ public function __construct($config = array()) { - $default_config = array( - 'adapter', - 'memcached' - ); - - foreach ($default_config as $key) - { - if (isset($config[$key])) - { - $param = '_'.$key; - - $this->{$param} = $config[$key]; - } - } - + isset($config['adapter']) && $this->_adapter = $config['adapter']; + isset($config['backup']) && $this->_backup_driver = $config['backup']; isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; - if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) - { - $this->_backup_driver = $config['backup']; - } - // If the specified adapter isn't available, check the backup. if ( ! $this->is_supported($this->_adapter)) { @@ -196,7 +178,7 @@ public function delete($id) */ public function increment($id, $offset = 1) { - return $this->{$this->_adapter}->increment($id, $offset); + return $this->{$this->_adapter}->increment($this->key_prefix.$id, $offset); } // ------------------------------------------------------------------------ @@ -210,7 +192,7 @@ public function increment($id, $offset = 1) */ public function decrement($id, $offset = 1) { - return $this->{$this->_adapter}->decrement($id, $offset); + return $this->{$this->_adapter}->decrement($this->key_prefix.$id, $offset); } // ------------------------------------------------------------------------ @@ -261,14 +243,13 @@ public function get_metadata($id) */ public function is_supported($driver) { - static $support = array(); + static $support; - if ( ! isset($support[$driver])) + if ( ! isset($support, $support[$driver])) { $support[$driver] = $this->{$driver}->is_supported(); } return $support[$driver]; } - } diff --git a/bonfire/ci3/libraries/Cache/drivers/Cache_memcached.php b/bonfire/ci3/libraries/Cache/drivers/Cache_memcached.php index b90b561c9..111e2109d 100644 --- a/bonfire/ci3/libraries/Cache/drivers/Cache_memcached.php +++ b/bonfire/ci3/libraries/Cache/drivers/Cache_memcached.php @@ -68,6 +68,76 @@ class CI_Cache_memcached extends CI_Driver { ) ); + // ------------------------------------------------------------------------ + + /** + * Class constructor + * + * Setup Memcache(d) + * + * @return void + */ + public function __construct() + { + // Try to load memcached server info from the config file. + $CI =& get_instance(); + $defaults = $this->_memcache_conf['default']; + + if ($CI->config->load('memcached', TRUE, TRUE)) + { + if (is_array($CI->config->config['memcached'])) + { + $this->_memcache_conf = array(); + + foreach ($CI->config->config['memcached'] as $name => $conf) + { + $this->_memcache_conf[$name] = $conf; + } + } + } + + if (class_exists('Memcached', FALSE)) + { + $this->_memcached = new Memcached(); + } + elseif (class_exists('Memcache', FALSE)) + { + $this->_memcached = new Memcache(); + } + else + { + throw new RuntimeException('Cache: Failed to create Memcache(d) object; extension not loaded?'); + } + + foreach ($this->_memcache_conf as $cache_server) + { + isset($cache_server['hostname']) OR $cache_server['hostname'] = $defaults['host']; + isset($cache_server['port']) OR $cache_server['port'] = $defaults['port']; + isset($cache_server['weight']) OR $cache_server['weight'] = $defaults['weight']; + + if (get_class($this->_memcached) === 'Memcache') + { + // Third parameter is persistance and defaults to TRUE. + $this->_memcached->addServer( + $cache_server['hostname'], + $cache_server['port'], + TRUE, + $cache_server['weight'] + ); + } + else + { + $this->_memcached->addServer( + $cache_server['hostname'], + $cache_server['port'], + $cache_server['weight'] + ); + } + } + } + + // ------------------------------------------------------------------------ + /** * Fetch from cache * @@ -204,75 +274,6 @@ public function get_metadata($id) // ------------------------------------------------------------------------ - /** - * Setup memcached. - * - * @return bool - */ - protected function _setup_memcached() - { - // Try to load memcached server info from the config file. - $CI =& get_instance(); - $defaults = $this->_memcache_conf['default']; - - if ($CI->config->load('memcached', TRUE, TRUE)) - { - if (is_array($CI->config->config['memcached'])) - { - $this->_memcache_conf = array(); - - foreach ($CI->config->config['memcached'] as $name => $conf) - { - $this->_memcache_conf[$name] = $conf; - } - } - } - - if (class_exists('Memcached', FALSE)) - { - $this->_memcached = new Memcached(); - } - elseif (class_exists('Memcache', FALSE)) - { - $this->_memcached = new Memcache(); - } - else - { - log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?'); - return FALSE; - } - - foreach ($this->_memcache_conf as $cache_server) - { - isset($cache_server['hostname']) OR $cache_server['hostname'] = $defaults['host']; - isset($cache_server['port']) OR $cache_server['port'] = $defaults['port']; - isset($cache_server['weight']) OR $cache_server['weight'] = $defaults['weight']; - - if (get_class($this->_memcached) === 'Memcache') - { - // Third parameter is persistance and defaults to TRUE. - $this->_memcached->addServer( - $cache_server['hostname'], - $cache_server['port'], - TRUE, - $cache_server['weight'] - ); - } - else - { - $this->_memcached->addServer( - $cache_server['hostname'], - $cache_server['port'], - $cache_server['weight'] - ); - } - } - - return TRUE; - } - - // ------------------------------------------------------------------------ - /** * Is supported * @@ -289,7 +290,6 @@ public function is_supported() return FALSE; } - return $this->_setup_memcached(); + return TRUE; } - } diff --git a/bonfire/ci3/libraries/Cache/drivers/Cache_redis.php b/bonfire/ci3/libraries/Cache/drivers/Cache_redis.php index 13f79dc5d..d7dca1973 100644 --- a/bonfire/ci3/libraries/Cache/drivers/Cache_redis.php +++ b/bonfire/ci3/libraries/Cache/drivers/Cache_redis.php @@ -78,6 +78,63 @@ class CI_Cache_redis extends CI_Driver // ------------------------------------------------------------------------ + /** + * Class constructor + * + * Setup Redis + * + * Loads Redis config file if present. Will halt execution + * if a Redis connection can't be established. + * + * @return void + * @see Redis::connect() + */ + public function __construct() + { + $config = array(); + $CI =& get_instance(); + + if ($CI->config->load('redis', TRUE, TRUE)) + { + $config = $CI->config->item('redis'); + } + + $config = array_merge(self::$_default_config, $config); + $this->_redis = new Redis(); + + try + { + if ($config['socket_type'] === 'unix') + { + $success = $this->_redis->connect($config['socket']); + } + else // tcp socket + { + $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + } + + if ( ! $success) + { + throw new RuntimeException('Cache: Redis connection failed. Check your configuration.'); + } + } + catch (RedisException $e) + { + throw new RuntimeException('Cache: Redis connection refused ('.$e->getMessage().')'); + } + + if (isset($config['password']) && ! $this->_redis->auth($config['password'])) + { + throw new RuntimeException('Cache: Redis authentication failed.'); + } + + // Initialize the index of serialized values. + $serialized = $this->_redis->sMembers('_ci_redis_serialized'); + empty($serialized) OR $this->_serialized = array_flip($serialized); + } + + // ------------------------------------------------------------------------ + /** * Get cache * @@ -111,7 +168,7 @@ public function save($id, $data, $ttl = 60, $raw = FALSE) { if (is_array($data) OR is_object($data)) { - if ( ! $this->_redis->sIsMember('_ci_redis_serialized', $id) && ! $this->_redis->sAdd('_ci_redis_serialized', $id)) + if ( ! $this->_redis->sIsMember('_ci_redis_serialized', $id) && ! $this->_redis->sAdd('_ci_redis_serialized', $id)) { return FALSE; } @@ -125,9 +182,7 @@ public function save($id, $data, $ttl = 60, $raw = FALSE) $this->_redis->sRemove('_ci_redis_serialized', $id); } - return ($ttl) - ? $this->_redis->setex($id, $ttl, $data) - : $this->_redis->set($id, $data); + return $this->_redis->set($id, $data, $ttl); } // ------------------------------------------------------------------------ @@ -223,7 +278,7 @@ public function get_metadata($key) { $value = $this->get($key); - if ($value) + if ($value !== FALSE) { return array( 'expire' => time() + $this->_redis->ttl($key), @@ -249,69 +304,6 @@ public function is_supported() return FALSE; } - return $this->_setup_redis(); - } - - // ------------------------------------------------------------------------ - - /** - * Setup Redis config and connection - * - * Loads Redis config file if present. Will halt execution - * if a Redis connection can't be established. - * - * @return bool - * @see Redis::connect() - */ - protected function _setup_redis() - { - $config = array(); - $CI =& get_instance(); - - if ($CI->config->load('redis', TRUE, TRUE)) - { - $config += $CI->config->item('redis'); - } - - $config = array_merge(self::$_default_config, $config); - - $this->_redis = new Redis(); - - try - { - if ($config['socket_type'] === 'unix') - { - $success = $this->_redis->connect($config['socket']); - } - else // tcp socket - { - $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); - } - - if ( ! $success) - { - log_message('debug', 'Cache: Redis connection refused. Check the config.'); - return FALSE; - } - } - catch (RedisException $e) - { - log_message('debug', 'Cache: Redis connection refused ('.$e->getMessage().')'); - return FALSE; - } - - if (isset($config['password'])) - { - $this->_redis->auth($config['password']); - } - - // Initialize the index of serialized values. - $serialized = $this->_redis->sMembers('_ci_redis_serialized'); - if ( ! empty($serialized)) - { - $this->_serialized = array_flip($serialized); - } - return TRUE; } @@ -331,5 +323,4 @@ public function __destruct() $this->_redis->close(); } } - } diff --git a/bonfire/ci3/libraries/Email.php b/bonfire/ci3/libraries/Email.php index 66b5803dd..459c8f590 100644 --- a/bonfire/ci3/libraries/Email.php +++ b/bonfire/ci3/libraries/Email.php @@ -804,11 +804,12 @@ public function attachment_cid($filename) * * @param string * @param string - * @return void + * @return CI_Email */ public function set_header($header, $value) { $this->_headers[$header] = str_replace(array("\n", "\r"), '', $value); + return $this; } // -------------------------------------------------------------------- @@ -2126,12 +2127,32 @@ protected function _smtp_authenticate() protected function _send_data($data) { $data .= $this->newline; - for ($written = 0, $length = strlen($data); $written < $length; $written += $result) + for ($written = $timestamp = 0, $length = strlen($data); $written < $length; $written += $result) { if (($result = fwrite($this->_smtp_connect, substr($data, $written))) === FALSE) { break; } + // See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951 + elseif ($result === 0) + { + if ($timestamp === 0) + { + $timestamp = time(); + } + elseif ($timestamp < (time() - $this->smtp_timeout)) + { + $result = FALSE; + break; + } + + usleep(250000); + continue; + } + else + { + $timestamp = 0; + } } if ($result === FALSE) diff --git a/bonfire/ci3/libraries/Encrypt.php b/bonfire/ci3/libraries/Encrypt.php index 5faf1f206..a46d4f462 100644 --- a/bonfire/ci3/libraries/Encrypt.php +++ b/bonfire/ci3/libraries/Encrypt.php @@ -65,7 +65,7 @@ class CI_Encrypt { protected $_hash_type = 'sha1'; /** - * Flag for the existance of mcrypt + * Flag for the existence of mcrypt * * @var bool */ diff --git a/bonfire/ci3/libraries/Encryption.php b/bonfire/ci3/libraries/Encryption.php index e3e68139a..f3e039881 100644 --- a/bonfire/ci3/libraries/Encryption.php +++ b/bonfire/ci3/libraries/Encryption.php @@ -121,7 +121,7 @@ class CI_Encryption { ); /** - * List of supported HMAC algorightms + * List of supported HMAC algorithms * * name => digest size pairs * diff --git a/bonfire/ci3/libraries/Form_validation.php b/bonfire/ci3/libraries/Form_validation.php index 6e3194120..d9ecc45f9 100644 --- a/bonfire/ci3/libraries/Form_validation.php +++ b/bonfire/ci3/libraries/Form_validation.php @@ -198,22 +198,20 @@ public function set_rules($field, $label = '', $rules = array(), $errors = array return $this; } - // No fields? Nothing to do... - if ( ! is_string($field) OR $field === '') + // No fields or no rules? Nothing to do... + if ( ! is_string($field) OR $field === '' OR empty($rules)) { return $this; } elseif ( ! is_array($rules)) { // BC: Convert pipe-separated rules string to an array - if (is_string($rules)) - { - $rules = explode('|', $rules); - } - else + if ( ! is_string($rules)) { return $this; } + + $rules = explode('|', $rules); } // If the field label wasn't passed we use the field name @@ -463,7 +461,7 @@ public function run($group = '') { $this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']); } - elseif (isset($validation_array[$field]) && $validation_array[$field] !== '') + elseif (isset($validation_array[$field])) { $this->_field_data[$field]['postdata'] = $validation_array[$field]; } @@ -620,6 +618,12 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0) $rules = array(1 => $rule); break; } + elseif (is_array($rule) && isset($rule[0], $rule[1]) && is_callable($rule[1])) + { + $callback = TRUE; + $rules = array(array($rule[0], $rule[1])); + break; + } } if ( ! $callback) @@ -817,11 +821,10 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0) // Callable rules might not have named error messages if ( ! is_string($rule)) { - return; + $line = $this->CI->lang->line('form_validation_error_message_not_set').'(Anonymous function)'; } - // Check if a custom message is defined - if (isset($this->_field_data[$row['field']]['errors'][$rule])) + elseif (isset($this->_field_data[$row['field']]['errors'][$rule])) { $line = $this->_field_data[$row['field']]['errors'][$rule]; } @@ -831,7 +834,7 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0) // DEPRECATED support for non-prefixed keys && FALSE === ($line = $this->CI->lang->line($rule, FALSE))) { - $line = $this->CI->lang->line('form_validation_error_message_not_set').'('.$rule.')'; + $line = $this->CI->lang->line('form_validation_error_message_not_set').'('.$rule.')'; } } else @@ -872,17 +875,11 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0) */ protected function _translate_fieldname($fieldname) { - // Do we need to translate the field name? - // We look for the prefix lang: to determine this - if (sscanf($fieldname, 'lang:%s', $line) === 1) + // Do we need to translate the field name? We look for the prefix 'lang:' to determine this + // If we find one, but there's no translation for the string - just return it + if (sscanf($fieldname, 'lang:%s', $line) === 1 && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE))) { - // Were we able to translate the field name? If not we use $line - if (FALSE === ($fieldname = $this->CI->lang->line('form_validation_'.$line)) - // DEPRECATED support for non-prefixed keys - && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE))) - { - return $line; - } + return $line; } return $fieldname; diff --git a/bonfire/ci3/libraries/Ftp.php b/bonfire/ci3/libraries/Ftp.php index af45bb55f..2d345c294 100644 --- a/bonfire/ci3/libraries/Ftp.php +++ b/bonfire/ci3/libraries/Ftp.php @@ -466,7 +466,7 @@ public function delete_file($filepath) /** * Delete a folder and recursively delete everything (including sub-folders) - * containted within it. + * contained within it. * * @param string $filepath * @return bool @@ -490,7 +490,7 @@ public function delete_dir($filepath) // so we'll recursively call delete_dir() if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->conn_id, $list[$i])) { - $this->delete_dir($list[$i]); + $this->delete_dir($filepath.$list[$i]); } } } diff --git a/bonfire/ci3/libraries/Image_lib.php b/bonfire/ci3/libraries/Image_lib.php index e056654bb..e813efd89 100644 --- a/bonfire/ci3/libraries/Image_lib.php +++ b/bonfire/ci3/libraries/Image_lib.php @@ -779,7 +779,7 @@ public function image_process_gd($action = 'resize') $this->y_axis = 0; } - // Create the image handle + // Create the image handle if ( ! ($src_img = $this->image_create_gd())) { return FALSE; @@ -845,7 +845,7 @@ public function image_process_gd($action = 'resize') */ public function image_process_imagemagick($action = 'resize') { - // Do we have a vaild library path? + // Do we have a vaild library path? if ($this->library_path === '') { $this->set_error('imglib_libpath_invalid'); @@ -1010,7 +1010,7 @@ public function image_rotate_gd() // going to have to figure out how to determine the color // of the alpha channel in a future release. - $white = imagecolorallocate($src_img, 255, 255, 255); + $white = imagecolorallocate($src_img, 255, 255, 255); // Rotate it! $dst_img = imagerotate($src_img, $this->rotation_angle, $white); @@ -1055,8 +1055,11 @@ public function image_mirror_gd() if ($this->rotation_angle === 'hor') { - for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1) + for ($i = 0; $i < $height; $i++) { + $left = 0; + $right = $width - 1; + while ($left < $right) { $cl = imagecolorat($src_img, $left, $i); @@ -1072,18 +1075,21 @@ public function image_mirror_gd() } else { - for ($i = 0; $i < $width; $i++, $top = 0, $bot = $height-1) + for ($i = 0; $i < $width; $i++) { - while ($top < $bot) + $top = 0; + $bottom = $height - 1; + + while ($top < $bottom) { $ct = imagecolorat($src_img, $i, $top); - $cb = imagecolorat($src_img, $i, $bot); + $cb = imagecolorat($src_img, $i, $bottom); imagesetpixel($src_img, $i, $top, $cb); - imagesetpixel($src_img, $i, $bot, $ct); + imagesetpixel($src_img, $i, $bottom, $ct); $top++; - $bot--; + $bottom--; } } } @@ -1189,7 +1195,7 @@ public function overlay_watermark() $x_axis += $this->orig_width - $wm_width; } - // Build the finalized image + // Build the finalized image if ($wm_img_type === 3 && function_exists('imagealphablending')) { @imagealphablending($src_img, TRUE); @@ -1327,7 +1333,7 @@ public function text_watermark() { $y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight / 2); } - + // Set horizontal alignment if ($this->wm_hor_alignment === 'R') { @@ -1337,13 +1343,13 @@ public function text_watermark() { $x_axis += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2); } - + if ($this->wm_use_drop_shadow) { // Offset from text $x_shad = $x_axis + $this->wm_shadow_distance; $y_shad = $y_axis + $this->wm_shadow_distance; - + /* Set RGB values for shadow * * First character is #, so we don't really need it. @@ -1352,7 +1358,7 @@ public function text_watermark() */ $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2])); - + // Add the shadow to the source image if ($this->wm_use_truetype) { @@ -1363,7 +1369,7 @@ public function text_watermark() imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); } } - + /* Set RGB values for text * * First character is #, so we don't really need it. @@ -1382,7 +1388,7 @@ public function text_watermark() { imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } - + // We can preserve transparency for PNG images if ($this->image_type === 3) { @@ -1431,7 +1437,7 @@ public function image_create_gd($path = '', $image_type = '') switch ($image_type) { - case 1 : + case 1: if ( ! function_exists('imagecreatefromgif')) { $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported')); @@ -1439,7 +1445,7 @@ public function image_create_gd($path = '', $image_type = '') } return imagecreatefromgif($path); - case 2 : + case 2: if ( ! function_exists('imagecreatefromjpeg')) { $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported')); @@ -1447,7 +1453,7 @@ public function image_create_gd($path = '', $image_type = '') } return imagecreatefromjpeg($path); - case 3 : + case 3: if ( ! function_exists('imagecreatefrompng')) { $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported')); diff --git a/bonfire/ci3/libraries/Javascript/Jquery.php b/bonfire/ci3/libraries/Javascript/Jquery.php index 25acceef7..11f2d2361 100644 --- a/bonfire/ci3/libraries/Javascript/Jquery.php +++ b/bonfire/ci3/libraries/Javascript/Jquery.php @@ -84,7 +84,7 @@ class CI_Jquery extends CI_Javascript { public $jquery_table_sorter_active = FALSE; /** - * JQuery table sorder pager active + * JQuery table sorter pager active * * @var bool */ diff --git a/bonfire/ci3/libraries/Migration.php b/bonfire/ci3/libraries/Migration.php index ae36a3b45..45a3cbbce 100644 --- a/bonfire/ci3/libraries/Migration.php +++ b/bonfire/ci3/libraries/Migration.php @@ -191,7 +191,7 @@ public function __construct($config = array()) * choice * * @param string $target_version Target schema version - * @return mixed TRUE if already latest, FALSE if failed, string if upgraded + * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure */ public function version($target_version) { @@ -294,7 +294,7 @@ public function version($target_version) /** * Sets the schema to the latest migration * - * @return mixed TRUE if already latest, FALSE if failed, string if upgraded + * @return mixed Current version string on success, FALSE on failure */ public function latest() { @@ -318,7 +318,7 @@ public function latest() /** * Sets the schema to the migration version set in config * - * @return mixed TRUE if already current, FALSE if failed, string if upgraded + * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure */ public function current() { diff --git a/bonfire/ci3/libraries/Pagination.php b/bonfire/ci3/libraries/Pagination.php index d63f61df6..5b3aa01f4 100644 --- a/bonfire/ci3/libraries/Pagination.php +++ b/bonfire/ci3/libraries/Pagination.php @@ -353,7 +353,8 @@ public function __construct($params = array()) */ public function initialize(array $params = array()) { - if (isset($params['attributes']) && is_array($params['attributes'])) + isset($params['attributes']) OR $params['attributes'] = array(); + if (is_array($params['attributes'])) { $this->_parse_attributes($params['attributes']); unset($params['attributes']); @@ -644,7 +645,7 @@ public function create_links() // Kill double slashes. Note: Sometimes we can end up with a double slash // in the penultimate link so we'll kill all double slashes. - $output = preg_replace('#([^:])//+#', '\\1/', $output); + $output = preg_replace('#([^:"])//+#', '\\1/', $output); // Add the wrapper HTML if exists return $this->full_tag_open.$output.$this->full_tag_close; diff --git a/bonfire/ci3/libraries/Profiler.php b/bonfire/ci3/libraries/Profiler.php index f35d23faf..1e464d8b0 100644 --- a/bonfire/ci3/libraries/Profiler.php +++ b/bonfire/ci3/libraries/Profiler.php @@ -100,12 +100,6 @@ public function __construct($config = array()) $this->CI =& get_instance(); $this->CI->load->language('profiler'); - if (isset($config['query_toggle_count'])) - { - $this->_query_toggle_count = (int) $config['query_toggle_count']; - unset($config['query_toggle_count']); - } - // default all sections to display foreach ($this->_available_sections as $section) { diff --git a/bonfire/ci3/libraries/Session/Session.php b/bonfire/ci3/libraries/Session/Session.php index 86d76425c..05a470d86 100644 --- a/bonfire/ci3/libraries/Session/Session.php +++ b/bonfire/ci3/libraries/Session/Session.php @@ -94,7 +94,7 @@ public function __construct(array $params = array()) $this->_driver = 'database'; } - $class = $this->_ci_load_classes($this->_driver); + $class = $this->_ci_load_classes($this->_driver); // Configuration ... $this->_configure($params); @@ -227,8 +227,7 @@ interface_exists('SessionHandlerInterface', FALSE) OR require_once(BASEPATH.'lib if ( ! class_exists('CI_'.$class, FALSE) && ! class_exists($class, FALSE)) { - log_message('error', "Session: Configured driver '".$driver."' was not found. Aborting."); - return FALSE; + throw new UnexpectedValueException("Session: Configured driver '".$driver."' was not found. Aborting."); } } @@ -796,7 +795,7 @@ public function flashdata($key = NULL) /** * Set flashdata * - * Legacy CI_Session compatibiliy method + * Legacy CI_Session compatibility method * * @param mixed $data Session data key or an associative array * @param mixed $value Value to store @@ -870,7 +869,7 @@ public function tempdata($key = NULL) public function set_tempdata($data, $value = NULL, $ttl = 300) { $this->set_userdata($data, $value); - $this->mark_as_temp($data, $ttl); + $this->mark_as_temp(is_array($data) ? array_keys($data) : $data, $ttl); } // ------------------------------------------------------------------------ diff --git a/bonfire/ci3/libraries/Session/drivers/Session_memcached_driver.php b/bonfire/ci3/libraries/Session/drivers/Session_memcached_driver.php index c7185ee44..97b860588 100644 --- a/bonfire/ci3/libraries/Session/drivers/Session_memcached_driver.php +++ b/bonfire/ci3/libraries/Session/drivers/Session_memcached_driver.php @@ -322,7 +322,7 @@ protected function _get_lock($session_id) $this->_lock_key = $lock_key; break; } - while ($attempt++ < 30); + while (++$attempt < 30); if ($attempt === 30) { diff --git a/bonfire/ci3/libraries/Session/drivers/Session_redis_driver.php b/bonfire/ci3/libraries/Session/drivers/Session_redis_driver.php index 1ce101daf..b098cc441 100644 --- a/bonfire/ci3/libraries/Session/drivers/Session_redis_driver.php +++ b/bonfire/ci3/libraries/Session/drivers/Session_redis_driver.php @@ -336,7 +336,7 @@ protected function _get_lock($session_id) $this->_lock_key = $lock_key; break; } - while ($attempt++ < 30); + while (++$attempt < 30); if ($attempt === 30) { diff --git a/bonfire/ci3/libraries/Unit_test.php b/bonfire/ci3/libraries/Unit_test.php index 7b744adc6..3f986f3e8 100644 --- a/bonfire/ci3/libraries/Unit_test.php +++ b/bonfire/ci3/libraries/Unit_test.php @@ -55,14 +55,14 @@ class CI_Unit_test { * * @var bool */ - public $active = TRUE; + public $active = TRUE; /** * Test results * * @var array */ - public $results = array(); + public $results = array(); /** * Strict comparison flag @@ -71,21 +71,21 @@ class CI_Unit_test { * * @var bool */ - public $strict = FALSE; + public $strict = FALSE; /** * Template * * @var string */ - protected $_template = NULL; + protected $_template = NULL; /** * Template rows * * @var string */ - protected $_template_rows = NULL; + protected $_template_rows = NULL; /** * List of visible test items @@ -93,13 +93,13 @@ class CI_Unit_test { * @var array */ protected $_test_items_visible = array( - 'test_name', - 'test_datatype', - 'res_datatype', - 'result', - 'file', - 'line', - 'notes' + 'test_name', + 'test_datatype', + 'res_datatype', + 'result', + 'file', + 'line', + 'notes' ); // -------------------------------------------------------------------- @@ -152,7 +152,7 @@ public function run($test, $expected = TRUE, $test_name = 'undefined', $notes = return FALSE; } - if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE)) + if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null', 'is_resource'), TRUE)) { $expected = str_replace('is_double', 'is_float', $expected); $result = $expected($test); @@ -167,14 +167,14 @@ public function run($test, $expected = TRUE, $test_name = 'undefined', $notes = $back = $this->_backtrace(); $report = array ( - 'test_name' => $test_name, - 'test_datatype' => gettype($test), - 'res_datatype' => $extype, - 'result' => ($result === TRUE) ? 'passed' : 'failed', - 'file' => $back['file'], - 'line' => $back['line'], - 'notes' => $notes - ); + 'test_name' => $test_name, + 'test_datatype' => gettype($test), + 'res_datatype' => $extype, + 'result' => ($result === TRUE) ? 'passed' : 'failed', + 'file' => $back['file'], + 'line' => $back['line'], + 'notes' => $notes + ); $this->results[] = $report; @@ -291,10 +291,12 @@ public function result($results = array()) { continue; } - - if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val), FALSE))) + elseif (in_array($key, array('test_name', 'test_datatype', 'test_res_datatype', 'result'), TRUE)) { - $val = $line; + if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val), FALSE))) + { + $val = $line; + } } $temp[$CI->lang->line('ut_'.$key, FALSE)] = $val; @@ -334,9 +336,9 @@ protected function _backtrace() { $back = debug_backtrace(); return array( - 'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''), - 'line' => (isset($back[1]['line']) ? $back[1]['line'] : '') - ); + 'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''), + 'line' => (isset($back[1]['line']) ? $back[1]['line'] : '') + ); } // -------------------------------------------------------------------- diff --git a/bonfire/ci3/libraries/Upload.php b/bonfire/ci3/libraries/Upload.php index f5534a7f7..8a2dec76a 100644 --- a/bonfire/ci3/libraries/Upload.php +++ b/bonfire/ci3/libraries/Upload.php @@ -397,7 +397,7 @@ public function do_upload($field = 'userfile') if ( ! isset($_file)) { - $this->set_error('upload_no_file_selected'); + $this->set_error('upload_no_file_selected', 'debug'); return FALSE; } @@ -416,28 +416,28 @@ public function do_upload($field = 'userfile') switch ($error) { case UPLOAD_ERR_INI_SIZE: - $this->set_error('upload_file_exceeds_limit'); + $this->set_error('upload_file_exceeds_limit', 'info'); break; case UPLOAD_ERR_FORM_SIZE: - $this->set_error('upload_file_exceeds_form_limit'); + $this->set_error('upload_file_exceeds_form_limit', 'info'); break; case UPLOAD_ERR_PARTIAL: - $this->set_error('upload_file_partial'); + $this->set_error('upload_file_partial', 'debug'); break; case UPLOAD_ERR_NO_FILE: - $this->set_error('upload_no_file_selected'); + $this->set_error('upload_no_file_selected', 'debug'); break; case UPLOAD_ERR_NO_TMP_DIR: - $this->set_error('upload_no_temp_directory'); + $this->set_error('upload_no_temp_directory', 'error'); break; case UPLOAD_ERR_CANT_WRITE: - $this->set_error('upload_unable_to_write_file'); + $this->set_error('upload_unable_to_write_file', 'error'); break; case UPLOAD_ERR_EXTENSION: - $this->set_error('upload_stopped_by_extension'); + $this->set_error('upload_stopped_by_extension', 'debug'); break; default: - $this->set_error('upload_no_file_selected'); + $this->set_error('upload_no_file_selected', 'debug'); break; } @@ -463,7 +463,7 @@ public function do_upload($field = 'userfile') // Is the file type allowed to be uploaded? if ( ! $this->is_allowed_filetype()) { - $this->set_error('upload_invalid_filetype'); + $this->set_error('upload_invalid_filetype', 'debug'); return FALSE; } @@ -485,7 +485,7 @@ public function do_upload($field = 'userfile') if ( ! $this->is_allowed_filetype(TRUE)) { - $this->set_error('upload_invalid_filetype'); + $this->set_error('upload_invalid_filetype', 'debug'); return FALSE; } } @@ -499,7 +499,7 @@ public function do_upload($field = 'userfile') // Is the file size within the allowed maximum? if ( ! $this->is_allowed_filesize()) { - $this->set_error('upload_invalid_filesize'); + $this->set_error('upload_invalid_filesize', 'info'); return FALSE; } @@ -507,7 +507,7 @@ public function do_upload($field = 'userfile') // Note: This can fail if the server has an open_basedir restriction. if ( ! $this->is_allowed_dimensions()) { - $this->set_error('upload_invalid_dimensions'); + $this->set_error('upload_invalid_dimensions', 'info'); return FALSE; } @@ -533,15 +533,9 @@ public function do_upload($field = 'userfile') * If it returns false there was a problem. */ $this->orig_name = $this->file_name; - - if ($this->overwrite === FALSE) + if (FALSE === ($this->file_name = $this->set_filename($this->upload_path, $this->file_name))) { - $this->file_name = $this->set_filename($this->upload_path, $this->file_name); - - if ($this->file_name === FALSE) - { - return FALSE; - } + return FALSE; } /* @@ -552,7 +546,7 @@ public function do_upload($field = 'userfile') */ if ($this->xss_clean && $this->do_xss_clean() === FALSE) { - $this->set_error('upload_unable_to_write_file'); + $this->set_error('upload_unable_to_write_file', 'error'); return FALSE; } @@ -567,7 +561,7 @@ public function do_upload($field = 'userfile') { if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name)) { - $this->set_error('upload_destination_error'); + $this->set_error('upload_destination_error', 'error'); return FALSE; } } @@ -656,7 +650,7 @@ public function set_filename($path, $filename) $filename = md5(uniqid(mt_rand())).$this->file_ext; } - if ( ! file_exists($path.$filename)) + if ($this->overwrite === TRUE OR ! file_exists($path.$filename)) { return $filename; } @@ -675,7 +669,7 @@ public function set_filename($path, $filename) if ($new_filename === '') { - $this->set_error('upload_bad_filename'); + $this->set_error('upload_bad_filename', 'debug'); return FALSE; } else @@ -700,6 +694,22 @@ public function set_max_filesize($n) // -------------------------------------------------------------------- + /** + * Set Maximum File Size + * + * An internal alias to set_max_filesize() to help with configuration + * as initialize() will look for a set_() method ... + * + * @param int $n + * @return CI_Upload + */ + protected function set_max_size($n) + { + return $this->set_max_filesize($n); + } + + // -------------------------------------------------------------------- + /** * Set Maximum File Name Length * @@ -875,7 +885,7 @@ public function is_allowed_filetype($ignore_mime = FALSE) if (empty($this->allowed_types) OR ! is_array($this->allowed_types)) { - $this->set_error('upload_no_file_types'); + $this->set_error('upload_no_file_types', 'debug'); return FALSE; } @@ -974,7 +984,7 @@ public function validate_upload_path() { if ($this->upload_path === '') { - $this->set_error('upload_no_filepath'); + $this->set_error('upload_no_filepath', 'error'); return FALSE; } @@ -985,13 +995,13 @@ public function validate_upload_path() if ( ! is_dir($this->upload_path)) { - $this->set_error('upload_no_filepath'); + $this->set_error('upload_no_filepath', 'error'); return FALSE; } if ( ! is_really_writable($this->upload_path)) { - $this->set_error('upload_not_writable'); + $this->set_error('upload_not_writable', 'error'); return FALSE; } @@ -1013,7 +1023,7 @@ public function get_extension($filename) if (count($x) === 1) { - return ''; + return ''; } $ext = ($this->file_ext_tolower) ? strtolower(end($x)) : end($x); @@ -1121,17 +1131,16 @@ public function do_xss_clean() * @param string $msg * @return CI_Upload */ - public function set_error($msg) + public function set_error($msg, $log_level = 'error') { $this->_CI->lang->load('upload'); is_array($msg) OR $msg = array($msg); - foreach ($msg as $val) { $msg = ($this->_CI->lang->line($val) === FALSE) ? $val : $this->_CI->lang->line($val); $this->error_msg[] = $msg; - log_message('error', $msg); + log_message($log_level, $msg); } return $this; diff --git a/bonfire/ci3/libraries/Xmlrpc.php b/bonfire/ci3/libraries/Xmlrpc.php index 8fbc18f04..55555f56f 100644 --- a/bonfire/ci3/libraries/Xmlrpc.php +++ b/bonfire/ci3/libraries/Xmlrpc.php @@ -735,12 +735,32 @@ public function sendPayload($msg) .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; - for ($written = 0, $length = strlen($op); $written < $length; $written += $result) + for ($written = $timestamp = 0, $length = strlen($op); $written < $length; $written += $result) { if (($result = fwrite($fp, substr($op, $written))) === FALSE) { break; } + // See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951 + elseif ($result === 0) + { + if ($timestamp === 0) + { + $timestamp = time(); + } + elseif ($timestamp < (time() - $this->timeout)) + { + $result = FALSE; + break; + } + + usleep(250000); + continue; + } + else + { + $timestamp = 0; + } } if ($result === FALSE) diff --git a/bonfire/ci3/libraries/Zip.php b/bonfire/ci3/libraries/Zip.php index f2f17148b..3e98ac568 100644 --- a/bonfire/ci3/libraries/Zip.php +++ b/bonfire/ci3/libraries/Zip.php @@ -352,7 +352,7 @@ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) // Set the original directory root for child dir's to use as relative if ($root_path === NULL) { - $root_path = dirname($path).DIRECTORY_SEPARATOR; + $root_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, dirname($path)).DIRECTORY_SEPARATOR; } while (FALSE !== ($file = readdir($fp))) diff --git a/bonfire/core/BF_Loader.php b/bonfire/core/BF_Loader.php index 3cf432e6c..acb0633b5 100644 --- a/bonfire/core/BF_Loader.php +++ b/bonfire/core/BF_Loader.php @@ -53,11 +53,7 @@ public function helper($helper = array()) list($path, $_helper) = Modules::find("{$helper}_helper", $this->_module, 'helpers/'); if ($path === false) { - // If the helper was not found in a module, check for a BF_ prefixed - // helper in the Bonfire helpers directory. - if (file_exists(BFPATH . "helpers/BF_{$helper}_helper.php")) { - include_once(BFPATH . "helpers/BF_{$helper}_helper.php"); - } + // If the helper was not found in a module, check the traditional locations. parent::helper($helper); return $this; } diff --git a/bonfire/docs/_toc.ini b/bonfire/docs/_toc.ini index 6b89e2712..316583ae7 100644 --- a/bonfire/docs/_toc.ini +++ b/bonfire/docs/_toc.ini @@ -7,6 +7,7 @@ developer/tut_blog = Simple Blog Tutorial developer/changelog = Change Log [Upgrade Notes] +developer/upgrade/083 = 0.8.2 to 0.8.3 developer/upgrade/082 = 0.8.1 to 0.8.2 developer/upgrade/081 = 0.8.0 to 0.8.1 developer/upgrade/080 = 0.7.4 to 0.8.0 diff --git a/bonfire/docs/changelog.md b/bonfire/docs/changelog.md index bf2c05a6a..a90727003 100644 --- a/bonfire/docs/changelog.md +++ b/bonfire/docs/changelog.md @@ -2,6 +2,22 @@ ## Released versions +### 0.8.3 +* Upgraded CodeIgniter 3 to 3.0.1 +* Upgraded CodeIgniter 2 to 2.2.4 + +#### New Features: +* MY_*_helper files can now override BF_*_helper files + +#### Closes Issues: +* #1153: Error: "Undefined index: user_agent" caused by out-dated `MX_Loader`. +* #1154: [Builder] Cancel button contains "Content" instead of "content". + +#### Additional Changes: +* `user_meta` view in `users` module updated to make it less likely to have issues with PHP 7. + +#### Known Issues: + ### 0.8.2 #### New Features: diff --git a/bonfire/docs/ci2.md b/bonfire/docs/ci2.md index c75556364..1fff7369d 100644 --- a/bonfire/docs/ci2.md +++ b/bonfire/docs/ci2.md @@ -1,7 +1,7 @@ # CodeIgniter 2.x Support in Bonfire This document is intended to help you configure your Bonfire application to use CodeIgniter 2.x (CI2). -Since CI2 is scheduled to reach end of life in October, 2014, this functionality is intended as a vehicle for upgrading an existing application to support CodeIgniter 3.x (CI3). +Since CI2 is scheduled to reach end of life in October, 2015, this functionality is intended as a vehicle for upgrading an existing application to support CodeIgniter 3.x (CI3). While there is every reason to believe that CI2 will work fine with Bonfire 0.8.x, this is not intended for long-term production use. ## Installing CI2 @@ -11,7 +11,7 @@ If you run into any problems while using CI2 with Bonfire, please feel free to [ To install CI2, you will need to do the following: - Setup (or update) a Bonfire installation with the [latest code from GitHub](https://github.com/ci-bonfire/Bonfire). -- Download [the latest CI2 release](http://www.codeigniter.com/download) ([CI 2.2.3](https://github.com/bcit-ci/CodeIgniter/archive/2.2.3.zip) is the latest 2.x release at the time of this writing). +- Download [the latest CI2 release](http://www.codeigniter.com/download) ([CI 2.2.4](https://github.com/bcit-ci/CodeIgniter/archive/2.2.4.zip) is the latest 2.x release at the time of this writing). - Making sure to *not* overwrite the existing files in the `/bonfire/ci2/` directory of your working test site, copy the files from the CI2 system directory into the `/bonfire/ci2/` directory. (If you do happen to overwrite the files, you can pull them down from the Bonfire GitHub repository.) ## Switching CodeIgniter versions diff --git a/bonfire/docs/ci3.md b/bonfire/docs/ci3.md index a0eb63163..f2586a18d 100644 --- a/bonfire/docs/ci3.md +++ b/bonfire/docs/ci3.md @@ -10,7 +10,7 @@ If you run into any problems while testing CI3 with Bonfire, please feel free to If you would like to test it out for yourself, you will need to do the following: - Setup (or update) a Bonfire installation with the latest code from the [develop branch on GitHub](https://github.com/ci-bonfire/Bonfire). Make sure the site is configured and working under CodeIgniter 2.x. -- Download [the latest CI3 release](http://www.codeigniter.com/download) ([CI3.0](https://github.com/bcit-ci/CodeIgniter/archive/3.0rc3.zip) is the latest release at the time of this writing). The more adventurous can download the latest code from [their development branch on GitHub](https://github.com/bcit-ci/CodeIgniter). +- Download [the latest CI3 release](http://www.codeigniter.com/download) ([CI3.0.1](https://github.com/bcit-ci/CodeIgniter/archive/3.0.1.zip) is the latest release at the time of this writing). The more adventurous can download the latest code from [their development branch on GitHub](https://github.com/bcit-ci/CodeIgniter). - Making sure to *not* overwrite the existing files in the /bonfire/ci3/ directory of your working test site, copy the files from the CI3 system directory into the /bonfire/ci3/ directory. (If you do happen to overwrite the files, you can pull them down from the Bonfire GitHub repository.) ## Updating your application diff --git a/bonfire/docs/upgrade/083.md b/bonfire/docs/upgrade/083.md new file mode 100644 index 000000000..6a856166d --- /dev/null +++ b/bonfire/docs/upgrade/083.md @@ -0,0 +1,33 @@ +# Upgrading Bonfire + +## 0.8.2 to 0.8.3 + +* Update `/application/config/application.php` +* Update `/application/config/autoload.php` +* Update `/application/config/config.php` +* Update `/application/config/constants.php` +* Update `/application/config/database.php` +* Update `/application/config/events.php` +* Update `/application/config/foreign_chars.php` +* Update `/application/config/hooks.php` +* Update `/application/config/migration.php` +* Update `/application/config/mimes.php` +* Update `/application/config/smileys.php` +* Update `/application/config/user_agents.php` +* Where relevant, update any of the config files above in environment directories. + +* Update `/application/third_party/MX/Loader.php` + +* Update `/application/views/errors/cli/error_exception.php` +* Update `/application/views/errors/cli/error_php.php` + +* Update all files in `/bonfire/ci3/` + +* Update `/bonfire/ci2/core/CodeIgniter.php` +* Update `/bonfire/ci2/core/Loader.php` +* Update `/bonfire/ci2/database/DB_active_rec.php` + +* Update `/bonfire/core/BF_Loader.php` +* Update `/bonfire/modules/builder/views/files/view_default.php` +* Update `/bonfire/modules/builder/views/files/view_index.php` +* Update `/bonfire/modules/users/views/user_meta.php` diff --git a/bonfire/modules/builder/config/modulebuilder.php b/bonfire/modules/builder/config/modulebuilder.php index b1c8c9c94..0f85c0568 100755 --- a/bonfire/modules/builder/config/modulebuilder.php +++ b/bonfire/modules/builder/config/modulebuilder.php @@ -52,6 +52,7 @@ 'portuguese_br', 'spanish_am', 'italian', + 'german', ); // Values below are MySQL database types diff --git a/bonfire/modules/builder/libraries/Modulebuilder.php b/bonfire/modules/builder/libraries/Modulebuilder.php index 5731bbe41..436f5e145 100644 --- a/bonfire/modules/builder/libraries/Modulebuilder.php +++ b/bonfire/modules/builder/libraries/Modulebuilder.php @@ -102,6 +102,7 @@ class Modulebuilder 'portuguese_br', 'russian', 'spanish_am', + 'german', ); //-------------------------------------------------------------------------- diff --git a/bonfire/modules/builder/views/files/languages/german.php b/bonfire/modules/builder/views/files/languages/german.php new file mode 100644 index 000000000..b80dddbc6 --- /dev/null +++ b/bonfire/modules/builder/views/files/languages/german.php @@ -0,0 +1,75 @@ += $counter; $counter++) { + if (set_value("view_field_label$counter") == null) { + continue; // move onto next iteration of the loop + } + + $field_label = set_value("view_field_label$counter"); + $field_name = set_value("view_field_name$counter"); + + $lang .= '$lang[\'' . $module_name_lower . '_field_' . $field_name . '\'] = \'' . $field_label . '\'; +'; +} + +echo $lang; \ No newline at end of file diff --git a/bonfire/modules/builder/views/files/view_default.php b/bonfire/modules/builder/views/files/view_default.php index e4477308f..c7dc1b478 100644 --- a/bonfire/modules/builder/views/files/view_default.php +++ b/bonfire/modules/builder/views/files/view_default.php @@ -171,7 +171,7 @@
\" /> - + {$delete}
diff --git a/bonfire/modules/builder/views/files/view_index.php b/bonfire/modules/builder/views/files/view_index.php index e7166156e..518c30acf 100644 --- a/bonfire/modules/builder/views/files/view_index.php +++ b/bonfire/modules/builder/views/files/view_index.php @@ -50,7 +50,7 @@ else { $table_records .= " - {$primary_key_field}, {$pencil_icon} \$record->{$field_name}); ?> + {$primary_key_field}, {$pencil_icon} \$record->{$field_name}); ?> {$field_name}); ?> "; diff --git a/bonfire/modules/users/views/user_meta.php b/bonfire/modules/users/views/user_meta.php index 332a1ba07..961adda74 100644 --- a/bonfire/modules/users/views/user_meta.php +++ b/bonfire/modules/users/views/user_meta.php @@ -28,7 +28,7 @@ echo form_dropdown( $field['form_detail']['settings'], $field['form_detail']['options'], - set_value($field['name'], isset($user->$field['name']) ? $user->$field['name'] : ''), + set_value($field['name'], isset($user->{$field['name']}) ? $user->{$field['name']} : ''), $field['label'] ); elseif ($field['form_detail']['type'] == 'checkbox') : @@ -42,7 +42,7 @@ $field['form_detail']['value'], $field['form_detail']['value'] == set_value( $field['name'], - isset($user->$field['name']) ? $user->$field['name'] : '' + isset($user->{$field['name']}) ? $user->{$field['name']} : '' ) ); ?> @@ -53,7 +53,7 @@ && is_callable('state_select') ) : $stateFieldId = $field['name']; - $stateValue = isset($user->$field['name']) ? $user->$field['name'] : $defaultState; + $stateValue = isset($user->{$field['name']}) ? $user->{$field['name']} : $defaultState; ?>
@@ -74,14 +74,14 @@ && is_callable('country_select') ) : $countryFieldId = $field['name']; - $countryValue = isset($user->$field['name']) ? $user->$field['name'] : $defaultCountry; + $countryValue = isset($user->{$field['name']}) ? $user->{$field['name']} : $defaultCountry; ?>
$field['name']) ? $user->$field['name'] : $defaultCountry), + set_value($field['name'], isset($user->{$field['name']}) ? $user->{$field['name']} : $defaultCountry), $defaultCountry, $field['name'], 'span6 chzn-select' @@ -95,7 +95,7 @@ if (is_callable($form_method)) { echo $form_method( $field['form_detail']['settings'], - set_value($field['name'], isset($user->$field['name']) ? $user->$field['name'] : ''), + set_value($field['name'], isset($user->{$field['name']}) ? $user->{$field['name']} : ''), $field['label'] ); } diff --git a/composer.json b/composer.json index 5e6a9b547..89637d27a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ci-bonfire/bonfire", "description": "Kickstart your CodeIgniter-based web application development.", - "version": "0.8.2", + "version": "0.8.3", "type": "project", "homepage": "http://cibonfire.com", "license": "MIT",