This license is a legal agreement between you and the Kohana Software Foundation for the use of Kohana Framework (the "Software"). By obtaining the Software you agree to comply with the terms and conditions of this license.
-
-
Copyright (c) 2007-2008 Kohana Team All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the Kohana nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
NOTE: This license is modeled after the BSD software license.
-
-
-
\ No newline at end of file
diff --git a/kohana/config/cache.php b/kohana/config/cache.php
deleted file mode 100644
index ccd3da4d..00000000
--- a/kohana/config/cache.php
+++ /dev/null
@@ -1,32 +0,0 @@
- File cache is fast and reliable, but requires many filesystem lookups.
- * > Database cache can be used to cache items remotely, but is slower.
- * > Memcache is very high performance, but prevents cache tags from being used.
- *
- * params - Driver parameters, specific to each driver.
- *
- * lifetime - Default lifetime of caches in seconds. By default caches are stored for
- * thirty minutes. Specific lifetime can also be set when creating a new cache.
- * Setting this to 0 will never automatically delete caches.
- *
- * requests - Average number of cache requests that will processed before all expired
- * caches are deleted. This is commonly referred to as "garbage collection".
- * Setting this to 0 or a negative number will disable automatic garbage collection.
- */
-$config['default'] = array
-(
- 'driver' => 'file',
- 'params' => APPPATH.'cache',
- 'lifetime' => 1800,
- 'requests' => 1000
-);
diff --git a/kohana/config/cache_memcache.php b/kohana/config/cache_memcache.php
deleted file mode 100644
index 43d8f205..00000000
--- a/kohana/config/cache_memcache.php
+++ /dev/null
@@ -1,20 +0,0 @@
- '127.0.0.1',
- 'port' => 11211,
- 'persistent' => FALSE,
- )
-);
-
-/**
- * Enable cache data compression.
- */
-$config['compression'] = FALSE;
diff --git a/kohana/config/cache_sqlite.php b/kohana/config/cache_sqlite.php
deleted file mode 100644
index 818b8932..00000000
--- a/kohana/config/cache_sqlite.php
+++ /dev/null
@@ -1,10 +0,0 @@
- array
- (
- 'length' => '13,14,15,16,17,18,19',
- 'prefix' => '',
- 'luhn' => TRUE
- ),
- 'american express' => array
- (
- 'length' => '15',
- 'prefix' => '3[47]',
- 'luhn' => TRUE
- ),
- 'diners club' => array
- (
- 'length' => '14,16',
- 'prefix' => '36|55|30[0-5]',
- 'luhn' => TRUE
- ),
- 'discover' => array
- (
- 'length' => '16',
- 'prefix' => '6(?:5|011)',
- 'luhn' => TRUE,
- ),
- 'jcb' => array
- (
- 'length' => '15,16',
- 'prefix' => '3|1800|2131',
- 'luhn' => TRUE
- ),
- 'maestro' => array
- (
- 'length' => '16,18',
- 'prefix' => '50(?:20|38)|6(?:304|759)',
- 'luhn' => TRUE
- ),
- 'mastercard' => array
- (
- 'length' => '16',
- 'prefix' => '5[1-5]',
- 'luhn' => TRUE
- ),
- 'visa' => array
- (
- 'length' => '13,16',
- 'prefix' => '4',
- 'luhn' => TRUE
- ),
-);
\ No newline at end of file
diff --git a/kohana/config/database.php b/kohana/config/database.php
deleted file mode 100644
index 6519156a..00000000
--- a/kohana/config/database.php
+++ /dev/null
@@ -1,45 +0,0 @@
- 'mysql://dbuser:secret@localhost/kohana'
- * character_set - Database character set
- * table_prefix - Database table prefix
- * object - Enable or disable object results
- * cache - Enable or disable query caching
- * escape - Enable automatic query builder escaping
- */
-$config['default'] = array
-(
- 'benchmark' => TRUE,
- 'persistent' => FALSE,
- 'connection' => array
- (
- 'type' => 'mysql',
- 'user' => 'dbuser',
- 'pass' => 'p@ssw0rd',
- 'host' => 'localhost',
- 'port' => FALSE,
- 'socket' => FALSE,
- 'database' => 'kohana'
- ),
- 'character_set' => 'utf8',
- 'table_prefix' => '',
- 'object' => TRUE,
- 'cache' => FALSE,
- 'escape' => TRUE
-);
\ No newline at end of file
diff --git a/kohana/config/email.php b/kohana/config/email.php
deleted file mode 100644
index c768367c..00000000
--- a/kohana/config/email.php
+++ /dev/null
@@ -1,22 +0,0 @@
- 'K0H@NA+PHP_7hE-SW!FtFraM3w0R|<',
- 'mode' => MCRYPT_MODE_NOFB,
- 'cipher' => MCRYPT_RIJNDAEL_128
-);
diff --git a/kohana/config/http.php b/kohana/config/http.php
deleted file mode 100644
index 3c4a86ac..00000000
--- a/kohana/config/http.php
+++ /dev/null
@@ -1,19 +0,0 @@
- 'children',
- 'clothes' => 'clothing',
- 'man' => 'men',
- 'movie' => 'movies',
- 'person' => 'people',
- 'woman' => 'women',
- 'mouse' => 'mice',
- 'goose' => 'geese',
- 'ox' => 'oxen',
- 'leaf' => 'leaves',
- 'course' => 'courses',
- 'size' => 'sizes',
-);
diff --git a/kohana/config/locale.php b/kohana/config/locale.php
deleted file mode 100644
index 3a268820..00000000
--- a/kohana/config/locale.php
+++ /dev/null
@@ -1,16 +0,0 @@
- array('text/h323'),
- '7z' => array('application/x-7z-compressed'),
- 'abw' => array('application/x-abiword'),
- 'acx' => array('application/internet-property-stream'),
- 'ai' => array('application/postscript'),
- 'aif' => array('audio/x-aiff'),
- 'aifc' => array('audio/x-aiff'),
- 'aiff' => array('audio/x-aiff'),
- 'asf' => array('video/x-ms-asf'),
- 'asr' => array('video/x-ms-asf'),
- 'asx' => array('video/x-ms-asf'),
- 'atom' => array('application/atom+xml'),
- 'avi' => array('video/avi', 'video/msvideo', 'video/x-msvideo'),
- 'bin' => array('application/octet-stream','application/macbinary'),
- 'bmp' => array('image/bmp'),
- 'c' => array('text/x-csrc'),
- 'c++' => array('text/x-c++src'),
- 'cab' => array('application/x-cab'),
- 'cc' => array('text/x-c++src'),
- 'cda' => array('application/x-cdf'),
- 'class' => array('application/octet-stream'),
- 'cpp' => array('text/x-c++src'),
- 'cpt' => array('application/mac-compactpro'),
- 'csh' => array('text/x-csh'),
- 'css' => array('text/css'),
- 'csv' => array('text/x-comma-separated-values', 'application/vnd.ms-excel', 'text/comma-separated-values', 'text/csv'),
- 'dbk' => array('application/docbook+xml'),
- 'dcr' => array('application/x-director'),
- 'deb' => array('application/x-debian-package'),
- 'diff' => array('text/x-diff'),
- 'dir' => array('application/x-director'),
- 'divx' => array('video/divx'),
- 'dll' => array('application/octet-stream', 'application/x-msdos-program'),
- 'dmg' => array('application/x-apple-diskimage'),
- 'dms' => array('application/octet-stream'),
- 'doc' => array('application/msword'),
- 'dvi' => array('application/x-dvi'),
- 'dxr' => array('application/x-director'),
- 'eml' => array('message/rfc822'),
- 'eps' => array('application/postscript'),
- 'evy' => array('application/envoy'),
- 'exe' => array('application/x-msdos-program', 'application/octet-stream'),
- 'fla' => array('application/octet-stream'),
- 'flac' => array('application/x-flac'),
- 'flc' => array('video/flc'),
- 'fli' => array('video/fli'),
- 'flv' => array('video/x-flv'),
- 'gif' => array('image/gif'),
- 'gtar' => array('application/x-gtar'),
- 'gz' => array('application/x-gzip'),
- 'h' => array('text/x-chdr'),
- 'h++' => array('text/x-c++hdr'),
- 'hh' => array('text/x-c++hdr'),
- 'hpp' => array('text/x-c++hdr'),
- 'hqx' => array('application/mac-binhex40'),
- 'hs' => array('text/x-haskell'),
- 'htm' => array('text/html'),
- 'html' => array('text/html'),
- 'ico' => array('image/x-icon'),
- 'ics' => array('text/calendar'),
- 'iii' => array('application/x-iphone'),
- 'ins' => array('application/x-internet-signup'),
- 'iso' => array('application/x-iso9660-image'),
- 'isp' => array('application/x-internet-signup'),
- 'jar' => array('application/java-archive'),
- 'java' => array('application/x-java-applet'),
- 'jpe' => array('image/jpeg', 'image/pjpeg'),
- 'jpeg' => array('image/jpeg', 'image/pjpeg'),
- 'jpg' => array('image/jpeg', 'image/pjpeg'),
- 'js' => array('application/x-javascript'),
- 'json' => array('application/json'),
- 'latex' => array('application/x-latex'),
- 'lha' => array('application/octet-stream'),
- 'log' => array('text/plain', 'text/x-log'),
- 'lzh' => array('application/octet-stream'),
- 'm4a' => array('audio/mpeg'),
- 'm4p' => array('video/mp4v-es'),
- 'm4v' => array('video/mp4'),
- 'man' => array('application/x-troff-man'),
- 'mdb' => array('application/x-msaccess'),
- 'midi' => array('audio/midi'),
- 'mid' => array('audio/midi'),
- 'mif' => array('application/vnd.mif'),
- 'mka' => array('audio/x-matroska'),
- 'mkv' => array('video/x-matroska'),
- 'mov' => array('video/quicktime'),
- 'movie' => array('video/x-sgi-movie'),
- 'mp2' => array('audio/mpeg'),
- 'mp3' => array('audio/mpeg'),
- 'mp4' => array('application/mp4','audio/mp4','video/mp4'),
- 'mpa' => array('video/mpeg'),
- 'mpe' => array('video/mpeg'),
- 'mpeg' => array('video/mpeg'),
- 'mpg' => array('video/mpeg'),
- 'mpg4' => array('video/mp4'),
- 'mpga' => array('audio/mpeg'),
- 'mpp' => array('application/vnd.ms-project'),
- 'mpv' => array('video/x-matroska'),
- 'mpv2' => array('video/mpeg'),
- 'ms' => array('application/x-troff-ms'),
- 'msg' => array('application/msoutlook','application/x-msg'),
- 'msi' => array('application/x-msi'),
- 'nws' => array('message/rfc822'),
- 'oda' => array('application/oda'),
- 'odb' => array('application/vnd.oasis.opendocument.database'),
- 'odc' => array('application/vnd.oasis.opendocument.chart'),
- 'odf' => array('application/vnd.oasis.opendocument.forumla'),
- 'odg' => array('application/vnd.oasis.opendocument.graphics'),
- 'odi' => array('application/vnd.oasis.opendocument.image'),
- 'odm' => array('application/vnd.oasis.opendocument.text-master'),
- 'odp' => array('application/vnd.oasis.opendocument.presentation'),
- 'ods' => array('application/vnd.oasis.opendocument.spreadsheet'),
- 'odt' => array('application/vnd.oasis.opendocument.text'),
- 'oga' => array('audio/ogg'),
- 'ogg' => array('application/ogg'),
- 'ogv' => array('video/ogg'),
- 'otg' => array('application/vnd.oasis.opendocument.graphics-template'),
- 'oth' => array('application/vnd.oasis.opendocument.web'),
- 'otp' => array('application/vnd.oasis.opendocument.presentation-template'),
- 'ots' => array('application/vnd.oasis.opendocument.spreadsheet-template'),
- 'ott' => array('application/vnd.oasis.opendocument.template'),
- 'p' => array('text/x-pascal'),
- 'pas' => array('text/x-pascal'),
- 'patch' => array('text/x-diff'),
- 'pbm' => array('image/x-portable-bitmap'),
- 'pdf' => array('application/pdf', 'application/x-download'),
- 'php' => array('application/x-httpd-php'),
- 'php3' => array('application/x-httpd-php'),
- 'php4' => array('application/x-httpd-php'),
- 'php5' => array('application/x-httpd-php'),
- 'phps' => array('application/x-httpd-php-source'),
- 'phtml' => array('application/x-httpd-php'),
- 'pl' => array('text/x-perl'),
- 'pm' => array('text/x-perl'),
- 'png' => array('image/png', 'image/x-png'),
- 'po' => array('text/x-gettext-translation'),
- 'pot' => array('application/vnd.ms-powerpoint'),
- 'pps' => array('application/vnd.ms-powerpoint'),
- 'ppt' => array('application/powerpoint'),
- 'ps' => array('application/postscript'),
- 'psd' => array('application/x-photoshop', 'image/x-photoshop'),
- 'pub' => array('application/x-mspublisher'),
- 'py' => array('text/x-python'),
- 'qt' => array('video/quicktime'),
- 'ra' => array('audio/x-realaudio'),
- 'ram' => array('audio/x-realaudio', 'audio/x-pn-realaudio'),
- 'rar' => array('application/rar'),
- 'rgb' => array('image/x-rgb'),
- 'rm' => array('audio/x-pn-realaudio'),
- 'rpm' => array('audio/x-pn-realaudio-plugin', 'application/x-redhat-package-manager'),
- 'rss' => array('application/rss+xml'),
- 'rtf' => array('text/rtf'),
- 'rtx' => array('text/richtext'),
- 'rv' => array('video/vnd.rn-realvideo'),
- 'sea' => array('application/octet-stream'),
- 'sh' => array('text/x-sh'),
- 'shtml' => array('text/html'),
- 'sit' => array('application/x-stuffit'),
- 'smi' => array('application/smil'),
- 'smil' => array('application/smil'),
- 'so' => array('application/octet-stream'),
- 'src' => array('application/x-wais-source'),
- 'svg' => array('image/svg+xml'),
- 'swf' => array('application/x-shockwave-flash'),
- 't' => array('application/x-troff'),
- 'tar' => array('application/x-tar'),
- 'tcl' => array('text/x-tcl'),
- 'tex' => array('application/x-tex'),
- 'text' => array('text/plain'),
- 'texti' => array('application/x-texinfo'),
- 'textinfo' => array('application/x-texinfo'),
- 'tgz' => array('application/x-tar'),
- 'tif' => array('image/tiff'),
- 'tiff' => array('image/tiff'),
- 'torrent' => array('application/x-bittorrent'),
- 'tr' => array('application/x-troff'),
- 'tsv' => array('text/tab-separated-values'),
- 'txt' => array('text/plain'),
- 'wav' => array('audio/x-wav'),
- 'wax' => array('audio/x-ms-wax'),
- 'wbxml' => array('application/wbxml'),
- 'wm' => array('video/x-ms-wm'),
- 'wma' => array('audio/x-ms-wma'),
- 'wmd' => array('application/x-ms-wmd'),
- 'wmlc' => array('application/wmlc'),
- 'wmv' => array('video/x-ms-wmv', 'application/octet-stream'),
- 'wmx' => array('video/x-ms-wmx'),
- 'wmz' => array('application/x-ms-wmz'),
- 'word' => array('application/msword', 'application/octet-stream'),
- 'wp5' => array('application/wordperfect5.1'),
- 'wpd' => array('application/vnd.wordperfect'),
- 'wvx' => array('video/x-ms-wvx'),
- 'xbm' => array('image/x-xbitmap'),
- 'xcf' => array('image/xcf'),
- 'xhtml' => array('application/xhtml+xml'),
- 'xht' => array('application/xhtml+xml'),
- 'xl' => array('application/excel', 'application/vnd.ms-excel'),
- 'xla' => array('application/excel', 'application/vnd.ms-excel'),
- 'xlc' => array('application/excel', 'application/vnd.ms-excel'),
- 'xlm' => array('application/excel', 'application/vnd.ms-excel'),
- 'xls' => array('application/excel', 'application/vnd.ms-excel'),
- 'xlt' => array('application/excel', 'application/vnd.ms-excel'),
- 'xml' => array('text/xml'),
- 'xof' => array('x-world/x-vrml'),
- 'xpm' => array('image/x-xpixmap'),
- 'xsl' => array('text/xml'),
- 'xvid' => array('video/x-xvid'),
- 'xwd' => array('image/x-xwindowdump'),
- 'z' => array('application/x-compress'),
- 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed')
-);
diff --git a/kohana/config/pagination.php b/kohana/config/pagination.php
deleted file mode 100644
index 808fc315..00000000
--- a/kohana/config/pagination.php
+++ /dev/null
@@ -1,25 +0,0 @@
- 'pagination',
- 'style' => 'classic',
- 'uri_segment' => 3,
- 'query_string' => '',
- 'items_per_page' => 20,
- 'auto_hide' => FALSE,
-);
diff --git a/kohana/config/profiler.php b/kohana/config/profiler.php
deleted file mode 100644
index 98ab5a49..00000000
--- a/kohana/config/profiler.php
+++ /dev/null
@@ -1,8 +0,0 @@
- array('type' => 'int', 'max' => 127),
- 'smallint' => array('type' => 'int', 'max' => 32767),
- 'mediumint' => array('type' => 'int', 'max' => 8388607),
- 'int' => array('type' => 'int', 'max' => 2147483647),
- 'integer' => array('type' => 'int', 'max' => 2147483647),
- 'bigint' => array('type' => 'int', 'max' => 9223372036854775807),
- 'float' => array('type' => 'float'),
- 'float unsigned' => array('type' => 'float', 'min' => 0),
- 'boolean' => array('type' => 'boolean'),
- 'time' => array('type' => 'string', 'format' => '00:00:00'),
- 'time with time zone' => array('type' => 'string'),
- 'date' => array('type' => 'string', 'format' => '0000-00-00'),
- 'year' => array('type' => 'string', 'format' => '0000'),
- 'datetime' => array('type' => 'string', 'format' => '0000-00-00 00:00:00'),
- 'timestamp with time zone' => array('type' => 'string'),
- 'char' => array('type' => 'string', 'exact' => TRUE),
- 'binary' => array('type' => 'string', 'binary' => TRUE, 'exact' => TRUE),
- 'varchar' => array('type' => 'string'),
- 'varbinary' => array('type' => 'string', 'binary' => TRUE),
- 'blob' => array('type' => 'string', 'binary' => TRUE),
- 'text' => array('type' => 'string')
-);
-
-// DOUBLE
-$config['double'] = $config['double precision'] = $config['decimal'] = $config['real'] = $config['numeric'] = $config['float'];
-$config['double unsigned'] = $config['float unsigned'];
-
-// BIT
-$config['bit'] = $config['boolean'];
-
-// TIMESTAMP
-$config['timestamp'] = $config['timestamp without time zone'] = $config['datetime'];
-
-// ENUM
-$config['enum'] = $config['set'] = $config['varchar'];
-
-// TEXT
-$config['tinytext'] = $config['mediumtext'] = $config['longtext'] = $config['text'];
-
-// BLOB
-$config['tinyblob'] = $config['mediumblob'] = $config['longblob'] = $config['clob'] = $config['bytea'] = $config['blob'];
-
-// CHARACTER
-$config['character'] = $config['char'];
-$config['character varying'] = $config['varchar'];
-
-// TIME
-$config['time without time zone'] = $config['time'];
diff --git a/kohana/config/upload.php b/kohana/config/upload.php
deleted file mode 100644
index df26a2d2..00000000
--- a/kohana/config/upload.php
+++ /dev/null
@@ -1,17 +0,0 @@
- 'Windows Vista',
- 'windows nt 5.2' => 'Windows 2003',
- 'windows nt 5.0' => 'Windows 2000',
- 'windows nt 5.1' => 'Windows XP',
- 'windows nt 4.0' => 'Windows NT',
- 'winnt4.0' => 'Windows NT',
- 'winnt 4.0' => 'Windows NT',
- 'winnt' => 'Windows NT',
- 'windows 98' => 'Windows 98',
- 'win98' => 'Windows 98',
- 'windows 95' => 'Windows 95',
- 'win95' => 'Windows 95',
- 'windows' => 'Unknown Windows OS',
- 'os x' => 'Mac OS X',
- 'intel mac' => 'Intel Mac',
- 'ppc mac' => 'PowerPC Mac',
- 'powerpc' => 'PowerPC',
- 'ppc' => 'PowerPC',
- 'cygwin' => 'Cygwin',
- 'linux' => 'Linux',
- 'debian' => 'Debian',
- 'openvms' => 'OpenVMS',
- 'sunos' => 'Sun Solaris',
- 'amiga' => 'Amiga',
- 'beos' => 'BeOS',
- 'apachebench' => 'ApacheBench',
- 'freebsd' => 'FreeBSD',
- 'netbsd' => 'NetBSD',
- 'bsdi' => 'BSDi',
- 'openbsd' => 'OpenBSD',
- 'os/2' => 'OS/2',
- 'warp' => 'OS/2',
- 'aix' => 'AIX',
- 'irix' => 'Irix',
- 'osf' => 'DEC OSF',
- 'hp-ux' => 'HP-UX',
- 'hurd' => 'GNU/Hurd',
- 'unix' => 'Unknown Unix OS',
-);
-
-// The order of this array should NOT be changed. Many browsers return
-// multiple browser types so we want to identify the sub-type first.
-$config['browser'] = array
-(
- 'Opera' => 'Opera',
- 'MSIE' => 'Internet Explorer',
- 'Internet Explorer' => 'Internet Explorer',
- 'Shiira' => 'Shiira',
- 'Firefox' => 'Firefox',
- 'Chimera' => 'Chimera',
- 'Phoenix' => 'Phoenix',
- 'Firebird' => 'Firebird',
- 'Camino' => 'Camino',
- 'Netscape' => 'Netscape',
- 'OmniWeb' => 'OmniWeb',
- 'Chrome' => 'Chrome',
- 'Safari' => 'Safari',
- 'Konqueror' => 'Konqueror',
- 'Epiphany' => 'Epiphany',
- 'Galeon' => 'Galeon',
- 'Mozilla' => 'Mozilla',
- 'icab' => 'iCab',
- 'lynx' => 'Lynx',
- 'links' => 'Links',
- 'hotjava' => 'HotJava',
- 'amaya' => 'Amaya',
- 'IBrowse' => 'IBrowse',
-);
-
-$config['mobile'] = array
-(
- 'mobileexplorer' => 'Mobile Explorer',
- 'openwave' => 'Open Wave',
- 'opera mini' => 'Opera Mini',
- 'operamini' => 'Opera Mini',
- 'elaine' => 'Palm',
- 'palmsource' => 'Palm',
- 'digital paths' => 'Palm',
- 'avantgo' => 'Avantgo',
- 'xiino' => 'Xiino',
- 'palmscape' => 'Palmscape',
- 'nokia' => 'Nokia',
- 'ericsson' => 'Ericsson',
- 'blackBerry' => 'BlackBerry',
- 'motorola' => 'Motorola',
- 'iphone' => 'iPhone',
- 'android' => 'Android',
-);
-
-// There are hundreds of bots but these are the most common.
-$config['robot'] = array
-(
- 'googlebot' => 'Googlebot',
- 'msnbot' => 'MSNBot',
- 'slurp' => 'Inktomi Slurp',
- 'yahoo' => 'Yahoo',
- 'askjeeves' => 'AskJeeves',
- 'fastcrawler' => 'FastCrawler',
- 'infoseek' => 'InfoSeek Robot 1.0',
- 'lycos' => 'Lycos',
-);
\ No newline at end of file
diff --git a/kohana/config/view.php b/kohana/config/view.php
deleted file mode 100644
index 6bed22e0..00000000
--- a/kohana/config/view.php
+++ /dev/null
@@ -1,17 +0,0 @@
-template = new View($this->template);
-
- if ($this->auto_render == TRUE)
- {
- // Render the template immediately after the controller method
- Event::add('system.post_controller', array($this, '_render'));
- }
- }
-
- /**
- * Render the loaded template.
- */
- public function _render()
- {
- if ($this->auto_render == TRUE)
- {
- // Render the template when the class is destroyed
- $this->template->render(TRUE);
- }
- }
-
-} // End Template_Controller
\ No newline at end of file
diff --git a/kohana/core/Benchmark.php b/kohana/core/Benchmark.php
deleted file mode 100644
index ce230f11..00000000
--- a/kohana/core/Benchmark.php
+++ /dev/null
@@ -1,125 +0,0 @@
- microtime(TRUE),
- 'stop' => FALSE,
- 'memory_start' => self::memory_usage(),
- 'memory_stop' => FALSE
- );
-
- array_unshift(self::$marks[$name], $mark);
- }
-
- /**
- * Set a benchmark stop point.
- *
- * @param string benchmark name
- * @return void
- */
- public static function stop($name)
- {
- if (isset(self::$marks[$name]) AND self::$marks[$name][0]['stop'] === FALSE)
- {
- self::$marks[$name][0]['stop'] = microtime(TRUE);
- self::$marks[$name][0]['memory_stop'] = self::memory_usage();
- }
- }
-
- /**
- * Get the elapsed time between a start and stop.
- *
- * @param string benchmark name, TRUE for all
- * @param integer number of decimal places to count to
- * @return array
- */
- public static function get($name, $decimals = 4)
- {
- if ($name === TRUE)
- {
- $times = array();
- $names = array_keys(self::$marks);
-
- foreach ($names as $name)
- {
- // Get each mark recursively
- $times[$name] = self::get($name, $decimals);
- }
-
- // Return the array
- return $times;
- }
-
- if ( ! isset(self::$marks[$name]))
- return FALSE;
-
- if (self::$marks[$name][0]['stop'] === FALSE)
- {
- // Stop the benchmark to prevent mis-matched results
- self::stop($name);
- }
-
- // Return a string version of the time between the start and stop points
- // Properly reading a float requires using number_format or sprintf
- $time = $memory = 0;
- for ($i = 0; $i < count(self::$marks[$name]); $i++)
- {
- $time += self::$marks[$name][$i]['stop'] - self::$marks[$name][$i]['start'];
- $memory += self::$marks[$name][$i]['memory_stop'] - self::$marks[$name][$i]['memory_start'];
- }
-
- return array
- (
- 'time' => number_format($time, $decimals),
- 'memory' => $memory,
- 'count' => count(self::$marks[$name])
- );
- }
-
- /**
- * Returns the current memory usage. This is only possible if the
- * memory_get_usage function is supported in PHP.
- *
- * @return integer
- */
- private static function memory_usage()
- {
- static $func;
-
- if ($func === NULL)
- {
- // Test if memory usage can be seen
- $func = function_exists('memory_get_usage');
- }
-
- return $func ? memory_get_usage() : 0;
- }
-
-} // End Benchmark
diff --git a/kohana/core/Bootstrap.php b/kohana/core/Bootstrap.php
deleted file mode 100644
index edfb086d..00000000
--- a/kohana/core/Bootstrap.php
+++ /dev/null
@@ -1,58 +0,0 @@
- $event_callback)
- {
- if ($callback === $event_callback)
- {
- unset(self::$events[$name][$i]);
- }
- }
- }
- }
-
- /**
- * Execute all of the callbacks attached to an event.
- *
- * @param string event name
- * @param array data can be processed as Event::$data by the callbacks
- * @return void
- */
- public static function run($name, & $data = NULL)
- {
- if ( ! empty(self::$events[$name]))
- {
- // So callbacks can access Event::$data
- self::$data =& $data;
- $callbacks = self::get($name);
-
- foreach ($callbacks as $callback)
- {
- call_user_func($callback);
- }
-
- // Do this to prevent data from getting 'stuck'
- $clear_data = '';
- self::$data =& $clear_data;
- }
-
- // The event has been run!
- self::$has_run[$name] = $name;
- }
-
- /**
- * Check if a given event has been run.
- *
- * @param string event name
- * @return boolean
- */
- public static function has_run($name)
- {
- return isset(self::$has_run[$name]);
- }
-
-} // End Event
\ No newline at end of file
diff --git a/kohana/core/Kohana.php b/kohana/core/Kohana.php
deleted file mode 100644
index ac64b5b8..00000000
--- a/kohana/core/Kohana.php
+++ /dev/null
@@ -1,1744 +0,0 @@
- 1,
- 'alert' => 2,
- 'info' => 3,
- 'debug' => 4,
- );
-
- // Internal caches and write status
- private static $internal_cache = array();
- private static $write_cache;
- private static $internal_cache_path;
-
- /**
- * Sets up the PHP environment. Adds error/exception handling, output
- * buffering, and adds an auto-loading method for loading classes.
- *
- * This method is run immediately when this file is loaded, and is
- * benchmarked as environment_setup.
- *
- * For security, this function also destroys the $_REQUEST global variable.
- * Using the proper global (GET, POST, COOKIE, etc) is inherently more secure.
- * The recommended way to fetch a global variable is using the Input library.
- * @see http://www.php.net/globals
- *
- * @return void
- */
- public static function setup()
- {
- static $run;
-
- // This function can only be run once
- if ($run === TRUE)
- return;
-
- // Start the environment setup benchmark
- Benchmark::start(SYSTEM_BENCHMARK.'_environment_setup');
-
- // Define Kohana error constant
- define('E_KOHANA', 42);
-
- // Define 404 error constant
- define('E_PAGE_NOT_FOUND', 43);
-
- // Define database error constant
- define('E_DATABASE_ERROR', 44);
-
- if (self::$cache_lifetime = self::config('core.internal_cache'))
- {
- // Set the directory to be used for the internal cache
- if ( ! self::$internal_cache_path = self::config('core.internal_cache_path'))
- {
- self::$internal_cache_path = APPPATH.'cache/';
- }
-
- // Load cached configuration and language files
- self::$internal_cache['configuration'] = self::cache('configuration', self::$cache_lifetime);
- self::$internal_cache['language'] = self::cache('language', self::$cache_lifetime);
-
- // Load cached file paths
- self::$internal_cache['find_file_paths'] = self::cache('find_file_paths', self::$cache_lifetime);
-
- // Enable cache saving
- Event::add('system.shutdown', array(__CLASS__, 'internal_cache_save'));
- }
-
- // Disable notices and "strict" errors
- $ER = error_reporting(~E_NOTICE & ~E_STRICT);
-
- // Set the user agent
- self::$user_agent = ( ! empty($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : '');
-
- if (function_exists('date_default_timezone_set'))
- {
- $timezone = self::config('locale.timezone');
-
- // Set default timezone, due to increased validation of date settings
- // which cause massive amounts of E_NOTICEs to be generated in PHP 5.2+
- date_default_timezone_set(empty($timezone) ? date_default_timezone_get() : $timezone);
- }
-
- // Restore error reporting
- error_reporting($ER);
-
- // Start output buffering
- ob_start(array(__CLASS__, 'output_buffer'));
-
- // Save buffering level
- self::$buffer_level = ob_get_level();
-
- // Set autoloader
- spl_autoload_register(array('Kohana', 'auto_load'));
-
- // Set error handler
- set_error_handler(array('Kohana', 'exception_handler'));
-
- // Set exception handler
- set_exception_handler(array('Kohana', 'exception_handler'));
-
- // Send default text/html UTF-8 header
- header('Content-Type: text/html; charset=UTF-8');
-
- // Load locales
- $locales = self::config('locale.language');
-
- // Make first locale UTF-8
- $locales[0] .= '.UTF-8';
-
- // Set locale information
- self::$locale = setlocale(LC_ALL, $locales);
-
- if (self::$configuration['core']['log_threshold'] > 0)
- {
- // Set the log directory
- self::log_directory(self::$configuration['core']['log_directory']);
-
- // Enable log writing at shutdown
- register_shutdown_function(array(__CLASS__, 'log_save'));
- }
-
- // Enable Kohana routing
- Event::add('system.routing', array('Router', 'find_uri'));
- Event::add('system.routing', array('Router', 'setup'));
-
- // Enable Kohana controller initialization
- Event::add('system.execute', array('Kohana', 'instance'));
-
- // Enable Kohana 404 pages
- Event::add('system.404', array('Kohana', 'show_404'));
-
- // Enable Kohana output handling
- Event::add('system.shutdown', array('Kohana', 'shutdown'));
-
- if (self::config('core.enable_hooks') === TRUE)
- {
- // Find all the hook files
- $hooks = self::list_files('hooks', TRUE);
-
- foreach ($hooks as $file)
- {
- // Load the hook
- include $file;
- }
- }
-
- // Setup is complete, prevent it from being run again
- $run = TRUE;
-
- // Stop the environment setup routine
- Benchmark::stop(SYSTEM_BENCHMARK.'_environment_setup');
- }
-
- /**
- * Loads the controller and initializes it. Runs the pre_controller,
- * post_controller_constructor, and post_controller events. Triggers
- * a system.404 event when the route cannot be mapped to a controller.
- *
- * This method is benchmarked as controller_setup and controller_execution.
- *
- * @return object instance of controller
- */
- public static function & instance()
- {
- if (self::$instance === NULL)
- {
- Benchmark::start(SYSTEM_BENCHMARK.'_controller_setup');
-
- // Include the Controller file
- require Router::$controller_path;
-
- try
- {
- // Start validation of the controller
- $class = new ReflectionClass(ucfirst(Router::$controller).'_Controller');
- }
- catch (ReflectionException $e)
- {
- // Controller does not exist
- Event::run('system.404');
- }
-
- if ($class->isAbstract() OR (IN_PRODUCTION AND $class->getConstant('ALLOW_PRODUCTION') == FALSE))
- {
- // Controller is not allowed to run in production
- Event::run('system.404');
- }
-
- // Run system.pre_controller
- Event::run('system.pre_controller');
-
- // Create a new controller instance
- $controller = $class->newInstance();
-
- // Controller constructor has been executed
- Event::run('system.post_controller_constructor');
-
- try
- {
- // Load the controller method
- $method = $class->getMethod(Router::$method);
-
- // Method exists
- if (Router::$method[0] === '_')
- {
- // Do not allow access to hidden methods
- Event::run('system.404');
- }
-
- if ($method->isProtected() or $method->isPrivate())
- {
- // Do not attempt to invoke protected methods
- throw new ReflectionException('protected controller method');
- }
-
- // Default arguments
- $arguments = Router::$arguments;
- }
- catch (ReflectionException $e)
- {
- // Use __call instead
- $method = $class->getMethod('__call');
-
- // Use arguments in __call format
- $arguments = array(Router::$method, Router::$arguments);
- }
-
- // Stop the controller setup benchmark
- Benchmark::stop(SYSTEM_BENCHMARK.'_controller_setup');
-
- // Start the controller execution benchmark
- Benchmark::start(SYSTEM_BENCHMARK.'_controller_execution');
-
- // Execute the controller method
- $method->invokeArgs($controller, $arguments);
-
- // Controller method has been executed
- Event::run('system.post_controller');
-
- // Stop the controller execution benchmark
- Benchmark::stop(SYSTEM_BENCHMARK.'_controller_execution');
- }
-
- return self::$instance;
- }
-
- /**
- * Get all include paths. APPPATH is the first path, followed by module
- * paths in the order they are configured, follow by the SYSPATH.
- *
- * @param boolean re-process the include paths
- * @return array
- */
- public static function include_paths($process = FALSE)
- {
- if ($process === TRUE)
- {
- self::$include_paths = array();
-
- foreach (self::$configuration['core']['modules'] as $path)
- {
- if ($path = str_replace('\\', '/', realpath($path)))
- {
- // Add a valid path
- self::$include_paths[] = $path.'/';
- }
- }
-
- // Add APPPATH after all modules
- self::$include_paths[] = APPPATH;
-
- // Add SYSPATH as the last path
- self::$include_paths[] = SYSPATH;
- }
-
- return self::$include_paths;
- }
-
- /**
- * Get a config item or group.
- *
- * @param string item name
- * @param boolean force a forward slash (/) at the end of the item
- * @param boolean is the item required?
- * @return mixed
- */
- public static function config($key, $slash = FALSE, $required = TRUE)
- {
- if (self::$configuration === NULL)
- {
- // Load core configuration
- self::$configuration['core'] = self::config_load('core');
-
- // Re-parse the include paths
- self::include_paths(TRUE);
- }
-
- // Get the group name from the key
- $group = explode('.', $key, 2);
- $group = $group[0];
-
- if ( ! isset(self::$configuration[$group]))
- {
- // Load the configuration group
- self::$configuration[$group] = self::config_load($group, $required);
- }
-
- // Get the value of the key string
- $value = self::key_string(self::$configuration, $key);
-
- if ($slash === TRUE AND is_string($value) AND $value !== '')
- {
- // Force the value to end with "/"
- $value = rtrim($value, '/').'/';
- }
-
- return $value;
- }
-
- /**
- * Sets a configuration item, if allowed.
- *
- * @param string config key string
- * @param string config value
- * @return boolean
- */
- public static function config_set($key, $value)
- {
- // Do this to make sure that the config array is already loaded
- self::config($key);
-
- if (substr($key, 0, 7) === 'routes.')
- {
- // Routes cannot contain sub keys due to possible dots in regex
- $keys = explode('.', $key, 2);
- }
- else
- {
- // Convert dot-noted key string to an array
- $keys = explode('.', $key);
- }
-
- // Used for recursion
- $conf =& self::$configuration;
- $last = count($keys) - 1;
-
- foreach ($keys as $i => $k)
- {
- if ($i === $last)
- {
- $conf[$k] = $value;
- }
- else
- {
- $conf =& $conf[$k];
- }
- }
-
- if ($key === 'core.modules')
- {
- // Reprocess the include paths
- self::include_paths(TRUE);
- }
-
- return TRUE;
- }
-
- /**
- * Load a config file.
- *
- * @param string config filename, without extension
- * @param boolean is the file required?
- * @return array
- */
- public static function config_load($name, $required = TRUE)
- {
- if ($name === 'core')
- {
- // Load the application configuration file
- require APPPATH.'config/config'.EXT;
-
- if ( ! isset($config['site_domain']))
- {
- // Invalid config file
- die('Your Kohana application configuration file is not valid.');
- }
-
- return $config;
- }
-
- if (isset(self::$internal_cache['configuration'][$name]))
- return self::$internal_cache['configuration'][$name];
-
- // Load matching configs
- $configuration = array();
-
- if ($files = self::find_file('config', $name, $required))
- {
- foreach ($files as $file)
- {
- require $file;
-
- if (isset($config) AND is_array($config))
- {
- // Merge in configuration
- $configuration = array_merge($configuration, $config);
- }
- }
- }
-
- if ( ! isset(self::$write_cache['configuration']))
- {
- // Cache has changed
- self::$write_cache['configuration'] = TRUE;
- }
-
- return self::$internal_cache['configuration'][$name] = $configuration;
- }
-
- /**
- * Clears a config group from the cached configuration.
- *
- * @param string config group
- * @return void
- */
- public static function config_clear($group)
- {
- // Remove the group from config
- unset(self::$configuration[$group], self::$internal_cache['configuration'][$group]);
-
- if ( ! isset(self::$write_cache['configuration']))
- {
- // Cache has changed
- self::$write_cache['configuration'] = TRUE;
- }
- }
-
- /**
- * Add a new message to the log.
- *
- * @param string type of message
- * @param string message text
- * @return void
- */
- public static function log($type, $message)
- {
- if (self::$log_levels[$type] <= self::$configuration['core']['log_threshold'])
- {
- $message = array(date('Y-m-d H:i:s P'), $type, $message);
-
- // Run the system.log event
- Event::run('system.log', $message);
-
- self::$log[] = $message;
- }
- }
-
- /**
- * Save all currently logged messages.
- *
- * @return void
- */
- public static function log_save()
- {
- if (empty(self::$log) OR self::$configuration['core']['log_threshold'] < 1)
- return;
-
- // Filename of the log
- $filename = self::log_directory().date('Y-m-d').'.log'.EXT;
-
- if ( ! is_file($filename))
- {
- // Write the SYSPATH checking header
- file_put_contents($filename,
- ''.PHP_EOL.PHP_EOL);
-
- // Prevent external writes
- chmod($filename, 0644);
- }
-
- // Messages to write
- $messages = array();
-
- do
- {
- // Load the next mess
- list ($date, $type, $text) = array_shift(self::$log);
-
- // Add a new message line
- $messages[] = $date.' --- '.$type.': '.$text;
- }
- while ( ! empty(self::$log));
-
- // Write messages to log file
- file_put_contents($filename, implode(PHP_EOL, $messages).PHP_EOL, FILE_APPEND);
- }
-
- /**
- * Get or set the logging directory.
- *
- * @param string new log directory
- * @return string
- */
- public static function log_directory($dir = NULL)
- {
- static $directory;
-
- if ( ! empty($dir))
- {
- // Get the directory path
- $dir = realpath($dir);
-
- if (is_dir($dir) AND is_writable($dir))
- {
- // Change the log directory
- $directory = str_replace('\\', '/', $dir).'/';
- }
- else
- {
- // Log directory is invalid
- throw new Kohana_Exception('core.log_dir_unwritable', $dir);
- }
- }
-
- return $directory;
- }
-
- /**
- * Load data from a simple cache file. This should only be used internally,
- * and is NOT a replacement for the Cache library.
- *
- * @param string unique name of cache
- * @param integer expiration in seconds
- * @return mixed
- */
- public static function cache($name, $lifetime)
- {
- if ($lifetime > 0)
- {
- $path = self::$internal_cache_path.'kohana_'.$name;
-
- if (is_file($path))
- {
- // Check the file modification time
- if ((time() - filemtime($path)) < $lifetime)
- {
- // Cache is valid
- return unserialize(file_get_contents($path));
- }
- else
- {
- // Cache is invalid, delete it
- unlink($path);
- }
- }
- }
-
- // No cache found
- return NULL;
- }
-
- /**
- * Save data to a simple cache file. This should only be used internally, and
- * is NOT a replacement for the Cache library.
- *
- * @param string cache name
- * @param mixed data to cache
- * @param integer expiration in seconds
- * @return boolean
- */
- public static function cache_save($name, $data, $lifetime)
- {
- if ($lifetime < 1)
- return FALSE;
-
- $path = self::$internal_cache_path.'kohana_'.$name;
-
- if ($data === NULL)
- {
- // Delete cache
- return (is_file($path) and unlink($path));
- }
- else
- {
- // Write data to cache file
- return (bool) file_put_contents($path, serialize($data));
- }
- }
-
- /**
- * Kohana output handler.
- *
- * @param string current output buffer
- * @return string
- */
- public static function output_buffer($output)
- {
- if ( ! Event::has_run('system.send_headers'))
- {
- // Run the send_headers event, specifically for cookies being set
- Event::run('system.send_headers');
- }
-
- // Set final output
- self::$output = $output;
-
- // Set and return the final output
- return $output;
- }
-
- /**
- * Closes all open output buffers, either by flushing or cleaning all
- * open buffers, including the Kohana output buffer.
- *
- * @param boolean disable to clear buffers, rather than flushing
- * @return void
- */
- public static function close_buffers($flush = TRUE)
- {
- if (ob_get_level() >= self::$buffer_level)
- {
- // Set the close function
- $close = ($flush === TRUE) ? 'ob_end_flush' : 'ob_end_clean';
-
- while (ob_get_level() > self::$buffer_level)
- {
- // Flush or clean the buffer
- $close();
- }
-
- // This will flush the Kohana buffer, which sets self::$output
- ob_end_clean();
-
- // Reset the buffer level
- self::$buffer_level = ob_get_level();
- }
- }
-
- /**
- * Triggers the shutdown of Kohana by closing the output buffer, runs the system.display event.
- *
- * @return void
- */
- public static function shutdown()
- {
- // Close output buffers
- self::close_buffers(TRUE);
-
- // Run the output event
- Event::run('system.display', self::$output);
-
- // Render the final output
- self::render(self::$output);
- }
-
- /**
- * Inserts global Kohana variables into the generated output and prints it.
- *
- * @param string final output that will displayed
- * @return void
- */
- public static function render($output)
- {
- if (self::config('core.render_stats') === TRUE)
- {
- // Fetch memory usage in MB
- $memory = function_exists('memory_get_usage') ? (memory_get_usage() / 1024 / 1024) : 0;
-
- // Fetch benchmark for page execution time
- $benchmark = Benchmark::get(SYSTEM_BENCHMARK.'_total_execution');
-
- // Replace the global template variables
- $output = str_replace(
- array
- (
- '{kohana_version}',
- '{kohana_codename}',
- '{execution_time}',
- '{memory_usage}',
- '{included_files}',
- ),
- array
- (
- KOHANA_VERSION,
- KOHANA_CODENAME,
- $benchmark['time'],
- number_format($memory, 2).'MB',
- count(get_included_files()),
- ),
- $output
- );
- }
-
- if ($level = self::config('core.output_compression') AND ini_get('output_handler') !== 'ob_gzhandler' AND (int) ini_get('zlib.output_compression') === 0)
- {
- if ($level < 1 OR $level > 9)
- {
- // Normalize the level to be an integer between 1 and 9. This
- // step must be done to prevent gzencode from triggering an error
- $level = max(1, min($level, 9));
- }
-
- if (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
- {
- $compress = 'gzip';
- }
- elseif (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== FALSE)
- {
- $compress = 'deflate';
- }
- }
-
- if (isset($compress) AND $level > 0)
- {
- switch ($compress)
- {
- case 'gzip':
- // Compress output using gzip
- $output = gzencode($output, $level);
- break;
- case 'deflate':
- // Compress output using zlib (HTTP deflate)
- $output = gzdeflate($output, $level);
- break;
- }
-
- // This header must be sent with compressed content to prevent
- // browser caches from breaking
- header('Vary: Accept-Encoding');
-
- // Send the content encoding header
- header('Content-Encoding: '.$compress);
-
- // Sending Content-Length in CGI can result in unexpected behavior
- if (stripos(PHP_SAPI, 'cgi') === FALSE)
- {
- header('Content-Length: '.strlen($output));
- }
- }
-
- echo $output;
- }
-
- /**
- * Displays a 404 page.
- *
- * @throws Kohana_404_Exception
- * @param string URI of page
- * @param string custom template
- * @return void
- */
- public static function show_404($page = FALSE, $template = FALSE)
- {
- throw new Kohana_404_Exception($page, $template);
- }
-
- /**
- * Dual-purpose PHP error and exception handler. Uses the kohana_error_page
- * view to display the message.
- *
- * @param integer|object exception object or error code
- * @param string error message
- * @param string filename
- * @param integer line number
- * @return void
- */
- public static function exception_handler($exception, $message = NULL, $file = NULL, $line = NULL)
- {
- try
- {
- // PHP errors have 5 args, always
- $PHP_ERROR = (func_num_args() === 5);
-
- // Test to see if errors should be displayed
- if ($PHP_ERROR AND (error_reporting() & $exception) === 0)
- return;
-
- // This is useful for hooks to determine if a page has an error
- self::$has_error = TRUE;
-
- // Error handling will use exactly 5 args, every time
- if ($PHP_ERROR)
- {
- $code = $exception;
- $type = 'PHP Error';
- $template = 'kohana_error_page';
- }
- else
- {
- $code = $exception->getCode();
- $type = get_class($exception);
- $message = $exception->getMessage();
- $file = $exception->getFile();
- $line = $exception->getLine();
- $template = ($exception instanceof Kohana_Exception) ? $exception->getTemplate() : 'kohana_error_page';
- }
-
- if (is_numeric($code))
- {
- $codes = self::lang('errors');
-
- if ( ! empty($codes[$code]))
- {
- list($level, $error, $description) = $codes[$code];
- }
- else
- {
- $level = 1;
- $error = $PHP_ERROR ? 'Unknown Error' : get_class($exception);
- $description = '';
- }
- }
- else
- {
- // Custom error message, this will never be logged
- $level = 5;
- $error = $code;
- $description = '';
- }
-
- // Remove the DOCROOT from the path, as a security precaution
- $file = str_replace('\\', '/', realpath($file));
- $file = preg_replace('|^'.preg_quote(DOCROOT).'|', '', $file);
-
- if ($level <= self::$configuration['core']['log_threshold'])
- {
- // Log the error
- self::log('error', self::lang('core.uncaught_exception', $type, $message, $file, $line));
- }
-
- if ($PHP_ERROR)
- {
- $description = self::lang('errors.'.E_RECOVERABLE_ERROR);
- $description = is_array($description) ? $description[2] : '';
-
- if ( ! headers_sent())
- {
- // Send the 500 header
- header('HTTP/1.1 500 Internal Server Error');
- }
- }
- else
- {
- if (method_exists($exception, 'sendHeaders') AND ! headers_sent())
- {
- // Send the headers if they have not already been sent
- $exception->sendHeaders();
- }
- }
-
- while (ob_get_level() > self::$buffer_level)
- {
- // Close open buffers
- ob_end_clean();
- }
-
- // Test if display_errors is on
- if (self::$configuration['core']['display_errors'] === TRUE)
- {
- if ( ! IN_PRODUCTION AND $line != FALSE)
- {
- // Remove the first entry of debug_backtrace(), it is the exception_handler call
- $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTrace();
-
- // Beautify backtrace
- $trace = self::backtrace($trace);
- }
-
- // Load the error
- require self::find_file('views', empty($template) ? 'kohana_error_page' : $template);
- }
- else
- {
- // Get the i18n messages
- $error = self::lang('core.generic_error');
- $message = self::lang('core.errors_disabled', url::site(), url::site(Router::$current_uri));
-
- // Load the errors_disabled view
- require self::find_file('views', 'kohana_error_disabled');
- }
-
- if ( ! Event::has_run('system.shutdown'))
- {
- // Run the shutdown even to ensure a clean exit
- Event::run('system.shutdown');
- }
-
- // Turn off error reporting
- error_reporting(0);
- exit;
- }
- catch (Exception $e)
- {
- if (IN_PRODUCTION)
- {
- die('Fatal Error');
- }
- else
- {
- die('Fatal Error: '.$e->getMessage().' File: '.$e->getFile().' Line: '.$e->getLine());
- }
- }
- }
-
- /**
- * Provides class auto-loading.
- *
- * @throws Kohana_Exception
- * @param string name of class
- * @return bool
- */
- public static function auto_load($class)
- {
- if (class_exists($class, FALSE))
- return TRUE;
-
- if (($suffix = strrpos($class, '_')) > 0)
- {
- // Find the class suffix
- $suffix = substr($class, $suffix + 1);
- }
- else
- {
- // No suffix
- $suffix = FALSE;
- }
-
- if ($suffix === 'Core')
- {
- $type = 'libraries';
- $file = substr($class, 0, -5);
- }
- elseif ($suffix === 'Controller')
- {
- $type = 'controllers';
- // Lowercase filename
- $file = strtolower(substr($class, 0, -11));
- }
- elseif ($suffix === 'Model')
- {
- $type = 'models';
- // Lowercase filename
- $file = strtolower(substr($class, 0, -6));
- }
- elseif ($suffix === 'Driver')
- {
- $type = 'libraries/drivers';
- $file = str_replace('_', '/', substr($class, 0, -7));
- }
- else
- {
- // This could be either a library or a helper, but libraries must
- // always be capitalized, so we check if the first character is
- // uppercase. If it is, we are loading a library, not a helper.
- $type = ($class[0] < 'a') ? 'libraries' : 'helpers';
- $file = $class;
- }
-
- if ($filename = self::find_file($type, $file))
- {
- // Load the class
- require $filename;
- }
- else
- {
- // The class could not be found
- return FALSE;
- }
-
- if ($filename = self::find_file($type, self::$configuration['core']['extension_prefix'].$class))
- {
- // Load the class extension
- require $filename;
- }
- elseif ($suffix !== 'Core' AND class_exists($class.'_Core', FALSE))
- {
- // Class extension to be evaluated
- $extension = 'class '.$class.' extends '.$class.'_Core { }';
-
- // Start class analysis
- $core = new ReflectionClass($class.'_Core');
-
- if ($core->isAbstract())
- {
- // Make the extension abstract
- $extension = 'abstract '.$extension;
- }
-
- // Transparent class extensions are handled using eval. This is
- // a disgusting hack, but it gets the job done.
- eval($extension);
- }
-
- return TRUE;
- }
-
- /**
- * Find a resource file in a given directory. Files will be located according
- * to the order of the include paths. Configuration and i18n files will be
- * returned in reverse order.
- *
- * @throws Kohana_Exception if file is required and not found
- * @param string directory to search in
- * @param string filename to look for (without extension)
- * @param boolean file required
- * @param string file extension
- * @return array if the type is config, i18n or l10n
- * @return string if the file is found
- * @return FALSE if the file is not found
- */
- public static function find_file($directory, $filename, $required = FALSE, $ext = FALSE)
- {
- // NOTE: This test MUST be not be a strict comparison (===), or empty
- // extensions will be allowed!
- if ($ext == '')
- {
- // Use the default extension
- $ext = EXT;
- }
- else
- {
- // Add a period before the extension
- $ext = '.'.$ext;
- }
-
- // Search path
- $search = $directory.'/'.$filename.$ext;
-
- if (isset(self::$internal_cache['find_file_paths'][$search]))
- return self::$internal_cache['find_file_paths'][$search];
-
- // Load include paths
- $paths = self::$include_paths;
-
- // Nothing found, yet
- $found = NULL;
-
- if ($directory === 'config' OR $directory === 'i18n')
- {
- // Search in reverse, for merging
- $paths = array_reverse($paths);
-
- foreach ($paths as $path)
- {
- if (is_file($path.$search))
- {
- // A matching file has been found
- $found[] = $path.$search;
- }
- }
- }
- else
- {
- foreach ($paths as $path)
- {
- if (is_file($path.$search))
- {
- // A matching file has been found
- $found = $path.$search;
-
- // Stop searching
- break;
- }
- }
- }
-
- if ($found === NULL)
- {
- if ($required === TRUE)
- {
- // Directory i18n key
- $directory = 'core.'.inflector::singular($directory);
-
- // If the file is required, throw an exception
- throw new Kohana_Exception('core.resource_not_found', self::lang($directory), $filename);
- }
- else
- {
- // Nothing was found, return FALSE
- $found = FALSE;
- }
- }
-
- if ( ! isset(self::$write_cache['find_file_paths']))
- {
- // Write cache at shutdown
- self::$write_cache['find_file_paths'] = TRUE;
- }
-
- return self::$internal_cache['find_file_paths'][$search] = $found;
- }
-
- /**
- * Lists all files and directories in a resource path.
- *
- * @param string directory to search
- * @param boolean list all files to the maximum depth?
- * @param string full path to search (used for recursion, *never* set this manually)
- * @return array filenames and directories
- */
- public static function list_files($directory, $recursive = FALSE, $path = FALSE)
- {
- $files = array();
-
- if ($path === FALSE)
- {
- $paths = array_reverse(self::include_paths());
-
- foreach ($paths as $path)
- {
- // Recursively get and merge all files
- $files = array_merge($files, self::list_files($directory, $recursive, $path.$directory));
- }
- }
- else
- {
- $path = rtrim($path, '/').'/';
-
- if (is_readable($path))
- {
- $items = (array) glob($path.'*');
-
- if ( ! empty($items))
- {
- foreach ($items as $index => $item)
- {
- $files[] = $item = str_replace('\\', '/', $item);
-
- // Handle recursion
- if (is_dir($item) AND $recursive == TRUE)
- {
- // Filename should only be the basename
- $item = pathinfo($item, PATHINFO_BASENAME);
-
- // Append sub-directory search
- $files = array_merge($files, self::list_files($directory, TRUE, $path.$item));
- }
- }
- }
- }
- }
-
- return $files;
- }
-
- /**
- * Fetch an i18n language item.
- *
- * @param string language key to fetch
- * @param array additional information to insert into the line
- * @return string i18n language string, or the requested key if the i18n item is not found
- */
- public static function lang($key, $args = array())
- {
- // Extract the main group from the key
- $group = explode('.', $key, 2);
- $group = $group[0];
-
- // Get locale name
- $locale = self::config('locale.language.0');
-
- if ( ! isset(self::$internal_cache['language'][$locale][$group]))
- {
- // Messages for this group
- $messages = array();
-
- if ($files = self::find_file('i18n', $locale.'/'.$group))
- {
- foreach ($files as $file)
- {
- include $file;
-
- // Merge in configuration
- if ( ! empty($lang) AND is_array($lang))
- {
- foreach ($lang as $k => $v)
- {
- $messages[$k] = $v;
- }
- }
- }
- }
-
- if ( ! isset(self::$write_cache['language']))
- {
- // Write language cache
- self::$write_cache['language'] = TRUE;
- }
-
- self::$internal_cache['language'][$locale][$group] = $messages;
- }
-
- // Get the line from cache
- $line = self::key_string(self::$internal_cache['language'][$locale], $key);
-
- if ($line === NULL)
- {
- self::log('error', 'Missing i18n entry '.$key.' for language '.$locale);
-
- // Return the key string as fallback
- return $key;
- }
-
- if (is_string($line) AND func_num_args() > 1)
- {
- $args = array_slice(func_get_args(), 1);
-
- // Add the arguments into the line
- $line = vsprintf($line, is_array($args[0]) ? $args[0] : $args);
- }
-
- return $line;
- }
-
- /**
- * Returns the value of a key, defined by a 'dot-noted' string, from an array.
- *
- * @param array array to search
- * @param string dot-noted string: foo.bar.baz
- * @return string if the key is found
- * @return void if the key is not found
- */
- public static function key_string($array, $keys)
- {
- if (empty($array))
- return NULL;
-
- // Prepare for loop
- $keys = explode('.', $keys);
-
- do
- {
- // Get the next key
- $key = array_shift($keys);
-
- if (isset($array[$key]))
- {
- if (is_array($array[$key]) AND ! empty($keys))
- {
- // Dig down to prepare the next loop
- $array = $array[$key];
- }
- else
- {
- // Requested key was found
- return $array[$key];
- }
- }
- else
- {
- // Requested key is not set
- break;
- }
- }
- while ( ! empty($keys));
-
- return NULL;
- }
-
- /**
- * Sets values in an array by using a 'dot-noted' string.
- *
- * @param array array to set keys in (reference)
- * @param string dot-noted string: foo.bar.baz
- * @return mixed fill value for the key
- * @return void
- */
- public static function key_string_set( & $array, $keys, $fill = NULL)
- {
- if (is_object($array) AND ($array instanceof ArrayObject))
- {
- // Copy the array
- $array_copy = $array->getArrayCopy();
-
- // Is an object
- $array_object = TRUE;
- }
- else
- {
- if ( ! is_array($array))
- {
- // Must always be an array
- $array = (array) $array;
- }
-
- // Copy is a reference to the array
- $array_copy =& $array;
- }
-
- if (empty($keys))
- return $array;
-
- // Create keys
- $keys = explode('.', $keys);
-
- // Create reference to the array
- $row =& $array_copy;
-
- for ($i = 0, $end = count($keys) - 1; $i <= $end; $i++)
- {
- // Get the current key
- $key = $keys[$i];
-
- if ( ! isset($row[$key]))
- {
- if (isset($keys[$i + 1]))
- {
- // Make the value an array
- $row[$key] = array();
- }
- else
- {
- // Add the fill key
- $row[$key] = $fill;
- }
- }
- elseif (isset($keys[$i + 1]))
- {
- // Make the value an array
- $row[$key] = (array) $row[$key];
- }
-
- // Go down a level, creating a new row reference
- $row =& $row[$key];
- }
-
- if (isset($array_object))
- {
- // Swap the array back in
- $array->exchangeArray($array_copy);
- }
- }
-
- /**
- * Retrieves current user agent information:
- * keys: browser, version, platform, mobile, robot, referrer, languages, charsets
- * tests: is_browser, is_mobile, is_robot, accept_lang, accept_charset
- *
- * @param string key or test name
- * @param string used with "accept" tests: user_agent(accept_lang, en)
- * @return array languages and charsets
- * @return string all other keys
- * @return boolean all tests
- */
- public static function user_agent($key = 'agent', $compare = NULL)
- {
- static $info;
-
- // Return the raw string
- if ($key === 'agent')
- return self::$user_agent;
-
- if ($info === NULL)
- {
- // Parse the user agent and extract basic information
- $agents = self::config('user_agents');
-
- foreach ($agents as $type => $data)
- {
- foreach ($data as $agent => $name)
- {
- if (stripos(self::$user_agent, $agent) !== FALSE)
- {
- if ($type === 'browser' AND preg_match('|'.preg_quote($agent).'[^0-9.]*+([0-9.][0-9.a-z]*)|i', self::$user_agent, $match))
- {
- // Set the browser version
- $info['version'] = $match[1];
- }
-
- // Set the agent name
- $info[$type] = $name;
- break;
- }
- }
- }
- }
-
- if (empty($info[$key]))
- {
- switch ($key)
- {
- case 'is_robot':
- case 'is_browser':
- case 'is_mobile':
- // A boolean result
- $return = ! empty($info[substr($key, 3)]);
- break;
- case 'languages':
- $return = array();
- if ( ! empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
- {
- if (preg_match_all('/[-a-z]{2,}/', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])), $matches))
- {
- // Found a result
- $return = $matches[0];
- }
- }
- break;
- case 'charsets':
- $return = array();
- if ( ! empty($_SERVER['HTTP_ACCEPT_CHARSET']))
- {
- if (preg_match_all('/[-a-z0-9]{2,}/', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])), $matches))
- {
- // Found a result
- $return = $matches[0];
- }
- }
- break;
- case 'referrer':
- if ( ! empty($_SERVER['HTTP_REFERER']))
- {
- // Found a result
- $return = trim($_SERVER['HTTP_REFERER']);
- }
- break;
- }
-
- // Cache the return value
- isset($return) and $info[$key] = $return;
- }
-
- if ( ! empty($compare))
- {
- // The comparison must always be lowercase
- $compare = strtolower($compare);
-
- switch ($key)
- {
- case 'accept_lang':
- // Check if the lange is accepted
- return in_array($compare, self::user_agent('languages'));
- break;
- case 'accept_charset':
- // Check if the charset is accepted
- return in_array($compare, self::user_agent('charsets'));
- break;
- default:
- // Invalid comparison
- return FALSE;
- break;
- }
- }
-
- // Return the key, if set
- return isset($info[$key]) ? $info[$key] : NULL;
- }
-
- /**
- * Quick debugging of any variable. Any number of parameters can be set.
- *
- * @return string
- */
- public static function debug()
- {
- if (func_num_args() === 0)
- return;
-
- // Get params
- $params = func_get_args();
- $output = array();
-
- foreach ($params as $var)
- {
- $output[] = '
';
-
- if (isset($entry['class']))
- {
- // Add class and call type
- $temp .= $entry['class'].$entry['type'];
- }
-
- // Add function
- $temp .= $entry['function'].'( ';
-
- // Add function args
- if (isset($entry['args']) AND is_array($entry['args']))
- {
- // Separator starts as nothing
- $sep = '';
-
- while ($arg = array_shift($entry['args']))
- {
- if (is_string($arg) AND is_file($arg))
- {
- // Remove docroot from filename
- $arg = preg_replace('!^'.preg_quote(DOCROOT).'!', '', $arg);
- }
-
- $temp .= $sep.html::specialchars(print_r($arg, TRUE));
-
- // Change separator to a comma
- $sep = ', ';
- }
- }
-
- $temp .= ' )
';
-
- $output[] = $temp;
- }
-
- return '
'.implode("\n", $output).'
';
- }
-
- /**
- * Saves the internal caches: configuration, include paths, etc.
- *
- * @return boolean
- */
- public static function internal_cache_save()
- {
- if ( ! is_array(self::$write_cache))
- return FALSE;
-
- // Get internal cache names
- $caches = array_keys(self::$write_cache);
-
- // Nothing written
- $written = FALSE;
-
- foreach ($caches as $cache)
- {
- if (isset(self::$internal_cache[$cache]))
- {
- // Write the cache file
- self::cache_save($cache, self::$internal_cache[$cache], self::$configuration['core']['internal_cache']);
-
- // A cache has been written
- $written = TRUE;
- }
- }
-
- return $written;
- }
-
-} // End Kohana
-
-/**
- * Creates a generic i18n exception.
- */
-class Kohana_Exception extends Exception {
-
- // Template file
- protected $template = 'kohana_error_page';
-
- // Header
- protected $header = FALSE;
-
- // Error code
- protected $code = E_KOHANA;
-
- /**
- * Set exception message.
- *
- * @param string i18n language key for the message
- * @param array addition line parameters
- */
- public function __construct($error)
- {
- $args = array_slice(func_get_args(), 1);
-
- // Fetch the error message
- $message = Kohana::lang($error, $args);
-
- if ($message === $error OR empty($message))
- {
- // Unable to locate the message for the error
- $message = 'Unknown Exception: '.$error;
- }
-
- // Sets $this->message the proper way
- parent::__construct($message);
- }
-
- /**
- * Magic method for converting an object to a string.
- *
- * @return string i18n message
- */
- public function __toString()
- {
- return (string) $this->message;
- }
-
- /**
- * Fetch the template name.
- *
- * @return string
- */
- public function getTemplate()
- {
- return $this->template;
- }
-
- /**
- * Sends an Internal Server Error header.
- *
- * @return void
- */
- public function sendHeaders()
- {
- // Send the 500 header
- header('HTTP/1.1 500 Internal Server Error');
- }
-
-} // End Kohana Exception
-
-/**
- * Creates a custom exception.
- */
-class Kohana_User_Exception extends Kohana_Exception {
-
- /**
- * Set exception title and message.
- *
- * @param string exception title string
- * @param string exception message string
- * @param string custom error template
- */
- public function __construct($title, $message, $template = FALSE)
- {
- Exception::__construct($message);
-
- $this->code = $title;
-
- if ($template !== FALSE)
- {
- $this->template = $template;
- }
- }
-
-} // End Kohana PHP Exception
-
-/**
- * Creates a Page Not Found exception.
- */
-class Kohana_404_Exception extends Kohana_Exception {
-
- protected $code = E_PAGE_NOT_FOUND;
-
- /**
- * Set internal properties.
- *
- * @param string URL of page
- * @param string custom error template
- */
- public function __construct($page = FALSE, $template = FALSE)
- {
- if ($page === FALSE)
- {
- // Construct the page URI using Router properties
- $page = Router::$current_uri.Router::$url_suffix.Router::$query_string;
- }
-
- Exception::__construct(Kohana::lang('core.page_not_found', $page));
-
- $this->template = $template;
- }
-
- /**
- * Sends "File Not Found" headers, to emulate server behavior.
- *
- * @return void
- */
- public function sendHeaders()
- {
- // Send the 404 header
- header('HTTP/1.1 404 File Not Found');
- }
-
-} // End Kohana 404 Exception
diff --git a/kohana/core/utf8.php b/kohana/core/utf8.php
deleted file mode 100644
index 9f20f421..00000000
--- a/kohana/core/utf8.php
+++ /dev/null
@@ -1,743 +0,0 @@
-PCRE has not been compiled with UTF-8 support. '.
- 'See PCRE Pattern Modifiers '.
- 'for more information. This application cannot be run without UTF-8 support.',
- E_USER_ERROR
- );
-}
-
-if ( ! extension_loaded('iconv'))
-{
- trigger_error
- (
- 'The iconv extension is not loaded. '.
- 'Without iconv, strings cannot be properly translated to UTF-8 from user input. '.
- 'This application cannot be run without UTF-8 support.',
- E_USER_ERROR
- );
-}
-
-if (extension_loaded('mbstring') AND (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING))
-{
- trigger_error
- (
- 'The mbstring extension is overloading PHP\'s native string functions. '.
- 'Disable this by setting mbstring.func_overload to 0, 1, 4 or 5 in php.ini or a .htaccess file.'.
- 'This application cannot be run without UTF-8 support.',
- E_USER_ERROR
- );
-}
-
-// Check PCRE support for Unicode properties such as \p and \X.
-$ER = error_reporting(0);
-define('PCRE_UNICODE_PROPERTIES', (bool) preg_match('/^\pL$/u', 'ñ'));
-error_reporting($ER);
-
-// SERVER_UTF8 ? use mb_* functions : use non-native functions
-if (extension_loaded('mbstring'))
-{
- mb_internal_encoding('UTF-8');
- define('SERVER_UTF8', TRUE);
-}
-else
-{
- define('SERVER_UTF8', FALSE);
-}
-
-// Convert all global variables to UTF-8.
-$_GET = utf8::clean($_GET);
-$_POST = utf8::clean($_POST);
-$_COOKIE = utf8::clean($_COOKIE);
-$_SERVER = utf8::clean($_SERVER);
-
-if (PHP_SAPI == 'cli')
-{
- // Convert command line arguments
- $_SERVER['argv'] = utf8::clean($_SERVER['argv']);
-}
-
-final class utf8 {
-
- // Called methods
- static $called = array();
-
- /**
- * Recursively cleans arrays, objects, and strings. Removes ASCII control
- * codes and converts to UTF-8 while silently discarding incompatible
- * UTF-8 characters.
- *
- * @param string string to clean
- * @return string
- */
- public static function clean($str)
- {
- if (is_array($str) OR is_object($str))
- {
- foreach ($str as $key => $val)
- {
- // Recursion!
- $str[self::clean($key)] = self::clean($val);
- }
- }
- elseif (is_string($str) AND $str !== '')
- {
- // Remove control characters
- $str = self::strip_ascii_ctrl($str);
-
- if ( ! self::is_ascii($str))
- {
- // Disable notices
- $ER = error_reporting(~E_NOTICE);
-
- // iconv is expensive, so it is only used when needed
- $str = iconv('UTF-8', 'UTF-8//IGNORE', $str);
-
- // Turn notices back on
- error_reporting($ER);
- }
- }
-
- return $str;
- }
-
- /**
- * Tests whether a string contains only 7bit ASCII bytes. This is used to
- * determine when to use native functions or UTF-8 functions.
- *
- * @param string string to check
- * @return bool
- */
- public static function is_ascii($str)
- {
- return ! preg_match('/[^\x00-\x7F]/S', $str);
- }
-
- /**
- * Strips out device control codes in the ASCII range.
- *
- * @param string string to clean
- * @return string
- */
- public static function strip_ascii_ctrl($str)
- {
- return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
- }
-
- /**
- * Strips out all non-7bit ASCII bytes.
- *
- * @param string string to clean
- * @return string
- */
- public static function strip_non_ascii($str)
- {
- return preg_replace('/[^\x00-\x7F]+/S', '', $str);
- }
-
- /**
- * Replaces special/accented UTF-8 characters by ASCII-7 'equivalents'.
- *
- * @author Andreas Gohr
- *
- * @param string string to transliterate
- * @param integer -1 lowercase only, +1 uppercase only, 0 both cases
- * @return string
- */
- public static function transliterate_to_ascii($str, $case = 0)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _transliterate_to_ascii($str, $case);
- }
-
- /**
- * Returns the length of the given string.
- * @see http://php.net/strlen
- *
- * @param string string being measured for length
- * @return integer
- */
- public static function strlen($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strlen($str);
- }
-
- /**
- * Finds position of first occurrence of a UTF-8 string.
- * @see http://php.net/strlen
- *
- * @author Harry Fuecks
- *
- * @param string haystack
- * @param string needle
- * @param integer offset from which character in haystack to start searching
- * @return integer position of needle
- * @return boolean FALSE if the needle is not found
- */
- public static function strpos($str, $search, $offset = 0)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strpos($str, $search, $offset);
- }
-
- /**
- * Finds position of last occurrence of a char in a UTF-8 string.
- * @see http://php.net/strrpos
- *
- * @author Harry Fuecks
- *
- * @param string haystack
- * @param string needle
- * @param integer offset from which character in haystack to start searching
- * @return integer position of needle
- * @return boolean FALSE if the needle is not found
- */
- public static function strrpos($str, $search, $offset = 0)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strrpos($str, $search, $offset);
- }
-
- /**
- * Returns part of a UTF-8 string.
- * @see http://php.net/substr
- *
- * @author Chris Smith
- *
- * @param string input string
- * @param integer offset
- * @param integer length limit
- * @return string
- */
- public static function substr($str, $offset, $length = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _substr($str, $offset, $length);
- }
-
- /**
- * Replaces text within a portion of a UTF-8 string.
- * @see http://php.net/substr_replace
- *
- * @author Harry Fuecks
- *
- * @param string input string
- * @param string replacement string
- * @param integer offset
- * @return string
- */
- public static function substr_replace($str, $replacement, $offset, $length = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _substr_replace($str, $replacement, $offset, $length);
- }
-
- /**
- * Makes a UTF-8 string lowercase.
- * @see http://php.net/strtolower
- *
- * @author Andreas Gohr
- *
- * @param string mixed case string
- * @return string
- */
- public static function strtolower($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strtolower($str);
- }
-
- /**
- * Makes a UTF-8 string uppercase.
- * @see http://php.net/strtoupper
- *
- * @author Andreas Gohr
- *
- * @param string mixed case string
- * @return string
- */
- public static function strtoupper($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strtoupper($str);
- }
-
- /**
- * Makes a UTF-8 string's first character uppercase.
- * @see http://php.net/ucfirst
- *
- * @author Harry Fuecks
- *
- * @param string mixed case string
- * @return string
- */
- public static function ucfirst($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _ucfirst($str);
- }
-
- /**
- * Makes the first character of every word in a UTF-8 string uppercase.
- * @see http://php.net/ucwords
- *
- * @author Harry Fuecks
- *
- * @param string mixed case string
- * @return string
- */
- public static function ucwords($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _ucwords($str);
- }
-
- /**
- * Case-insensitive UTF-8 string comparison.
- * @see http://php.net/strcasecmp
- *
- * @author Harry Fuecks
- *
- * @param string string to compare
- * @param string string to compare
- * @return integer less than 0 if str1 is less than str2
- * @return integer greater than 0 if str1 is greater than str2
- * @return integer 0 if they are equal
- */
- public static function strcasecmp($str1, $str2)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strcasecmp($str1, $str2);
- }
-
- /**
- * Returns a string or an array with all occurrences of search in subject (ignoring case).
- * replaced with the given replace value.
- * @see http://php.net/str_ireplace
- *
- * @note It's not fast and gets slower if $search and/or $replace are arrays.
- * @author Harry Fuecks
- *
- * @param string input string
- * @param string needle
- * @return string matched substring if found
- * @return boolean FALSE if the substring was not found
- */
- public static function stristr($str, $search)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _stristr($str, $search);
- }
-
- /**
- * Finds the length of the initial segment matching mask.
- * @see http://php.net/strspn
- *
- * @author Harry Fuecks
- *
- * @param string input string
- * @param string mask for search
- * @param integer start position of the string to examine
- * @param integer length of the string to examine
- * @return integer length of the initial segment that contains characters in the mask
- */
- public static function strspn($str, $mask, $offset = NULL, $length = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strspn($str, $mask, $offset, $length);
- }
-
- /**
- * Finds the length of the initial segment not matching mask.
- * @see http://php.net/strcspn
- *
- * @author Harry Fuecks
- *
- * @param string input string
- * @param string mask for search
- * @param integer start position of the string to examine
- * @param integer length of the string to examine
- * @return integer length of the initial segment that contains characters not in the mask
- */
- public static function strcspn($str, $mask, $offset = NULL, $length = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strcspn($str, $mask, $offset, $length);
- }
-
- /**
- * Pads a UTF-8 string to a certain length with another string.
- * @see http://php.net/str_pad
- *
- * @author Harry Fuecks
- *
- * @param string input string
- * @param integer desired string length after padding
- * @param string string to use as padding
- * @param string padding type: STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH
- * @return string
- */
- public static function str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _str_pad($str, $final_str_length, $pad_str, $pad_type);
- }
-
- /**
- * Converts a UTF-8 string to an array.
- * @see http://php.net/str_split
- *
- * @author Harry Fuecks
- *
- * @param string input string
- * @param integer maximum length of each chunk
- * @return array
- */
- public static function str_split($str, $split_length = 1)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _str_split($str, $split_length);
- }
-
- /**
- * Reverses a UTF-8 string.
- * @see http://php.net/strrev
- *
- * @author Harry Fuecks
- *
- * @param string string to be reversed
- * @return string
- */
- public static function strrev($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _strrev($str);
- }
-
- /**
- * Strips whitespace (or other UTF-8 characters) from the beginning and
- * end of a string.
- * @see http://php.net/trim
- *
- * @author Andreas Gohr
- *
- * @param string input string
- * @param string string of characters to remove
- * @return string
- */
- public static function trim($str, $charlist = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _trim($str, $charlist);
- }
-
- /**
- * Strips whitespace (or other UTF-8 characters) from the beginning of a string.
- * @see http://php.net/ltrim
- *
- * @author Andreas Gohr
- *
- * @param string input string
- * @param string string of characters to remove
- * @return string
- */
- public static function ltrim($str, $charlist = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _ltrim($str, $charlist);
- }
-
- /**
- * Strips whitespace (or other UTF-8 characters) from the end of a string.
- * @see http://php.net/rtrim
- *
- * @author Andreas Gohr
- *
- * @param string input string
- * @param string string of characters to remove
- * @return string
- */
- public static function rtrim($str, $charlist = NULL)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _rtrim($str, $charlist);
- }
-
- /**
- * Returns the unicode ordinal for a character.
- * @see http://php.net/ord
- *
- * @author Harry Fuecks
- *
- * @param string UTF-8 encoded character
- * @return integer
- */
- public static function ord($chr)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _ord($chr);
- }
-
- /**
- * Takes an UTF-8 string and returns an array of ints representing the Unicode characters.
- * Astral planes are supported i.e. the ints in the output can be > 0xFFFF.
- * Occurrances of the BOM are ignored. Surrogates are not allowed.
- *
- * The Original Code is Mozilla Communicator client code.
- * The Initial Developer of the Original Code is Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer.
- * Ported to PHP by Henri Sivonen , see http://hsivonen.iki.fi/php-utf8/.
- * Slight modifications to fit with phputf8 library by Harry Fuecks .
- *
- * @param string UTF-8 encoded string
- * @return array unicode code points
- * @return boolean FALSE if the string is invalid
- */
- public static function to_unicode($str)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _to_unicode($str);
- }
-
- /**
- * Takes an array of ints representing the Unicode characters and returns a UTF-8 string.
- * Astral planes are supported i.e. the ints in the input can be > 0xFFFF.
- * Occurrances of the BOM are ignored. Surrogates are not allowed.
- *
- * The Original Code is Mozilla Communicator client code.
- * The Initial Developer of the Original Code is Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer.
- * Ported to PHP by Henri Sivonen , see http://hsivonen.iki.fi/php-utf8/.
- * Slight modifications to fit with phputf8 library by Harry Fuecks .
- *
- * @param array unicode code points representing a string
- * @return string utf8 string of characters
- * @return boolean FALSE if a code point cannot be found
- */
- public static function from_unicode($arr)
- {
- if ( ! isset(self::$called[__FUNCTION__]))
- {
- require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
-
- // Function has been called
- self::$called[__FUNCTION__] = TRUE;
- }
-
- return _from_unicode($arr);
- }
-
-} // End utf8
\ No newline at end of file
diff --git a/kohana/core/utf8/from_unicode.php b/kohana/core/utf8/from_unicode.php
deleted file mode 100644
index 66c6742d..00000000
--- a/kohana/core/utf8/from_unicode.php
+++ /dev/null
@@ -1,68 +0,0 @@
-= 0) AND ($arr[$k] <= 0x007f))
- {
- echo chr($arr[$k]);
- }
- // 2 byte sequence
- elseif ($arr[$k] <= 0x07ff)
- {
- echo chr(0xc0 | ($arr[$k] >> 6));
- echo chr(0x80 | ($arr[$k] & 0x003f));
- }
- // Byte order mark (skip)
- elseif ($arr[$k] == 0xFEFF)
- {
- // nop -- zap the BOM
- }
- // Test for illegal surrogates
- elseif ($arr[$k] >= 0xD800 AND $arr[$k] <= 0xDFFF)
- {
- // Found a surrogate
- trigger_error('utf8::from_unicode: Illegal surrogate at index: '.$k.', value: '.$arr[$k], E_USER_WARNING);
- return FALSE;
- }
- // 3 byte sequence
- elseif ($arr[$k] <= 0xffff)
- {
- echo chr(0xe0 | ($arr[$k] >> 12));
- echo chr(0x80 | (($arr[$k] >> 6) & 0x003f));
- echo chr(0x80 | ($arr[$k] & 0x003f));
- }
- // 4 byte sequence
- elseif ($arr[$k] <= 0x10ffff)
- {
- echo chr(0xf0 | ($arr[$k] >> 18));
- echo chr(0x80 | (($arr[$k] >> 12) & 0x3f));
- echo chr(0x80 | (($arr[$k] >> 6) & 0x3f));
- echo chr(0x80 | ($arr[$k] & 0x3f));
- }
- // Out of range
- else
- {
- trigger_error('utf8::from_unicode: Codepoint out of Unicode range at index: '.$k.', value: '.$arr[$k], E_USER_WARNING);
- return FALSE;
- }
- }
-
- $result = ob_get_contents();
- ob_end_clean();
- return $result;
-}
diff --git a/kohana/core/utf8/ltrim.php b/kohana/core/utf8/ltrim.php
deleted file mode 100644
index 556fe07f..00000000
--- a/kohana/core/utf8/ltrim.php
+++ /dev/null
@@ -1,22 +0,0 @@
-= 0 AND $ord0 <= 127)
- {
- return $ord0;
- }
-
- if ( ! isset($chr[1]))
- {
- trigger_error('Short sequence - at least 2 bytes expected, only 1 seen', E_USER_WARNING);
- return FALSE;
- }
-
- $ord1 = ord($chr[1]);
-
- if ($ord0 >= 192 AND $ord0 <= 223)
- {
- return ($ord0 - 192) * 64 + ($ord1 - 128);
- }
-
- if ( ! isset($chr[2]))
- {
- trigger_error('Short sequence - at least 3 bytes expected, only 2 seen', E_USER_WARNING);
- return FALSE;
- }
-
- $ord2 = ord($chr[2]);
-
- if ($ord0 >= 224 AND $ord0 <= 239)
- {
- return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128);
- }
-
- if ( ! isset($chr[3]))
- {
- trigger_error('Short sequence - at least 4 bytes expected, only 3 seen', E_USER_WARNING);
- return FALSE;
- }
-
- $ord3 = ord($chr[3]);
-
- if ($ord0 >= 240 AND $ord0 <= 247)
- {
- return ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2-128) * 64 + ($ord3 - 128);
- }
-
- if ( ! isset($chr[4]))
- {
- trigger_error('Short sequence - at least 5 bytes expected, only 4 seen', E_USER_WARNING);
- return FALSE;
- }
-
- $ord4 = ord($chr[4]);
-
- if ($ord0 >= 248 AND $ord0 <= 251)
- {
- return ($ord0 - 248) * 16777216 + ($ord1-128) * 262144 + ($ord2 - 128) * 4096 + ($ord3 - 128) * 64 + ($ord4 - 128);
- }
-
- if ( ! isset($chr[5]))
- {
- trigger_error('Short sequence - at least 6 bytes expected, only 5 seen', E_USER_WARNING);
- return FALSE;
- }
-
- if ($ord0 >= 252 AND $ord0 <= 253)
- {
- return ($ord0 - 252) * 1073741824 + ($ord1 - 128) * 16777216 + ($ord2 - 128) * 262144 + ($ord3 - 128) * 4096 + ($ord4 - 128) * 64 + (ord($chr[5]) - 128);
- }
-
- if ($ord0 >= 254 AND $ord0 <= 255)
- {
- trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0, E_USER_WARNING);
- return FALSE;
- }
-}
\ No newline at end of file
diff --git a/kohana/core/utf8/rtrim.php b/kohana/core/utf8/rtrim.php
deleted file mode 100644
index efa0e19d..00000000
--- a/kohana/core/utf8/rtrim.php
+++ /dev/null
@@ -1,22 +0,0 @@
- $val)
- {
- $str[$key] = utf8::str_ireplace($search, $replace, $val, $count);
- }
- return $str;
- }
-
- if (is_array($search))
- {
- $keys = array_keys($search);
-
- foreach ($keys as $k)
- {
- if (is_array($replace))
- {
- if (array_key_exists($k, $replace))
- {
- $str = utf8::str_ireplace($search[$k], $replace[$k], $str, $count);
- }
- else
- {
- $str = utf8::str_ireplace($search[$k], '', $str, $count);
- }
- }
- else
- {
- $str = utf8::str_ireplace($search[$k], $replace, $str, $count);
- }
- }
- return $str;
- }
-
- $search = utf8::strtolower($search);
- $str_lower = utf8::strtolower($str);
-
- $total_matched_strlen = 0;
- $i = 0;
-
- while (preg_match('/(.*?)'.preg_quote($search, '/').'/s', $str_lower, $matches))
- {
- $matched_strlen = strlen($matches[0]);
- $str_lower = substr($str_lower, $matched_strlen);
-
- $offset = $total_matched_strlen + strlen($matches[1]) + ($i * (strlen($replace) - 1));
- $str = substr_replace($str, $replace, $offset, strlen($search));
-
- $total_matched_strlen += $matched_strlen;
- $i++;
- }
-
- $count += $i;
- return $str;
-}
diff --git a/kohana/core/utf8/str_pad.php b/kohana/core/utf8/str_pad.php
deleted file mode 100644
index aab4ccc7..00000000
--- a/kohana/core/utf8/str_pad.php
+++ /dev/null
@@ -1,54 +0,0 @@
-0x0061, 0x03A6=>0x03C6, 0x0162=>0x0163, 0x00C5=>0x00E5, 0x0042=>0x0062,
- 0x0139=>0x013A, 0x00C1=>0x00E1, 0x0141=>0x0142, 0x038E=>0x03CD, 0x0100=>0x0101,
- 0x0490=>0x0491, 0x0394=>0x03B4, 0x015A=>0x015B, 0x0044=>0x0064, 0x0393=>0x03B3,
- 0x00D4=>0x00F4, 0x042A=>0x044A, 0x0419=>0x0439, 0x0112=>0x0113, 0x041C=>0x043C,
- 0x015E=>0x015F, 0x0143=>0x0144, 0x00CE=>0x00EE, 0x040E=>0x045E, 0x042F=>0x044F,
- 0x039A=>0x03BA, 0x0154=>0x0155, 0x0049=>0x0069, 0x0053=>0x0073, 0x1E1E=>0x1E1F,
- 0x0134=>0x0135, 0x0427=>0x0447, 0x03A0=>0x03C0, 0x0418=>0x0438, 0x00D3=>0x00F3,
- 0x0420=>0x0440, 0x0404=>0x0454, 0x0415=>0x0435, 0x0429=>0x0449, 0x014A=>0x014B,
- 0x0411=>0x0431, 0x0409=>0x0459, 0x1E02=>0x1E03, 0x00D6=>0x00F6, 0x00D9=>0x00F9,
- 0x004E=>0x006E, 0x0401=>0x0451, 0x03A4=>0x03C4, 0x0423=>0x0443, 0x015C=>0x015D,
- 0x0403=>0x0453, 0x03A8=>0x03C8, 0x0158=>0x0159, 0x0047=>0x0067, 0x00C4=>0x00E4,
- 0x0386=>0x03AC, 0x0389=>0x03AE, 0x0166=>0x0167, 0x039E=>0x03BE, 0x0164=>0x0165,
- 0x0116=>0x0117, 0x0108=>0x0109, 0x0056=>0x0076, 0x00DE=>0x00FE, 0x0156=>0x0157,
- 0x00DA=>0x00FA, 0x1E60=>0x1E61, 0x1E82=>0x1E83, 0x00C2=>0x00E2, 0x0118=>0x0119,
- 0x0145=>0x0146, 0x0050=>0x0070, 0x0150=>0x0151, 0x042E=>0x044E, 0x0128=>0x0129,
- 0x03A7=>0x03C7, 0x013D=>0x013E, 0x0422=>0x0442, 0x005A=>0x007A, 0x0428=>0x0448,
- 0x03A1=>0x03C1, 0x1E80=>0x1E81, 0x016C=>0x016D, 0x00D5=>0x00F5, 0x0055=>0x0075,
- 0x0176=>0x0177, 0x00DC=>0x00FC, 0x1E56=>0x1E57, 0x03A3=>0x03C3, 0x041A=>0x043A,
- 0x004D=>0x006D, 0x016A=>0x016B, 0x0170=>0x0171, 0x0424=>0x0444, 0x00CC=>0x00EC,
- 0x0168=>0x0169, 0x039F=>0x03BF, 0x004B=>0x006B, 0x00D2=>0x00F2, 0x00C0=>0x00E0,
- 0x0414=>0x0434, 0x03A9=>0x03C9, 0x1E6A=>0x1E6B, 0x00C3=>0x00E3, 0x042D=>0x044D,
- 0x0416=>0x0436, 0x01A0=>0x01A1, 0x010C=>0x010D, 0x011C=>0x011D, 0x00D0=>0x00F0,
- 0x013B=>0x013C, 0x040F=>0x045F, 0x040A=>0x045A, 0x00C8=>0x00E8, 0x03A5=>0x03C5,
- 0x0046=>0x0066, 0x00DD=>0x00FD, 0x0043=>0x0063, 0x021A=>0x021B, 0x00CA=>0x00EA,
- 0x0399=>0x03B9, 0x0179=>0x017A, 0x00CF=>0x00EF, 0x01AF=>0x01B0, 0x0045=>0x0065,
- 0x039B=>0x03BB, 0x0398=>0x03B8, 0x039C=>0x03BC, 0x040C=>0x045C, 0x041F=>0x043F,
- 0x042C=>0x044C, 0x00DE=>0x00FE, 0x00D0=>0x00F0, 0x1EF2=>0x1EF3, 0x0048=>0x0068,
- 0x00CB=>0x00EB, 0x0110=>0x0111, 0x0413=>0x0433, 0x012E=>0x012F, 0x00C6=>0x00E6,
- 0x0058=>0x0078, 0x0160=>0x0161, 0x016E=>0x016F, 0x0391=>0x03B1, 0x0407=>0x0457,
- 0x0172=>0x0173, 0x0178=>0x00FF, 0x004F=>0x006F, 0x041B=>0x043B, 0x0395=>0x03B5,
- 0x0425=>0x0445, 0x0120=>0x0121, 0x017D=>0x017E, 0x017B=>0x017C, 0x0396=>0x03B6,
- 0x0392=>0x03B2, 0x0388=>0x03AD, 0x1E84=>0x1E85, 0x0174=>0x0175, 0x0051=>0x0071,
- 0x0417=>0x0437, 0x1E0A=>0x1E0B, 0x0147=>0x0148, 0x0104=>0x0105, 0x0408=>0x0458,
- 0x014C=>0x014D, 0x00CD=>0x00ED, 0x0059=>0x0079, 0x010A=>0x010B, 0x038F=>0x03CE,
- 0x0052=>0x0072, 0x0410=>0x0430, 0x0405=>0x0455, 0x0402=>0x0452, 0x0126=>0x0127,
- 0x0136=>0x0137, 0x012A=>0x012B, 0x038A=>0x03AF, 0x042B=>0x044B, 0x004C=>0x006C,
- 0x0397=>0x03B7, 0x0124=>0x0125, 0x0218=>0x0219, 0x00DB=>0x00FB, 0x011E=>0x011F,
- 0x041E=>0x043E, 0x1E40=>0x1E41, 0x039D=>0x03BD, 0x0106=>0x0107, 0x03AB=>0x03CB,
- 0x0426=>0x0446, 0x00DE=>0x00FE, 0x00C7=>0x00E7, 0x03AA=>0x03CA, 0x0421=>0x0441,
- 0x0412=>0x0432, 0x010E=>0x010F, 0x00D8=>0x00F8, 0x0057=>0x0077, 0x011A=>0x011B,
- 0x0054=>0x0074, 0x004A=>0x006A, 0x040B=>0x045B, 0x0406=>0x0456, 0x0102=>0x0103,
- 0x039B=>0x03BB, 0x00D1=>0x00F1, 0x041D=>0x043D, 0x038C=>0x03CC, 0x00C9=>0x00E9,
- 0x00D0=>0x00F0, 0x0407=>0x0457, 0x0122=>0x0123,
- );
- }
-
- $uni = utf8::to_unicode($str);
-
- if ($uni === FALSE)
- return FALSE;
-
- for ($i = 0, $c = count($uni); $i < $c; $i++)
- {
- if (isset($UTF8_UPPER_TO_LOWER[$uni[$i]]))
- {
- $uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]];
- }
- }
-
- return utf8::from_unicode($uni);
-}
\ No newline at end of file
diff --git a/kohana/core/utf8/strtoupper.php b/kohana/core/utf8/strtoupper.php
deleted file mode 100644
index f3ded739..00000000
--- a/kohana/core/utf8/strtoupper.php
+++ /dev/null
@@ -1,84 +0,0 @@
-0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042,
- 0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100,
- 0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393,
- 0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C,
- 0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F,
- 0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E,
- 0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3,
- 0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A,
- 0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9,
- 0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C,
- 0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4,
- 0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164,
- 0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156,
- 0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118,
- 0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128,
- 0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428,
- 0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055,
- 0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A,
- 0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC,
- 0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0,
- 0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D,
- 0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0,
- 0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5,
- 0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA,
- 0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045,
- 0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F,
- 0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048,
- 0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6,
- 0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407,
- 0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395,
- 0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396,
- 0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051,
- 0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408,
- 0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F,
- 0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126,
- 0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C,
- 0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E,
- 0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB,
- 0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421,
- 0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A,
- 0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102,
- 0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9,
- 0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
- );
- }
-
- $uni = utf8::to_unicode($str);
-
- if ($uni === FALSE)
- return FALSE;
-
- for ($i = 0, $c = count($uni); $i < $c; $i++)
- {
- if (isset($UTF8_LOWER_TO_UPPER[$uni[$i]]))
- {
- $uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]];
- }
- }
-
- return utf8::from_unicode($uni);
-}
\ No newline at end of file
diff --git a/kohana/core/utf8/substr.php b/kohana/core/utf8/substr.php
deleted file mode 100644
index daf66b81..00000000
--- a/kohana/core/utf8/substr.php
+++ /dev/null
@@ -1,75 +0,0 @@
-= $strlen OR ($length < 0 AND $length <= $offset - $strlen))
- return '';
-
- // Whole string
- if ($offset == 0 AND ($length === NULL OR $length >= $strlen))
- return $str;
-
- // Build regex
- $regex = '^';
-
- // Create an offset expression
- if ($offset > 0)
- {
- // PCRE repeating quantifiers must be less than 65536, so repeat when necessary
- $x = (int) ($offset / 65535);
- $y = (int) ($offset % 65535);
- $regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}';
- $regex .= ($y == 0) ? '' : '.{'.$y.'}';
- }
-
- // Create a length expression
- if ($length === NULL)
- {
- $regex .= '(.*)'; // No length set, grab it all
- }
- // Find length from the left (positive length)
- elseif ($length > 0)
- {
- // Reduce length so that it can't go beyond the end of the string
- $length = min($strlen - $offset, $length);
-
- $x = (int) ($length / 65535);
- $y = (int) ($length % 65535);
- $regex .= '(';
- $regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}';
- $regex .= '.{'.$y.'})';
- }
- // Find length from the right (negative length)
- else
- {
- $x = (int) (-$length / 65535);
- $y = (int) (-$length % 65535);
- $regex .= '(.*)';
- $regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}';
- $regex .= '.{'.$y.'}';
- }
-
- preg_match('/'.$regex.'/us', $str, $matches);
- return $matches[1];
-}
\ No newline at end of file
diff --git a/kohana/core/utf8/substr_replace.php b/kohana/core/utf8/substr_replace.php
deleted file mode 100644
index 45e2d2a3..00000000
--- a/kohana/core/utf8/substr_replace.php
+++ /dev/null
@@ -1,22 +0,0 @@
- 0x10FFFF))
- {
- trigger_error('utf8::to_unicode: Illegal sequence or codepoint in UTF-8 at byte '.$i, E_USER_WARNING);
- return FALSE;
- }
-
- if (0xFEFF != $mUcs4)
- {
- // BOM is legal but we don't want to output it
- $out[] = $mUcs4;
- }
-
- // Initialize UTF-8 cache
- $mState = 0;
- $mUcs4 = 0;
- $mBytes = 1;
- }
- }
- else
- {
- // ((0xC0 & (*in) != 0x80) AND (mState != 0))
- // Incomplete multi-octet sequence
- trigger_error('utf8::to_unicode: Incomplete multi-octet sequence in UTF-8 at byte '.$i, E_USER_WARNING);
- return FALSE;
- }
- }
- }
-
- return $out;
-}
\ No newline at end of file
diff --git a/kohana/core/utf8/transliterate_to_ascii.php b/kohana/core/utf8/transliterate_to_ascii.php
deleted file mode 100644
index 07461fbb..00000000
--- a/kohana/core/utf8/transliterate_to_ascii.php
+++ /dev/null
@@ -1,77 +0,0 @@
- 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o',
- 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
- 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
- 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
- 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
- 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
- 'ū' => 'u', 'č' => 'c', 'ö' => 'o', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
- 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
- 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
- 'ŗ' => 'r', 'ä' => 'a', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'u', 'ò' => 'o',
- 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
- 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
- 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
- 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
- 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'ĕ' => 'e',
- );
- }
-
- $str = str_replace(
- array_keys($UTF8_LOWER_ACCENTS),
- array_values($UTF8_LOWER_ACCENTS),
- $str
- );
- }
-
- if ($case >= 0)
- {
- if ($UTF8_UPPER_ACCENTS === NULL)
- {
- $UTF8_UPPER_ACCENTS = array(
- 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O',
- 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K', 'Ĕ' => 'E',
- 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O',
- 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O',
- 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C',
- 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T',
- 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'O', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L',
- 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z',
- 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T',
- 'Ŗ' => 'R', 'Ä' => 'A', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'U', 'Ò' => 'O',
- 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J',
- 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O',
- 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G',
- 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A',
- 'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae',
- );
- }
-
- $str = str_replace(
- array_keys($UTF8_UPPER_ACCENTS),
- array_values($UTF8_UPPER_ACCENTS),
- $str
- );
- }
-
- return $str;
-}
\ No newline at end of file
diff --git a/kohana/core/utf8/trim.php b/kohana/core/utf8/trim.php
deleted file mode 100644
index 7434102a..00000000
--- a/kohana/core/utf8/trim.php
+++ /dev/null
@@ -1,17 +0,0 @@
- $value)
- {
- $value = ($keep_keys === TRUE) ? $value : array_values($value);
- foreach ($value as $k => $v)
- {
- $new_array[$k][$key] = $v;
- }
- }
-
- return $new_array;
- }
-
- /**
- * Removes a key from an array and returns the value.
- *
- * @param string key to return
- * @param array array to work on
- * @return mixed value of the requested array key
- */
- public static function remove($key, & $array)
- {
- if ( ! array_key_exists($key, $array))
- return NULL;
-
- $val = $array[$key];
- unset($array[$key]);
-
- return $val;
- }
-
-
- /**
- * Extract one or more keys from an array. Each key given after the first
- * argument (the array) will be extracted. Keys that do not exist in the
- * search array will be NULL in the extracted data.
- *
- * @param array array to search
- * @param string key name
- * @return array
- */
- public static function extract(array $search, $keys)
- {
- // Get the keys, removing the $search array
- $keys = array_slice(func_get_args(), 1);
-
- $found = array();
- foreach ($keys as $key)
- {
- if (isset($search[$key]))
- {
- $found[$key] = $search[$key];
- }
- else
- {
- $found[$key] = NULL;
- }
- }
-
- return $found;
- }
-
- /**
- * Because PHP does not have this function.
- *
- * @param array array to unshift
- * @param string key to unshift
- * @param mixed value to unshift
- * @return array
- */
- public static function unshift_assoc( array & $array, $key, $val)
- {
- $array = array_reverse($array, TRUE);
- $array[$key] = $val;
- $array = array_reverse($array, TRUE);
-
- return $array;
- }
-
- /**
- * Because PHP does not have this function, and array_walk_recursive creates
- * references in arrays and is not truly recursive.
- *
- * @param mixed callback to apply to each member of the array
- * @param array array to map to
- * @return array
- */
- public static function map_recursive($callback, array $array)
- {
- foreach ($array as $key => $val)
- {
- // Map the callback to the key
- $array[$key] = is_array($val) ? arr::map_recursive($callback, $val) : call_user_func($callback, $val);
- }
-
- return $array;
- }
-
- /**
- * @param mixed $needle the value to search for
- * @param array $haystack an array of values to search in
- * @param boolean $sort sort the array now
- * @return integer|FALSE the index of the match or FALSE when not found
- */
- public static function binary_search($needle, $haystack, $sort = FALSE)
- {
- if ($sort)
- {
- sort($haystack);
- }
-
- $high = count($haystack) - 1;
- $low = 0;
-
- while ($low <= $high)
- {
- $mid = ($low + $high) >> 1;
-
- if ($haystack[$mid] < $needle)
- {
- $low = $mid + 1;
- }
- elseif ($haystack[$mid] > $needle)
- {
- $high = $mid - 1;
- }
- else
- {
- return $mid;
- }
- }
-
- return FALSE;
- }
-
-
- /**
- * Emulates array_merge_recursive, but appends numeric keys and replaces
- * associative keys, instead of appending all keys.
- *
- * @param array any number of arrays
- * @return array
- */
- public static function merge()
- {
- $total = func_num_args();
-
- $result = array();
- for ($i = 0; $i < $total; $i++)
- {
- foreach (func_get_arg($i) as $key => $val)
- {
- if (isset($result[$key]))
- {
- if (is_array($val))
- {
- // Arrays are merged recursively
- $result[$key] = arr::merge($result[$key], $val);
- }
- elseif (is_int($key))
- {
- // Indexed arrays are appended
- array_push($result, $val);
- }
- else
- {
- // Associative arrays are replaced
- $result[$key] = $val;
- }
- }
- else
- {
- // New values are added
- $result[$key] = $val;
- }
- }
- }
-
- return $result;
- }
-
- /**
- * Overwrites an array with values from input array(s).
- * Non-existing keys will not be appended!
- *
- * @param array key array
- * @param array input array(s) that will overwrite key array values
- * @return array
- */
- public static function overwrite($array1, $array2)
- {
- foreach (array_intersect_key($array2, $array1) as $key => $value)
- {
- $array1[$key] = $value;
- }
-
- if (func_num_args() > 2)
- {
- foreach (array_slice(func_get_args(), 2) as $array2)
- {
- foreach (array_intersect_key($array2, $array1) as $key => $value)
- {
- $array1[$key] = $value;
- }
- }
- }
-
- return $array1;
- }
-
- /**
- * Fill an array with a range of numbers.
- *
- * @param integer stepping
- * @param integer ending number
- * @return array
- */
- public static function range($step = 10, $max = 100)
- {
- if ($step < 1)
- return array();
-
- $array = array();
- for ($i = $step; $i <= $max; $i += $step)
- {
- $array[$i] = $i;
- }
-
- return $array;
- }
-
- /**
- * Recursively convert an array to an object.
- *
- * @param array array to convert
- * @return object
- */
- public static function to_object(array $array, $class = 'stdClass')
- {
- $object = new $class;
-
- foreach ($array as $key => $value)
- {
- if (is_array($value))
- {
- // Convert the array to an object
- $value = arr::to_object($value, $class);
- }
-
- // Add the value to the object
- $object->{$key} = $value;
- }
-
- return $object;
- }
-
-} // End arr
diff --git a/kohana/helpers/cookie.php b/kohana/helpers/cookie.php
deleted file mode 100644
index 901b6d86..00000000
--- a/kohana/helpers/cookie.php
+++ /dev/null
@@ -1,84 +0,0 @@
-cookie($name, $default, $xss_clean);
- }
-
- /**
- * Nullify and unset a cookie.
- *
- * @param string cookie name
- * @param string URL path
- * @param string URL domain
- * @return boolean
- */
- public static function delete($name, $path = NULL, $domain = NULL)
- {
- if ( ! isset($_COOKIE[$name]))
- return FALSE;
-
- // Delete the cookie from globals
- unset($_COOKIE[$name]);
-
- // Sets the cookie value to an empty string, and the expiration to 24 hours ago
- return cookie::set($name, '', -86400, $path, $domain, FALSE, FALSE);
- }
-
-} // End cookie
\ No newline at end of file
diff --git a/kohana/helpers/date.php b/kohana/helpers/date.php
deleted file mode 100644
index 7d5a9ab6..00000000
--- a/kohana/helpers/date.php
+++ /dev/null
@@ -1,405 +0,0 @@
-> 1);
- }
-
- /**
- * Converts a DOS timestamp to UNIX format.
- *
- * @param integer DOS timestamp
- * @return integer
- */
- public static function dos2unix($timestamp = FALSE)
- {
- $sec = 2 * ($timestamp & 0x1f);
- $min = ($timestamp >> 5) & 0x3f;
- $hrs = ($timestamp >> 11) & 0x1f;
- $day = ($timestamp >> 16) & 0x1f;
- $mon = ($timestamp >> 21) & 0x0f;
- $year = ($timestamp >> 25) & 0x7f;
-
- return mktime($hrs, $min, $sec, $mon, $day, $year + 1980);
- }
-
- /**
- * Returns the offset (in seconds) between two time zones.
- * @see http://php.net/timezones
- *
- * @param string timezone that to find the offset of
- * @param string|boolean timezone used as the baseline
- * @return integer
- */
- public static function offset($remote, $local = TRUE)
- {
- static $offsets;
-
- // Default values
- $remote = (string) $remote;
- $local = ($local === TRUE) ? date_default_timezone_get() : (string) $local;
-
- // Cache key name
- $cache = $remote.$local;
-
- if (empty($offsets[$cache]))
- {
- // Create timezone objects
- $remote = new DateTimeZone($remote);
- $local = new DateTimeZone($local);
-
- // Create date objects from timezones
- $time_there = new DateTime('now', $remote);
- $time_here = new DateTime('now', $local);
-
- // Find the offset
- $offsets[$cache] = $remote->getOffset($time_there) - $local->getOffset($time_here);
- }
-
- return $offsets[$cache];
- }
-
- /**
- * Number of seconds in a minute, incrementing by a step.
- *
- * @param integer amount to increment each step by, 1 to 30
- * @param integer start value
- * @param integer end value
- * @return array A mirrored (foo => foo) array from 1-60.
- */
- public static function seconds($step = 1, $start = 0, $end = 60)
- {
- // Always integer
- $step = (int) $step;
-
- $seconds = array();
-
- for ($i = $start; $i < $end; $i += $step)
- {
- $seconds[$i] = ($i < 10) ? '0'.$i : $i;
- }
-
- return $seconds;
- }
-
- /**
- * Number of minutes in an hour, incrementing by a step.
- *
- * @param integer amount to increment each step by, 1 to 30
- * @return array A mirrored (foo => foo) array from 1-60.
- */
- public static function minutes($step = 5)
- {
- // Because there are the same number of minutes as seconds in this set,
- // we choose to re-use seconds(), rather than creating an entirely new
- // function. Shhhh, it's cheating! ;) There are several more of these
- // in the following methods.
- return date::seconds($step);
- }
-
- /**
- * Number of hours in a day.
- *
- * @param integer amount to increment each step by
- * @param boolean use 24-hour time
- * @param integer the hour to start at
- * @return array A mirrored (foo => foo) array from start-12 or start-23.
- */
- public static function hours($step = 1, $long = FALSE, $start = NULL)
- {
- // Default values
- $step = (int) $step;
- $long = (bool) $long;
- $hours = array();
-
- // Set the default start if none was specified.
- if ($start === NULL)
- {
- $start = ($long === FALSE) ? 1 : 0;
- }
-
- $hours = array();
-
- // 24-hour time has 24 hours, instead of 12
- $size = ($long === TRUE) ? 23 : 12;
-
- for ($i = $start; $i <= $size; $i += $step)
- {
- $hours[$i] = $i;
- }
-
- return $hours;
- }
-
- /**
- * Returns AM or PM, based on a given hour.
- *
- * @param integer number of the hour
- * @return string
- */
- public static function ampm($hour)
- {
- // Always integer
- $hour = (int) $hour;
-
- return ($hour > 11) ? 'PM' : 'AM';
- }
-
- /**
- * Adjusts a non-24-hour number into a 24-hour number.
- *
- * @param integer hour to adjust
- * @param string AM or PM
- * @return string
- */
- public static function adjust($hour, $ampm)
- {
- $hour = (int) $hour;
- $ampm = strtolower($ampm);
-
- switch ($ampm)
- {
- case 'am':
- if ($hour == 12)
- $hour = 0;
- break;
- case 'pm':
- if ($hour < 12)
- $hour += 12;
- break;
- }
-
- return sprintf('%02s', $hour);
- }
-
- /**
- * Number of days in month.
- *
- * @param integer number of month
- * @param integer number of year to check month, defaults to the current year
- * @return array A mirrored (foo => foo) array of the days.
- */
- public static function days($month, $year = FALSE)
- {
- static $months;
-
- // Always integers
- $month = (int) $month;
- $year = (int) $year;
-
- // Use the current year by default
- $year = ($year == FALSE) ? date('Y') : $year;
-
- // We use caching for months, because time functions are used
- if (empty($months[$year][$month]))
- {
- $months[$year][$month] = array();
-
- // Use date to find the number of days in the given month
- $total = date('t', mktime(1, 0, 0, $month, 1, $year)) + 1;
-
- for ($i = 1; $i < $total; $i++)
- {
- $months[$year][$month][$i] = $i;
- }
- }
-
- return $months[$year][$month];
- }
-
- /**
- * Number of months in a year
- *
- * @return array A mirrored (foo => foo) array from 1-12.
- */
- public static function months()
- {
- return date::hours();
- }
-
- /**
- * Returns an array of years between a starting and ending year.
- * Uses the current year +/- 5 as the max/min.
- *
- * @param integer starting year
- * @param integer ending year
- * @return array
- */
- public static function years($start = FALSE, $end = FALSE)
- {
- // Default values
- $start = ($start === FALSE) ? date('Y') - 5 : (int) $start;
- $end = ($end === FALSE) ? date('Y') + 5 : (int) $end;
-
- $years = array();
-
- // Add one, so that "less than" works
- $end += 1;
-
- for ($i = $start; $i < $end; $i++)
- {
- $years[$i] = $i;
- }
-
- return $years;
- }
-
- /**
- * Returns time difference between two timestamps, in human readable format.
- *
- * @param integer timestamp
- * @param integer timestamp, defaults to the current time
- * @param string formatting string
- * @return string|array
- */
- public static function timespan($time1, $time2 = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds')
- {
- // Array with the output formats
- $output = preg_split('/[^a-z]+/', strtolower((string) $output));
-
- // Invalid output
- if (empty($output))
- return FALSE;
-
- // Make the output values into keys
- extract(array_flip($output), EXTR_SKIP);
-
- // Default values
- $time1 = max(0, (int) $time1);
- $time2 = empty($time2) ? time() : max(0, (int) $time2);
-
- // Calculate timespan (seconds)
- $timespan = abs($time1 - $time2);
-
- // All values found using Google Calculator.
- // Years and months do not match the formula exactly, due to leap years.
-
- // Years ago, 60 * 60 * 24 * 365
- isset($years) and $timespan -= 31556926 * ($years = (int) floor($timespan / 31556926));
-
- // Months ago, 60 * 60 * 24 * 30
- isset($months) and $timespan -= 2629744 * ($months = (int) floor($timespan / 2629743.83));
-
- // Weeks ago, 60 * 60 * 24 * 7
- isset($weeks) and $timespan -= 604800 * ($weeks = (int) floor($timespan / 604800));
-
- // Days ago, 60 * 60 * 24
- isset($days) and $timespan -= 86400 * ($days = (int) floor($timespan / 86400));
-
- // Hours ago, 60 * 60
- isset($hours) and $timespan -= 3600 * ($hours = (int) floor($timespan / 3600));
-
- // Minutes ago, 60
- isset($minutes) and $timespan -= 60 * ($minutes = (int) floor($timespan / 60));
-
- // Seconds ago, 1
- isset($seconds) and $seconds = $timespan;
-
- // Remove the variables that cannot be accessed
- unset($timespan, $time1, $time2);
-
- // Deny access to these variables
- $deny = array_flip(array('deny', 'key', 'difference', 'output'));
-
- // Return the difference
- $difference = array();
- foreach ($output as $key)
- {
- if (isset($$key) AND ! isset($deny[$key]))
- {
- // Add requested key to the output
- $difference[$key] = $$key;
- }
- }
-
- // Invalid output formats string
- if (empty($difference))
- return FALSE;
-
- // If only one output format was asked, don't put it in an array
- if (count($difference) === 1)
- return current($difference);
-
- // Return array
- return $difference;
- }
-
- /**
- * Returns time difference between two timestamps, in the format:
- * N year, N months, N weeks, N days, N hours, N minutes, and N seconds ago
- *
- * @param integer timestamp
- * @param integer timestamp, defaults to the current time
- * @param string formatting string
- * @return string
- */
- public static function timespan_string($time1, $time2 = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds')
- {
- if ($difference = date::timespan($time1, $time2, $output) AND is_array($difference))
- {
- // Determine the key of the last item in the array
- $last = end($difference);
- $last = key($difference);
-
- $span = array();
- foreach ($difference as $name => $amount)
- {
- if ($amount === 0)
- {
- // Skip empty amounts
- continue;
- }
-
- // Add the amount to the span
- $span[] = ($name === $last ? ' and ' : ', ').$amount.' '.($amount === 1 ? inflector::singular($name) : $name);
- }
-
- // If the difference is less than 60 seconds, remove the preceding and.
- if (count($span) === 1)
- {
- $span[0] = ltrim($span[0], 'and ');
- }
-
- // Replace difference by making the span into a string
- $difference = trim(implode('', $span), ',');
- }
- elseif (is_int($difference))
- {
- // Single-value return
- $difference = $difference.' '.($difference === 1 ? inflector::singular($output) : $output);
- }
-
- return $difference;
- }
-
-} // End date
\ No newline at end of file
diff --git a/kohana/helpers/download.php b/kohana/helpers/download.php
deleted file mode 100644
index 49fed42c..00000000
--- a/kohana/helpers/download.php
+++ /dev/null
@@ -1,105 +0,0 @@
-setUsername($config['options']['username']);
- empty($config['options']['password']) or $connection->setPassword($config['options']['password']);
-
- if ( ! empty($config['options']['auth']))
- {
- // Get the class name and params
- list ($class, $params) = arr::callback_string($config['options']['auth']);
-
- if ($class === 'PopB4Smtp')
- {
- // Load the PopB4Smtp class manually, due to its odd filename
- require Kohana::find_file('vendor', 'swift/Swift/Authenticator/$PopB4Smtp$');
- }
-
- // Prepare the class name for auto-loading
- $class = 'Swift_Authenticator_'.$class;
-
- // Attach the authenticator
- $connection->attachAuthenticator(($params === NULL) ? new $class : new $class($params[0]));
- }
-
- // Set the timeout to 5 seconds
- $connection->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
- break;
- case 'sendmail':
- // Create a sendmail connection
- $connection = new Swift_Connection_Sendmail
- (
- empty($config['options']) ? Swift_Connection_Sendmail::AUTO_DETECT : $config['options']
- );
-
- // Set the timeout to 5 seconds
- $connection->setTimeout(5);
- break;
- default:
- // Use the native connection
- $connection = new Swift_Connection_NativeMail($config['options']);
- break;
- }
-
- // Create the SwiftMailer instance
- return email::$mail = new Swift($connection);
- }
-
- /**
- * Send an email message.
- *
- * @param string|array recipient email (and name), or an array of To, Cc, Bcc names
- * @param string|array sender email (and name)
- * @param string message subject
- * @param string message body
- * @param boolean send email as HTML
- * @return integer number of emails sent
- */
- public static function send($to, $from, $subject, $message, $html = FALSE)
- {
- // Connect to SwiftMailer
- (email::$mail === NULL) and email::connect();
-
- // Determine the message type
- $html = ($html === TRUE) ? 'text/html' : 'text/plain';
-
- // Create the message
- $message = new Swift_Message($subject, $message, $html, '8bit', 'utf-8');
-
- if (is_string($to))
- {
- // Single recipient
- $recipients = new Swift_Address($to);
- }
- elseif (is_array($to))
- {
- if (isset($to[0]) AND isset($to[1]))
- {
- // Create To: address set
- $to = array('to' => $to);
- }
-
- // Create a list of recipients
- $recipients = new Swift_RecipientList;
-
- foreach ($to as $method => $set)
- {
- if ( ! in_array($method, array('to', 'cc', 'bcc')))
- {
- // Use To: by default
- $method = 'to';
- }
-
- // Create method name
- $method = 'add'.ucfirst($method);
-
- if (is_array($set))
- {
- // Add a recipient with name
- $recipients->$method($set[0], $set[1]);
- }
- else
- {
- // Add a recipient without name
- $recipients->$method($set);
- }
- }
- }
-
- if (is_string($from))
- {
- // From without a name
- $from = new Swift_Address($from);
- }
- elseif (is_array($from))
- {
- // From with a name
- $from = new Swift_Address($from[0], $from[1]);
- }
-
- return email::$mail->send($message, $recipients, $from);
- }
-
-} // End email
\ No newline at end of file
diff --git a/kohana/helpers/expires.php b/kohana/helpers/expires.php
deleted file mode 100644
index c43cc0cc..00000000
--- a/kohana/helpers/expires.php
+++ /dev/null
@@ -1,111 +0,0 @@
- 0)
- {
- // Re-send headers
- header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $mod_time));
- header('Expires: '.gmdate('D, d M Y H:i:s T', time() + $mod_time_diff));
- header('Cache-Control: max-age='.$mod_time_diff);
- header('Status: 304 Not Modified', TRUE, 304);
-
- // Prevent any output
- Event::add('system.display', array('expires', 'prevent_output'));
-
- // Exit to prevent other output
- exit;
- }
- }
-
- return FALSE;
- }
-
- /**
- * Check headers already created to not step on download or Img_lib's feet
- *
- * @return boolean
- */
- public static function check_headers()
- {
- foreach (headers_list() as $header)
- {
- if ((session_cache_limiter() == '' AND stripos($header, 'Last-Modified:') === 0)
- OR stripos($header, 'Expires:') === 0)
- {
- return FALSE;
- }
- }
-
- return TRUE;
- }
-
- /**
- * Prevent any output from being displayed. Executed during system.display.
- *
- * @return void
- */
- public static function prevent_output()
- {
- Kohana::$output = '';
- }
-
-} // End expires
\ No newline at end of file
diff --git a/kohana/helpers/feed.php b/kohana/helpers/feed.php
deleted file mode 100644
index 74bb2f6b..00000000
--- a/kohana/helpers/feed.php
+++ /dev/null
@@ -1,122 +0,0 @@
-channel) ? $feed->xpath('//item') : $feed->entry;
-
- $i = 0;
- $items = array();
-
- foreach ($feed as $item)
- {
- if ($limit > 0 AND $i++ === $limit)
- break;
-
- $items[] = (array) $item;
- }
-
- return $items;
- }
-
- /**
- * Creates a feed from the given parameters.
- *
- * @param array feed information
- * @param array items to add to the feed
- * @param string define which format to use
- * @param string define which encoding to use
- * @return string
- */
- public static function create($info, $items, $format = 'rss2', $encoding = 'UTF-8')
- {
- $info += array('title' => 'Generated Feed', 'link' => '', 'generator' => 'KohanaPHP');
-
- $feed = '';
- $feed = simplexml_load_string($feed);
-
- foreach ($info as $name => $value)
- {
- if (($name === 'pubDate' OR $name === 'lastBuildDate') AND (is_int($value) OR ctype_digit($value)))
- {
- // Convert timestamps to RFC 822 formatted dates
- $value = date(DATE_RFC822, $value);
- }
- elseif (($name === 'link' OR $name === 'docs') AND strpos($value, '://') === FALSE)
- {
- // Convert URIs to URLs
- $value = url::site($value, 'http');
- }
-
- // Add the info to the channel
- $feed->channel->addChild($name, $value);
- }
-
- foreach ($items as $item)
- {
- // Add the item to the channel
- $row = $feed->channel->addChild('item');
-
- foreach ($item as $name => $value)
- {
- if ($name === 'pubDate' AND (is_int($value) OR ctype_digit($value)))
- {
- // Convert timestamps to RFC 822 formatted dates
- $value = date(DATE_RFC822, $value);
- }
- elseif (($name === 'link' OR $name === 'guid') AND strpos($value, '://') === FALSE)
- {
- // Convert URIs to URLs
- $value = url::site($value, 'http');
- }
-
- // Add the info to the row
- $row->addChild($name, $value);
- }
- }
-
- return $feed->asXML();
- }
-
-} // End feed
\ No newline at end of file
diff --git a/kohana/helpers/file.php b/kohana/helpers/file.php
deleted file mode 100644
index b1b71740..00000000
--- a/kohana/helpers/file.php
+++ /dev/null
@@ -1,186 +0,0 @@
-'."\n";
-
- // Add hidden fields immediate after opening tag
- empty($hidden) or $form .= form::hidden($hidden);
-
- return $form;
- }
-
- /**
- * Generates an opening HTML form tag that can be used for uploading files.
- *
- * @param string form action attribute
- * @param array extra attributes
- * @param array hidden fields to be created immediately after the form tag
- * @return string
- */
- public static function open_multipart($action = NULL, $attr = array(), $hidden = array())
- {
- // Set multi-part form type
- $attr['enctype'] = 'multipart/form-data';
-
- return form::open($action, $attr, $hidden);
- }
-
- /**
- * Generates a fieldset opening tag.
- *
- * @param array html attributes
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function open_fieldset($data = NULL, $extra = '')
- {
- return ''."\n";
- }
-
- /**
- * Generates a legend tag for use with a fieldset.
- *
- * @param string legend text
- * @param array HTML attributes
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function legend($text = '', $data = NULL, $extra = '')
- {
- return ''."\n";
- }
-
- /**
- * Generates hidden form fields.
- * You can pass a simple key/value string or an associative array with multiple values.
- *
- * @param string|array input name (string) or key/value pairs (array)
- * @param string input value, if using an input name
- * @return string
- */
- public static function hidden($data, $value = '')
- {
- if ( ! is_array($data))
- {
- $data = array
- (
- $data => $value
- );
- }
-
- $input = '';
- foreach ($data as $name => $value)
- {
- $attr = array
- (
- 'type' => 'hidden',
- 'name' => $name,
- 'value' => $value
- );
-
- $input .= form::input($attr)."\n";
- }
-
- return $input;
- }
-
- /**
- * Creates an HTML form input tag. Defaults to a text type.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function input($data, $value = '', $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- // Type and value are required attributes
- $data += array
- (
- 'type' => 'text',
- 'value' => $value
- );
-
- return '';
- }
-
- /**
- * Creates a HTML form password input tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function password($data, $value = '', $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- $data['type'] = 'password';
-
- return form::input($data, $value, $extra);
- }
-
- /**
- * Creates an HTML form upload input tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function upload($data, $value = '', $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- $data['type'] = 'file';
-
- return form::input($data, $value, $extra);
- }
-
- /**
- * Creates an HTML form textarea tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param string a string to be attached to the end of the attributes
- * @param boolean encode existing entities
- * @return string
- */
- public static function textarea($data, $value = '', $extra = '', $double_encode = TRUE)
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- // Use the value from $data if possible, or use $value
- $value = isset($data['value']) ? $data['value'] : $value;
-
- // Value is not part of the attributes
- unset($data['value']);
-
- return '';
- }
-
- /**
- * Creates an HTML form select tag, or "dropdown menu".
- *
- * @param string|array input name or an array of HTML attributes
- * @param array select options, when using a name
- * @param string|array option key(s) that should be selected by default
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function dropdown($data, $options = NULL, $selected = NULL, $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
- else
- {
- if (isset($data['options']))
- {
- // Use data options
- $options = $data['options'];
- }
-
- if (isset($data['selected']))
- {
- // Use data selected
- $selected = $data['selected'];
- }
- }
-
- if (is_array($selected))
- {
- // Multi-select box
- $data['multiple'] = 'multiple';
- }
- else
- {
- // Single selection (but converted to an array)
- $selected = array($selected);
- }
-
- $input = '';
-
- return $input;
- }
-
- /**
- * Creates an HTML form checkbox input tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param boolean make the checkbox checked by default
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function checkbox($data, $value = '', $checked = FALSE, $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- $data['type'] = 'checkbox';
-
- if ($checked == TRUE OR (isset($data['checked']) AND $data['checked'] == TRUE))
- {
- $data['checked'] = 'checked';
- }
- else
- {
- unset($data['checked']);
- }
-
- return form::input($data, $value, $extra);
- }
-
- /**
- * Creates an HTML form radio input tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param boolean make the radio selected by default
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function radio($data = '', $value = '', $checked = FALSE, $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- $data['type'] = 'radio';
-
- if ($checked == TRUE OR (isset($data['checked']) AND $data['checked'] == TRUE))
- {
- $data['checked'] = 'checked';
- }
- else
- {
- unset($data['checked']);
- }
-
- return form::input($data, $value, $extra);
- }
-
- /**
- * Creates an HTML form submit input tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function submit($data = '', $value = '', $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- if (empty($data['name']))
- {
- // Remove the name if it is empty
- unset($data['name']);
- }
-
- $data['type'] = 'submit';
-
- return form::input($data, $value, $extra);
- }
-
- /**
- * Creates an HTML form button input tag.
- *
- * @param string|array input name or an array of HTML attributes
- * @param string input value, when using a name
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function button($data = '', $value = '', $extra = '')
- {
- if ( ! is_array($data))
- {
- $data = array('name' => $data);
- }
-
- if (empty($data['name']))
- {
- // Remove the name if it is empty
- unset($data['name']);
- }
-
- if (isset($data['value']) AND empty($value))
- {
- $value = arr::remove('value', $data);
- }
-
- return '';
- }
-
- /**
- * Closes an open form tag.
- *
- * @param string string to be attached after the closing tag
- * @return string
- */
- public static function close($extra = '')
- {
- return ''."\n".$extra;
- }
-
- /**
- * Creates an HTML form label tag.
- *
- * @param string|array label "for" name or an array of HTML attributes
- * @param string label text or HTML
- * @param string a string to be attached to the end of the attributes
- * @return string
- */
- public static function label($data = '', $text = NULL, $extra = '')
- {
- if ( ! is_array($data))
- {
- if (is_string($data))
- {
- // Specify the input this label is for
- $data = array('for' => $data);
- }
- else
- {
- // No input specified
- $data = array();
- }
- }
-
- if ($text === NULL AND isset($data['for']))
- {
- // Make the text the human-readable input name
- $text = ucwords(inflector::humanize($data['for']));
- }
-
- return '';
- }
-
- /**
- * Sorts a key/value array of HTML attributes, putting form attributes first,
- * and returns an attribute string.
- *
- * @param array HTML attributes array
- * @return string
- */
- public static function attributes($attr, $type = NULL)
- {
- if (empty($attr))
- return '';
-
- if (isset($attr['name']) AND empty($attr['id']) AND strpos($attr['name'], '[') === FALSE)
- {
- if ($type === NULL AND ! empty($attr['type']))
- {
- // Set the type by the attributes
- $type = $attr['type'];
- }
-
- switch ($type)
- {
- case 'text':
- case 'textarea':
- case 'password':
- case 'select':
- case 'checkbox':
- case 'file':
- case 'image':
- case 'button':
- case 'submit':
- // Only specific types of inputs use name to id matching
- $attr['id'] = $attr['name'];
- break;
- }
- }
-
- $order = array
- (
- 'action',
- 'method',
- 'type',
- 'id',
- 'name',
- 'value',
- 'src',
- 'size',
- 'maxlength',
- 'rows',
- 'cols',
- 'accept',
- 'tabindex',
- 'accesskey',
- 'align',
- 'alt',
- 'title',
- 'class',
- 'style',
- 'selected',
- 'checked',
- 'readonly',
- 'disabled'
- );
-
- $sorted = array();
- foreach ($order as $key)
- {
- if (isset($attr[$key]))
- {
- // Move the attribute to the sorted array
- $sorted[$key] = $attr[$key];
-
- // Remove the attribute from unsorted array
- unset($attr[$key]);
- }
- }
-
- // Combine the sorted and unsorted attributes and create an HTML string
- return html::attributes(array_merge($sorted, $attr));
- }
-
-} // End form
\ No newline at end of file
diff --git a/kohana/helpers/format.php b/kohana/helpers/format.php
deleted file mode 100644
index fb8a0294..00000000
--- a/kohana/helpers/format.php
+++ /dev/null
@@ -1,66 +0,0 @@
-='))
- {
- $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8', FALSE);
- }
- else
- {
- $str = preg_replace('/&(?!(?:#\d++|[a-z]++);)/ui', '&', $str);
- $str = str_replace(array('<', '>', '\'', '"'), array('<', '>', ''', '"'), $str);
- }
- }
-
- return $str;
- }
-
- /**
- * Perform a html::specialchars() with additional URL specific encoding.
- *
- * @param string string to convert
- * @param boolean encode existing entities
- * @return string
- */
- public static function specialurlencode($str, $double_encode = TRUE)
- {
- return str_replace(' ', '%20', html::specialchars($str, $double_encode));
- }
-
- /**
- * Create HTML link anchors.
- *
- * @param string URL or URI string
- * @param string link text
- * @param array HTML anchor attributes
- * @param string non-default protocol, eg: https
- * @return string
- */
- public static function anchor($uri, $title = NULL, $attributes = NULL, $protocol = NULL)
- {
- if ($uri === '')
- {
- $site_url = url::base(FALSE);
- }
- elseif (strpos($uri, '://') === FALSE AND strpos($uri, '#') !== 0)
- {
- $site_url = url::site($uri, $protocol);
- }
- else
- {
- if (html::$windowed_urls === TRUE AND empty($attributes['target']))
- {
- $attributes['target'] = '_blank';
- }
-
- $site_url = $uri;
- }
-
- return
- // Parsed URL
- ''
- // Title empty? Use the parsed URL
- .(($title === NULL) ? $site_url : $title).'';
- }
-
- /**
- * Creates an HTML anchor to a file.
- *
- * @param string name of file to link to
- * @param string link text
- * @param array HTML anchor attributes
- * @param string non-default protocol, eg: ftp
- * @return string
- */
- public static function file_anchor($file, $title = NULL, $attributes = NULL, $protocol = NULL)
- {
- return
- // Base URL + URI = full URL
- ''
- // Title empty? Use the filename part of the URI
- .(($title === NULL) ? end(explode('/', $file)) : $title) .'';
- }
-
- /**
- * Similar to anchor, but with the protocol parameter first.
- *
- * @param string link protocol
- * @param string URI or URL to link to
- * @param string link text
- * @param array HTML anchor attributes
- * @return string
- */
- public static function panchor($protocol, $uri, $title = NULL, $attributes = FALSE)
- {
- return html::anchor($uri, $title, $attributes, $protocol);
- }
-
- /**
- * Create an array of anchors from an array of link/title pairs.
- *
- * @param array link/title pairs
- * @return array
- */
- public static function anchor_array(array $array)
- {
- $anchors = array();
- foreach ($array as $link => $title)
- {
- // Create list of anchors
- $anchors[] = html::anchor($link, $title);
- }
- return $anchors;
- }
-
- /**
- * Generates an obfuscated version of an email address.
- *
- * @param string email address
- * @return string
- */
- public static function email($email)
- {
- $safe = '';
- foreach (str_split($email) as $letter)
- {
- switch (($letter === '@') ? rand(1, 2) : rand(1, 3))
- {
- // HTML entity code
- case 1: $safe .= ''.ord($letter).';'; break;
- // Hex character code
- case 2: $safe .= ''.dechex(ord($letter)).';'; break;
- // Raw (no) encoding
- case 3: $safe .= $letter;
- }
- }
-
- return $safe;
- }
-
- /**
- * Creates an email anchor.
- *
- * @param string email address to send to
- * @param string link text
- * @param array HTML anchor attributes
- * @return string
- */
- public static function mailto($email, $title = NULL, $attributes = NULL)
- {
- if (empty($email))
- return $title;
-
- // Remove the subject or other parameters that do not need to be encoded
- if (strpos($email, '?') !== FALSE)
- {
- // Extract the parameters from the email address
- list ($email, $params) = explode('?', $email, 2);
-
- // Make the params into a query string, replacing spaces
- $params = '?'.str_replace(' ', '%20', $params);
- }
- else
- {
- // No parameters
- $params = '';
- }
-
- // Obfuscate email address
- $safe = html::email($email);
-
- // Title defaults to the encoded email address
- empty($title) and $title = $safe;
-
- // Parse attributes
- empty($attributes) or $attributes = html::attributes($attributes);
-
- // Encoded start of the href="" is a static encoded version of 'mailto:'
- return ''.$title.'';
- }
-
- /**
- * Generate a "breadcrumb" list of anchors representing the URI.
- *
- * @param array segments to use as breadcrumbs, defaults to using Router::$segments
- * @return string
- */
- public static function breadcrumb($segments = NULL)
- {
- empty($segments) and $segments = Router::$segments;
-
- $array = array();
- while ($segment = array_pop($segments))
- {
- $array[] = html::anchor
- (
- // Complete URI for the URL
- implode('/', $segments).'/'.$segment,
- // Title for the current segment
- ucwords(inflector::humanize($segment))
- );
- }
-
- // Retrun the array of all the segments
- return array_reverse($array);
- }
-
- /**
- * Creates a meta tag.
- *
- * @param string|array tag name, or an array of tags
- * @param string tag "content" value
- * @return string
- */
- public static function meta($tag, $value = NULL)
- {
- if (is_array($tag))
- {
- $tags = array();
- foreach ($tag as $t => $v)
- {
- // Build each tag and add it to the array
- $tags[] = html::meta($t, $v);
- }
-
- // Return all of the tags as a string
- return implode("\n", $tags);
- }
-
- // Set the meta attribute value
- $attr = in_array(strtolower($tag), Kohana::config('http.meta_equiv')) ? 'http-equiv' : 'name';
-
- return '';
- }
-
- /**
- * Creates a stylesheet link.
- *
- * @param string|array filename, or array of filenames to match to array of medias
- * @param string|array media type of stylesheet, or array to match filenames
- * @param boolean include the index_page in the link
- * @return string
- */
- public static function stylesheet($style, $media = FALSE, $index = FALSE)
- {
- return html::link($style, 'stylesheet', 'text/css', '.css', $media, $index);
- }
-
- /**
- * Creates a link tag.
- *
- * @param string|array filename
- * @param string|array relationship
- * @param string|array mimetype
- * @param string specifies suffix of the file
- * @param string|array specifies on what device the document will be displayed
- * @param boolean include the index_page in the link
- * @return string
- */
- public static function link($href, $rel, $type, $suffix = FALSE, $media = FALSE, $index = FALSE)
- {
- $compiled = '';
-
- if (is_array($href))
- {
- foreach ($href as $_href)
- {
- $_rel = is_array($rel) ? array_shift($rel) : $rel;
- $_type = is_array($type) ? array_shift($type) : $type;
- $_media = is_array($media) ? array_shift($media) : $media;
-
- $compiled .= html::link($_href, $_rel, $_type, $suffix, $_media, $index);
- }
- }
- else
- {
- if (strpos($href, '://') === FALSE)
- {
- // Make the URL absolute
- $href = url::base($index).$href;
- }
-
- $length = strlen($suffix);
-
- if ( $length > 0 AND substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
- {
- // Add the defined suffix
- $href .= $suffix;
- }
-
- $attr = array
- (
- 'rel' => $rel,
- 'type' => $type,
- 'href' => $href,
- );
-
- if ( ! empty($media))
- {
- // Add the media type to the attributes
- $attr['media'] = $media;
- }
-
- $compiled = '';
- }
-
- return $compiled."\n";
- }
-
- /**
- * Creates a script link.
- *
- * @param string|array filename
- * @param boolean include the index_page in the link
- * @return string
- */
- public static function script($script, $index = FALSE)
- {
- $compiled = '';
-
- if (is_array($script))
- {
- foreach ($script as $name)
- {
- $compiled .= html::script($name, $index);
- }
- }
- else
- {
- if (strpos($script, '://') === FALSE)
- {
- // Add the suffix only when it's not already present
- $script = url::base((bool) $index).$script;
- }
-
- if (substr_compare($script, '.js', -3, 3, FALSE) !== 0)
- {
- // Add the javascript suffix
- $script .= '.js';
- }
-
- $compiled = '';
- }
-
- return $compiled."\n";
- }
-
- /**
- * Creates a image link.
- *
- * @param string image source, or an array of attributes
- * @param string|array image alt attribute, or an array of attributes
- * @param boolean include the index_page in the link
- * @return string
- */
- public static function image($src = NULL, $alt = NULL, $index = FALSE)
- {
- // Create attribute list
- $attributes = is_array($src) ? $src : array('src' => $src);
-
- if (is_array($alt))
- {
- $attributes += $alt;
- }
- elseif ( ! empty($alt))
- {
- // Add alt to attributes
- $attributes['alt'] = $alt;
- }
-
- if (strpos($attributes['src'], '://') === FALSE)
- {
- // Make the src attribute into an absolute URL
- $attributes['src'] = url::base($index).$attributes['src'];
- }
-
- return '';
- }
-
- /**
- * Compiles an array of HTML attributes into an attribute string.
- *
- * @param string|array array of attributes
- * @return string
- */
- public static function attributes($attrs)
- {
- if (empty($attrs))
- return '';
-
- if (is_string($attrs))
- return ' '.$attrs;
-
- $compiled = '';
- foreach ($attrs as $key => $val)
- {
- $compiled .= ' '.$key.'="'.html::specialchars($val).'"';
- }
-
- return $compiled;
- }
-
-} // End html
diff --git a/kohana/helpers/inflector.php b/kohana/helpers/inflector.php
deleted file mode 100644
index 1e4fee23..00000000
--- a/kohana/helpers/inflector.php
+++ /dev/null
@@ -1,193 +0,0 @@
- 1)
- return $str;
-
- // Cache key name
- $key = 'singular_'.$str.$count;
-
- if (isset(inflector::$cache[$key]))
- return inflector::$cache[$key];
-
- if (inflector::uncountable($str))
- return inflector::$cache[$key] = $str;
-
- if (empty(inflector::$irregular))
- {
- // Cache irregular words
- inflector::$irregular = Kohana::config('inflector.irregular');
- }
-
- if ($irregular = array_search($str, inflector::$irregular))
- {
- $str = $irregular;
- }
- elseif (preg_match('/[sxz]es$/', $str) OR preg_match('/[^aeioudgkprt]hes$/', $str))
- {
- // Remove "es"
- $str = substr($str, 0, -2);
- }
- elseif (preg_match('/[^aeiou]ies$/', $str))
- {
- $str = substr($str, 0, -3).'y';
- }
- elseif (substr($str, -1) === 's' AND substr($str, -2) !== 'ss')
- {
- $str = substr($str, 0, -1);
- }
-
- return inflector::$cache[$key] = $str;
- }
-
- /**
- * Makes a singular word plural.
- *
- * @param string word to pluralize
- * @return string
- */
- public static function plural($str, $count = NULL)
- {
- // Remove garbage
- $str = strtolower(trim($str));
-
- if (is_string($count))
- {
- // Convert to integer when using a digit string
- $count = (int) $count;
- }
-
- // Do nothing with singular
- if ($count === 1)
- return $str;
-
- // Cache key name
- $key = 'plural_'.$str.$count;
-
- if (isset(inflector::$cache[$key]))
- return inflector::$cache[$key];
-
- if (inflector::uncountable($str))
- return inflector::$cache[$key] = $str;
-
- if (empty(inflector::$irregular))
- {
- // Cache irregular words
- inflector::$irregular = Kohana::config('inflector.irregular');
- }
-
- if (isset(inflector::$irregular[$str]))
- {
- $str = inflector::$irregular[$str];
- }
- elseif (preg_match('/[sxz]$/', $str) OR preg_match('/[^aeioudgkprt]h$/', $str))
- {
- $str .= 'es';
- }
- elseif (preg_match('/[^aeiou]y$/', $str))
- {
- // Change "y" to "ies"
- $str = substr_replace($str, 'ies', -1);
- }
- else
- {
- $str .= 's';
- }
-
- // Set the cache and return
- return inflector::$cache[$key] = $str;
- }
-
- /**
- * Makes a phrase camel case.
- *
- * @param string phrase to camelize
- * @return string
- */
- public static function camelize($str)
- {
- $str = 'x'.strtolower(trim($str));
- $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
-
- return substr(str_replace(' ', '', $str), 1);
- }
-
- /**
- * Makes a phrase underscored instead of spaced.
- *
- * @param string phrase to underscore
- * @return string
- */
- public static function underscore($str)
- {
- return preg_replace('/\s+/', '_', trim($str));
- }
-
- /**
- * Makes an underscored or dashed phrase human-reable.
- *
- * @param string phrase to make human-reable
- * @return string
- */
- public static function humanize($str)
- {
- return preg_replace('/[_-]+/', ' ', trim($str));
- }
-
-} // End inflector
\ No newline at end of file
diff --git a/kohana/helpers/num.php b/kohana/helpers/num.php
deleted file mode 100644
index 3eb5d5ac..00000000
--- a/kohana/helpers/num.php
+++ /dev/null
@@ -1,26 +0,0 @@
- 0);
- }
-
- /**
- * Compare the q values for given array of content types and return the one with the highest value.
- * If items are found to have the same q value, the first one encountered in the given array wins.
- * If all items in the given array have a q value of 0, FALSE is returned.
- *
- * @param array content types
- * @param boolean set to TRUE to disable wildcard checking
- * @return mixed string mime type with highest q value, FALSE if none of the given types are accepted
- */
- public static function preferred_accept($types, $explicit_check = FALSE)
- {
- // Initialize
- $mime_types = array();
- $max_q = 0;
- $preferred = FALSE;
-
- // Load q values for all given content types
- foreach (array_unique($types) as $type)
- {
- $mime_types[$type] = request::accepts_at_quality($type, $explicit_check);
- }
-
- // Look for the highest q value
- foreach ($mime_types as $type => $q)
- {
- if ($q > $max_q)
- {
- $max_q = $q;
- $preferred = $type;
- }
- }
-
- return $preferred;
- }
-
- /**
- * Returns quality factor at which the client accepts content type.
- *
- * @param string content type (e.g. "image/jpg", "jpg")
- * @param boolean set to TRUE to disable wildcard checking
- * @return integer|float
- */
- public static function accepts_at_quality($type = NULL, $explicit_check = FALSE)
- {
- request::parse_accept_header();
-
- // Normalize type
- $type = strtolower((string) $type);
-
- // General content type (e.g. "jpg")
- if (strpos($type, '/') === FALSE)
- {
- // Don't accept anything by default
- $q = 0;
-
- // Look up relevant mime types
- foreach ((array) Kohana::config('mimes.'.$type) as $type)
- {
- $q2 = request::accepts_at_quality($type, $explicit_check);
- $q = ($q2 > $q) ? $q2 : $q;
- }
-
- return $q;
- }
-
- // Content type with subtype given (e.g. "image/jpg")
- $type = explode('/', $type, 2);
-
- // Exact match
- if (isset(request::$accept_types[$type[0]][$type[1]]))
- return request::$accept_types[$type[0]][$type[1]];
-
- // Wildcard match (if not checking explicitly)
- if ($explicit_check === FALSE AND isset(request::$accept_types[$type[0]]['*']))
- return request::$accept_types[$type[0]]['*'];
-
- // Catch-all wildcard match (if not checking explicitly)
- if ($explicit_check === FALSE AND isset(request::$accept_types['*']['*']))
- return request::$accept_types['*']['*'];
-
- // Content type not accepted
- return 0;
- }
-
- /**
- * Parses client's HTTP Accept request header, and builds array structure representing it.
- *
- * @return void
- */
- protected static function parse_accept_header()
- {
- // Run this function just once
- if (request::$accept_types !== NULL)
- return;
-
- // Initialize accept_types array
- request::$accept_types = array();
-
- // No HTTP Accept header found
- if (empty($_SERVER['HTTP_ACCEPT']))
- {
- // Accept everything
- request::$accept_types['*']['*'] = 1;
- return;
- }
-
- // Remove linebreaks and parse the HTTP Accept header
- foreach (explode(',', str_replace(array("\r", "\n"), '', $_SERVER['HTTP_ACCEPT'])) as $accept_entry)
- {
- // Explode each entry in content type and possible quality factor
- $accept_entry = explode(';', trim($accept_entry), 2);
-
- // Explode each content type (e.g. "text/html")
- $type = explode('/', $accept_entry[0], 2);
-
- // Skip invalid content types
- if ( ! isset($type[1]))
- continue;
-
- // Assume a default quality factor of 1 if no custom q value found
- $q = (isset($accept_entry[1]) AND preg_match('~\bq\s*+=\s*+([.0-9]+)~', $accept_entry[1], $match)) ? (float) $match[1] : 1;
-
- // Populate accept_types array
- if ( ! isset(request::$accept_types[$type[0]][$type[1]]) OR $q > request::$accept_types[$type[0]][$type[1]])
- {
- request::$accept_types[$type[0]][$type[1]] = $q;
- }
- }
- }
-
-} // End request
\ No newline at end of file
diff --git a/kohana/helpers/security.php b/kohana/helpers/security.php
deleted file mode 100644
index cd48d2e0..00000000
--- a/kohana/helpers/security.php
+++ /dev/null
@@ -1,47 +0,0 @@
-xss_clean($str);
- }
-
- /**
- * Remove image tags from a string.
- *
- * @param string string to sanitize
- * @return string
- */
- public static function strip_image_tags($str)
- {
- return preg_replace('#\s]*)["\']?[^>]*)?>#is', '$1', $str);
- }
-
- /**
- * Remove PHP tags from a string.
- *
- * @param string string to sanitize
- * @return string
- */
- public static function encode_php_tags($str)
- {
- return str_replace(array('', '?>'), array('<?', '?>'), $str);
- }
-
-} // End security
\ No newline at end of file
diff --git a/kohana/helpers/text.php b/kohana/helpers/text.php
deleted file mode 100644
index d0e573ec..00000000
--- a/kohana/helpers/text.php
+++ /dev/null
@@ -1,410 +0,0 @@
- 1)
- {
- if (ctype_alpha($str))
- {
- // Add a random digit
- $str[mt_rand(0, $length - 1)] = chr(mt_rand(48, 57));
- }
- elseif (ctype_digit($str))
- {
- // Add a random letter
- $str[mt_rand(0, $length - 1)] = chr(mt_rand(65, 90));
- }
- }
-
- return $str;
- }
-
- /**
- * Reduces multiple slashes in a string to single slashes.
- *
- * @param string string to reduce slashes of
- * @return string
- */
- public static function reduce_slashes($str)
- {
- return preg_replace('#(? $badword)
- {
- $badwords[$key] = str_replace('\*', '\S*?', preg_quote((string) $badword));
- }
-
- $regex = '('.implode('|', $badwords).')';
-
- if ($replace_partial_words == TRUE)
- {
- // Just using \b isn't sufficient when we need to replace a badword that already contains word boundaries itself
- $regex = '(?<=\b|\s|^)'.$regex.'(?=\b|\s|$)';
- }
-
- $regex = '!'.$regex.'!ui';
-
- if (utf8::strlen($replacement) == 1)
- {
- $regex .= 'e';
- return preg_replace($regex, 'str_repeat($replacement, utf8::strlen(\'$1\'))', $str);
- }
-
- return preg_replace($regex, $replacement, $str);
- }
-
- /**
- * Finds the text that is similar between a set of words.
- *
- * @param array words to find similar text of
- * @return string
- */
- public static function similar(array $words)
- {
- // First word is the word to match against
- $word = current($words);
-
- for ($i = 0, $max = strlen($word); $i < $max; ++$i)
- {
- foreach ($words as $w)
- {
- // Once a difference is found, break out of the loops
- if ( ! isset($w[$i]) OR $w[$i] !== $word[$i])
- break 2;
- }
- }
-
- // Return the similar text
- return substr($word, 0, $i);
- }
-
- /**
- * Converts text email addresses and anchors into links.
- *
- * @param string text to auto link
- * @return string
- */
- public static function auto_link($text)
- {
- // Auto link emails first to prevent problems with "www.domain.com@example.com"
- return text::auto_link_urls(text::auto_link_emails($text));
- }
-
- /**
- * Converts text anchors into links.
- *
- * @param string text to auto link
- * @return string
- */
- public static function auto_link_urls($text)
- {
- // Finds all http/https/ftp/ftps links that are not part of an existing html anchor
- if (preg_match_all('~\b(?)(?:ht|f)tps?://\S+(?:/|\b)~i', $text, $matches))
- {
- foreach ($matches[0] as $match)
- {
- // Replace each link with an anchor
- $text = str_replace($match, html::anchor($match), $text);
- }
- }
-
- // Find all naked www.links.com (without http://)
- if (preg_match_all('~\b(?|58;)(?!\.)[-+_a-z0-9.]++(? and markup to text. Basically nl2br() on steroids.
- *
- * @param string subject
- * @return string
- */
- public static function auto_p($str)
- {
- // Trim whitespace
- if (($str = trim($str)) === '')
- return '';
-
- // Standardize newlines
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
-
- // Trim whitespace on each line
- $str = preg_replace('~^[ \t]+~m', '', $str);
- $str = preg_replace('~[ \t]+$~m', '', $str);
-
- // The following regexes only need to be executed if the string contains html
- if ($html_found = (strpos($str, '<') !== FALSE))
- {
- // Elements that should not be surrounded by p tags
- $no_p = '(?:p|div|h[1-6r]|ul|ol|li|blockquote|d[dlt]|pre|t[dhr]|t(?:able|body|foot|head)|c(?:aption|olgroup)|form|s(?:elect|tyle)|a(?:ddress|rea)|ma(?:p|th))';
-
- // Put at least two linebreaks before and after $no_p elements
- $str = preg_replace('~^<'.$no_p.'[^>]*+>~im', "\n$0", $str);
- $str = preg_replace('~'.$no_p.'\s*+>$~im', "$0\n", $str);
- }
-
- // Do the
magic!
- $str = '
'.trim($str).'
';
- $str = preg_replace('~\n{2,}~', "
\n\n
", $str);
-
- // The following regexes only need to be executed if the string contains html
- if ($html_found !== FALSE)
- {
- // Remove p tags around $no_p elements
- $str = preg_replace('~