New upstream version 0.6.27

This commit is contained in:
geos_one
2025-08-06 18:11:51 +02:00
parent a6b4158f1f
commit 56a986c0ba
563 changed files with 45811 additions and 35282 deletions

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Cache
*
@@ -25,8 +29,8 @@
*/
$config['default'] = array
(
'driver' => 'file',
'params' => APPPATH.'cache',
'lifetime' => 1800,
'requests' => 1000
'driver' => 'file',
'params' => APPPATH . 'cache',
'lifetime' => 1800,
'requests' => 1000
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Cache:Memcache
*
@@ -6,15 +10,15 @@
*/
$config['servers'] = array
(
array
(
'host' => '127.0.0.1',
'port' => 11211,
'persistent' => FALSE,
)
array
(
'host' => '127.0.0.1',
'port' => 11211,
'persistent' => false,
)
);
/**
* Enable cache data compression.
*/
$config['compression'] = FALSE;
$config['compression'] = false;

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Cache:SQLite
*/
@@ -7,4 +11,4 @@ $config['schema'] =
id VARCHAR(127) PRIMARY KEY,
tags VARCHAR(255),
expiration INTEGER,
cache TEXT);';
cache TEXT);';

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Cache:Xcache
*

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
@@ -18,12 +22,12 @@
*/
$config['default'] = array
(
'style' => 'basic',
'width' => 150,
'height' => 50,
'complexity' => 4,
'background' => '',
'fontpath' => SYSPATH.'fonts/',
'fonts' => array('DejaVuSerif.ttf'),
'promote' => FALSE,
);
'style' => 'basic',
'width' => 150,
'height' => 50,
'complexity' => 4,
'background' => '',
'fontpath' => SYSPATH . 'fonts/',
'fonts' => array('DejaVuSerif.ttf'),
'promote' => false,
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
@@ -23,10 +27,10 @@ $config['expire'] = 0;
* Enable this option to only allow the cookie to be read when using the a
* secure protocol.
*/
$config['secure'] = FALSE;
$config['secure'] = false;
/**
* Enable this option to disable the cookie from being accessed when using a
* secure protocol. This option is only available in PHP 5.2 and above.
*/
$config['httponly'] = FALSE;
$config['httponly'] = false;

View File

@@ -1,7 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* Credit card validation configuration.
*
*
* Options for each credit card:
* length - All the allowed card number lengths, in a comma separated string
* prefix - The digits the card needs to start with, in regex format
@@ -9,52 +13,52 @@
*/
$config = array
(
'default' => 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
),
);
'default' => 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
),
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Database
*
@@ -21,25 +25,25 @@
* table_prefix - Database table prefix
* object - Enable or disable object results
* cache - Enable or disable query caching
* escape - Enable automatic query builder escaping
* 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
);
'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
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* SwiftMailer driver, used with the email helper.
*
@@ -19,4 +23,4 @@ $config['driver'] = 'native';
* @param string sendmail: executable path, with -bs or equivalent attached
* @param array smtp: hostname, (username), (password), (port), (auth), (encryption)
*/
$config['options'] = NULL;
$config['options'] = null;

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Encrypt
*
@@ -25,7 +29,7 @@
*/
$config['default'] = array
(
'key' => 'K0H@NA+PHP_7hE-SW!FtFraM3w0R|<',
'mode' => MCRYPT_MODE_NOFB,
'cipher' => MCRYPT_RIJNDAEL_128
'key' => 'K0H@NA+PHP_7hE-SW!FtFraM3w0R|<',
'mode' => MCRYPT_MODE_NOFB,
'cipher' => MCRYPT_RIJNDAEL_128
);

View File

@@ -1,19 +1,23 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// HTTP-EQUIV type meta tags
$config['meta_equiv'] = array
(
'cache-control',
'content-type', 'content-script-type', 'content-style-type',
'content-disposition',
'content-language',
'default-style',
'expires',
'ext-cache',
'pics-label',
'pragma',
'refresh',
'set-cookie',
'vary',
'window-target',
);
'cache-control',
'content-type', 'content-script-type', 'content-style-type',
'content-disposition',
'content-language',
'default-style',
'expires',
'ext-cache',
'pics-label',
'pragma',
'refresh',
'set-cookie',
'vary',
'window-target',
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Image
*
@@ -10,4 +14,4 @@ $config['driver'] = 'GD';
* Driver parameters:
* ImageMagick - set the "directory" parameter to your ImageMagick installation directory
*/
$config['params'] = array();
$config['params'] = array();

View File

@@ -1,58 +1,62 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$config['uncountable'] = array
(
'access',
'advice',
'art',
'baggage',
'dances',
'equipment',
'fish',
'fuel',
'furniture',
'food',
'heat',
'honey',
'homework',
'impatience',
'information',
'knowledge',
'luggage',
'money',
'music',
'news',
'patience',
'progress',
'pollution',
'research',
'rice',
'sand',
'series',
'sheep',
'sms',
'species',
'staff',
'toothpaste',
'traffic',
'understanding',
'water',
'weather',
'work',
'access',
'advice',
'art',
'baggage',
'dances',
'equipment',
'fish',
'fuel',
'furniture',
'food',
'heat',
'honey',
'homework',
'impatience',
'information',
'knowledge',
'luggage',
'money',
'music',
'news',
'patience',
'progress',
'pollution',
'research',
'rice',
'sand',
'series',
'sheep',
'sms',
'species',
'staff',
'toothpaste',
'traffic',
'understanding',
'water',
'weather',
'work',
);
$config['irregular'] = array
(
'child' => 'children',
'clothes' => 'clothing',
'man' => 'men',
'movie' => 'movies',
'person' => 'people',
'woman' => 'women',
'mouse' => 'mice',
'goose' => 'geese',
'ox' => 'oxen',
'leaf' => 'leaves',
'course' => 'courses',
'size' => 'sizes',
'child' => 'children',
'clothes' => 'clothing',
'man' => 'men',
'movie' => 'movies',
'person' => 'people',
'woman' => 'women',
'mouse' => 'mice',
'goose' => 'geese',
'ox' => 'oxen',
'leaf' => 'leaves',
'course' => 'courses',
'size' => 'sizes',
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
@@ -13,4 +17,4 @@ $config['language'] = array('en_US', 'English_United States');
* Locale timezone. Defaults to use the server timezone.
* @see http://php.net/timezones
*/
$config['timezone'] = '';
$config['timezone'] = '';

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
@@ -11,214 +15,214 @@
*/
$config = array
(
'323' => 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')
'323' => 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')
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Pagination
*
@@ -16,10 +20,10 @@
*/
$config['default'] = array
(
'directory' => 'pagination',
'style' => 'classic',
'uri_segment' => 3,
'query_string' => '',
'items_per_page' => 20,
'auto_hide' => FALSE,
'directory' => 'pagination',
'style' => 'classic',
'uri_segment' => 3,
'query_string' => '',
'items_per_page' => 20,
'auto_hide' => false,
);

View File

@@ -1,8 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Profiler
*
* Array of section names to display in the Profiler, TRUE to display all of them.
* Built in sections are benchmarks, database, session, post and cookies, custom sections can be used too.
*/
$config['show'] = TRUE;
$config['show'] = true;

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Session
*
@@ -27,7 +31,7 @@ $config['validate'] = array('user_agent');
* Note: this has no effect on the native session driver.
* Note: the cookie driver always encrypts session data. Set to TRUE for stronger encryption.
*/
$config['encryption'] = FALSE;
$config['encryption'] = false;
/**
* Session lifetime. Number of seconds that each session will last.
@@ -44,4 +48,4 @@ $config['regenerate'] = 3;
/**
* Percentage probability that the gc (garbage collection) routine is started.
*/
$config['gc_probability'] = 2;
$config['gc_probability'] = 2;

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Database
*
@@ -8,27 +12,27 @@
*/
$config = array
(
'tinyint' => 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')
'tinyint' => 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

View File

@@ -1,17 +1,21 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
* This path is relative to your index file. Absolute paths are also supported.
*/
$config['directory'] = DOCROOT.'upload';
$config['directory'] = DOCROOT . 'upload';
/**
* Enable or disable directory creation.
*/
$config['create_directories'] = FALSE;
$config['create_directories'] = false;
/**
* Remove spaces from uploaded filenames.
*/
$config['remove_spaces'] = TRUE;
$config['remove_spaces'] = true;

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
@@ -9,104 +13,104 @@
*/
$config['platform'] = array
(
'windows nt 6.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',
'windows nt 6.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',
'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',
'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',
);
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'askjeeves' => 'AskJeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
);

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* @package Core
*
@@ -6,12 +10,12 @@
*/
$config['allowed_filetypes'] = array
(
'gif',
'jpg', 'jpeg',
'png',
'tif', 'tiff',
'swf',
'htm', 'html',
'css',
'js'
'gif',
'jpg', 'jpeg',
'png',
'tif', 'tiff',
'swf',
'htm', 'html',
'css',
'js'
);

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Outputs the dynamic Captcha resource.
* Usage: Call the Captcha controller from a view, e.g.
@@ -11,13 +18,13 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Controller extends Controller {
public function __call($method, $args)
{
// Output the Captcha challenge resource (no html)
// Pull the config group name from the URL
Captcha::factory($this->uri->segment(2))->render(FALSE);
}
} // End Captcha_Controller
class Captcha_Controller extends Controller
{
public function __call($method, $args)
{
// Output the Captcha challenge resource (no html)
// Pull the config group name from the URL
Captcha::factory($this->uri->segment(2))->render(false);
}
}
// End Captcha_Controller

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Allows a template to be automatically loaded and displayed. Display can be
* dynamically turned off in the controller methods, and the template file
@@ -14,41 +22,39 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
abstract class Template_Controller extends Controller {
abstract class Template_Controller extends Controller
{
// Template view name
public $template = 'template';
// Template view name
public $template = 'template';
// Default to do auto-rendering
public $auto_render = true;
// Default to do auto-rendering
public $auto_render = TRUE;
/**
* Template loading and setup routine.
*/
public function __construct()
{
parent::__construct();
/**
* Template loading and setup routine.
*/
public function __construct()
{
parent::__construct();
// Load the template
$this->template = new View($this->template);
// Load the template
$this->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, 'Xrender'));
}
}
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
/**
* Render the loaded template.
*/
public function Xrender()
{
if ($this->auto_render == true) {
// Render the template when the class is destroyed
$this->template->render(true);
}
}
}
// End Template_Controller

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* Simple benchmarking.
*
@@ -9,117 +16,111 @@
* @copyright (c) 2007 Kohana Team
* @license http://kohanaphp.com/license.html
*/
final class Benchmark {
final class Benchmark
{
// Benchmark timestamps
private static $marks;
// Benchmark timestamps
private static $marks;
/**
* Set a benchmark start point.
*
* @param string benchmark name
* @return void
*/
public static function start($name)
{
if (! isset(self::$marks[$name])) {
self::$marks[$name] = array();
}
/**
* Set a benchmark start point.
*
* @param string benchmark name
* @return void
*/
public static function start($name)
{
if ( ! isset(self::$marks[$name]))
{
self::$marks[$name] = array();
}
$mark = array
(
'start' => microtime(true),
'stop' => false,
'memory_start' => self::memory_usage(),
'memory_stop' => false
);
$mark = array
(
'start' => microtime(TRUE),
'stop' => FALSE,
'memory_start' => self::memory_usage(),
'memory_stop' => FALSE
);
array_unshift(self::$marks[$name], $mark);
}
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();
}
}
/**
* 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);
/**
* 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);
}
foreach ($names as $name)
{
// Get each mark recursively
$times[$name] = self::get($name, $decimals);
}
// Return the array
return $times;
}
// Return the array
return $times;
}
if (! isset(self::$marks[$name])) {
return false;
}
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);
}
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 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])
);
}
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;
/**
* 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');
}
if ($func === NULL)
{
// Test if memory usage can be seen
$func = function_exists('memory_get_usage');
}
return $func ? memory_get_usage() : 0;
}
} // End Benchmark
return $func ? memory_get_usage() : 0;
}
}
// End Benchmark

View File

@@ -1,7 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
/**
* Kohana process control file, loaded by the front controller.
*
*
* $Id: Bootstrap.php 4409 2009-06-06 00:48:26Z zombor $
*
* @package Core
@@ -10,7 +14,7 @@
* @license http://kohanaphp.com/license.html
*/
define('KOHANA_VERSION', '2.3.4');
define('KOHANA_VERSION', '2.3.4');
define('KOHANA_CODENAME', 'buteo regalis');
// Test of Kohana is running in Windows
@@ -20,27 +24,28 @@ define('KOHANA_IS_WIN', DIRECTORY_SEPARATOR === '\\');
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH.'core/Benchmark'.EXT;
require SYSPATH . 'core/Benchmark' . EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK.'_total_execution');
Benchmark::start(SYSTEM_BENCHMARK . '_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading');
Benchmark::start(SYSTEM_BENCHMARK . '_kohana_loading');
// Load core files
require SYSPATH.'core/utf8'.EXT;
require SYSPATH.'core/Event'.EXT;
require SYSPATH.'core/Kohana'.EXT;
require SYSPATH . 'core/utf8' . EXT;
require SYSPATH . 'core/Event' . EXT;
require SYSPATH . 'core/Security' . EXT;
require SYSPATH . 'core/Kohana' . EXT;
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading');
Benchmark::stop(SYSTEM_BENCHMARK . '_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization');
Benchmark::start(SYSTEM_BENCHMARK . '_system_initialization');
// Prepare the system
Event::run('system.ready');
@@ -49,7 +54,7 @@ Event::run('system.ready');
Event::run('system.routing');
// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization');
Benchmark::stop(SYSTEM_BENCHMARK . '_system_initialization');
// Make the magic happen!
Event::run('system.execute');

View File

@@ -1,4 +1,10 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* Process queuing/execution class. Allows an unlimited number of callbacks
* to be added to 'events'. Events can be run multiple times, and can also
@@ -12,221 +18,203 @@
* @license http://kohanaphp.com/license.html
* @link http://docs.kohanaphp.com/general/events
*/
final class Event {
final class Event
{
// Event callbacks
private static $events = array();
// Event callbacks
private static $events = array();
// Cache of events that have been run
private static $has_run = array();
// Cache of events that have been run
private static $has_run = array();
// Data that can be processed during events
public static $data;
// Data that can be processed during events
public static $data;
/**
* Add a callback to an event queue.
*
* @param string event name
* @param array http://php.net/callback
* @return boolean
*/
public static function add($name, $callback)
{
if (! isset(self::$events[$name])) {
// Create an empty event if it is not yet defined
self::$events[$name] = array();
} elseif (in_array($callback, self::$events[$name], true)) {
// The event already exists
return false;
}
/**
* Add a callback to an event queue.
*
* @param string event name
* @param array http://php.net/callback
* @return boolean
*/
public static function add($name, $callback)
{
if ( ! isset(self::$events[$name]))
{
// Create an empty event if it is not yet defined
self::$events[$name] = array();
}
elseif (in_array($callback, self::$events[$name], TRUE))
{
// The event already exists
return FALSE;
}
// Add the event
self::$events[$name][] = $callback;
// Add the event
self::$events[$name][] = $callback;
return true;
}
return TRUE;
}
/**
* Add a callback to an event queue, before a given event.
*
* @param string event name
* @param array existing event callback
* @param array event callback
* @return boolean
*/
public static function add_before($name, $existing, $callback)
{
if (empty(self::$events[$name]) or ($key = array_search($existing, self::$events[$name])) === false) {
// Just add the event if there are no events
return self::add($name, $callback);
} else {
// Insert the event immediately before the existing event
return self::insert_event($name, $key, $callback);
}
}
/**
* Add a callback to an event queue, before a given event.
*
* @param string event name
* @param array existing event callback
* @param array event callback
* @return boolean
*/
public static function add_before($name, $existing, $callback)
{
if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name])) === FALSE)
{
// Just add the event if there are no events
return self::add($name, $callback);
}
else
{
// Insert the event immediately before the existing event
return self::insert_event($name, $key, $callback);
}
}
/**
* Add a callback to an event queue, after a given event.
*
* @param string event name
* @param array existing event callback
* @param array event callback
* @return boolean
*/
public static function add_after($name, $existing, $callback)
{
if (empty(self::$events[$name]) or ($key = array_search($existing, self::$events[$name])) === false) {
// Just add the event if there are no events
return self::add($name, $callback);
} else {
// Insert the event immediately after the existing event
return self::insert_event($name, $key + 1, $callback);
}
}
/**
* Add a callback to an event queue, after a given event.
*
* @param string event name
* @param array existing event callback
* @param array event callback
* @return boolean
*/
public static function add_after($name, $existing, $callback)
{
if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name])) === FALSE)
{
// Just add the event if there are no events
return self::add($name, $callback);
}
else
{
// Insert the event immediately after the existing event
return self::insert_event($name, $key + 1, $callback);
}
}
/**
* Inserts a new event at a specfic key location.
*
* @param string event name
* @param integer key to insert new event at
* @param array event callback
* @return void
*/
private static function insert_event($name, $key, $callback)
{
if (in_array($callback, self::$events[$name], true)) {
return false;
}
/**
* Inserts a new event at a specfic key location.
*
* @param string event name
* @param integer key to insert new event at
* @param array event callback
* @return void
*/
private static function insert_event($name, $key, $callback)
{
if (in_array($callback, self::$events[$name], TRUE))
return FALSE;
// Add the new event at the given key location
self::$events[$name] = array_merge(
// Events before the key
array_slice(self::$events[$name], 0, $key),
// New event callback
array($callback),
// Events after the key
array_slice(self::$events[$name], $key)
);
// Add the new event at the given key location
self::$events[$name] = array_merge
(
// Events before the key
array_slice(self::$events[$name], 0, $key),
// New event callback
array($callback),
// Events after the key
array_slice(self::$events[$name], $key)
);
return true;
}
return TRUE;
}
/**
* Replaces an event with another event.
*
* @param string event name
* @param array event to replace
* @param array new callback
* @return boolean
*/
public static function replace($name, $existing, $callback)
{
if (empty(self::$events[$name]) or ($key = array_search($existing, self::$events[$name], true)) === false) {
return false;
}
/**
* Replaces an event with another event.
*
* @param string event name
* @param array event to replace
* @param array new callback
* @return boolean
*/
public static function replace($name, $existing, $callback)
{
if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name], TRUE)) === FALSE)
return FALSE;
if (! in_array($callback, self::$events[$name], true)) {
// Replace the exisiting event with the new event
self::$events[$name][$key] = $callback;
} else {
// Remove the existing event from the queue
unset(self::$events[$name][$key]);
if ( ! in_array($callback, self::$events[$name], TRUE))
{
// Replace the exisiting event with the new event
self::$events[$name][$key] = $callback;
}
else
{
// Remove the existing event from the queue
unset(self::$events[$name][$key]);
// Reset the array so the keys are ordered properly
self::$events[$name] = array_values(self::$events[$name]);
}
// Reset the array so the keys are ordered properly
self::$events[$name] = array_values(self::$events[$name]);
}
return true;
}
return TRUE;
}
/**
* Get all callbacks for an event.
*
* @param string event name
* @return array
*/
public static function get($name)
{
return empty(self::$events[$name]) ? array() : self::$events[$name];
}
/**
* Get all callbacks for an event.
*
* @param string event name
* @return array
*/
public static function get($name)
{
return empty(self::$events[$name]) ? array() : self::$events[$name];
}
/**
* Clear some or all callbacks from an event.
*
* @param string event name
* @param array specific callback to remove, FALSE for all callbacks
* @return void
*/
public static function clear($name, $callback = false)
{
if ($callback === false) {
self::$events[$name] = array();
} elseif (isset(self::$events[$name])) {
// Loop through each of the event callbacks and compare it to the
// callback requested for removal. The callback is removed if it
// matches.
foreach (self::$events[$name] as $i => $event_callback) {
if ($callback === $event_callback) {
unset(self::$events[$name][$i]);
}
}
}
}
/**
* Clear some or all callbacks from an event.
*
* @param string event name
* @param array specific callback to remove, FALSE for all callbacks
* @return void
*/
public static function clear($name, $callback = FALSE)
{
if ($callback === FALSE)
{
self::$events[$name] = array();
}
elseif (isset(self::$events[$name]))
{
// Loop through each of the event callbacks and compare it to the
// callback requested for removal. The callback is removed if it
// matches.
foreach (self::$events[$name] as $i => $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);
/**
* 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);
}
foreach ($callbacks as $callback)
{
call_user_func($callback);
}
// Do this to prevent data from getting 'stuck'
$clear_data = '';
self::$data =& $clear_data;
}
// Do this to prevent data from getting 'stuck'
$clear_data = '';
self::$data =& $clear_data;
}
// The event has been run!
self::$has_run[$name] = $name;
}
// 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
/**
* 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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,138 @@
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct script access.');
// phpcs:enable PSR1.Files.SideEffects
/**
* Security helper class.
*
* @package Kohana
* @category Security
* @author Kohana Team
* @copyright (c) 2007-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Security
{
/**
* @var string key name used for token storage
*/
public static $token_name = 'security_token';
/**
* Generate and store a unique token which can be used to help prevent
* [CSRF](http://wikipedia.org/wiki/Cross_Site_Request_Forgery) attacks.
*
* $token = Security::token();
*
* You can insert this token into your forms as a hidden field:
*
* echo Form::hidden('csrf', Security::token());
*
* And then check it when using [Validation]:
*
* $array->rules('csrf', array(
* array('not_empty'),
* array('Security::check'),
* ));
*
* This provides a basic, but effective, method of preventing CSRF attacks.
*
* @param boolean $new force a new token to be generated?
* @return string
* @uses Session::instance
*/
public static function token($new = false)
{
$session = Session::instance();
// Get the current token
$token = $session->get(Security::$token_name);
if ($new === true or ! $token) {
// Generate a new unique token
if (function_exists('openssl_random_pseudo_bytes')) {
// Generate a random pseudo bytes token if openssl_random_pseudo_bytes is available
// This is more secure than uniqid, because uniqid relies on microtime, which is predictable
$token = base64_encode(openssl_random_pseudo_bytes(32));
} else {
// Otherwise, fall back to a hashed uniqid
$token = sha1(uniqid(null, true));
}
// Store the new token
$session->set(Security::$token_name, $token);
}
return $token;
}
/**
* Check that the given token matches the currently stored security token.
*
* if (Security::check($token))
* {
* // Pass
* }
*
* @param string $token token to check
* @return boolean
* @uses Security::token
*/
public static function check($token)
{
return Security::slow_equals(Security::token(), $token);
}
/**
* Compare two hashes in a time-invariant manner.
* Prevents cryptographic side-channel attacks (timing attacks, specifically)
*
* @param string $a cryptographic hash
* @param string $b cryptographic hash
* @return boolean
*/
public static function slow_equals($a, $b)
{
$diff = strlen($a) ^ strlen($b);
for ($i = 0; $i < strlen($a) and $i < strlen($b); $i++) {
$diff |= ord($a[$i]) ^ ord($b[$i]);
}
return $diff === 0;
}
/**
* Deprecated for security reasons.
* See https://github.com/kohana/kohana/issues/107
*
* Remove image tags from a string.
*
* $str = Security::strip_image_tags($str);
*
* @deprecated since version 3.3.6
* @param string $str string to sanitize
* @return string
*/
public static function strip_image_tags($str)
{
return preg_replace('#<img\s.*?(?:src\s*=\s*["\']?([^"\'<>\s]*)["\']?[^>]*)?>#is', '$1', $str);
}
/**
* Encodes PHP tags in a string.
*
* $str = Security::encode_php_tags($str);
*
* @param string $str string to sanitize
* @return string
*/
public static function encode_php_tags($str)
{
return str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $str);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,9 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::from_unicode
*
@@ -10,59 +15,45 @@
*/
function _from_unicode($arr)
{
ob_start();
ob_start();
$keys = array_keys($arr);
$keys = array_keys($arr);
foreach ($keys as $k)
{
// ASCII range (including control chars)
if (($arr[$k] >= 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;
}
}
foreach ($keys as $k) {
// ASCII range (including control chars)
if (($arr[$k] >= 0) and ($arr[$k] <= 0x007f)) {
echo chr($arr[$k]);
} elseif ($arr[$k] <= 0x07ff) {
// 2 byte sequence
echo chr(0xc0 | ($arr[$k] >> 6));
echo chr(0x80 | ($arr[$k] & 0x003f));
} elseif ($arr[$k] == 0xFEFF) {
// Byte order mark (skip)
// nop -- zap the BOM
} elseif ($arr[$k] >= 0xD800 and $arr[$k] <= 0xDFFF) {
// Test for illegal surrogates
// Found a surrogate
trigger_error('utf8::from_unicode: Illegal surrogate at index: ' . $k . ', value: ' . $arr[$k], E_USER_WARNING);
return false;
} elseif ($arr[$k] <= 0xffff) {
// 3 byte sequence
echo chr(0xe0 | ($arr[$k] >> 12));
echo chr(0x80 | (($arr[$k] >> 6) & 0x003f));
echo chr(0x80 | ($arr[$k] & 0x003f));
} elseif ($arr[$k] <= 0x10ffff) {
// 4 byte sequence
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));
} else {
// Out of range
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;
$result = ob_get_contents();
ob_end_clean();
return $result;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::ltrim
*
@@ -8,15 +12,17 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ltrim($str, $charlist = NULL)
function _ltrim($str, $charlist = null)
{
if ($charlist === NULL)
return ltrim($str);
if ($charlist === null) {
return ltrim($str);
}
if (utf8::is_ascii($charlist))
return ltrim($str, $charlist);
if (utf8::is_ascii($charlist)) {
return ltrim($str, $charlist);
}
$charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
$charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
return preg_replace('/^['.$charlist.']+/u', '', $str);
}
return preg_replace('/^[' . $charlist . ']+/u', '', $str);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::ord
*
@@ -10,79 +14,67 @@
*/
function _ord($chr)
{
$ord0 = ord($chr);
$ord0 = ord($chr);
if ($ord0 >= 0 AND $ord0 <= 127)
{
return $ord0;
}
if ($ord0 >= 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;
}
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]);
$ord1 = ord($chr[1]);
if ($ord0 >= 192 AND $ord0 <= 223)
{
return ($ord0 - 192) * 64 + ($ord1 - 128);
}
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;
}
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]);
$ord2 = ord($chr[2]);
if ($ord0 >= 224 AND $ord0 <= 239)
{
return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128);
}
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;
}
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]);
$ord3 = ord($chr[3]);
if ($ord0 >= 240 AND $ord0 <= 247)
{
return ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2-128) * 64 + ($ord3 - 128);
}
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;
}
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]);
$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 ($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 (! 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 >= 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;
}
}
if ($ord0 >= 254 and $ord0 <= 255) {
trigger_error('Invalid UTF-8 with surrogate ordinal ' . $ord0, E_USER_WARNING);
return false;
}
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::rtrim
*
@@ -8,15 +12,17 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _rtrim($str, $charlist = NULL)
function _rtrim($str, $charlist = null)
{
if ($charlist === NULL)
return rtrim($str);
if ($charlist === null) {
return rtrim($str);
}
if (utf8::is_ascii($charlist))
return rtrim($str, $charlist);
if (utf8::is_ascii($charlist)) {
return rtrim($str, $charlist);
}
$charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
$charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
return preg_replace('/['.$charlist.']++$/uD', '', $str);
}
return preg_replace('/[' . $charlist . ']++$/uD', '', $str);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::str_ireplace
*
@@ -8,63 +12,53 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _str_ireplace($search, $replace, $str, & $count = NULL)
function _str_ireplace($search, $replace, $str, &$count = null)
{
if (utf8::is_ascii($search) AND utf8::is_ascii($replace) AND utf8::is_ascii($str))
return str_ireplace($search, $replace, $str, $count);
if (utf8::is_ascii($search) and utf8::is_ascii($replace) and utf8::is_ascii($str)) {
return str_ireplace($search, $replace, $str, $count);
}
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = utf8::str_ireplace($search, $replace, $val, $count);
}
return $str;
}
if (is_array($str)) {
foreach ($str as $key => $val) {
$str[$key] = utf8::str_ireplace($search, $replace, $val, $count);
}
return $str;
}
if (is_array($search))
{
$keys = array_keys($search);
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;
}
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);
$search = utf8::strtolower($search);
$str_lower = utf8::strtolower($str);
$total_matched_strlen = 0;
$i = 0;
$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);
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));
$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++;
}
$total_matched_strlen += $matched_strlen;
$i++;
}
$count += $i;
return $str;
$count += $i;
return $str;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::str_pad
*
@@ -10,45 +14,40 @@
*/
function _str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
if (utf8::is_ascii($str) AND utf8::is_ascii($pad_str))
{
return str_pad($str, $final_str_length, $pad_str, $pad_type);
}
if (utf8::is_ascii($str) and utf8::is_ascii($pad_str)) {
return str_pad($str, $final_str_length, $pad_str, $pad_type);
}
$str_length = utf8::strlen($str);
$str_length = utf8::strlen($str);
if ($final_str_length <= 0 OR $final_str_length <= $str_length)
{
return $str;
}
if ($final_str_length <= 0 or $final_str_length <= $str_length) {
return $str;
}
$pad_str_length = utf8::strlen($pad_str);
$pad_length = $final_str_length - $str_length;
$pad_str_length = utf8::strlen($pad_str);
$pad_length = $final_str_length - $str_length;
if ($pad_type == STR_PAD_RIGHT)
{
$repeat = ceil($pad_length / $pad_str_length);
return utf8::substr($str.str_repeat($pad_str, $repeat), 0, $final_str_length);
}
if ($pad_type == STR_PAD_RIGHT) {
$repeat = ceil($pad_length / $pad_str_length);
return utf8::substr($str . str_repeat($pad_str, $repeat), 0, $final_str_length);
}
if ($pad_type == STR_PAD_LEFT)
{
$repeat = ceil($pad_length / $pad_str_length);
return utf8::substr(str_repeat($pad_str, $repeat), 0, floor($pad_length)).$str;
}
if ($pad_type == STR_PAD_LEFT) {
$repeat = ceil($pad_length / $pad_str_length);
return utf8::substr(str_repeat($pad_str, $repeat), 0, floor($pad_length)) . $str;
}
if ($pad_type == STR_PAD_BOTH)
{
$pad_length /= 2;
$pad_length_left = floor($pad_length);
$pad_length_right = ceil($pad_length);
$repeat_left = ceil($pad_length_left / $pad_str_length);
$repeat_right = ceil($pad_length_right / $pad_str_length);
if ($pad_type == STR_PAD_BOTH) {
$pad_length /= 2;
$pad_length_left = floor($pad_length);
$pad_length_right = ceil($pad_length);
$repeat_left = ceil($pad_length_left / $pad_str_length);
$repeat_right = ceil($pad_length_right / $pad_str_length);
$pad_left = utf8::substr(str_repeat($pad_str, $repeat_left), 0, $pad_length_left);
$pad_right = utf8::substr(str_repeat($pad_str, $repeat_right), 0, $pad_length_left);
return $pad_left.$str.$pad_right;
}
$pad_left = utf8::substr(str_repeat($pad_str, $repeat_left), 0, $pad_length_left);
$pad_right = utf8::substr(str_repeat($pad_str, $repeat_right), 0, $pad_length_left);
return $pad_left . $str . $pad_right;
}
trigger_error('utf8::str_pad: Unknown padding type (' . $pad_type . ')', E_USER_ERROR);
}
trigger_error('utf8::str_pad: Unknown padding type (' . $pad_type . ')', E_USER_ERROR);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::str_split
*
@@ -10,24 +14,21 @@
*/
function _str_split($str, $split_length = 1)
{
$split_length = (int) $split_length;
$split_length = (int) $split_length;
if (utf8::is_ascii($str))
{
return str_split($str, $split_length);
}
if (utf8::is_ascii($str)) {
return str_split($str, $split_length);
}
if ($split_length < 1)
{
return FALSE;
}
if ($split_length < 1) {
return false;
}
if (utf8::strlen($str) <= $split_length)
{
return array($str);
}
if (utf8::strlen($str) <= $split_length) {
return array($str);
}
preg_match_all('/.{'.$split_length.'}|[^\x00]{1,'.$split_length.'}$/us', $str, $matches);
preg_match_all('/.{' . $split_length . '}|[^\x00]{1,' . $split_length . '}$/us', $str, $matches);
return $matches[0];
}
return $matches[0];
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strcasecmp
*
@@ -10,10 +14,11 @@
*/
function _strcasecmp($str1, $str2)
{
if (utf8::is_ascii($str1) AND utf8::is_ascii($str2))
return strcasecmp($str1, $str2);
if (utf8::is_ascii($str1) and utf8::is_ascii($str2)) {
return strcasecmp($str1, $str2);
}
$str1 = utf8::strtolower($str1);
$str2 = utf8::strtolower($str2);
return strcmp($str1, $str2);
}
$str1 = utf8::strtolower($str1);
$str2 = utf8::strtolower($str2);
return strcmp($str1, $str2);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strcspn
*
@@ -8,23 +12,24 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strcspn($str, $mask, $offset = NULL, $length = NULL)
function _strcspn($str, $mask, $offset = null, $length = null)
{
if ($str == '' OR $mask == '')
return 0;
if ($str == '' or $mask == '') {
return 0;
}
if (utf8::is_ascii($str) AND utf8::is_ascii($mask))
return ($offset === NULL) ? strcspn($str, $mask) : (($length === NULL) ? strcspn($str, $mask, $offset) : strcspn($str, $mask, $offset, $length));
if (utf8::is_ascii($str) and utf8::is_ascii($mask)) {
return ($offset === null) ? strcspn($str, $mask) : (($length === null) ? strcspn($str, $mask, $offset) : strcspn($str, $mask, $offset, $length));
}
if ($str !== NULL OR $length !== NULL)
{
$str = utf8::substr($str, $offset, $length);
}
if ($str !== null or $length !== null) {
$str = utf8::substr($str, $offset, $length);
}
// Escape these characters: - [ ] . : \ ^ /
// The . and : are escaped to prevent possible warnings about POSIX regex elements
$mask = preg_replace('#[-[\].:\\\\^/]#', '\\\\$0', $mask);
preg_match('/^[^'.$mask.']+/u', $str, $matches);
// Escape these characters: - [ ] . : \ ^ /
// The . and : are escaped to prevent possible warnings about POSIX regex elements
$mask = preg_replace('#[-[\].:\\\\^/]#', '\\\\$0', $mask);
preg_match('/^[^' . $mask . ']+/u', $str, $matches);
return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}
return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::stristr
*
@@ -10,19 +14,22 @@
*/
function _stristr($str, $search)
{
if (utf8::is_ascii($str) AND utf8::is_ascii($search))
return stristr($str, $search);
if (utf8::is_ascii($str) and utf8::is_ascii($search)) {
return stristr($str, $search);
}
if ($search == '')
return $str;
if ($search == '') {
return $str;
}
$str_lower = utf8::strtolower($str);
$search_lower = utf8::strtolower($search);
$str_lower = utf8::strtolower($str);
$search_lower = utf8::strtolower($search);
preg_match('/^(.*?)'.preg_quote($search, '/').'/s', $str_lower, $matches);
preg_match('/^(.*?)' . preg_quote($search, '/') . '/s', $str_lower, $matches);
if (isset($matches[1]))
return substr($str, strlen($matches[1]));
if (isset($matches[1])) {
return substr($str, strlen($matches[1]));
}
return FALSE;
}
return false;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strlen
*
@@ -10,12 +14,14 @@
*/
function _strlen($str)
{
// Try mb_strlen() first because it's faster than combination of is_ascii() and strlen()
if (SERVER_UTF8)
return mb_strlen($str);
// Try mb_strlen() first because it's faster than combination of is_ascii() and strlen()
if (SERVER_UTF8) {
return mb_strlen($str);
}
if (utf8::is_ascii($str))
return strlen($str);
if (utf8::is_ascii($str)) {
return strlen($str);
}
return strlen(utf8_decode($str));
}
return strlen(utf8_decode($str));
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strpos
*
@@ -10,21 +14,22 @@
*/
function _strpos($str, $search, $offset = 0)
{
$offset = (int) $offset;
$offset = (int) $offset;
if (SERVER_UTF8)
return mb_strpos($str, $search, $offset);
if (SERVER_UTF8) {
return mb_strpos($str, $search, $offset);
}
if (utf8::is_ascii($str) AND utf8::is_ascii($search))
return strpos($str, $search, $offset);
if (utf8::is_ascii($str) and utf8::is_ascii($search)) {
return strpos($str, $search, $offset);
}
if ($offset == 0)
{
$array = explode($search, $str, 2);
return isset($array[1]) ? utf8::strlen($array[0]) : FALSE;
}
if ($offset == 0) {
$array = explode($search, $str, 2);
return isset($array[1]) ? utf8::strlen($array[0]) : false;
}
$str = utf8::substr($str, $offset);
$pos = utf8::strpos($str, $search);
return ($pos === FALSE) ? FALSE : $pos + $offset;
}
$str = utf8::substr($str, $offset);
$pos = utf8::strpos($str, $search);
return ($pos === false) ? false : $pos + $offset;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strrev
*
@@ -10,9 +14,10 @@
*/
function _strrev($str)
{
if (utf8::is_ascii($str))
return strrev($str);
if (utf8::is_ascii($str)) {
return strrev($str);
}
preg_match_all('/./us', $str, $matches);
return implode('', array_reverse($matches[0]));
}
preg_match_all('/./us', $str, $matches);
return implode('', array_reverse($matches[0]));
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strrpos
*
@@ -10,21 +14,22 @@
*/
function _strrpos($str, $search, $offset = 0)
{
$offset = (int) $offset;
$offset = (int) $offset;
if (SERVER_UTF8)
return mb_strrpos($str, $search, $offset);
if (SERVER_UTF8) {
return mb_strrpos($str, $search, $offset);
}
if (utf8::is_ascii($str) AND utf8::is_ascii($search))
return strrpos($str, $search, $offset);
if (utf8::is_ascii($str) and utf8::is_ascii($search)) {
return strrpos($str, $search, $offset);
}
if ($offset == 0)
{
$array = explode($search, $str, -1);
return isset($array[0]) ? utf8::strlen(implode($search, $array)) : FALSE;
}
if ($offset == 0) {
$array = explode($search, $str, -1);
return isset($array[0]) ? utf8::strlen(implode($search, $array)) : false;
}
$str = utf8::substr($str, $offset);
$pos = utf8::strrpos($str, $search);
return ($pos === FALSE) ? FALSE : $pos + $offset;
}
$str = utf8::substr($str, $offset);
$pos = utf8::strrpos($str, $search);
return ($pos === false) ? false : $pos + $offset;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strspn
*
@@ -8,23 +12,24 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strspn($str, $mask, $offset = NULL, $length = NULL)
function _strspn($str, $mask, $offset = null, $length = null)
{
if ($str == '' OR $mask == '')
return 0;
if ($str == '' or $mask == '') {
return 0;
}
if (utf8::is_ascii($str) AND utf8::is_ascii($mask))
return ($offset === NULL) ? strspn($str, $mask) : (($length === NULL) ? strspn($str, $mask, $offset) : strspn($str, $mask, $offset, $length));
if (utf8::is_ascii($str) and utf8::is_ascii($mask)) {
return ($offset === null) ? strspn($str, $mask) : (($length === null) ? strspn($str, $mask, $offset) : strspn($str, $mask, $offset, $length));
}
if ($offset !== NULL OR $length !== NULL)
{
$str = utf8::substr($str, $offset, $length);
}
if ($offset !== null or $length !== null) {
$str = utf8::substr($str, $offset, $length);
}
// Escape these characters: - [ ] . : \ ^ /
// The . and : are escaped to prevent possible warnings about POSIX regex elements
$mask = preg_replace('#[-[\].:\\\\^/]#', '\\\\$0', $mask);
preg_match('/^[^'.$mask.']+/u', $str, $matches);
// Escape these characters: - [ ] . : \ ^ /
// The . and : are escaped to prevent possible warnings about POSIX regex elements
$mask = preg_replace('#[-[\].:\\\\^/]#', '\\\\$0', $mask);
preg_match('/^[^' . $mask . ']+/u', $str, $matches);
return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}
return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strtolower
*
@@ -10,75 +14,75 @@
*/
function _strtolower($str)
{
if (SERVER_UTF8)
return mb_strtolower($str);
if (SERVER_UTF8) {
return mb_strtolower($str);
}
if (utf8::is_ascii($str))
return strtolower($str);
if (utf8::is_ascii($str)) {
return strtolower($str);
}
static $UTF8_UPPER_TO_LOWER = NULL;
static $UTF8_UPPER_TO_LOWER = null;
if ($UTF8_UPPER_TO_LOWER === NULL)
{
$UTF8_UPPER_TO_LOWER = array(
0x0041=>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,
);
}
if ($UTF8_UPPER_TO_LOWER === null) {
$UTF8_UPPER_TO_LOWER = array(
0x0041 => 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);
$uni = utf8::to_unicode($str);
if ($uni === FALSE)
return FALSE;
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]];
}
}
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);
}
return utf8::from_unicode($uni);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::strtoupper
*
@@ -10,75 +14,75 @@
*/
function _strtoupper($str)
{
if (SERVER_UTF8)
return mb_strtoupper($str);
if (SERVER_UTF8) {
return mb_strtoupper($str);
}
if (utf8::is_ascii($str))
return strtoupper($str);
if (utf8::is_ascii($str)) {
return strtoupper($str);
}
static $UTF8_LOWER_TO_UPPER = NULL;
static $UTF8_LOWER_TO_UPPER = null;
if ($UTF8_LOWER_TO_UPPER === NULL)
{
$UTF8_LOWER_TO_UPPER = array(
0x0061=>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,
);
}
if ($UTF8_LOWER_TO_UPPER === null) {
$UTF8_LOWER_TO_UPPER = array(
0x0061 => 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);
$uni = utf8::to_unicode($str);
if ($uni === FALSE)
return FALSE;
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]];
}
}
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);
}
return utf8::from_unicode($uni);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::substr
*
@@ -8,68 +12,66 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _substr($str, $offset, $length = NULL)
function _substr($str, $offset, $length = null)
{
if (SERVER_UTF8)
return ($length === NULL) ? mb_substr($str, $offset) : mb_substr($str, $offset, $length);
if (SERVER_UTF8) {
return ($length === null) ? mb_substr($str, $offset) : mb_substr($str, $offset, $length);
}
if (utf8::is_ascii($str))
return ($length === NULL) ? substr($str, $offset) : substr($str, $offset, $length);
if (utf8::is_ascii($str)) {
return ($length === null) ? substr($str, $offset) : substr($str, $offset, $length);
}
// Normalize params
$str = (string) $str;
$strlen = utf8::strlen($str);
$offset = (int) ($offset < 0) ? max(0, $strlen + $offset) : $offset; // Normalize to positive offset
$length = ($length === NULL) ? NULL : (int) $length;
// Normalize params
$str = (string) $str;
$strlen = utf8::strlen($str);
$offset = (int) ($offset < 0) ? max(0, $strlen + $offset) : $offset; // Normalize to positive offset
$length = ($length === null) ? null : (int) $length;
// Impossible
if ($length === 0 OR $offset >= $strlen OR ($length < 0 AND $length <= $offset - $strlen))
return '';
// Impossible
if ($length === 0 or $offset >= $strlen or ($length < 0 and $length <= $offset - $strlen)) {
return '';
}
// Whole string
if ($offset == 0 AND ($length === NULL OR $length >= $strlen))
return $str;
// Whole string
if ($offset == 0 and ($length === null or $length >= $strlen)) {
return $str;
}
// Build regex
$regex = '^';
// 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 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);
// Create a length expression
if ($length === null) {
$regex .= '(.*)'; // No length set, grab it all
} elseif ($length > 0) {
// Find length from the left (positive length)
// 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.'}';
}
$x = (int) ($length / 65535);
$y = (int) ($length % 65535);
$regex .= '(';
$regex .= ($x == 0) ? '' : '(?:.{65535}){' . $x . '}';
$regex .= '.{' . $y . '})';
} else {
// Find length from the right (negative length)
$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];
}
preg_match('/' . $regex . '/us', $str, $matches);
return $matches[1];
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::substr_replace
*
@@ -8,15 +12,16 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _substr_replace($str, $replacement, $offset, $length = NULL)
function _substr_replace($str, $replacement, $offset, $length = null)
{
if (utf8::is_ascii($str))
return ($length === NULL) ? substr_replace($str, $replacement, $offset) : substr_replace($str, $replacement, $offset, $length);
if (utf8::is_ascii($str)) {
return ($length === null) ? substr_replace($str, $replacement, $offset) : substr_replace($str, $replacement, $offset, $length);
}
$length = ($length === NULL) ? utf8::strlen($str) : (int) $length;
preg_match_all('/./us', $str, $str_array);
preg_match_all('/./us', $replacement, $replacement_array);
$length = ($length === null) ? utf8::strlen($str) : (int) $length;
preg_match_all('/./us', $str, $str_array);
preg_match_all('/./us', $replacement, $replacement_array);
array_splice($str_array[0], $offset, $length, $replacement_array[0]);
return implode('', $str_array[0]);
}
array_splice($str_array[0], $offset, $length, $replacement_array[0]);
return implode('', $str_array[0]);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::to_unicode
*
@@ -10,132 +14,111 @@
*/
function _to_unicode($str)
{
$mState = 0; // cached expected number of octets after the current octet until the beginning of the next UTF8 character sequence
$mUcs4 = 0; // cached Unicode character
$mBytes = 1; // cached expected number of octets in the current sequence
$mState = 0; // cached expected number of octets after the current octet until the beginning of the next UTF8 character sequence
$mUcs4 = 0; // cached Unicode character
$mBytes = 1; // cached expected number of octets in the current sequence
$out = array();
$out = array();
$len = strlen($str);
$len = strlen($str);
for ($i = 0; $i < $len; $i++)
{
$in = ord($str[$i]);
for ($i = 0; $i < $len; $i++) {
$in = ord($str[$i]);
if ($mState == 0)
{
// When mState is zero we expect either a US-ASCII character or a
// multi-octet sequence.
if (0 == (0x80 & $in))
{
// US-ASCII, pass straight through.
$out[] = $in;
$mBytes = 1;
}
elseif (0xC0 == (0xE0 & $in))
{
// First octet of 2 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x1F) << 6;
$mState = 1;
$mBytes = 2;
}
elseif (0xE0 == (0xF0 & $in))
{
// First octet of 3 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x0F) << 12;
$mState = 2;
$mBytes = 3;
}
elseif (0xF0 == (0xF8 & $in))
{
// First octet of 4 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x07) << 18;
$mState = 3;
$mBytes = 4;
}
elseif (0xF8 == (0xFC & $in))
{
// First octet of 5 octet sequence.
//
// This is illegal because the encoded codepoint must be either
// (a) not the shortest form or
// (b) outside the Unicode range of 0-0x10FFFF.
// Rather than trying to resynchronize, we will carry on until the end
// of the sequence and let the later error handling code catch it.
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x03) << 24;
$mState = 4;
$mBytes = 5;
}
elseif (0xFC == (0xFE & $in))
{
// First octet of 6 octet sequence, see comments for 5 octet sequence.
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 1) << 30;
$mState = 5;
$mBytes = 6;
}
else
{
// Current octet is neither in the US-ASCII range nor a legal first octet of a multi-octet sequence.
trigger_error('utf8::to_unicode: Illegal sequence identifier in UTF-8 at byte '.$i, E_USER_WARNING);
return FALSE;
}
}
else
{
// When mState is non-zero, we expect a continuation of the multi-octet sequence
if (0x80 == (0xC0 & $in))
{
// Legal continuation
$shift = ($mState - 1) * 6;
$tmp = $in;
$tmp = ($tmp & 0x0000003F) << $shift;
$mUcs4 |= $tmp;
if ($mState == 0) {
// When mState is zero we expect either a US-ASCII character or a
// multi-octet sequence.
if (0 == (0x80 & $in)) {
// US-ASCII, pass straight through.
$out[] = $in;
$mBytes = 1;
} elseif (0xC0 == (0xE0 & $in)) {
// First octet of 2 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x1F) << 6;
$mState = 1;
$mBytes = 2;
} elseif (0xE0 == (0xF0 & $in)) {
// First octet of 3 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x0F) << 12;
$mState = 2;
$mBytes = 3;
} elseif (0xF0 == (0xF8 & $in)) {
// First octet of 4 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x07) << 18;
$mState = 3;
$mBytes = 4;
} elseif (0xF8 == (0xFC & $in)) {
// First octet of 5 octet sequence.
//
// This is illegal because the encoded codepoint must be either
// (a) not the shortest form or
// (b) outside the Unicode range of 0-0x10FFFF.
// Rather than trying to resynchronize, we will carry on until the end
// of the sequence and let the later error handling code catch it.
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x03) << 24;
$mState = 4;
$mBytes = 5;
} elseif (0xFC == (0xFE & $in)) {
// First octet of 6 octet sequence, see comments for 5 octet sequence.
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 1) << 30;
$mState = 5;
$mBytes = 6;
} else {
// Current octet is neither in the US-ASCII range nor a legal first octet of a multi-octet sequence.
trigger_error('utf8::to_unicode: Illegal sequence identifier in UTF-8 at byte ' . $i, E_USER_WARNING);
return false;
}
} else {
// When mState is non-zero, we expect a continuation of the multi-octet sequence
if (0x80 == (0xC0 & $in)) {
// Legal continuation
$shift = ($mState - 1) * 6;
$tmp = $in;
$tmp = ($tmp & 0x0000003F) << $shift;
$mUcs4 |= $tmp;
// End of the multi-octet sequence. mUcs4 now contains the final Unicode codepoint to be output
if (0 == --$mState)
{
// Check for illegal sequences and codepoints
// End of the multi-octet sequence. mUcs4 now contains the final Unicode codepoint to be output
if (0 == --$mState) {
// Check for illegal sequences and codepoints
// From Unicode 3.1, non-shortest form is illegal
if (((2 == $mBytes) AND ($mUcs4 < 0x0080)) OR
((3 == $mBytes) AND ($mUcs4 < 0x0800)) OR
((4 == $mBytes) AND ($mUcs4 < 0x10000)) OR
(4 < $mBytes) OR
// From Unicode 3.2, surrogate characters are illegal
(($mUcs4 & 0xFFFFF800) == 0xD800) OR
// Codepoints outside the Unicode range are illegal
($mUcs4 > 0x10FFFF))
{
trigger_error('utf8::to_unicode: Illegal sequence or codepoint in UTF-8 at byte '.$i, E_USER_WARNING);
return FALSE;
}
// From Unicode 3.1, non-shortest form is illegal
if (
((2 == $mBytes) and ($mUcs4 < 0x0080)) or
((3 == $mBytes) and ($mUcs4 < 0x0800)) or
((4 == $mBytes) and ($mUcs4 < 0x10000)) or
(4 < $mBytes) or
// From Unicode 3.2, surrogate characters are illegal
(($mUcs4 & 0xFFFFF800) == 0xD800) or
// Codepoints outside the Unicode range are illegal
($mUcs4 > 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;
}
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;
}
}
}
// 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;
}
return $out;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::transliterate_to_ascii
*
@@ -10,68 +14,64 @@
*/
function _transliterate_to_ascii($str, $case = 0)
{
static $UTF8_LOWER_ACCENTS = NULL;
static $UTF8_UPPER_ACCENTS = NULL;
static $UTF8_LOWER_ACCENTS = null;
static $UTF8_UPPER_ACCENTS = null;
if ($case <= 0)
{
if ($UTF8_LOWER_ACCENTS === NULL)
{
$UTF8_LOWER_ACCENTS = array(
'à' => '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',
);
}
if ($case <= 0) {
if ($UTF8_LOWER_ACCENTS === null) {
$UTF8_LOWER_ACCENTS = array(
'à' => '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
);
}
$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',
);
}
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
);
}
$str = str_replace(
array_keys($UTF8_UPPER_ACCENTS),
array_values($UTF8_UPPER_ACCENTS),
$str
);
}
return $str;
}
return $str;
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::trim
*
@@ -8,10 +12,11 @@
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _trim($str, $charlist = NULL)
function _trim($str, $charlist = null)
{
if ($charlist === NULL)
return trim($str);
if ($charlist === null) {
return trim($str);
}
return utf8::ltrim(utf8::rtrim($str, $charlist), $charlist);
}
return utf8::ltrim(utf8::rtrim($str, $charlist), $charlist);
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::ucfirst
*
@@ -10,9 +14,10 @@
*/
function _ucfirst($str)
{
if (utf8::is_ascii($str))
return ucfirst($str);
if (utf8::is_ascii($str)) {
return ucfirst($str);
}
preg_match('/^(.?)(.*)$/us', $str, $matches);
return utf8::strtoupper($matches[1]).$matches[2];
}
preg_match('/^(.?)(.*)$/us', $str, $matches);
return utf8::strtoupper($matches[1]) . $matches[2];
}

View File

@@ -1,4 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
/**
* utf8::ucwords
*
@@ -10,17 +14,19 @@
*/
function _ucwords($str)
{
if (SERVER_UTF8)
return mb_convert_case($str, MB_CASE_TITLE);
if (SERVER_UTF8) {
return mb_convert_case($str, MB_CASE_TITLE);
}
if (utf8::is_ascii($str))
return ucwords($str);
if (utf8::is_ascii($str)) {
return ucwords($str);
}
// [\x0c\x09\x0b\x0a\x0d\x20] matches form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns.
// This corresponds to the definition of a 'word' defined at http://php.net/ucwords
return preg_replace(
'/(?<=^|[\x0c\x09\x0b\x0a\x0d\x20])[^\x0c\x09\x0b\x0a\x0d\x20]/ue',
'utf8::strtoupper(\'$0\')',
$str
);
}
// [\x0c\x09\x0b\x0a\x0d\x20] matches form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns.
// This corresponds to the definition of a 'word' defined at http://php.net/ucwords
return preg_replace(
'/(?<=^|[\x0c\x09\x0b\x0a\x0d\x20])[^\x0c\x09\x0b\x0a\x0d\x20]/ue',
'utf8::strtoupper(\'$0\')',
$str
);
}

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Array helper class.
*
@@ -9,304 +17,272 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class arr_Core {
class arr_Core
{
/**
* Return a callback array from a string, eg: limit[10,20] would become
* array('limit', array('10', '20'))
*
* @param string callback string
* @return array
*/
public static function callback_string($str)
{
// command[param,param]
if (preg_match('/([^\[]*+)\[(.+)\]/', (string) $str, $match)) {
// command
$command = $match[1];
/**
* Return a callback array from a string, eg: limit[10,20] would become
* array('limit', array('10', '20'))
*
* @param string callback string
* @return array
*/
public static function callback_string($str)
{
// command[param,param]
if (preg_match('/([^\[]*+)\[(.+)\]/', (string) $str, $match))
{
// command
$command = $match[1];
// param,param
$params = preg_split('/(?<!\\\\),/', $match[2]);
$params = str_replace('\,', ',', $params);
} else {
// command
$command = $str;
// param,param
$params = preg_split('/(?<!\\\\),/', $match[2]);
$params = str_replace('\,', ',', $params);
}
else
{
// command
$command = $str;
// No params
$params = null;
}
// No params
$params = NULL;
}
return array($command, $params);
}
return array($command, $params);
}
/**
* Rotates a 2D array clockwise.
* Example, turns a 2x3 array into a 3x2 array.
*
* @param array array to rotate
* @param boolean keep the keys in the final rotated array. the sub arrays of the source array need to have the same key values.
* if your subkeys might not match, you need to pass FALSE here!
* @return array
*/
public static function rotate($source_array, $keep_keys = true)
{
$new_array = array();
foreach ($source_array as $key => $value) {
$value = ($keep_keys === true) ? $value : array_values($value);
foreach ($value as $k => $v) {
$new_array[$k][$key] = $v;
}
}
/**
* Rotates a 2D array clockwise.
* Example, turns a 2x3 array into a 3x2 array.
*
* @param array array to rotate
* @param boolean keep the keys in the final rotated array. the sub arrays of the source array need to have the same key values.
* if your subkeys might not match, you need to pass FALSE here!
* @return array
*/
public static function rotate($source_array, $keep_keys = TRUE)
{
$new_array = array();
foreach ($source_array as $key => $value)
{
$value = ($keep_keys === TRUE) ? $value : array_values($value);
foreach ($value as $k => $v)
{
$new_array[$k][$key] = $v;
}
}
return $new_array;
}
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;
}
/**
* 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]);
$val = $array[$key];
unset($array[$key]);
return $val;
}
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);
/**
* 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;
}
}
$found = array();
foreach ($keys as $key) {
if (isset($search[$key])) {
$found[$key] = $search[$key];
} else {
$found[$key] = null;
}
}
return $found;
}
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);
/**
* 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;
}
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);
}
/**
* 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;
}
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);
}
/**
* @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;
$high = count($haystack) - 1;
$low = 0;
while ($low <= $high)
{
$mid = ($low + $high) >> 1;
while ($low <= $high) {
$mid = ($low + $high) >> 1;
if ($haystack[$mid] < $needle)
{
$low = $mid + 1;
}
elseif ($haystack[$mid] > $needle)
{
$high = $mid - 1;
}
else
{
return $mid;
}
}
if ($haystack[$mid] < $needle) {
$low = $mid + 1;
} elseif ($haystack[$mid] > $needle) {
$high = $mid - 1;
} else {
return $mid;
}
}
return FALSE;
}
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();
/**
* 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;
}
}
}
$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;
}
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;
}
/**
* 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;
}
}
}
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;
}
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();
/**
* 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;
}
$array = array();
for ($i = $step; $i <= $max; $i += $step) {
$array[$i] = $i;
}
return $array;
}
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;
/**
* 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);
}
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;
}
// Add the value to the object
$object->{$key} = $value;
}
return $object;
}
} // End arr
return $object;
}
}
// End arr

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Cookie helper class.
*
@@ -9,76 +16,76 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class cookie_Core {
class cookie_Core
{
/**
* Sets a cookie with the given parameters.
*
* @param string cookie name or array of config options
* @param string cookie value
* @param integer number of seconds before the cookie expires
* @param string URL path to allow
* @param string URL domain to allow
* @param boolean HTTPS only
* @param boolean HTTP only (requires PHP 5.2 or higher)
* @return boolean
*/
public static function set($name, $value = null, $expire = null, $path = null, $domain = null, $secure = null, $httponly = null)
{
if (headers_sent()) {
return false;
}
/**
* Sets a cookie with the given parameters.
*
* @param string cookie name or array of config options
* @param string cookie value
* @param integer number of seconds before the cookie expires
* @param string URL path to allow
* @param string URL domain to allow
* @param boolean HTTPS only
* @param boolean HTTP only (requires PHP 5.2 or higher)
* @return boolean
*/
public static function set($name, $value = NULL, $expire = NULL, $path = NULL, $domain = NULL, $secure = NULL, $httponly = NULL)
{
if (headers_sent())
return FALSE;
// If the name param is an array, we import it
is_array($name) and extract($name, EXTR_OVERWRITE);
// If the name param is an array, we import it
is_array($name) and extract($name, EXTR_OVERWRITE);
// Fetch default options
$config = Kohana::config('cookie');
// Fetch default options
$config = Kohana::config('cookie');
foreach (array('value', 'expire', 'domain', 'path', 'secure', 'httponly') as $item) {
if ($$item === null and isset($config[$item])) {
$$item = $config[$item];
}
}
foreach (array('value', 'expire', 'domain', 'path', 'secure', 'httponly') as $item)
{
if ($$item === NULL AND isset($config[$item]))
{
$$item = $config[$item];
}
}
// Expiration timestamp
$expire = ($expire == 0) ? 0 : time() + (int) $expire;
// Expiration timestamp
$expire = ($expire == 0) ? 0 : time() + (int) $expire;
return setcookie($name, $value, $expire, $path, $domain, $secure);
}
return setcookie($name, $value, $expire, $path, $domain, $secure);
}
/**
* Fetch a cookie value, using the Input library.
*
* @param string cookie name
* @param mixed default value
* @param boolean use XSS cleaning on the value
* @return string
*/
public static function get($name, $default = null, $xss_clean = false)
{
return Input::instance()->cookie($name, $default, $xss_clean);
}
/**
* Fetch a cookie value, using the Input library.
*
* @param string cookie name
* @param mixed default value
* @param boolean use XSS cleaning on the value
* @return string
*/
public static function get($name, $default = NULL, $xss_clean = FALSE)
{
return Input::instance()->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;
}
/**
* 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]);
// 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
// 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

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Date helper class.
*
@@ -9,397 +16,385 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class date_Core {
/**
* Converts a UNIX timestamp to DOS format.
*
* @param integer UNIX timestamp
* @return integer
*/
public static function unix2dos($timestamp = FALSE)
{
$timestamp = ($timestamp === FALSE) ? getdate() : getdate($timestamp);
if ($timestamp['year'] < 1980)
{
return (1 << 21 | 1 << 16);
}
$timestamp['year'] -= 1980;
// What voodoo is this? I have no idea... Geert can explain it though,
// and that's good enough for me.
return ($timestamp['year'] << 25 | $timestamp['mon'] << 21 |
$timestamp['mday'] << 16 | $timestamp['hours'] << 11 |
$timestamp['minutes'] << 5 | $timestamp['seconds'] >> 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
class date_Core
{
/**
* Converts a UNIX timestamp to DOS format.
*
* @param integer UNIX timestamp
* @return integer
*/
public static function unix2dos($timestamp = false)
{
$timestamp = ($timestamp === false) ? getdate() : getdate($timestamp);
if ($timestamp['year'] < 1980) {
return (1 << 21 | 1 << 16);
}
$timestamp['year'] -= 1980;
// What voodoo is this? I have no idea... Geert can explain it though,
// and that's good enough for me.
return ($timestamp['year'] << 25 | $timestamp['mon'] << 21 |
$timestamp['mday'] << 16 | $timestamp['hours'] << 11 |
$timestamp['minutes'] << 5 | $timestamp['seconds'] >> 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

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Download helper class.
*
@@ -9,97 +16,88 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class download_Core {
class download_Core
{
/**
* Force a download of a file to the user's browser. This function is
* binary-safe and will work with any MIME type that Kohana is aware of.
*
* @param string a file path or file name
* @param mixed data to be sent if the filename does not exist
* @param string suggested filename to display in the download
* @return void
*/
public static function force($filename = null, $data = null, $nicename = null)
{
if (empty($filename)) {
return false;
}
/**
* Force a download of a file to the user's browser. This function is
* binary-safe and will work with any MIME type that Kohana is aware of.
*
* @param string a file path or file name
* @param mixed data to be sent if the filename does not exist
* @param string suggested filename to display in the download
* @return void
*/
public static function force($filename = NULL, $data = NULL, $nicename = NULL)
{
if (empty($filename))
return FALSE;
if (is_file($filename)) {
// Get the real path
$filepath = str_replace('\\', '/', realpath($filename));
if (is_file($filename))
{
// Get the real path
$filepath = str_replace('\\', '/', realpath($filename));
// Set filesize
$filesize = filesize($filepath);
// Set filesize
$filesize = filesize($filepath);
// Get filename
$filename = substr(strrchr('/' . $filepath, '/'), 1);
// Get filename
$filename = substr(strrchr('/'.$filepath, '/'), 1);
// Get extension
$extension = strtolower(substr(strrchr($filepath, '.'), 1));
} else {
// Get filesize
$filesize = strlen($data);
// Get extension
$extension = strtolower(substr(strrchr($filepath, '.'), 1));
}
else
{
// Get filesize
$filesize = strlen($data);
// Make sure the filename does not have directory info
$filename = substr(strrchr('/' . $filename, '/'), 1);
// Make sure the filename does not have directory info
$filename = substr(strrchr('/'.$filename, '/'), 1);
// Get extension
$extension = strtolower(substr(strrchr($filename, '.'), 1));
}
// Get extension
$extension = strtolower(substr(strrchr($filename, '.'), 1));
}
// Get the mime type of the file
$mime = Kohana::config('mimes.' . $extension);
// Get the mime type of the file
$mime = Kohana::config('mimes.'.$extension);
if (empty($mime)) {
// Set a default mime if none was found
$mime = array('application/octet-stream');
}
if (empty($mime))
{
// Set a default mime if none was found
$mime = array('application/octet-stream');
}
// Generate the server headers
header('Content-Type: ' . $mime[0]);
header('Content-Disposition: attachment; filename="' . (empty($nicename) ? $filename : $nicename) . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . sprintf('%d', $filesize));
// Generate the server headers
header('Content-Type: '.$mime[0]);
header('Content-Disposition: attachment; filename="'.(empty($nicename) ? $filename : $nicename).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filesize));
// More caching prevention
header('Expires: 0');
// More caching prevention
header('Expires: 0');
if (Kohana::user_agent('browser') === 'Internet Explorer') {
// Send IE headers
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
// Send normal headers
header('Pragma: no-cache');
}
if (Kohana::user_agent('browser') === 'Internet Explorer')
{
// Send IE headers
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else
{
// Send normal headers
header('Pragma: no-cache');
}
// Clear the output buffer
Kohana::close_buffers(false);
// Clear the output buffer
Kohana::close_buffers(FALSE);
if (isset($filepath)) {
// Open the file
$handle = fopen($filepath, 'rb');
if (isset($filepath))
{
// Open the file
$handle = fopen($filepath, 'rb');
// Send the file data
fpassthru($handle);
// Send the file data
fpassthru($handle);
// Close the file
fclose($handle);
}
else
{
// Send the file data
echo $data;
}
}
} // End download
// Close the file
fclose($handle);
} else {
// Send the file data
echo $data;
}
}
}
// End download

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Email helper class.
*
@@ -9,173 +16,156 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class email_Core {
class email_Core
{
// SwiftMailer instance
protected static $mail;
// SwiftMailer instance
protected static $mail;
/**
* Creates a SwiftMailer instance.
*
* @param string DSN connection string
* @return object Swift object
*/
public static function connect($config = null)
{
if (! class_exists('Swift', false)) {
// Load SwiftMailer
require Kohana::find_file('vendor', 'swift/Swift');
/**
* Creates a SwiftMailer instance.
*
* @param string DSN connection string
* @return object Swift object
*/
public static function connect($config = NULL)
{
if ( ! class_exists('Swift', FALSE))
{
// Load SwiftMailer
require Kohana::find_file('vendor', 'swift/Swift');
// Register the Swift ClassLoader as an autoload
spl_autoload_register(array('Swift_ClassLoader', 'load'));
}
// Register the Swift ClassLoader as an autoload
spl_autoload_register(array('Swift_ClassLoader', 'load'));
}
// Load default configuration
($config === null) and $config = Kohana::config('email');
// Load default configuration
($config === NULL) and $config = Kohana::config('email');
switch ($config['driver']) {
case 'smtp':
// Set port
$port = empty($config['options']['port']) ? null : (int) $config['options']['port'];
switch ($config['driver'])
{
case 'smtp':
// Set port
$port = empty($config['options']['port']) ? NULL : (int) $config['options']['port'];
if (empty($config['options']['encryption'])) {
// No encryption
$encryption = Swift_Connection_SMTP::ENC_OFF;
} else {
// Set encryption
switch (strtolower($config['options']['encryption'])) {
case 'tls':
$encryption = Swift_Connection_SMTP::ENC_TLS;
break;
case 'ssl':
$encryption = Swift_Connection_SMTP::ENC_SSL;
break;
}
}
if (empty($config['options']['encryption']))
{
// No encryption
$encryption = Swift_Connection_SMTP::ENC_OFF;
}
else
{
// Set encryption
switch (strtolower($config['options']['encryption']))
{
case 'tls': $encryption = Swift_Connection_SMTP::ENC_TLS; break;
case 'ssl': $encryption = Swift_Connection_SMTP::ENC_SSL; break;
}
}
// Create a SMTP connection
$connection = new Swift_Connection_SMTP($config['options']['hostname'], $port, $encryption);
// Create a SMTP connection
$connection = new Swift_Connection_SMTP($config['options']['hostname'], $port, $encryption);
// Do authentication, if part of the DSN
empty($config['options']['username']) or $connection->setUsername($config['options']['username']);
empty($config['options']['password']) or $connection->setPassword($config['options']['password']);
// Do authentication, if part of the DSN
empty($config['options']['username']) or $connection->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 ( ! 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$');
}
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;
// Prepare the class name for auto-loading
$class = 'Swift_Authenticator_'.$class;
// Attach the authenticator
$connection->attachAuthenticator(($params === null) ? new $class() : new $class($params[0]));
}
// 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(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;
}
// 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);
}
// 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();
/**
* 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';
// Determine the message type
$html = ($html === TRUE) ? 'text/html' : 'text/plain';
// Create the message
$message = new Swift_Message($subject, $message, $html, '8bit', 'utf-8');
// 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);
}
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();
// 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';
}
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);
// 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_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]);
}
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
return email::$mail->send($message, $recipients, $from);
}
}
// End email

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Controls headers that effect client caching of pages
*
@@ -9,103 +16,97 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class expires_Core {
class expires_Core
{
/**
* Sets the amount of time before a page expires
*
* @param integer Seconds before the page expires
* @return boolean
*/
public static function set($seconds = 60)
{
if (expires::check_headers()) {
$now = $expires = time();
/**
* Sets the amount of time before a page expires
*
* @param integer Seconds before the page expires
* @return boolean
*/
public static function set($seconds = 60)
{
if (expires::check_headers())
{
$now = $expires = time();
// Set the expiration timestamp
$expires += $seconds;
// Set the expiration timestamp
$expires += $seconds;
// Send headers
header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $now));
header('Expires: ' . gmdate('D, d M Y H:i:s T', $expires));
header('Cache-Control: max-age=' . $seconds);
// Send headers
header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $now));
header('Expires: '.gmdate('D, d M Y H:i:s T', $expires));
header('Cache-Control: max-age='.$seconds);
return $expires;
}
return $expires;
}
return false;
}
return FALSE;
}
/**
* Checks to see if a page should be updated or send Not Modified status
*
* @param integer Seconds added to the modified time received to calculate what should be sent
* @return bool FALSE when the request needs to be updated
*/
public static function check($seconds = 60)
{
if (! empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) and expires::check_headers()) {
if (($strpos = strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], ';')) !== false) {
// IE6 and perhaps other IE versions send length too, compensate here
$mod_time = substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, $strpos);
} else {
$mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
/**
* Checks to see if a page should be updated or send Not Modified status
*
* @param integer Seconds added to the modified time received to calculate what should be sent
* @return bool FALSE when the request needs to be updated
*/
public static function check($seconds = 60)
{
if ( ! empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND expires::check_headers())
{
if (($strpos = strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], ';')) !== FALSE)
{
// IE6 and perhaps other IE versions send length too, compensate here
$mod_time = substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, $strpos);
}
else
{
$mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
$mod_time = strtotime($mod_time);
$mod_time_diff = $mod_time + $seconds - time();
$mod_time = strtotime($mod_time);
$mod_time_diff = $mod_time + $seconds - time();
if ($mod_time_diff > 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);
if ($mod_time_diff > 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'));
// Prevent any output
Event::add('system.display', array('expires', 'prevent_output'));
// Exit to prevent other output
exit;
}
}
// Exit to prevent other output
exit;
}
}
return false;
}
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;
}
}
/**
* 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;
}
return TRUE;
}
/**
* Prevent any output from being displayed. Executed during system.display.
*
* @return void
*/
public static function prevent_output()
{
Kohana::$output = '';
}
} // End expires
/**
* Prevent any output from being displayed. Executed during system.display.
*
* @return void
*/
public static function prevent_output()
{
Kohana::$output = '';
}
}
// End expires

View File

@@ -1,4 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Feed helper class.
*
@@ -9,114 +16,107 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class feed_Core {
class feed_Core
{
/**
* Parses a remote feed into an array.
*
* @param string remote feed URL
* @param integer item limit to fetch
* @return array
*/
public static function parse($feed, $limit = 0)
{
// Check if SimpleXML is installed
if (! function_exists('simplexml_load_file')) {
throw new Kohana_User_Exception('Feed Error', 'SimpleXML must be installed!');
}
/**
* Parses a remote feed into an array.
*
* @param string remote feed URL
* @param integer item limit to fetch
* @return array
*/
public static function parse($feed, $limit = 0)
{
// Check if SimpleXML is installed
if( ! function_exists('simplexml_load_file'))
throw new Kohana_User_Exception('Feed Error', 'SimpleXML must be installed!');
// Make limit an integer
$limit = (int) $limit;
// Make limit an integer
$limit = (int) $limit;
// Disable error reporting while opening the feed
$ER = error_reporting(0);
// Disable error reporting while opening the feed
$ER = error_reporting(0);
// Allow loading by filename or raw XML string
$load = (is_file($feed) OR valid::url($feed)) ? 'simplexml_load_file' : 'simplexml_load_string';
// Allow loading by filename or raw XML string
$load = (is_file($feed) or valid::url($feed)) ? 'simplexml_load_file' : 'simplexml_load_string';
// Load the feed
$feed = $load($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
// Load the feed
$feed = $load($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
// Restore error reporting
error_reporting($ER);
// Restore error reporting
error_reporting($ER);
// Feed could not be loaded
if ($feed === FALSE)
return array();
// Feed could not be loaded
if ($feed === false) {
return array();
}
// Detect the feed type. RSS 1.0/2.0 and Atom 1.0 are supported.
$feed = isset($feed->channel) ? $feed->xpath('//item') : $feed->entry;
// Detect the feed type. RSS 1.0/2.0 and Atom 1.0 are supported.
$feed = isset($feed->channel) ? $feed->xpath('//item') : $feed->entry;
$i = 0;
$items = array();
$i = 0;
$items = array();
foreach ($feed as $item)
{
if ($limit > 0 AND $i++ === $limit)
break;
foreach ($feed as $item) {
if ($limit > 0 and $i++ === $limit) {
break;
}
$items[] = (array) $item;
}
$items[] = (array) $item;
}
return $items;
}
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');
/**
* 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 = '<?xml version="1.0" encoding="'.$encoding.'"?><rss version="2.0"><channel></channel></rss>';
$feed = simplexml_load_string($feed);
$feed = '<?xml version="1.0" encoding="' . $encoding . '"?><rss version="2.0"><channel></channel></rss>';
$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');
}
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);
}
// 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 ($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');
}
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);
}
}
// Add the info to the row
$row->addChild($name, $value);
}
}
return $feed->asXML();
}
} // End feed
return $feed->asXML();
}
}
// End feed

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* File helper class.
*
@@ -9,178 +17,171 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class file_Core {
class file_Core
{
/**
* Attempt to get the mime type from a file. This method is horribly
* unreliable, due to PHP being horribly unreliable when it comes to
* determining the mime-type of a file.
*
* @param string filename
* @return string mime-type, if found
* @return boolean FALSE, if not found
*/
public static function mime($filename)
{
// Make sure the file is readable
if (! (is_file($filename) and is_readable($filename))) {
return false;
}
/**
* Attempt to get the mime type from a file. This method is horribly
* unreliable, due to PHP being horribly unreliable when it comes to
* determining the mime-type of a file.
*
* @param string filename
* @return string mime-type, if found
* @return boolean FALSE, if not found
*/
public static function mime($filename)
{
// Make sure the file is readable
if ( ! (is_file($filename) AND is_readable($filename)))
return FALSE;
// Get the extension from the filename
$extension = strtolower(substr(strrchr($filename, '.'), 1));
// Get the extension from the filename
$extension = strtolower(substr(strrchr($filename, '.'), 1));
if (preg_match('/^(?:jpe?g|png|[gt]if|bmp|swf)$/', $extension)) {
// Disable error reporting
$ER = error_reporting(0);
if (preg_match('/^(?:jpe?g|png|[gt]if|bmp|swf)$/', $extension))
{
// Disable error reporting
$ER = error_reporting(0);
// Use getimagesize() to find the mime type on images
$mime = getimagesize($filename);
// Use getimagesize() to find the mime type on images
$mime = getimagesize($filename);
// Turn error reporting back on
error_reporting($ER);
// Turn error reporting back on
error_reporting($ER);
// Return the mime type
if (isset($mime['mime'])) {
return $mime['mime'];
}
}
// Return the mime type
if (isset($mime['mime']))
return $mime['mime'];
}
if (function_exists('finfo_open')) {
// Use the fileinfo extension
$finfo = finfo_open(FILEINFO_MIME);
$mime = finfo_file($finfo, $filename);
finfo_close($finfo);
if (function_exists('finfo_open'))
{
// Use the fileinfo extension
$finfo = finfo_open(FILEINFO_MIME);
$mime = finfo_file($finfo, $filename);
finfo_close($finfo);
// Return the mime type
return $mime;
}
// Return the mime type
return $mime;
}
if (ini_get('mime_magic.magicfile') and function_exists('mime_content_type')) {
// Return the mime type using mime_content_type
return mime_content_type($filename);
}
if (ini_get('mime_magic.magicfile') AND function_exists('mime_content_type'))
{
// Return the mime type using mime_content_type
return mime_content_type($filename);
}
if (! KOHANA_IS_WIN) {
// Attempt to locate use the file command, checking the return value
if ($command = trim(exec('which file', $output, $return)) and $return === 0) {
return trim(exec($command . ' -bi ' . escapeshellarg($filename)));
}
}
if ( ! KOHANA_IS_WIN)
{
// Attempt to locate use the file command, checking the return value
if ($command = trim(exec('which file', $output, $return)) AND $return === 0)
{
return trim(exec($command.' -bi '.escapeshellarg($filename)));
}
}
if (! empty($extension) and is_array($mime = Kohana::config('mimes.' . $extension))) {
// Return the mime-type guess, based on the extension
return $mime[0];
}
if ( ! empty($extension) AND is_array($mime = Kohana::config('mimes.'.$extension)))
{
// Return the mime-type guess, based on the extension
return $mime[0];
}
// Unable to find the mime-type
return false;
}
// Unable to find the mime-type
return FALSE;
}
/**
* Split a file into pieces matching a specific size.
*
* @param string file to be split
* @param string directory to output to, defaults to the same directory as the file
* @param integer size, in MB, for each chunk to be
* @return integer The number of pieces that were created.
*/
public static function split($filename, $output_dir = false, $piece_size = 10)
{
// Find output dir
$output_dir = ($output_dir == false) ? pathinfo(str_replace('\\', '/', realpath($filename)), PATHINFO_DIRNAME) : str_replace('\\', '/', realpath($output_dir));
$output_dir = rtrim($output_dir, '/') . '/';
/**
* Split a file into pieces matching a specific size.
*
* @param string file to be split
* @param string directory to output to, defaults to the same directory as the file
* @param integer size, in MB, for each chunk to be
* @return integer The number of pieces that were created.
*/
public static function split($filename, $output_dir = FALSE, $piece_size = 10)
{
// Find output dir
$output_dir = ($output_dir == FALSE) ? pathinfo(str_replace('\\', '/', realpath($filename)), PATHINFO_DIRNAME) : str_replace('\\', '/', realpath($output_dir));
$output_dir = rtrim($output_dir, '/').'/';
// Open files for writing
$input_file = fopen($filename, 'rb');
// Open files for writing
$input_file = fopen($filename, 'rb');
// Change the piece size to bytes
$piece_size = 1024 * 1024 * (int) $piece_size; // Size in bytes
// Change the piece size to bytes
$piece_size = 1024 * 1024 * (int) $piece_size; // Size in bytes
// Set up reading variables
$read = 0; // Number of bytes read
$piece = 1; // Current piece
$chunk = 1024 * 8; // Chunk size to read
// Set up reading variables
$read = 0; // Number of bytes read
$piece = 1; // Current piece
$chunk = 1024 * 8; // Chunk size to read
// Split the file
while (! feof($input_file)) {
// Open a new piece
$piece_name = $filename . '.' . str_pad($piece, 3, '0', STR_PAD_LEFT);
$piece_open = @fopen($piece_name, 'wb+') or die('Could not write piece ' . $piece_name);
// Split the file
while ( ! feof($input_file))
{
// Open a new piece
$piece_name = $filename.'.'.str_pad($piece, 3, '0', STR_PAD_LEFT);
$piece_open = @fopen($piece_name, 'wb+') or die('Could not write piece '.$piece_name);
// Fill the current piece
while ($read < $piece_size and $data = fread($input_file, $chunk)) {
fwrite($piece_open, $data) or die('Could not write to open piece ' . $piece_name);
$read += $chunk;
}
// Fill the current piece
while ($read < $piece_size AND $data = fread($input_file, $chunk))
{
fwrite($piece_open, $data) or die('Could not write to open piece '.$piece_name);
$read += $chunk;
}
// Close the current piece
fclose($piece_open);
// Close the current piece
fclose($piece_open);
// Prepare to open a new piece
$read = 0;
$piece++;
// Prepare to open a new piece
$read = 0;
$piece++;
// Make sure that piece is valid
($piece < 999) or die('Maximum of 999 pieces exceeded, try a larger piece size');
}
// Make sure that piece is valid
($piece < 999) or die('Maximum of 999 pieces exceeded, try a larger piece size');
}
// Close input file
fclose($input_file);
// Close input file
fclose($input_file);
// Returns the number of pieces that were created
return ($piece - 1);
}
// Returns the number of pieces that were created
return ($piece - 1);
}
/**
* Join a split file into a whole file.
*
* @param string split filename, without .000 extension
* @param string output filename, if different then an the filename
* @return integer The number of pieces that were joined.
*/
public static function join($filename, $output = false)
{
if ($output == false) {
$output = $filename;
}
/**
* Join a split file into a whole file.
*
* @param string split filename, without .000 extension
* @param string output filename, if different then an the filename
* @return integer The number of pieces that were joined.
*/
public static function join($filename, $output = FALSE)
{
if ($output == FALSE)
$output = $filename;
// Set up reading variables
$piece = 1; // Current piece
$chunk = 1024 * 8; // Chunk size to read
// Set up reading variables
$piece = 1; // Current piece
$chunk = 1024 * 8; // Chunk size to read
// Open output file
$output_file = @fopen($output, 'wb+') or die('Could not open output file ' . $output);
// Open output file
$output_file = @fopen($output, 'wb+') or die('Could not open output file '.$output);
// Read each piece
while ($piece_open = @fopen(($piece_name = $filename . '.' . str_pad($piece, 3, '0', STR_PAD_LEFT)), 'rb')) {
// Write the piece into the output file
while (! feof($piece_open)) {
fwrite($output_file, fread($piece_open, $chunk));
}
// Read each piece
while ($piece_open = @fopen(($piece_name = $filename.'.'.str_pad($piece, 3, '0', STR_PAD_LEFT)), 'rb'))
{
// Write the piece into the output file
while ( ! feof($piece_open))
{
fwrite($output_file, fread($piece_open, $chunk));
}
// Close the current piece
fclose($piece_open);
// Close the current piece
fclose($piece_open);
// Prepare for a new piece
$piece++;
// Prepare for a new piece
$piece++;
// Make sure piece is valid
($piece < 999) or die('Maximum of 999 pieces exceeded');
}
// Make sure piece is valid
($piece < 999) or die('Maximum of 999 pieces exceeded');
}
// Close the output file
fclose($output_file);
// Close the output file
fclose($output_file);
// Return the number of pieces joined
return ($piece - 1);
}
} // End file
// Return the number of pieces joined
return ($piece - 1);
}
}
// End file

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Form helper class.
*
@@ -9,534 +17,489 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class form_Core {
class form_Core
{
/**
* Generates an opening HTML form tag.
*
* @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($action = null, $attr = array(), $hidden = null)
{
// Make sure that the method is always set
empty($attr['method']) and $attr['method'] = 'post';
/**
* Generates an opening HTML form tag.
*
* @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($action = NULL, $attr = array(), $hidden = NULL)
{
// Make sure that the method is always set
empty($attr['method']) and $attr['method'] = 'post';
if ($attr['method'] !== 'post' and $attr['method'] !== 'get') {
// If the method is invalid, use post
$attr['method'] = 'post';
}
if ($attr['method'] !== 'post' AND $attr['method'] !== 'get')
{
// If the method is invalid, use post
$attr['method'] = 'post';
}
if ($action === null) {
// Use the current URL as the default action
$action = url::site(Router::$complete_uri);
} elseif (strpos($action, '://') === false) {
// Make the action URI into a URL
$action = url::site($action);
}
if ($action === NULL)
{
// Use the current URL as the default action
$action = url::site(Router::$complete_uri);
}
elseif (strpos($action, '://') === FALSE)
{
// Make the action URI into a URL
$action = url::site($action);
}
// Set action
$attr['action'] = $action;
// Set action
$attr['action'] = $action;
// Form opening tag
$form = '<form' . form::attributes($attr) . '>' . "\n";
// Form opening tag
$form = '<form'.form::attributes($attr).'>'."\n";
// Add hidden fields immediate after opening tag
empty($hidden) or $form .= form::hidden($hidden);
// Add hidden fields immediate after opening tag
empty($hidden) or $form .= form::hidden($hidden);
return $form;
}
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';
/**
* 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);
}
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 '<fieldset' . html::attributes((array) $data) . ' ' . $extra . '>' . "\n";
}
/**
* 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 '<fieldset'.html::attributes((array) $data).' '.$extra.'>'."\n";
}
/**
* Generates a fieldset closing tag.
*
* @return string
*/
public static function close_fieldset()
{
return '</fieldset>' . "\n";
}
/**
* Generates a fieldset closing tag.
*
* @return string
*/
public static function close_fieldset()
{
return '</fieldset>'."\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 '<legend' . form::attributes((array) $data) . ' ' . $extra . '>' . $text . '</legend>' . "\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 '<legend'.form::attributes((array) $data).' '.$extra.'>'.$text.'</legend>'."\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
);
}
/**
* 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 = '';
foreach ($data as $name => $value)
{
$attr = array
(
'type' => 'hidden',
'name' => $name,
'value' => $value
);
$input .= form::input($attr) . "\n";
}
$input .= form::input($attr)."\n";
}
return $input;
}
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);
}
/**
* 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
);
// Type and value are required attributes
$data += array
(
'type' => 'text',
'value' => $value
);
return '<input' . form::attributes($data) . ' ' . $extra . ' />';
}
return '<input'.form::attributes($data).' '.$extra.' />';
}
/**
* 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);
}
/**
* 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';
$data['type'] = 'password';
return form::input($data, $value, $extra);
}
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);
}
/**
* 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';
$data['type'] = 'file';
return form::input($data, $value, $extra);
}
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);
}
/**
* 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;
// 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']);
// Value is not part of the attributes
unset($data['value']);
return '<textarea' . form::attributes($data, 'textarea') . ' ' . $extra . '>' . html::specialchars($value, $double_encode) . '</textarea>';
}
return '<textarea'.form::attributes($data, 'textarea').' '.$extra.'>'.html::specialchars($value, $double_encode).'</textarea>';
}
/**
* 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'];
}
/**
* 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 (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);
}
if (is_array($selected))
{
// Multi-select box
$data['multiple'] = 'multiple';
}
else
{
// Single selection (but converted to an array)
$selected = array($selected);
}
$input = '<select' . form::attributes($data, 'select') . ' ' . $extra . '>' . "\n";
foreach ((array) $options as $key => $val) {
// Key should always be a string
$key = (string) $key;
$input = '<select'.form::attributes($data, 'select').' '.$extra.'>'."\n";
foreach ((array) $options as $key => $val)
{
// Key should always be a string
$key = (string) $key;
if (is_array($val)) {
$input .= '<optgroup label="' . $key . '">' . "\n";
foreach ($val as $inner_key => $inner_val) {
// Inner key should always be a string
$inner_key = (string) $inner_key;
if (is_array($val))
{
$input .= '<optgroup label="'.$key.'">'."\n";
foreach ($val as $inner_key => $inner_val)
{
// Inner key should always be a string
$inner_key = (string) $inner_key;
$sel = in_array($inner_key, $selected) ? ' selected="selected"' : '';
$input .= '<option value="' . $inner_key . '"' . $sel . '>' . $inner_val . '</option>' . "\n";
}
$input .= '</optgroup>' . "\n";
} else {
$sel = in_array($key, $selected) ? ' selected="selected"' : '';
$input .= '<option value="' . $key . '"' . $sel . '>' . $val . '</option>' . "\n";
}
}
$input .= '</select>';
$sel = in_array($inner_key, $selected) ? ' selected="selected"' : '';
$input .= '<option value="'.$inner_key.'"'.$sel.'>'.$inner_val.'</option>'."\n";
}
$input .= '</optgroup>'."\n";
}
else
{
$sel = in_array($key, $selected) ? ' selected="selected"' : '';
$input .= '<option value="'.$key.'"'.$sel.'>'.$val.'</option>'."\n";
}
}
$input .= '</select>';
return $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);
}
/**
* 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';
$data['type'] = 'checkbox';
if ($checked == true or (isset($data['checked']) and $data['checked'] == true)) {
$data['checked'] = 'checked';
} else {
unset($data['checked']);
}
if ($checked == TRUE OR (isset($data['checked']) AND $data['checked'] == TRUE))
{
$data['checked'] = 'checked';
}
else
{
unset($data['checked']);
}
return form::input($data, $value, $extra);
}
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);
}
/**
* 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';
$data['type'] = 'radio';
if ($checked == true or (isset($data['checked']) and $data['checked'] == true)) {
$data['checked'] = 'checked';
} else {
unset($data['checked']);
}
if ($checked == TRUE OR (isset($data['checked']) AND $data['checked'] == TRUE))
{
$data['checked'] = 'checked';
}
else
{
unset($data['checked']);
}
return form::input($data, $value, $extra);
}
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);
}
/**
* 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']);
}
if (empty($data['name']))
{
// Remove the name if it is empty
unset($data['name']);
}
$data['type'] = 'submit';
$data['type'] = 'submit';
return form::input($data, $value, $extra);
}
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);
}
/**
* 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 (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);
}
if (isset($data['value']) AND empty($value))
{
$value = arr::remove('value', $data);
}
return '<button' . form::attributes($data, 'button') . ' ' . $extra . '>' . $value . '</button>';
}
return '<button'.form::attributes($data, 'button').' '.$extra.'>'.$value.'</button>';
}
/**
* Closes an open form tag.
*
* @param string string to be attached after the closing tag
* @return string
*/
public static function close($extra = '')
{
return '</form>' . "\n" . $extra;
}
/**
* Closes an open form tag.
*
* @param string string to be attached after the closing tag
* @return string
*/
public static function close($extra = '')
{
return '</form>'."\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();
}
}
/**
* 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']));
}
if ($text === NULL AND isset($data['for']))
{
// Make the text the human-readable input name
$text = ucwords(inflector::humanize($data['for']));
}
return '<label' . form::attributes($data) . ' ' . $extra . '>' . $text . '</label>';
}
return '<label'.form::attributes($data).' '.$extra.'>'.$text.'</label>';
}
/**
* 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 '';
}
/**
* 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'];
}
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;
}
}
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'
);
$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];
$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]);
}
}
// 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
// Combine the sorted and unsorted attributes and create an HTML string
return html::attributes(array_merge($sorted, $attr));
}
}
// End form

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Format helper class.
*
@@ -9,58 +17,60 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class format_Core {
class format_Core
{
/**
* Formats a phone number according to the specified format.
*
* @param string phone number
* @param string format string
* @return string
*/
public static function phone($number, $format = '3-3-4')
{
// Get rid of all non-digit characters in number string
$number_clean = preg_replace('/\D+/', '', (string) $number);
/**
* Formats a phone number according to the specified format.
*
* @param string phone number
* @param string format string
* @return string
*/
public static function phone($number, $format = '3-3-4')
{
// Get rid of all non-digit characters in number string
$number_clean = preg_replace('/\D+/', '', (string) $number);
// Array of digits we need for a valid format
$format_parts = preg_split('/[^1-9][^0-9]*/', $format, -1, PREG_SPLIT_NO_EMPTY);
// Array of digits we need for a valid format
$format_parts = preg_split('/[^1-9][^0-9]*/', $format, -1, PREG_SPLIT_NO_EMPTY);
// Number must match digit count of a valid format
if (strlen($number_clean) !== array_sum($format_parts)) {
return $number;
}
// Number must match digit count of a valid format
if (strlen($number_clean) !== array_sum($format_parts))
return $number;
// Build regex
$regex = '(\d{' . implode('})(\d{', $format_parts) . '})';
// Build regex
$regex = '(\d{'.implode('})(\d{', $format_parts).'})';
// Build replace string
for ($i = 1, $c = count($format_parts); $i <= $c; $i++) {
$format = preg_replace('/(?<!\$)[1-9][0-9]*/', '\$' . $i, $format, 1);
}
// Build replace string
for ($i = 1, $c = count($format_parts); $i <= $c; $i++)
{
$format = preg_replace('/(?<!\$)[1-9][0-9]*/', '\$'.$i, $format, 1);
}
// Hocus pocus!
return preg_replace('/^' . $regex . '$/', $format, $number_clean);
}
// Hocus pocus!
return preg_replace('/^'.$regex.'$/', $format, $number_clean);
}
/**
* Formats a URL to contain a protocol at the beginning.
*
* @param string possibly incomplete URL
* @return string
*/
public static function url($str = '')
{
// Clear protocol-only strings like "http://"
if ($str === '' or substr($str, -3) === '://') {
return '';
}
/**
* Formats a URL to contain a protocol at the beginning.
*
* @param string possibly incomplete URL
* @return string
*/
public static function url($str = '')
{
// Clear protocol-only strings like "http://"
if ($str === '' OR substr($str, -3) === '://')
return '';
// If no protocol given, prepend "http://" by default
if (strpos($str, '://') === false) {
return 'http://' . $str;
}
// If no protocol given, prepend "http://" by default
if (strpos($str, '://') === FALSE)
return 'http://'.$str;
// Return the original URL
return $str;
}
} // End format
// Return the original URL
return $str;
}
}
// End format

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* HTML helper class.
*
@@ -9,438 +17,404 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class html_Core {
class html_Core
{
// Enable or disable automatic setting of target="_blank"
public static $windowed_urls = false;
// Enable or disable automatic setting of target="_blank"
public static $windowed_urls = FALSE;
/**
* Convert special characters to HTML entities
*
* @param string string to convert
* @param boolean encode existing entities
* @return string
*/
public static function specialchars($str, $double_encode = true)
{
// Force the string to be a string
$str = (string) $str;
/**
* Convert special characters to HTML entities
*
* @param string string to convert
* @param boolean encode existing entities
* @return string
*/
public static function specialchars($str, $double_encode = TRUE)
{
// Force the string to be a string
$str = (string) $str;
// Do encode existing HTML entities (default)
if ($double_encode === true) {
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
} else {
// Do not encode existing HTML entities
// From PHP 5.2.3 this functionality is built-in, otherwise use a regex
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8', false);
} else {
$str = preg_replace('/&(?!(?:#\d++|[a-z]++);)/ui', '&amp;', $str);
$str = str_replace(array('<', '>', '\'', '"'), array('&lt;', '&gt;', '&#39;', '&quot;'), $str);
}
}
// Do encode existing HTML entities (default)
if ($double_encode === TRUE)
{
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
else
{
// Do not encode existing HTML entities
// From PHP 5.2.3 this functionality is built-in, otherwise use a regex
if (version_compare(PHP_VERSION, '5.2.3', '>='))
{
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8', FALSE);
}
else
{
$str = preg_replace('/&(?!(?:#\d++|[a-z]++);)/ui', '&amp;', $str);
$str = str_replace(array('<', '>', '\'', '"'), array('&lt;', '&gt;', '&#39;', '&quot;'), $str);
}
}
return $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));
}
/**
* 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
* @param boolean option to escape the title that is output
* @return string
*/
public static function anchor($uri, $title = NULL, $attributes = NULL, $protocol = NULL, $escape_title = FALSE)
{
if ($uri === '')
{
$site_url = url::base(FALSE);
}
elseif (strpos($uri, '#') === 0)
{
// This is an id target link, not a URL
$site_url = $uri;
}
elseif (strpos($uri, '://') === FALSE)
{
$site_url = url::site($uri, $protocol);
}
else
{
if (html::$windowed_urls === TRUE AND empty($attributes['target']))
{
$attributes['target'] = '_blank';
}
/**
* 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
* @param boolean option to escape the title that is output
* @return string
*/
public static function anchor($uri, $title = null, $attributes = null, $protocol = null, $escape_title = false)
{
if ($uri === '') {
$site_url = url::base(false);
} elseif (strpos($uri, '#') === 0) {
// This is an id target link, not a URL
$site_url = $uri;
} elseif (strpos($uri, '://') === false) {
$site_url = url::site($uri, $protocol);
} else {
if (html::$windowed_urls === true and empty($attributes['target'])) {
$attributes['target'] = '_blank';
}
$site_url = $uri;
}
$site_url = $uri;
}
return
// Parsed URL
'<a href="'.html::specialurlencode($site_url, FALSE).'"'
// Attributes empty? Use an empty string
.(is_array($attributes) ? html::attributes($attributes) : '').'>'
// Title empty? Use the parsed URL
.($escape_title ? html::specialchars((($title === NULL) ? $site_url : $title), FALSE) : (($title === NULL) ? $site_url : $title)).'</a>';
}
return
// Parsed URL
'<a href="' . html::specialurlencode($site_url, false) . '"'
// Attributes empty? Use an empty string
. (is_array($attributes) ? html::attributes($attributes) : '') . '>'
// Title empty? Use the parsed URL
. ($escape_title ? html::specialchars((($title === null) ? $site_url : $title), false) : (($title === null) ? $site_url : $title)) . '</a>';
}
/**
* 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
'<a href="'.html::specialurlencode(url::base(FALSE, $protocol).$file, FALSE).'"'
// Attributes empty? Use an empty string
.(is_array($attributes) ? html::attributes($attributes) : '').'>'
// Title empty? Use the filename part of the URI
.(($title === NULL) ? end(explode('/', $file)) : $title) .'</a>';
}
/**
* 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
'<a href="' . html::specialurlencode(url::base(false, $protocol) . $file, false) . '"'
// Attributes empty? Use an empty string
. (is_array($attributes) ? html::attributes($attributes) : '') . '>'
// Title empty? Use the filename part of the URI
. (($title === null) ? end(explode('/', $file)) : $title) . '</a>';
}
/**
* 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);
}
/**
* 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;
}
/**
* 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 .= '&#x'.dechex(ord($letter)).';'; break;
// Raw (no) encoding
case 3: $safe .= $letter;
}
}
/**
* 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 .= '&#x' . dechex(ord($letter)) . ';';
break;
// Raw (no) encoding
case 3:
$safe .= $letter;
}
}
return $safe;
}
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;
/**
* 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);
// 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 = '';
}
// 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);
// Obfuscate email address
$safe = html::email($email);
// Title defaults to the encoded email address
empty($title) and $title = $safe;
// Title defaults to the encoded email address
empty($title) and $title = $safe;
// Parse attributes
empty($attributes) or $attributes = html::attributes($attributes);
// Parse attributes
empty($attributes) or $attributes = html::attributes($attributes);
// Encoded start of the href="" is a static encoded version of 'mailto:'
return '<a href="&#109;&#097;&#105;&#108;&#116;&#111;&#058;'.$safe.$params.'"'.$attributes.'>'.$title.'</a>';
}
// Encoded start of the href="" is a static encoded version of 'mailto:'
return '<a href="&#109;&#097;&#105;&#108;&#116;&#111;&#058;' . $safe . $params . '"' . $attributes . '>' . $title . '</a>';
}
/**
* 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;
/**
* 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))
);
}
$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);
}
// 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);
}
/**
* 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);
}
// 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';
// Set the meta attribute value
$attr = in_array(strtolower($tag), Kohana::config('http.meta_equiv')) ? 'http-equiv' : 'name';
return '<meta '.$attr.'="'.$tag.'" content="'.$value.'" />';
}
return '<meta ' . $attr . '="' . $tag . '" content="' . $value . '" />';
}
/**
* 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 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 = '';
/**
* 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;
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;
}
$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);
$length = strlen($suffix);
if ( $length > 0 AND substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
{
// Add the defined suffix
$href .= $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,
);
$attr = array
(
'rel' => $rel,
'type' => $type,
'href' => $href,
);
if ( ! empty($media))
{
// Add the media type to the attributes
$attr['media'] = $media;
}
if (! empty($media)) {
// Add the media type to the attributes
$attr['media'] = $media;
}
$compiled = '<link'.html::attributes($attr).' />';
}
$compiled = '<link' . html::attributes($attr) . ' />';
}
return $compiled."\n";
}
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 = '';
/**
* 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 (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';
}
if (substr_compare($script, '.js', -3, 3, false) !== 0) {
// Add the javascript suffix
$script .= '.js';
}
$compiled = '<script type="text/javascript" src="'.$script.'"></script>';
}
$compiled = '<script type="text/javascript" src="' . $script . '"></script>';
}
return $compiled."\n";
}
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);
/**
* 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 (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'];
}
if (strpos($attributes['src'], '://') === false) {
// Make the src attribute into an absolute URL
$attributes['src'] = url::base($index) . $attributes['src'];
}
return '<img'.html::attributes($attributes).' />';
}
return '<img' . html::attributes($attributes) . ' />';
}
/**
* 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 '';
/**
* 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;
if (is_string($attrs)) {
return ' ' . $attrs;
}
$compiled = '';
foreach ($attrs as $key => $val)
{
$compiled .= ' '.$key.'="'.html::specialchars($val).'"';
}
$compiled = '';
foreach ($attrs as $key => $val) {
$compiled .= ' ' . $key . '="' . html::specialchars($val) . '"';
}
return $compiled;
}
} // End html
return $compiled;
}
}
// End html

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Inflector helper class.
*
@@ -9,185 +17,172 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class inflector_Core {
class inflector_Core
{
// Cached inflections
protected static $cache = array();
// Cached inflections
protected static $cache = array();
// Uncountable and irregular words
protected static $uncountable;
protected static $irregular;
// Uncountable and irregular words
protected static $uncountable;
protected static $irregular;
/**
* Checks if a word is defined as uncountable.
*
* @param string word to check
* @return boolean
*/
public static function uncountable($str)
{
if (inflector::$uncountable === null) {
// Cache uncountables
inflector::$uncountable = Kohana::config('inflector.uncountable');
/**
* Checks if a word is defined as uncountable.
*
* @param string word to check
* @return boolean
*/
public static function uncountable($str)
{
if (inflector::$uncountable === NULL)
{
// Cache uncountables
inflector::$uncountable = Kohana::config('inflector.uncountable');
// Make uncountables mirroed
inflector::$uncountable = array_combine(inflector::$uncountable, inflector::$uncountable);
}
// Make uncountables mirroed
inflector::$uncountable = array_combine(inflector::$uncountable, inflector::$uncountable);
}
return isset(inflector::$uncountable[strtolower($str)]);
}
return isset(inflector::$uncountable[strtolower($str)]);
}
/**
* Makes a plural word singular.
*
* @param string word to singularize
* @param integer number of things
* @return string
*/
public static function singular($str, $count = null)
{
// Remove garbage
$str = strtolower(trim($str));
/**
* Makes a plural word singular.
*
* @param string word to singularize
* @param integer number of things
* @return string
*/
public static function singular($str, $count = NULL)
{
// Remove garbage
$str = strtolower(trim($str));
if (is_string($count)) {
// Convert to integer when using a digit string
$count = (int) $count;
}
if (is_string($count))
{
// Convert to integer when using a digit string
$count = (int) $count;
}
// Do nothing with a single count
if ($count === 0 or $count > 1) {
return $str;
}
// Do nothing with a single count
if ($count === 0 OR $count > 1)
return $str;
// Cache key name
$key = 'singular_' . $str . $count;
// Cache key name
$key = 'singular_'.$str.$count;
if (isset(inflector::$cache[$key])) {
return inflector::$cache[$key];
}
if (isset(inflector::$cache[$key]))
return inflector::$cache[$key];
if (inflector::uncountable($str)) {
return inflector::$cache[$key] = $str;
}
if (inflector::uncountable($str))
return inflector::$cache[$key] = $str;
if (empty(inflector::$irregular)) {
// Cache irregular words
inflector::$irregular = Kohana::config('inflector.irregular');
}
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);
}
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;
}
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));
/**
* 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;
}
if (is_string($count))
{
// Convert to integer when using a digit string
$count = (int) $count;
}
// Do nothing with singular
if ($count === 1) {
return $str;
}
// Do nothing with singular
if ($count === 1)
return $str;
// Cache key name
$key = 'plural_' . $str . $count;
// Cache key name
$key = 'plural_'.$str.$count;
if (isset(inflector::$cache[$key])) {
return inflector::$cache[$key];
}
if (isset(inflector::$cache[$key]))
return inflector::$cache[$key];
if (inflector::uncountable($str)) {
return inflector::$cache[$key] = $str;
}
if (inflector::uncountable($str))
return inflector::$cache[$key] = $str;
if (empty(inflector::$irregular)) {
// Cache irregular words
inflector::$irregular = Kohana::config('inflector.irregular');
}
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';
}
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;
}
// 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));
/**
* 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);
}
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 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
/**
* 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

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Number helper class.
*
@@ -9,18 +17,18 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class num_Core {
/**
* Round a number to the nearest nth
*
* @param integer number to round
* @param integer number to round to
* @return integer
*/
public static function round($number, $nearest = 5)
{
return round($number / $nearest) * $nearest;
}
} // End num
class num_Core
{
/**
* Round a number to the nearest nth
*
* @param integer number to round
* @param integer number to round to
* @return integer
*/
public static function round($number, $nearest = 5)
{
return round($number / $nearest) * $nearest;
}
}
// End num

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Remote url/file helper.
*
@@ -9,58 +17,57 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class remote_Core {
class remote_Core
{
public static function status($url)
{
if (! valid::url($url, 'http')) {
return false;
}
public static function status($url)
{
if ( ! valid::url($url, 'http'))
return FALSE;
// Get the hostname and path
$url = parse_url($url);
// Get the hostname and path
$url = parse_url($url);
if (empty($url['path'])) {
// Request the root document
$url['path'] = '/';
}
if (empty($url['path']))
{
// Request the root document
$url['path'] = '/';
}
// Open a remote connection
$remote = fsockopen($url['host'], 80, $errno, $errstr, 5);
// Open a remote connection
$remote = fsockopen($url['host'], 80, $errno, $errstr, 5);
if (! is_resource($remote)) {
return false;
}
if ( ! is_resource($remote))
return FALSE;
// Set CRLF
$CRLF = "\r\n";
// Set CRLF
$CRLF = "\r\n";
// Send request
fwrite($remote, 'HEAD ' . $url['path'] . ' HTTP/1.0' . $CRLF);
fwrite($remote, 'Host: ' . $url['host'] . $CRLF);
fwrite($remote, 'Connection: close' . $CRLF);
fwrite($remote, 'User-Agent: Kohana Framework (+http://kohanaphp.com/)' . $CRLF);
// Send request
fwrite($remote, 'HEAD '.$url['path'].' HTTP/1.0'.$CRLF);
fwrite($remote, 'Host: '.$url['host'].$CRLF);
fwrite($remote, 'Connection: close'.$CRLF);
fwrite($remote, 'User-Agent: Kohana Framework (+http://kohanaphp.com/)'.$CRLF);
// Send one more CRLF to terminate the headers
fwrite($remote, $CRLF);
// Send one more CRLF to terminate the headers
fwrite($remote, $CRLF);
while (! feof($remote)) {
// Get the line
$line = trim(fgets($remote, 512));
while ( ! feof($remote))
{
// Get the line
$line = trim(fgets($remote, 512));
if ($line !== '' and preg_match('#^HTTP/1\.[01] (\d{3})#', $line, $matches)) {
// Response code found
$response = (int) $matches[1];
if ($line !== '' AND preg_match('#^HTTP/1\.[01] (\d{3})#', $line, $matches))
{
// Response code found
$response = (int) $matches[1];
break;
}
}
break;
}
}
// Close the connection
fclose($remote);
// Close the connection
fclose($remote);
return isset($response) ? $response : FALSE;
}
} // End remote
return isset($response) ? $response : false;
}
}
// End remote

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Request helper class.
*
@@ -9,231 +17,223 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class request_Core {
class request_Core
{
// Possible HTTP methods
protected static $http_methods = array('get', 'head', 'options', 'post', 'put', 'delete');
// Possible HTTP methods
protected static $http_methods = array('get', 'head', 'options', 'post', 'put', 'delete');
// Content types from client's HTTP Accept request header (array)
protected static $accept_types;
// Content types from client's HTTP Accept request header (array)
protected static $accept_types;
/**
* Returns the HTTP referrer, or the default if the referrer is not set.
*
* @param mixed default to return
* @return string
*/
public static function referrer($default = false)
{
if (! empty($_SERVER['HTTP_REFERER'])) {
// Set referrer
$ref = $_SERVER['HTTP_REFERER'];
/**
* Returns the HTTP referrer, or the default if the referrer is not set.
*
* @param mixed default to return
* @return string
*/
public static function referrer($default = FALSE)
{
if ( ! empty($_SERVER['HTTP_REFERER']))
{
// Set referrer
$ref = $_SERVER['HTTP_REFERER'];
if (strpos($ref, url::base(false)) === 0) {
// Remove the base URL from the referrer
$ref = substr($ref, strlen(url::base(false)));
}
}
if (strpos($ref, url::base(FALSE)) === 0)
{
// Remove the base URL from the referrer
$ref = substr($ref, strlen(url::base(FALSE)));
}
}
return isset($ref) ? $ref : $default;
}
return isset($ref) ? $ref : $default;
}
/**
* Returns the current request protocol, based on $_SERVER['https']. In CLI
* mode, NULL will be returned.
*
* @return string
*/
public static function protocol()
{
if (PHP_SAPI === 'cli') {
return null;
} elseif (! empty($_SERVER['HTTPS']) and $_SERVER['HTTPS'] === 'on') {
return 'https';
} else {
return 'http';
}
}
/**
* Returns the current request protocol, based on $_SERVER['https']. In CLI
* mode, NULL will be returned.
*
* @return string
*/
public static function protocol()
{
if (PHP_SAPI === 'cli')
{
return NULL;
}
elseif ( ! empty($_SERVER['HTTPS']) AND $_SERVER['HTTPS'] === 'on')
{
return 'https';
}
else
{
return 'http';
}
}
/**
* Tests if the current request is an AJAX request by checking the X-Requested-With HTTP
* request header that most popular JS frameworks now set for AJAX calls.
*
* @return boolean
*/
public static function is_ajax()
{
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
}
/**
* Tests if the current request is an AJAX request by checking the X-Requested-With HTTP
* request header that most popular JS frameworks now set for AJAX calls.
*
* @return boolean
*/
public static function is_ajax()
{
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
}
/**
* Returns current request method.
*
* @throws Kohana_Exception in case of an unknown request method
* @return string
*/
public static function method()
{
$method = strtolower($_SERVER['REQUEST_METHOD']);
/**
* Returns current request method.
*
* @throws Kohana_Exception in case of an unknown request method
* @return string
*/
public static function method()
{
$method = strtolower($_SERVER['REQUEST_METHOD']);
if (! in_array($method, request::$http_methods)) {
throw new Kohana_Exception('request.unknown_method', $method);
}
if ( ! in_array($method, request::$http_methods))
throw new Kohana_Exception('request.unknown_method', $method);
return $method;
}
return $method;
}
/**
* Returns boolean of whether client accepts content type.
*
* @param string content type
* @param boolean set to TRUE to disable wildcard checking
* @return boolean
*/
public static function accepts($type = null, $explicit_check = false)
{
request::parse_accept_header();
/**
* Returns boolean of whether client accepts content type.
*
* @param string content type
* @param boolean set to TRUE to disable wildcard checking
* @return boolean
*/
public static function accepts($type = NULL, $explicit_check = FALSE)
{
request::parse_accept_header();
if ($type === null) {
return request::$accept_types;
}
if ($type === NULL)
return request::$accept_types;
return (request::accepts_at_quality($type, $explicit_check) > 0);
}
return (request::accepts_at_quality($type, $explicit_check) > 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;
/**
* 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);
}
// 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;
}
}
// Look for the highest q value
foreach ($mime_types as $type => $q)
{
if ($q > $max_q)
{
$max_q = $q;
$preferred = $type;
}
}
return $preferred;
}
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();
/**
* 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);
// Normalize type
$type = strtolower((string) $type);
// General content type (e.g. "jpg")
if (strpos($type, '/') === false) {
// Don't accept anything by default
$q = 0;
// 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;
}
// 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;
}
return $q;
}
// Content type with subtype given (e.g. "image/jpg")
$type = explode('/', $type, 2);
// 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]];
}
// 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]]['*'];
}
// 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['*']['*'];
}
// 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;
}
// 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;
}
/**
* 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();
// 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;
}
// 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);
// 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);
// Explode each content type (e.g. "text/html")
$type = explode('/', $accept_entry[0], 2);
// Skip invalid content types
if (! isset($type[1])) {
continue;
}
// 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;
// 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
// 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

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Security helper class.
*
@@ -9,39 +17,39 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class security_Core {
class security_Core
{
/**
* Sanitize a string with the xss_clean method.
*
* @param string string to sanitize
* @return string
*/
public static function xss_clean($str)
{
return Input::instance()->xss_clean($str);
}
/**
* Sanitize a string with the xss_clean method.
*
* @param string string to sanitize
* @return string
*/
public static function xss_clean($str)
{
return Input::instance()->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('#<img\s.*?(?:src\s*=\s*["\']?([^"\'<>\s]*)["\']?[^>]*)?>#is', '$1', $str);
}
/**
* Remove image tags from a string.
*
* @param string string to sanitize
* @return string
*/
public static function strip_image_tags($str)
{
return preg_replace('#<img\s.*?(?:src\s*=\s*["\']?([^"\'<>\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('&lt;?', '?&gt;'), $str);
}
} // End security
/**
* 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('&lt;?', '?&gt;'), $str);
}
}
// End security

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Text helper class.
*
@@ -9,402 +17,382 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class text_Core {
class text_Core
{
/**
* Limits a phrase to a given number of words.
*
* @param string phrase to limit words of
* @param integer number of words to limit to
* @param string end character or entity
* @return string
*/
public static function limit_words($str, $limit = 100, $end_char = null)
{
$limit = (int) $limit;
$end_char = ($end_char === null) ? '&#8230;' : $end_char;
/**
* Limits a phrase to a given number of words.
*
* @param string phrase to limit words of
* @param integer number of words to limit to
* @param string end character or entity
* @return string
*/
public static function limit_words($str, $limit = 100, $end_char = NULL)
{
$limit = (int) $limit;
$end_char = ($end_char === NULL) ? '&#8230;' : $end_char;
if (trim($str) === '') {
return $str;
}
if (trim($str) === '')
return $str;
if ($limit <= 0) {
return $end_char;
}
if ($limit <= 0)
return $end_char;
preg_match('/^\s*+(?:\S++\s*+){1,' . $limit . '}/u', $str, $matches);
preg_match('/^\s*+(?:\S++\s*+){1,'.$limit.'}/u', $str, $matches);
// Only attach the end character if the matched string is shorter
// than the starting string.
return rtrim($matches[0]) . (strlen($matches[0]) === strlen($str) ? '' : $end_char);
}
// Only attach the end character if the matched string is shorter
// than the starting string.
return rtrim($matches[0]).(strlen($matches[0]) === strlen($str) ? '' : $end_char);
}
/**
* Limits a phrase to a given number of characters.
*
* @param string phrase to limit characters of
* @param integer number of characters to limit to
* @param string end character or entity
* @param boolean enable or disable the preservation of words while limiting
* @return string
*/
public static function limit_chars($str, $limit = 100, $end_char = null, $preserve_words = false)
{
$end_char = ($end_char === null) ? '&#8230;' : $end_char;
/**
* Limits a phrase to a given number of characters.
*
* @param string phrase to limit characters of
* @param integer number of characters to limit to
* @param string end character or entity
* @param boolean enable or disable the preservation of words while limiting
* @return string
*/
public static function limit_chars($str, $limit = 100, $end_char = NULL, $preserve_words = FALSE)
{
$end_char = ($end_char === NULL) ? '&#8230;' : $end_char;
$limit = (int) $limit;
$limit = (int) $limit;
if (trim($str) === '' or utf8::strlen($str) <= $limit) {
return $str;
}
if (trim($str) === '' OR utf8::strlen($str) <= $limit)
return $str;
if ($limit <= 0) {
return $end_char;
}
if ($limit <= 0)
return $end_char;
if ($preserve_words == false) {
return rtrim(utf8::substr($str, 0, $limit)) . $end_char;
}
if ($preserve_words == FALSE)
{
return rtrim(utf8::substr($str, 0, $limit)).$end_char;
}
preg_match('/^.{' . ($limit - 1) . '}\S*/us', $str, $matches);
preg_match('/^.{'.($limit - 1).'}\S*/us', $str, $matches);
return rtrim($matches[0]) . (strlen($matches[0]) == strlen($str) ? '' : $end_char);
}
return rtrim($matches[0]).(strlen($matches[0]) == strlen($str) ? '' : $end_char);
}
/**
* Alternates between two or more strings.
*
* @param string strings to alternate between
* @return string
*/
public static function alternate()
{
static $i;
/**
* Alternates between two or more strings.
*
* @param string strings to alternate between
* @return string
*/
public static function alternate()
{
static $i;
if (func_num_args() === 0) {
$i = 0;
return '';
}
if (func_num_args() === 0)
{
$i = 0;
return '';
}
$args = func_get_args();
return $args[($i++ % count($args))];
}
$args = func_get_args();
return $args[($i++ % count($args))];
}
/**
* Generates a random string of a given type and length.
*
* @param string a type of pool, or a string of characters to use as the pool
* @param integer length of string to return
* @return string
*
* @tutorial alnum alpha-numeric characters
* @tutorial alpha alphabetical characters
* @tutorial hexdec hexadecimal characters, 0-9 plus a-f
* @tutorial numeric digit characters, 0-9
* @tutorial nozero digit characters, 1-9
* @tutorial distinct clearly distinct alpha-numeric characters
*/
public static function random($type = 'alnum', $length = 8)
{
$utf8 = false;
/**
* Generates a random string of a given type and length.
*
* @param string a type of pool, or a string of characters to use as the pool
* @param integer length of string to return
* @return string
*
* @tutorial alnum alpha-numeric characters
* @tutorial alpha alphabetical characters
* @tutorial hexdec hexadecimal characters, 0-9 plus a-f
* @tutorial numeric digit characters, 0-9
* @tutorial nozero digit characters, 1-9
* @tutorial distinct clearly distinct alpha-numeric characters
*/
public static function random($type = 'alnum', $length = 8)
{
$utf8 = FALSE;
switch ($type) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
$pool = '0123456789abcdef';
break;
case 'numeric':
$pool = '0123456789';
break;
case 'nozero':
$pool = '123456789';
break;
case 'distinct':
$pool = '2345679ACDEFHJKLMNPRSTUVWXYZ';
break;
default:
$pool = (string) $type;
$utf8 = ! utf8::is_ascii($pool);
break;
}
switch ($type)
{
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
$pool = '0123456789abcdef';
break;
case 'numeric':
$pool = '0123456789';
break;
case 'nozero':
$pool = '123456789';
break;
case 'distinct':
$pool = '2345679ACDEFHJKLMNPRSTUVWXYZ';
break;
default:
$pool = (string) $type;
$utf8 = ! utf8::is_ascii($pool);
break;
}
// Split the pool into an array of characters
$pool = ($utf8 === true) ? utf8::str_split($pool, 1) : str_split($pool, 1);
// Split the pool into an array of characters
$pool = ($utf8 === TRUE) ? utf8::str_split($pool, 1) : str_split($pool, 1);
// Largest pool key
$max = count($pool) - 1;
// Largest pool key
$max = count($pool) - 1;
$str = '';
for ($i = 0; $i < $length; $i++) {
// Select a random character from the pool and add it to the string
$str .= $pool[mt_rand(0, $max)];
}
$str = '';
for ($i = 0; $i < $length; $i++)
{
// Select a random character from the pool and add it to the string
$str .= $pool[mt_rand(0, $max)];
}
// Make sure alnum strings contain at least one letter and one digit
if ($type === 'alnum' and $length > 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));
}
}
// Make sure alnum strings contain at least one letter and one digit
if ($type === 'alnum' AND $length > 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;
}
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('#(?<!:)//+#', '/', $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('#(?<!:)//+#', '/', $str);
}
/**
* Replaces the given words with a string.
*
* @param string phrase to replace words in
* @param array words to replace
* @param string replacement string
* @param boolean replace words across word boundries (space, period, etc)
* @return string
*/
public static function censor($str, $badwords, $replacement = '#', $replace_partial_words = false)
{
foreach ((array) $badwords as $key => $badword) {
$badwords[$key] = str_replace('\*', '\S*?', preg_quote((string) $badword));
}
/**
* Replaces the given words with a string.
*
* @param string phrase to replace words in
* @param array words to replace
* @param string replacement string
* @param boolean replace words across word boundries (space, period, etc)
* @return string
*/
public static function censor($str, $badwords, $replacement = '#', $replace_partial_words = FALSE)
{
foreach ((array) $badwords as $key => $badword)
{
$badwords[$key] = str_replace('\*', '\S*?', preg_quote((string) $badword));
}
$regex = '(' . implode('|', $badwords) . ')';
$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|$)';
}
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';
$regex = '!'.$regex.'!ui';
if (utf8::strlen($replacement) == 1) {
$regex .= 'e';
return preg_replace($regex, 'str_repeat($replacement, utf8::strlen(\'$1\'))', $str);
}
if (utf8::strlen($replacement) == 1)
{
$regex .= 'e';
return preg_replace($regex, 'str_repeat($replacement, utf8::strlen(\'$1\'))', $str);
}
return preg_replace($regex, $replacement, $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);
/**
* 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;
}
}
}
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);
}
// 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 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(?<!href="|">)(?: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);
}
}
/**
* 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(?<!href="|">)(?: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(?<!://)www(?:\.[a-z0-9][-a-z0-9]*+)+\.[a-z]{2,6}\b~i', $text, $matches)) {
foreach ($matches[0] as $match) {
// Replace each link with an anchor
$text = str_replace($match, html::anchor('http://' . $match, $match), $text);
}
}
// Find all naked www.links.com (without http://)
if (preg_match_all('~\b(?<!://)www(?:\.[a-z0-9][-a-z0-9]*+)+\.[a-z]{2,6}\b~i', $text, $matches))
{
foreach ($matches[0] as $match)
{
// Replace each link with an anchor
$text = str_replace($match, html::anchor('http://'.$match, $match), $text);
}
}
return $text;
}
return $text;
}
/**
* Converts text email addresses into links.
*
* @param string text to auto link
* @return string
*/
public static function auto_link_emails($text)
{
// Finds all email addresses that are not part of an existing html mailto anchor
// Note: The "58;" negative lookbehind prevents matching of existing encoded html mailto anchors
// The html entity for a colon (:) is &#58; or &#058; or &#0058; etc.
if (preg_match_all('~\b(?<!href="mailto:|">|58;)(?!\.)[-+_a-z0-9.]++(?<!\.)@(?![-.])[-a-z0-9.]+(?<!\.)\.[a-z]{2,6}\b~i', $text, $matches)) {
foreach ($matches[0] as $match) {
// Replace each email with an encoded mailto
$text = str_replace($match, html::mailto($match), $text);
}
}
/**
* Converts text email addresses into links.
*
* @param string text to auto link
* @return string
*/
public static function auto_link_emails($text)
{
// Finds all email addresses that are not part of an existing html mailto anchor
// Note: The "58;" negative lookbehind prevents matching of existing encoded html mailto anchors
// The html entity for a colon (:) is &#58; or &#058; or &#0058; etc.
if (preg_match_all('~\b(?<!href="mailto:|">|58;)(?!\.)[-+_a-z0-9.]++(?<!\.)@(?![-.])[-a-z0-9.]+(?<!\.)\.[a-z]{2,6}\b~i', $text, $matches))
{
foreach ($matches[0] as $match)
{
// Replace each email with an encoded mailto
$text = str_replace($match, html::mailto($match), $text);
}
}
return $text;
}
return $text;
}
/**
* Automatically applies <p> and <br /> 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 '';
}
/**
* Automatically applies <p> and <br /> 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);
// 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);
// 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))';
// 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);
}
// 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 <p> magic!
$str = '<p>' . trim($str) . '</p>';
$str = preg_replace('~\n{2,}~', "</p>\n\n<p>", $str);
// Do the <p> magic!
$str = '<p>'.trim($str).'</p>';
$str = preg_replace('~\n{2,}~', "</p>\n\n<p>", $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('~<p>(?=</?' . $no_p . '[^>]*+>)~i', '', $str);
$str = preg_replace('~(</?' . $no_p . '[^>]*+>)</p>~i', '$1', $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('~<p>(?=</?'.$no_p.'[^>]*+>)~i', '', $str);
$str = preg_replace('~(</?'.$no_p.'[^>]*+>)</p>~i', '$1', $str);
}
// Convert single linebreaks to <br />
$str = preg_replace('~(?<!\n)\n(?!\n)~', "<br />\n", $str);
// Convert single linebreaks to <br />
$str = preg_replace('~(?<!\n)\n(?!\n)~', "<br />\n", $str);
return $str;
}
return $str;
}
/**
* Returns human readable sizes.
* @see Based on original functions written by:
* @see Aidan Lister: http://aidanlister.com/repos/v/function.size_readable.php
* @see Quentin Zervaas: http://www.phpriot.com/d/code/strings/filesize-format/
*
* @param integer size in bytes
* @param string a definitive unit
* @param string the return string format
* @param boolean whether to use SI prefixes or IEC
* @return string
*/
public static function bytes($bytes, $force_unit = null, $format = null, $si = true)
{
// Format string
$format = ($format === null) ? '%01.2f %s' : (string) $format;
/**
* Returns human readable sizes.
* @see Based on original functions written by:
* @see Aidan Lister: http://aidanlister.com/repos/v/function.size_readable.php
* @see Quentin Zervaas: http://www.phpriot.com/d/code/strings/filesize-format/
*
* @param integer size in bytes
* @param string a definitive unit
* @param string the return string format
* @param boolean whether to use SI prefixes or IEC
* @return string
*/
public static function bytes($bytes, $force_unit = NULL, $format = NULL, $si = TRUE)
{
// Format string
$format = ($format === NULL) ? '%01.2f %s' : (string) $format;
// IEC prefixes (binary)
if ($si == false or strpos($force_unit, 'i') !== false) {
$units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$mod = 1024;
} else {
// SI prefixes (decimal)
$units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB');
$mod = 1000;
}
// IEC prefixes (binary)
if ($si == FALSE OR strpos($force_unit, 'i') !== FALSE)
{
$units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$mod = 1024;
}
// SI prefixes (decimal)
else
{
$units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB');
$mod = 1000;
}
// Determine unit to use
if (($power = array_search((string) $force_unit, $units)) === false) {
$power = ($bytes > 0) ? floor(log($bytes, $mod)) : 0;
}
// Determine unit to use
if (($power = array_search((string) $force_unit, $units)) === FALSE)
{
$power = ($bytes > 0) ? floor(log($bytes, $mod)) : 0;
}
return sprintf($format, $bytes / pow($mod, $power), $units[$power]);
}
return sprintf($format, $bytes / pow($mod, $power), $units[$power]);
}
/**
* Prevents widow words by inserting a non-breaking space between the last two words.
* @see http://www.shauninman.com/archive/2006/08/22/widont_wordpress_plugin
*
* @param string string to remove widows from
* @return string
*/
public static function widont($str)
{
$str = rtrim($str);
$space = strrpos($str, ' ');
/**
* Prevents widow words by inserting a non-breaking space between the last two words.
* @see http://www.shauninman.com/archive/2006/08/22/widont_wordpress_plugin
*
* @param string string to remove widows from
* @return string
*/
public static function widont($str)
{
$str = rtrim($str);
$space = strrpos($str, ' ');
if ($space !== false) {
$str = substr($str, 0, $space) . '&nbsp;' . substr($str, $space + 1);
}
if ($space !== FALSE)
{
$str = substr($str, 0, $space).'&nbsp;'.substr($str, $space + 1);
}
return $str;
}
} // End text
return $str;
}
}
// End text

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Upload helper class for working with the global $_FILES
* array and Validation library.
@@ -10,153 +18,158 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class upload_Core {
class upload_Core
{
/**
* Save an uploaded file to a new location.
*
* @param mixed name of $_FILE input or array of upload data
* @param string new filename
* @param string new directory
* @param integer chmod mask
* @return string full path to new file
*/
public static function save($file, $filename = null, $directory = null, $chmod = 0644)
{
// Load file data from FILES if not passed as array
$file = is_array($file) ? $file : $_FILES[$file];
/**
* Save an uploaded file to a new location.
*
* @param mixed name of $_FILE input or array of upload data
* @param string new filename
* @param string new directory
* @param integer chmod mask
* @return string full path to new file
*/
public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0644)
{
// Load file data from FILES if not passed as array
$file = is_array($file) ? $file : $_FILES[$file];
if ($filename === null) {
// Use the default filename, with a timestamp pre-pended
$filename = time() . $file['name'];
}
if ($filename === NULL)
{
// Use the default filename, with a timestamp pre-pended
$filename = time().$file['name'];
}
if (Kohana::config('upload.remove_spaces') === true) {
// Remove spaces from the filename
$filename = preg_replace('/\s+/', '_', $filename);
}
if (Kohana::config('upload.remove_spaces') === TRUE)
{
// Remove spaces from the filename
$filename = preg_replace('/\s+/', '_', $filename);
}
if ($directory === null) {
// Use the pre-configured upload directory
$directory = Kohana::config('upload.directory', true);
}
if ($directory === NULL)
{
// Use the pre-configured upload directory
$directory = Kohana::config('upload.directory', TRUE);
}
// Make sure the directory ends with a slash
$directory = rtrim($directory, '/') . '/';
// Make sure the directory ends with a slash
$directory = rtrim($directory, '/').'/';
if (! is_dir($directory) and Kohana::config('upload.create_directories') === true) {
// Create the upload directory
mkdir($directory, 0777, true);
}
if ( ! is_dir($directory) AND Kohana::config('upload.create_directories') === TRUE)
{
// Create the upload directory
mkdir($directory, 0777, TRUE);
}
if (! is_writable($directory)) {
throw new Kohana_Exception('upload.not_writable', $directory);
}
if ( ! is_writable($directory))
throw new Kohana_Exception('upload.not_writable', $directory);
if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
if ($chmod !== false) {
// Set permissions on filename
chmod($filename, $chmod);
}
if (is_uploaded_file($file['tmp_name']) AND move_uploaded_file($file['tmp_name'], $filename = $directory.$filename))
{
if ($chmod !== FALSE)
{
// Set permissions on filename
chmod($filename, $chmod);
}
// Return new file path
return $filename;
}
// Return new file path
return $filename;
}
return false;
}
return FALSE;
}
/* Validation Rules */
/* Validation Rules */
/**
* Tests if input data is valid file type, even if no upload is present.
*
* @param array $_FILES item
* @return bool
*/
public static function valid($file)
{
return (is_array($file)
and isset($file['error'])
and isset($file['name'])
and isset($file['type'])
and isset($file['tmp_name'])
and isset($file['size']));
}
/**
* Tests if input data is valid file type, even if no upload is present.
*
* @param array $_FILES item
* @return bool
*/
public static function valid($file)
{
return (is_array($file)
AND isset($file['error'])
AND isset($file['name'])
AND isset($file['type'])
AND isset($file['tmp_name'])
AND isset($file['size']));
}
/**
* Tests if input data has valid upload data.
*
* @param array $_FILES item
* @return bool
*/
public static function required(array $file)
{
return (isset($file['tmp_name'])
and isset($file['error'])
and is_uploaded_file($file['tmp_name'])
and (int) $file['error'] === UPLOAD_ERR_OK);
}
/**
* Tests if input data has valid upload data.
*
* @param array $_FILES item
* @return bool
*/
public static function required(array $file)
{
return (isset($file['tmp_name'])
AND isset($file['error'])
AND is_uploaded_file($file['tmp_name'])
AND (int) $file['error'] === UPLOAD_ERR_OK);
}
/**
* Validation rule to test if an uploaded file is allowed by extension.
*
* @param array $_FILES item
* @param array allowed file extensions
* @return bool
*/
public static function type(array $file, array $allowed_types)
{
if ((int) $file['error'] !== UPLOAD_ERR_OK) {
return true;
}
/**
* Validation rule to test if an uploaded file is allowed by extension.
*
* @param array $_FILES item
* @param array allowed file extensions
* @return bool
*/
public static function type(array $file, array $allowed_types)
{
if ((int) $file['error'] !== UPLOAD_ERR_OK)
return TRUE;
// Get the default extension of the file
$extension = strtolower(substr(strrchr($file['name'], '.'), 1));
// Get the default extension of the file
$extension = strtolower(substr(strrchr($file['name'], '.'), 1));
// Get the mime types for the extension
$mime_types = Kohana::config('mimes.' . $extension);
// Get the mime types for the extension
$mime_types = Kohana::config('mimes.'.$extension);
// Make sure there is an extension, that the extension is allowed, and that mime types exist
return ( ! empty($extension) and in_array($extension, $allowed_types) and is_array($mime_types));
}
// Make sure there is an extension, that the extension is allowed, and that mime types exist
return ( ! empty($extension) AND in_array($extension, $allowed_types) AND is_array($mime_types));
}
/**
* Validation rule to test if an uploaded file is allowed by file size.
* File sizes are defined as: SB, where S is the size (1, 15, 300, etc) and
* B is the byte modifier: (B)ytes, (K)ilobytes, (M)egabytes, (G)igabytes.
* Eg: to limit the size to 1MB or less, you would use "1M".
*
* @param array $_FILES item
* @param array maximum file size
* @return bool
*/
public static function size(array $file, array $size)
{
if ((int) $file['error'] !== UPLOAD_ERR_OK) {
return true;
}
/**
* Validation rule to test if an uploaded file is allowed by file size.
* File sizes are defined as: SB, where S is the size (1, 15, 300, etc) and
* B is the byte modifier: (B)ytes, (K)ilobytes, (M)egabytes, (G)igabytes.
* Eg: to limit the size to 1MB or less, you would use "1M".
*
* @param array $_FILES item
* @param array maximum file size
* @return bool
*/
public static function size(array $file, array $size)
{
if ((int) $file['error'] !== UPLOAD_ERR_OK)
return TRUE;
// Only one size is allowed
$size = strtoupper($size[0]);
// Only one size is allowed
$size = strtoupper($size[0]);
if (! preg_match('/[0-9]++[BKMG]/', $size)) {
return false;
}
if ( ! preg_match('/[0-9]++[BKMG]/', $size))
return FALSE;
// Make the size into a power of 1024
switch (substr($size, -1)) {
case 'G':
$size = intval($size) * pow(1024, 3);
break;
case 'M':
$size = intval($size) * pow(1024, 2);
break;
case 'K':
$size = intval($size) * pow(1024, 1);
break;
default:
$size = intval($size);
break;
}
// Make the size into a power of 1024
switch (substr($size, -1))
{
case 'G': $size = intval($size) * pow(1024, 3); break;
case 'M': $size = intval($size) * pow(1024, 2); break;
case 'K': $size = intval($size) * pow(1024, 1); break;
default: $size = intval($size); break;
}
// Test that the file is under or equal to the max size
return ($file['size'] <= $size);
}
} // End upload
// Test that the file is under or equal to the max size
return ($file['size'] <= $size);
}
}
// End upload

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* URL helper class.
*
@@ -9,244 +17,217 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class url_Core {
class url_Core
{
/**
* Fetches the current URI.
*
* @param boolean include the query string
* @return string
*/
public static function current($qs = false)
{
return ($qs === true) ? Router::$complete_uri : Router::$current_uri;
}
/**
* Fetches the current URI.
*
* @param boolean include the query string
* @return string
*/
public static function current($qs = FALSE)
{
return ($qs === TRUE) ? Router::$complete_uri : Router::$current_uri;
}
/**
* Base URL, with or without the index page.
*
* If protocol (and core.site_protocol) and core.site_domain are both empty,
* then
*
* @param boolean include the index page
* @param boolean non-default protocol
* @return string
*/
public static function base($index = false, $protocol = false)
{
if ($protocol == false) {
// Use the default configured protocol
$protocol = Kohana::config('core.site_protocol');
}
/**
* Base URL, with or without the index page.
*
* If protocol (and core.site_protocol) and core.site_domain are both empty,
* then
*
* @param boolean include the index page
* @param boolean non-default protocol
* @return string
*/
public static function base($index = FALSE, $protocol = FALSE)
{
if ($protocol == FALSE)
{
// Use the default configured protocol
$protocol = Kohana::config('core.site_protocol');
}
// Load the site domain
$site_domain = (string) Kohana::config('core.site_domain', true);
// Load the site domain
$site_domain = (string) Kohana::config('core.site_domain', TRUE);
if ($protocol == false) {
if ($site_domain === '' or $site_domain[0] === '/') {
// Use the configured site domain
$base_url = $site_domain;
} else {
// Guess the protocol to provide full http://domain/path URL
$base_url = ((empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off') ? 'http' : 'https') . '://' . $site_domain;
}
} else {
if ($site_domain === '' or $site_domain[0] === '/') {
// Guess the server name if the domain starts with slash
$base_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $site_domain;
} else {
// Use the configured site domain
$base_url = $protocol . '://' . $site_domain;
}
}
if ($protocol == FALSE)
{
if ($site_domain === '' OR $site_domain[0] === '/')
{
// Use the configured site domain
$base_url = $site_domain;
}
else
{
// Guess the protocol to provide full http://domain/path URL
$base_url = ((empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off') ? 'http' : 'https').'://'.$site_domain;
}
}
else
{
if ($site_domain === '' OR $site_domain[0] === '/')
{
// Guess the server name if the domain starts with slash
$base_url = $protocol.'://'.$_SERVER['HTTP_HOST'].$site_domain;
}
else
{
// Use the configured site domain
$base_url = $protocol.'://'.$site_domain;
}
}
if ($index === true and $index = Kohana::config('core.index_page')) {
// Append the index page
$base_url = $base_url . $index;
}
if ($index === TRUE AND $index = Kohana::config('core.index_page'))
{
// Append the index page
$base_url = $base_url.$index;
}
// Force a slash on the end of the URL
return rtrim($base_url, '/') . '/';
}
// Force a slash on the end of the URL
return rtrim($base_url, '/').'/';
}
/**
* Fetches an absolute site URL based on a URI segment.
*
* @param string site URI to convert
* @param string non-default protocol
* @return string
*/
public static function site($uri = '', $protocol = false)
{
if ($path = trim(parse_url($uri, PHP_URL_PATH), '/')) {
// Add path suffix
$path .= Kohana::config('core.url_suffix');
}
/**
* Fetches an absolute site URL based on a URI segment.
*
* @param string site URI to convert
* @param string non-default protocol
* @return string
*/
public static function site($uri = '', $protocol = FALSE)
{
if ($path = trim(parse_url($uri, PHP_URL_PATH), '/'))
{
// Add path suffix
$path .= Kohana::config('core.url_suffix');
}
if ($query = parse_url($uri, PHP_URL_QUERY)) {
// ?query=string
$query = '?' . $query;
}
if ($query = parse_url($uri, PHP_URL_QUERY))
{
// ?query=string
$query = '?'.$query;
}
if ($fragment = parse_url($uri, PHP_URL_FRAGMENT)) {
// #fragment
$fragment = '#' . $fragment;
}
if ($fragment = parse_url($uri, PHP_URL_FRAGMENT))
{
// #fragment
$fragment = '#'.$fragment;
}
// Concat the URL
return url::base(true, $protocol) . $path . $query . $fragment;
}
// Concat the URL
return url::base(TRUE, $protocol).$path.$query.$fragment;
}
/**
* Return the URL to a file. Absolute filenames and relative filenames
* are allowed.
*
* @param string filename
* @param boolean include the index page
* @return string
*/
public static function file($file, $index = false)
{
if (strpos($file, '://') === false) {
// Add the base URL to the filename
$file = url::base($index) . $file;
}
/**
* Return the URL to a file. Absolute filenames and relative filenames
* are allowed.
*
* @param string filename
* @param boolean include the index page
* @return string
*/
public static function file($file, $index = FALSE)
{
if (strpos($file, '://') === FALSE)
{
// Add the base URL to the filename
$file = url::base($index).$file;
}
return $file;
}
return $file;
}
/**
* Merges an array of arguments with the current URI and query string to
* overload, instead of replace, the current query string.
*
* @param array associative array of arguments
* @return string
*/
public static function merge(array $arguments)
{
if ($_GET === $arguments) {
$query = Router::$query_string;
} elseif ($query = http_build_query(array_merge($_GET, $arguments))) {
$query = '?' . $query;
}
/**
* Merges an array of arguments with the current URI and query string to
* overload, instead of replace, the current query string.
*
* @param array associative array of arguments
* @return string
*/
public static function merge(array $arguments)
{
if ($_GET === $arguments)
{
$query = Router::$query_string;
}
elseif ($query = http_build_query(array_merge($_GET, $arguments)))
{
$query = '?'.$query;
}
// Return the current URI with the arguments merged into the query string
return Router::$current_uri . $query;
}
// Return the current URI with the arguments merged into the query string
return Router::$current_uri.$query;
}
/**
* Convert a phrase to a URL-safe title.
*
* @param string phrase to convert
* @param string word separator (- or _)
* @return string
*/
public static function title($title, $separator = '-')
{
$separator = ($separator === '-') ? '-' : '_';
/**
* Convert a phrase to a URL-safe title.
*
* @param string phrase to convert
* @param string word separator (- or _)
* @return string
*/
public static function title($title, $separator = '-')
{
$separator = ($separator === '-') ? '-' : '_';
// Replace accented characters by their unaccented equivalents
$title = utf8::transliterate_to_ascii($title);
// Replace accented characters by their unaccented equivalents
$title = utf8::transliterate_to_ascii($title);
// Remove all characters that are not the separator, a-z, 0-9, or whitespace
$title = preg_replace('/[^' . $separator . 'a-z0-9\s]+/', '', strtolower($title));
// Remove all characters that are not the separator, a-z, 0-9, or whitespace
$title = preg_replace('/[^'.$separator.'a-z0-9\s]+/', '', strtolower($title));
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('/[' . $separator . '\s]+/', $separator, $title);
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('/['.$separator.'\s]+/', $separator, $title);
// Trim separators from the beginning and end
return trim($title, $separator);
}
// Trim separators from the beginning and end
return trim($title, $separator);
}
/**
* Sends a page redirect header and runs the system.redirect Event.
*
* @param mixed string site URI or URL to redirect to, or array of strings if method is 300
* @param string HTTP method of redirect
* @return void
*/
public static function redirect($uri = '', $method = '302')
{
if (Event::has_run('system.send_headers')) {
return false;
}
/**
* Sends a page redirect header and runs the system.redirect Event.
*
* @param mixed string site URI or URL to redirect to, or array of strings if method is 300
* @param string HTTP method of redirect
* @return void
*/
public static function redirect($uri = '', $method = '302')
{
if (Event::has_run('system.send_headers'))
{
return FALSE;
}
$codes = array
(
'refresh' => 'Refresh',
'300' => 'Multiple Choices',
'301' => 'Moved Permanently',
'302' => 'Found',
'303' => 'See Other',
'304' => 'Not Modified',
'305' => 'Use Proxy',
'307' => 'Temporary Redirect'
);
$codes = array
(
'refresh' => 'Refresh',
'300' => 'Multiple Choices',
'301' => 'Moved Permanently',
'302' => 'Found',
'303' => 'See Other',
'304' => 'Not Modified',
'305' => 'Use Proxy',
'307' => 'Temporary Redirect'
);
// Validate the method and default to 302
$method = isset($codes[$method]) ? (string) $method : '302';
// Validate the method and default to 302
$method = isset($codes[$method]) ? (string) $method : '302';
if ($method === '300') {
$uri = (array) $uri;
if ($method === '300')
{
$uri = (array) $uri;
$output = '<ul>';
foreach ($uri as $link) {
$output .= '<li>' . html::anchor($link) . '</li>';
}
$output .= '</ul>';
$output = '<ul>';
foreach ($uri as $link)
{
$output .= '<li>'.html::anchor($link).'</li>';
}
$output .= '</ul>';
// The first URI will be used for the Location header
$uri = $uri[0];
} else {
$output = '<p>' . html::anchor($uri) . '</p>';
}
// The first URI will be used for the Location header
$uri = $uri[0];
}
else
{
$output = '<p>'.html::anchor($uri).'</p>';
}
// Run the redirect event
Event::run('system.redirect', $uri);
// Run the redirect event
Event::run('system.redirect', $uri);
if (strpos($uri, '://') === false) {
// HTTP headers expect absolute URLs
$uri = url::site($uri, request::protocol());
}
if (strpos($uri, '://') === FALSE)
{
// HTTP headers expect absolute URLs
$uri = url::site($uri, request::protocol());
}
if ($method === 'refresh') {
header('Refresh: 0; url=' . $uri);
} else {
header('HTTP/1.1 ' . $method . ' ' . $codes[$method]);
header('Location: ' . $uri);
}
if ($method === 'refresh')
{
header('Refresh: 0; url='.$uri);
}
else
{
header('HTTP/1.1 '.$method.' '.$codes[$method]);
header('Location: '.$uri);
}
// We are about to exit, so run the send_headers event
Event::run('system.send_headers');
// We are about to exit, so run the send_headers event
Event::run('system.send_headers');
exit('<h1>'.$method.' - '.$codes[$method].'</h1>'.$output);
}
} // End url
exit('<h1>' . $method . ' - ' . $codes[$method] . '</h1>' . $output);
}
}
// End url

View File

@@ -1,4 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
/**
* Validation helper class.
*
@@ -9,322 +17,319 @@
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class valid_Core {
class valid_Core
{
/**
* Validate email, commonly used characters only
*
* @param string email address
* @return boolean
*/
public static function email($email)
{
return (bool) preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++' .
'(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+' .
'@(?:(?![-.])[-a-z0-9.]+(?<![-.])' .
'\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', (string) $email);
}
/**
* Validate email, commonly used characters only
*
* @param string email address
* @return boolean
*/
public static function email($email)
{
return (bool) preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', (string) $email);
}
/**
* Validate the domain of an email address by checking if the domain has a
* valid MX record.
*
* @param string email address
* @return boolean
*/
public static function email_domain($email)
{
// If we can't prove the domain is invalid, consider it valid
// Note: checkdnsrr() is not implemented on Windows platforms
if (! function_exists('checkdnsrr')) {
return true;
}
/**
* Validate the domain of an email address by checking if the domain has a
* valid MX record.
*
* @param string email address
* @return boolean
*/
public static function email_domain($email)
{
// If we can't prove the domain is invalid, consider it valid
// Note: checkdnsrr() is not implemented on Windows platforms
if ( ! function_exists('checkdnsrr'))
return TRUE;
// Check if the email domain has a valid MX record
return (bool) checkdnsrr(preg_replace('/^[^@]+@/', '', $email), 'MX');
}
// Check if the email domain has a valid MX record
return (bool) checkdnsrr(preg_replace('/^[^@]+@/', '', $email), 'MX');
}
/**
* Validate email, RFC compliant version
* Note: This function is LESS strict than valid_email. Choose carefully.
*
* @see Originally by Cal Henderson, modified to fit Kohana syntax standards:
* @see http://www.iamcal.com/publish/articles/php/parsing_email/
* @see http://www.w3.org/Protocols/rfc822/
*
* @param string email address
* @return boolean
*/
public static function email_rfc($email)
{
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$pair = '\\x5c[\\x00-\\x7f]';
/**
* Validate email, RFC compliant version
* Note: This function is LESS strict than valid_email. Choose carefully.
*
* @see Originally by Cal Henderson, modified to fit Kohana syntax standards:
* @see http://www.iamcal.com/publish/articles/php/parsing_email/
* @see http://www.w3.org/Protocols/rfc822/
*
* @param string email address
* @return boolean
*/
public static function email_rfc($email)
{
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$pair = '\\x5c[\\x00-\\x7f]';
$domain_literal = "\\x5b($dtext|$pair)*\\x5d";
$quoted_string = "\\x22($qtext|$pair)*\\x22";
$sub_domain = "($atom|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
$domain_literal = "\\x5b($dtext|$pair)*\\x5d";
$quoted_string = "\\x22($qtext|$pair)*\\x22";
$sub_domain = "($atom|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return (bool) preg_match('/^' . $addr_spec . '$/D', (string) $email);
}
return (bool) preg_match('/^'.$addr_spec.'$/D', (string) $email);
}
/**
* Validate URL
*
* @param string URL
* @return boolean
*/
public static function url($url)
{
return (bool) filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);
}
/**
* Validate URL
*
* @param string URL
* @return boolean
*/
public static function url($url)
{
return (bool) filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);
}
/**
* Validate IP
*
* @param string IP address
* @param boolean allow IPv6 addresses
* @param boolean allow private IP networks
* @return boolean
*/
public static function ip($ip, $ipv6 = false, $allow_private = true)
{
return (bool) preg_match('/(\d+).(\d+).(\d+).(\d+)/', $ip);
}
/**
* Validate IP
*
* @param string IP address
* @param boolean allow IPv6 addresses
* @param boolean allow private IP networks
* @return boolean
*/
public static function ip($ip, $ipv6 = FALSE, $allow_private = TRUE)
{
return (bool) preg_match('/(\d+).(\d+).(\d+).(\d+)/',$ip);
}
/**
* Validates a credit card number using the Luhn (mod10) formula.
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
*
* @param integer credit card number
* @param string|array card type, or an array of card types
* @return boolean
*/
public static function credit_card($number, $type = null)
{
// Remove all non-digit characters from the number
if (($number = preg_replace('/\D+/', '', $number)) === '') {
return false;
}
/**
* Validates a credit card number using the Luhn (mod10) formula.
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
*
* @param integer credit card number
* @param string|array card type, or an array of card types
* @return boolean
*/
public static function credit_card($number, $type = NULL)
{
// Remove all non-digit characters from the number
if (($number = preg_replace('/\D+/', '', $number)) === '')
return FALSE;
if ($type == null) {
// Use the default type
$type = 'default';
} elseif (is_array($type)) {
foreach ($type as $t) {
// Test each type for validity
if (valid::credit_card($number, $t)) {
return true;
}
}
if ($type == NULL)
{
// Use the default type
$type = 'default';
}
elseif (is_array($type))
{
foreach ($type as $t)
{
// Test each type for validity
if (valid::credit_card($number, $t))
return TRUE;
}
return false;
}
return FALSE;
}
$cards = Kohana::config('credit_cards');
$cards = Kohana::config('credit_cards');
// Check card type
$type = strtolower($type);
// Check card type
$type = strtolower($type);
if (! isset($cards[$type])) {
return false;
}
if ( ! isset($cards[$type]))
return FALSE;
// Check card number length
$length = strlen($number);
// Check card number length
$length = strlen($number);
// Validate the card length by the card type
if (! in_array($length, preg_split('/\D+/', $cards[$type]['length']))) {
return false;
}
// Validate the card length by the card type
if ( ! in_array($length, preg_split('/\D+/', $cards[$type]['length'])))
return FALSE;
// Check card number prefix
if (! preg_match('/^' . $cards[$type]['prefix'] . '/', $number)) {
return false;
}
// Check card number prefix
if ( ! preg_match('/^'.$cards[$type]['prefix'].'/', $number))
return FALSE;
// No Luhn check required
if ($cards[$type]['luhn'] == false) {
return true;
}
// No Luhn check required
if ($cards[$type]['luhn'] == FALSE)
return TRUE;
// Checksum of the card number
$checksum = 0;
// Checksum of the card number
$checksum = 0;
for ($i = $length - 1; $i >= 0; $i -= 2) {
// Add up every 2nd digit, starting from the right
$checksum += $number[$i];
}
for ($i = $length - 1; $i >= 0; $i -= 2)
{
// Add up every 2nd digit, starting from the right
$checksum += $number[$i];
}
for ($i = $length - 2; $i >= 0; $i -= 2) {
// Add up every 2nd digit doubled, starting from the right
$double = $number[$i] * 2;
for ($i = $length - 2; $i >= 0; $i -= 2)
{
// Add up every 2nd digit doubled, starting from the right
$double = $number[$i] * 2;
// Subtract 9 from the double where value is greater than 10
$checksum += ($double >= 10) ? $double - 9 : $double;
}
// Subtract 9 from the double where value is greater than 10
$checksum += ($double >= 10) ? $double - 9 : $double;
}
// If the checksum is a multiple of 10, the number is valid
return ($checksum % 10 === 0);
}
// If the checksum is a multiple of 10, the number is valid
return ($checksum % 10 === 0);
}
/**
* Checks if a phone number is valid.
*
* @param string phone number to check
* @return boolean
*/
public static function phone($number, $lengths = null)
{
if (! is_array($lengths)) {
$lengths = array(7,10,11);
}
/**
* Checks if a phone number is valid.
*
* @param string phone number to check
* @return boolean
*/
public static function phone($number, $lengths = NULL)
{
if ( ! is_array($lengths))
{
$lengths = array(7,10,11);
}
// Remove all non-digit characters from the number
$number = preg_replace('/\D+/', '', $number);
// Remove all non-digit characters from the number
$number = preg_replace('/\D+/', '', $number);
// Check if the number is within range
return in_array(strlen($number), $lengths);
}
// Check if the number is within range
return in_array(strlen($number), $lengths);
}
/**
* Tests if a string is a valid date string.
*
* @param string date to check
* @return boolean
*/
public static function date($str)
{
return (strtotime($str) !== false);
}
/**
* Tests if a string is a valid date string.
*
* @param string date to check
* @return boolean
*/
public static function date($str)
{
return (strtotime($str) !== FALSE);
}
/**
* Checks whether a string consists of alphabetical characters only.
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function alpha($str, $utf8 = false)
{
return ($utf8 === true)
? (bool) preg_match('/^\pL++$/uD', (string) $str)
: ctype_alpha((string) $str);
}
/**
* Checks whether a string consists of alphabetical characters only.
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function alpha($str, $utf8 = FALSE)
{
return ($utf8 === TRUE)
? (bool) preg_match('/^\pL++$/uD', (string) $str)
: ctype_alpha((string) $str);
}
/**
* Checks whether a string consists of alphabetical characters and numbers only.
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function alpha_numeric($str, $utf8 = false)
{
return ($utf8 === true)
? (bool) preg_match('/^[\pL\pN]++$/uD', (string) $str)
: ctype_alnum((string) $str);
}
/**
* Checks whether a string consists of alphabetical characters and numbers only.
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function alpha_numeric($str, $utf8 = FALSE)
{
return ($utf8 === TRUE)
? (bool) preg_match('/^[\pL\pN]++$/uD', (string) $str)
: ctype_alnum((string) $str);
}
/**
* Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function alpha_dash($str, $utf8 = false)
{
return ($utf8 === true)
? (bool) preg_match('/^[-\pL\pN_]++$/uD', (string) $str)
: (bool) preg_match('/^[-a-z0-9_]++$/iD', (string) $str);
}
/**
* Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function alpha_dash($str, $utf8 = FALSE)
{
return ($utf8 === TRUE)
? (bool) preg_match('/^[-\pL\pN_]++$/uD', (string) $str)
: (bool) preg_match('/^[-a-z0-9_]++$/iD', (string) $str);
}
/**
* Checks whether a string consists of digits only (no dots or dashes).
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function digit($str, $utf8 = false)
{
return ($utf8 === true)
? (bool) preg_match('/^\pN++$/uD', (string) $str)
: ctype_digit((string) $str);
}
/**
* Checks whether a string consists of digits only (no dots or dashes).
*
* @param string input string
* @param boolean trigger UTF-8 compatibility
* @return boolean
*/
public static function digit($str, $utf8 = FALSE)
{
return ($utf8 === TRUE)
? (bool) preg_match('/^\pN++$/uD', (string) $str)
: ctype_digit((string) $str);
}
/**
* Checks whether a string is a valid number (negative and decimal numbers allowed).
*
* @see Uses locale conversion to allow decimal point to be locale specific.
* @see http://www.php.net/manual/en/function.localeconv.php
*
* @param string input string
* @return boolean
*/
public static function numeric($str)
{
// Use localeconv to set the decimal_point value: Usually a comma or period.
$locale = localeconv();
return (bool) preg_match('/^-?[0-9' . $locale['decimal_point'] . ']++$/D', (string) $str);
}
/**
* Checks whether a string is a valid number (negative and decimal numbers allowed).
*
* @see Uses locale conversion to allow decimal point to be locale specific.
* @see http://www.php.net/manual/en/function.localeconv.php
*
* @param string input string
* @return boolean
*/
public static function numeric($str)
{
// Use localeconv to set the decimal_point value: Usually a comma or period.
$locale = localeconv();
return (bool) preg_match('/^-?[0-9'.$locale['decimal_point'].']++$/D', (string) $str);
}
/**
* Checks whether a string is a valid text. Letters, numbers, whitespace,
* dashes, periods, and underscores are allowed.
*
* @param string text to check
* @return boolean
*/
public static function standard_text($str)
{
// pL matches letters
// pN matches numbers
// pZ matches whitespace
// pPc matches underscores
// pPd matches dashes
// pPo matches normal puncuation
return (bool) preg_match('/^[\pL\pN\pZ\p{Pc}\p{Pd}\p{Po}]++$/uD', (string) $str);
}
/**
* Checks whether a string is a valid text. Letters, numbers, whitespace,
* dashes, periods, and underscores are allowed.
*
* @param string text to check
* @return boolean
*/
public static function standard_text($str)
{
// pL matches letters
// pN matches numbers
// pZ matches whitespace
// pPc matches underscores
// pPd matches dashes
// pPo matches normal puncuation
return (bool) preg_match('/^[\pL\pN\pZ\p{Pc}\p{Pd}\p{Po}]++$/uD', (string) $str);
}
/**
* Checks if a string is a proper decimal format. The format array can be
* used to specify a decimal length, or a number and decimal length, eg:
* array(2) would force the number to have 2 decimal places, array(4,2)
* would force the number to have 4 digits and 2 decimal places.
*
* @param string input string
* @param array decimal format: y or x,y
* @return boolean
*/
public static function decimal($str, $format = null)
{
// Create the pattern
$pattern = '/^[0-9]%s\.[0-9]%s$/';
/**
* Checks if a string is a proper decimal format. The format array can be
* used to specify a decimal length, or a number and decimal length, eg:
* array(2) would force the number to have 2 decimal places, array(4,2)
* would force the number to have 4 digits and 2 decimal places.
*
* @param string input string
* @param array decimal format: y or x,y
* @return boolean
*/
public static function decimal($str, $format = NULL)
{
// Create the pattern
$pattern = '/^[0-9]%s\.[0-9]%s$/';
if (! empty($format)) {
if (count($format) > 1) {
// Use the format for number and decimal length
$pattern = sprintf($pattern, '{' . $format[0] . '}', '{' . $format[1] . '}');
} elseif (count($format) > 0) {
// Use the format as decimal length
$pattern = sprintf($pattern, '+', '{' . $format[0] . '}');
}
} else {
// No format
$pattern = sprintf($pattern, '+', '+');
}
if ( ! empty($format))
{
if (count($format) > 1)
{
// Use the format for number and decimal length
$pattern = sprintf($pattern, '{'.$format[0].'}', '{'.$format[1].'}');
}
elseif (count($format) > 0)
{
// Use the format as decimal length
$pattern = sprintf($pattern, '+', '{'.$format[0].'}');
}
}
else
{
// No format
$pattern = sprintf($pattern, '+', '+');
}
return (bool) preg_match($pattern, (string) $str);
}
} // End valid
return (bool) preg_match($pattern, (string) $str);
}
}
// End valid

View File

@@ -1,10 +1,14 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'undefined_group' => 'Die Gruppe %s ist in Ihrer Konfiguration nicht definiert.',
'extension_not_loaded' => 'Die PHP-Erweiterung %s muss geladen sein, um diesen Treiber benutzen zu können.',
'unwritable' => 'Der eingestellte Speicherort %s ist nicht beschreibbar.',
'resources' => 'Das Cachen von Ressourcen ist nicht möglich, da diese nicht serialisiert werden können.',
'driver_error' => '%s'
);
'undefined_group' => 'Die Gruppe %s ist in Ihrer Konfiguration nicht definiert.',
'extension_not_loaded' => 'Die PHP-Erweiterung %s muss geladen sein, um diesen Treiber benutzen zu können.',
'unwritable' => 'Der eingestellte Speicherort %s ist nicht beschreibbar.',
'resources' => 'Das Cachen von Ressourcen ist nicht möglich, da diese nicht serialisiert werden können.',
'driver_error' => '%s'
);

View File

@@ -1,59 +1,63 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
// Two letter days
'su' => 'So',
'mo' => 'Mo',
'tu' => 'Di',
'we' => 'Mi',
'th' => 'Do',
'fr' => 'Fr',
'sa' => 'Sa',
// Two letter days
'su' => 'So',
'mo' => 'Mo',
'tu' => 'Di',
'we' => 'Mi',
'th' => 'Do',
'fr' => 'Fr',
'sa' => 'Sa',
// Short day names
'sun' => 'Son',
'mon' => 'Mon',
'tue' => 'Die',
'wed' => 'Mit',
'thu' => 'Don',
'fri' => 'Fre',
'sat' => 'Sam',
// Short day names
'sun' => 'Son',
'mon' => 'Mon',
'tue' => 'Die',
'wed' => 'Mit',
'thu' => 'Don',
'fri' => 'Fre',
'sat' => 'Sam',
// Long day names
'sunday' => 'Sonntag',
'monday' => 'Montag',
'tuesday' => 'Dienstag',
'wednesday' => 'Mittwoch',
'thursday' => 'Donnerstag',
'friday' => 'Freitag',
'saturday' => 'Samstag',
// Long day names
'sunday' => 'Sonntag',
'monday' => 'Montag',
'tuesday' => 'Dienstag',
'wednesday' => 'Mittwoch',
'thursday' => 'Donnerstag',
'friday' => 'Freitag',
'saturday' => 'Samstag',
// Short month names
'jan' => 'Jan',
'feb' => 'Feb',
'mar' => 'Mär',
'apr' => 'Apr',
'may' => 'Mai',
'jun' => 'Jun',
'jul' => 'Jul',
'aug' => 'Aug',
'sep' => 'Sep',
'oct' => 'Okt',
'nov' => 'Nov',
'dec' => 'Dez',
// Short month names
'jan' => 'Jan',
'feb' => 'Feb',
'mar' => 'Mär',
'apr' => 'Apr',
'may' => 'Mai',
'jun' => 'Jun',
'jul' => 'Jul',
'aug' => 'Aug',
'sep' => 'Sep',
'oct' => 'Okt',
'nov' => 'Nov',
'dec' => 'Dez',
// Long month names
'january' => 'Januar',
'february' => 'Februar',
'march' => 'März',
'april' => 'April',
'mayl' => 'Mai',
'june' => 'Juni',
'july' => 'Juli',
'august' => 'August',
'september' => 'September',
'october' => 'Oktober',
'november' => 'November',
'december' => 'Dezember'
);
// Long month names
'january' => 'Januar',
'february' => 'Februar',
'march' => 'März',
'april' => 'April',
'mayl' => 'Mai',
'june' => 'Juni',
'july' => 'Juli',
'august' => 'August',
'september' => 'September',
'october' => 'Oktober',
'november' => 'November',
'december' => 'Dezember'
);

View File

@@ -1,33 +1,40 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'file_not_found' => 'Die eingestellte Datei %s konnte nicht gefunden werden. Kontrollieren Sie bitte, bevor Sie Dateien benutzen, ob diese existieren. Sie können dafür die Funktion file_exists() benutzen.',
'requires_GD2' => 'Die Captcha-Bibliothek erfordert GD2 mit FreeType-Unterstützung. Sehen Sie sich die Seite http://php.net/gd_info an, um weitere Informationen zu erhalten.',
'file_not_found' => 'Die eingestellte Datei %s konnte nicht gefunden werden.' .
' Kontrollieren Sie bitte, bevor Sie Dateien benutzen, ob diese existieren.' .
' Sie können dafür die Funktion file_exists() benutzen.',
'requires_GD2' => 'Die Captcha-Bibliothek erfordert GD2 mit FreeType-Unterstützung.' .
' Sehen Sie sich die Seite http://php.net/gd_info an, um weitere Informationen zu erhalten.',
// Words of varying length for the Captcha_Word_Driver to pick from
// Note: use only alphanumeric characters
'words' => array
(
'cd', 'tv', 'it', 'to', 'be', 'or',
'sun', 'car', 'dog', 'bed', 'kid', 'egg',
'bike', 'tree', 'bath', 'roof', 'road', 'hair',
'hello', 'world', 'earth', 'beard', 'chess', 'water',
'barber', 'bakery', 'banana', 'market', 'purple', 'writer',
'america', 'release', 'playing', 'working', 'foreign', 'general',
'aircraft', 'computer', 'laughter', 'alphabet', 'kangaroo', 'spelling',
'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders',
),
// Words of varying length for the Captcha_Word_Driver to pick from
// Note: use only alphanumeric characters
'words' => array
(
'cd', 'tv', 'it', 'to', 'be', 'or',
'sun', 'car', 'dog', 'bed', 'kid', 'egg',
'bike', 'tree', 'bath', 'roof', 'road', 'hair',
'hello', 'world', 'earth', 'beard', 'chess', 'water',
'barber', 'bakery', 'banana', 'market', 'purple', 'writer',
'america', 'release', 'playing', 'working', 'foreign', 'general',
'aircraft', 'computer', 'laughter', 'alphabet', 'kangaroo', 'spelling',
'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders',
),
// Riddles for the Captcha_Riddle_Driver to pick from
// Note: use only alphanumeric characters
'riddles' => array
(
array('Hasst du Spam? (ja oder nein)', 'ja'),
array('Bist du ein Roboter? (ja oder nein)', 'nein'),
array('Feuer ist ... (heiß or kalt)', 'heiß'),
array('Die Jahreszeit, die nach Herbst kommt ist ...', 'Winter'),
array('Welcher Wochentag ist heute?', strftime('%A')),
array('In welchem Monat befinden wir uns gerade?', strftime('%B')),
),
// Riddles for the Captcha_Riddle_Driver to pick from
// Note: use only alphanumeric characters
'riddles' => array
(
array('Hasst du Spam? (ja oder nein)', 'ja'),
array('Bist du ein Roboter? (ja oder nein)', 'nein'),
array('Feuer ist ... (heiß or kalt)', 'heiß'),
array('Die Jahreszeit, die nach Herbst kommt ist ...', 'Winter'),
array('Welcher Wochentag ist heute?', strftime('%A')),
array('In welchem Monat befinden wir uns gerade?', strftime('%B')),
),
);

View File

@@ -1,34 +1,38 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'there_can_be_only_one' => 'Pro Seitenaufruf kann es nur eine Instanz von Kohana geben',
'uncaught_exception' => 'Unerwarteter Fehler vom Typ %s: %s in %s in Zeile %s',
'invalid_method' => 'Ungültige Methode %s aufgerufen in %s',
'invalid_property' => '%s ist keine Eigenschaft der Klasse %s.',
'log_dir_unwritable' => 'Das Log-Verzeichnis ist nicht beschreibbar: %s',
'resource_not_found' => '%s %s konnte nicht gefunden werden',
'invalid_filetype' => 'Die Dateiendung .%s ist in Ihrer View-Konfiguration nicht vorhanden',
'view_set_filename' => 'Sie müssen den Dateinamen der Ansicht festlegen, bevor render aufgerufen wird',
'no_default_route' => 'Erstellen Sie bitte eine Standardroute config/routes.php',
'no_controller' => 'Kohana gelang es nicht einen Controller zu finden, um diesen Aufruf zu verarbeiten: %s',
'page_not_found' => 'Die Seite %s konnte nicht gefunden werden.',
'stats_footer' => 'Seite geladen in {execution_time} Sekunden bei {memory_usage} Speichernutzung. Generiert von Kohana v{kohana_version}.',
'error_file_line' => '<tt>%s <strong>[%s]:</strong></tt>',
'stack_trace' => 'Stack Trace',
'generic_error' => 'Die Abfrage konnte nicht abgeschlossen werden',
'errors_disabled' => 'Sie können zur <a href="%s">Startseite</a> zurück kehren oder es <a href="%s">erneut versuchen</a>.',
'there_can_be_only_one' => 'Pro Seitenaufruf kann es nur eine Instanz von Kohana geben',
'uncaught_exception' => 'Unerwarteter Fehler vom Typ %s: %s in %s in Zeile %s',
'invalid_method' => 'Ungültige Methode %s aufgerufen in %s',
'invalid_property' => '%s ist keine Eigenschaft der Klasse %s.',
'log_dir_unwritable' => 'Das Log-Verzeichnis ist nicht beschreibbar: %s',
'resource_not_found' => '%s %s konnte nicht gefunden werden',
'invalid_filetype' => 'Die Dateiendung .%s ist in Ihrer View-Konfiguration nicht vorhanden',
'view_set_filename' => 'Sie müssen den Dateinamen der Ansicht festlegen, bevor render aufgerufen wird',
'no_default_route' => 'Erstellen Sie bitte eine Standardroute config/routes.php',
'no_controller' => 'Kohana gelang es nicht einen Controller zu finden, um diesen Aufruf zu verarbeiten: %s',
'page_not_found' => 'Die Seite %s konnte nicht gefunden werden.',
'stats_footer' => 'Seite geladen in {execution_time} Sekunden bei {memory_usage} Speichernutzung. Generiert von Kohana v{kohana_version}.',
'error_file_line' => '<tt>%s <strong>[%s]:</strong></tt>',
'stack_trace' => 'Stack Trace',
'generic_error' => 'Die Abfrage konnte nicht abgeschlossen werden',
'errors_disabled' => 'Sie können zur <a href="%s">Startseite</a> zurück kehren oder es <a href="%s">erneut versuchen</a>.',
// Drivers
'driver_implements' => 'Der Treiber %s für die Bibliothek %s muss das Interface %s implementieren',
'driver_not_found' => 'Der Treiber %s für die Bibliothek %s konnte nicht gefunden werden',
// Drivers
'driver_implements' => 'Der Treiber %s für die Bibliothek %s muss das Interface %s implementieren',
'driver_not_found' => 'Der Treiber %s für die Bibliothek %s konnte nicht gefunden werden',
// Resource names
'config' => 'Die Konfigurationsdatei',
'controller' => 'Der Controller',
'helper' => 'Der Helfer',
'library' => 'Die Bibliothek',
'driver' => 'Der Treiber',
'model' => 'Das Modell',
'view' => 'Die Ansicht',
);
// Resource names
'config' => 'Die Konfigurationsdatei',
'controller' => 'Der Controller',
'helper' => 'Der Helfer',
'library' => 'Die Bibliothek',
'driver' => 'Der Treiber',
'model' => 'Das Modell',
'view' => 'Die Ansicht',
);

View File

@@ -1,15 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'undefined_group' => 'Die Gruppe %s ist in Ihrer Konfiguration nicht definiert worden.',
'error' => 'Es gab einen SQL-Fehler: %s',
'connection' => 'Es gab einen Fehler bei der Verbindung mit der Datenbank: %s',
'invalid_dsn' => 'Die von Ihnen angegebene DSN ist ungültig: %s',
'must_use_set' => 'Sie müssen SET in Ihrem Query benutzen.',
'must_use_where' => 'Sie müssen WHERE in Ihrem Query benutzen.',
'must_use_table' => 'Sie müssen eine Tabelle für Ihren Query angeben.',
'table_not_found' => 'Die Tabelle %s konnte in der Datenbank nicht gefunden werden.',
'not_implemented' => 'Die Methode %s wird von diesem Datenbanktreiber nicht unterstützt.',
'result_read_only' => 'Ergebnisse der Anfrage können nur gelesen werden.',
);
'undefined_group' => 'Die Gruppe %s ist in Ihrer Konfiguration nicht definiert worden.',
'error' => 'Es gab einen SQL-Fehler: %s',
'connection' => 'Es gab einen Fehler bei der Verbindung mit der Datenbank: %s',
'invalid_dsn' => 'Die von Ihnen angegebene DSN ist ungültig: %s',
'must_use_set' => 'Sie müssen SET in Ihrem Query benutzen.',
'must_use_where' => 'Sie müssen WHERE in Ihrem Query benutzen.',
'must_use_table' => 'Sie müssen eine Tabelle für Ihren Query angeben.',
'table_not_found' => 'Die Tabelle %s konnte in der Datenbank nicht gefunden werden.',
'not_implemented' => 'Die Methode %s wird von diesem Datenbanktreiber nicht unterstützt.',
'result_read_only' => 'Ergebnisse der Anfrage können nur gelesen werden.',
);

View File

@@ -1,8 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'undefined_group' => 'Die Gruppe %s ist nicht in Ihrer Konfiguration enthalten.',
'requires_mcrypt' => 'Um die Bibliothek Encrypt zu benutzen, muss mcrypt in Ihrer PHP-Installation aktiviert werden',
'no_encryption_key' => 'Um die Bibliothek Encrypt zu benutzen, müssen Sie einen Schlüssel in Ihrer Konfiguration eintragen'
'undefined_group' => 'Die Gruppe %s ist nicht in Ihrer Konfiguration enthalten.',
'requires_mcrypt' => 'Um die Bibliothek Encrypt zu benutzen, muss mcrypt in Ihrer PHP-Installation aktiviert werden',
'no_encryption_key' => 'Um die Bibliothek Encrypt zu benutzen, müssen Sie einen Schlüssel in Ihrer Konfiguration eintragen'
);

View File

@@ -1,16 +1,24 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
E_KOHANA => array( 1, 'Framework-Fehler', 'Lesen Sie bitte in der Kohana-Dokumentation, um mehr über den folgenden Fehler zu erfahren.'),
E_PAGE_NOT_FOUND => array( 1, 'Seite Nicht Gefunden', 'Die aufgerufene Seite wurde nicht gefunden. Sie wurde entweder verschoben, gelöscht oder archiviert.'),
E_DATABASE_ERROR => array( 1, 'Datenbank-Fehler', 'Ein Datenbankfehler ist während des Aufrufs aufgetreten. Überprüfen Sie bitte den unten stehenden Fehler für mehr Informationen.'),
E_RECOVERABLE_ERROR => array( 1, 'Behebbarer Fehler', 'Es ist ein Fehler aufgetreten, der das Laden der Seite verhindert hat. Wenn der Fehler weiterhin besteht, kontaktieren Sie bitte den Administrator der Seite.'),
E_ERROR => array( 1, 'Fataler Fehler', ''),
E_USER_ERROR => array( 1, 'Fataler Fehler', ''),
E_PARSE => array( 1, 'Syntax-Fehler', ''),
E_WARNING => array( 1, 'Warnung', ''),
E_USER_WARNING => array( 1, 'Warnung', ''),
E_STRICT => array( 2, 'Strict Mode Error', ''),
E_NOTICE => array( 2, 'Laufzeitfehler', ''),
);
E_KOHANA => array( 1, 'Framework-Fehler', 'Lesen Sie bitte in der Kohana-Dokumentation, um mehr über den folgenden Fehler zu erfahren.'),
E_PAGE_NOT_FOUND => array( 1, 'Seite Nicht Gefunden', 'Die aufgerufene Seite wurde nicht gefunden. Sie wurde entweder verschoben, gelöscht oder archiviert.'),
E_DATABASE_ERROR => array( 1, 'Datenbank-Fehler',
'Ein Datenbankfehler ist während des Aufrufs aufgetreten.' .
' Überprüfen Sie bitte den unten stehenden Fehler für mehr Informationen.'),
E_RECOVERABLE_ERROR => array( 1, 'Behebbarer Fehler',
'Es ist ein Fehler aufgetreten, der das Laden der Seite verhindert hat.' .
' Wenn der Fehler weiterhin besteht, kontaktieren Sie bitte den Administrator der Seite.'),
E_ERROR => array( 1, 'Fataler Fehler', ''),
E_USER_ERROR => array( 1, 'Fataler Fehler', ''),
E_PARSE => array( 1, 'Syntax-Fehler', ''),
E_WARNING => array( 1, 'Warnung', ''),
E_USER_WARNING => array( 1, 'Warnung', ''),
E_STRICT => array( 2, 'Strict Mode Error', ''),
E_NOTICE => array( 2, 'Laufzeitfehler', ''),
);

View File

@@ -1,7 +1,11 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'invalid_subject' => 'Der Versuch, das ungültige Subjekt %s an %s anzuhängen, ist fehlgeschlagen. Subjekte müssen die Klasse Event_Subject erweitern.',
'invalid_observer' => 'Der Versuch, den ungültigen Beobachter %s an %s anzuhängen, ist fehlgeschlagen. Beobachter müssen die Klasse Event_Observer erweitern.',
'invalid_subject' => 'Der Versuch, das ungültige Subjekt %s an %s anzuhängen, ist fehlgeschlagen. Subjekte müssen die Klasse Event_Subject erweitern.',
'invalid_observer' => 'Der Versuch, den ungültigen Beobachter %s an %s anzuhängen, ist fehlgeschlagen. Beobachter müssen die Klasse Event_Observer erweitern.',
);

View File

@@ -1,33 +1,39 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'getimagesize_missing' => 'Die Bildbibliothek versucht die PHP-Funktion getimagesize() zu benutzen, die aber nicht Bestandteil ihrer PHP-Installation ist.',
'unsupported_method' => 'Der Bildtreiber, den Sie benutzen, unterstützt nicht die %s-Bildtransformation.',
'file_not_found' => 'Das angegebene Bild %s konnte nicht gefunden werden. Stellen Sie bitte sicher, dass das Bild existiert. Benutzen Sie hierzu die Funktion file_exists().',
'type_not_allowed' => 'Das angegebene Bild %s ist kein erlaubter Bildtyp.',
'invalid_width' => 'Die von Ihnen festgelegte Bildbreite, %s, ist ungültig.',
'invalid_height' => 'Die von Ihnen festgelegte Bildhöhe, %s, ist ungültig.',
'invalid_dimensions' => 'Das festgelegte Format für %s ist ungültig.',
'invalid_master' => 'Die festgelegte Master-Dimension ist ungültig.',
'invalid_flip' => 'Die festgelegte Richtung der Spiegelung ist ungültig.',
'directory_unwritable' => 'Das Verzeichnis %s ist nicht beschreibbar.',
'getimagesize_missing' => 'Die Bildbibliothek versucht die PHP-Funktion getimagesize() zu benutzen, die aber nicht Bestandteil ihrer PHP-Installation ist.',
'unsupported_method' => 'Der Bildtreiber, den Sie benutzen, unterstützt nicht die %s-Bildtransformation.',
'file_not_found' => 'Das angegebene Bild %s konnte nicht gefunden werden.' .
' Stellen Sie bitte sicher, dass das Bild existiert.' .
' Benutzen Sie hierzu die Funktion file_exists().',
'type_not_allowed' => 'Das angegebene Bild %s ist kein erlaubter Bildtyp.',
'invalid_width' => 'Die von Ihnen festgelegte Bildbreite, %s, ist ungültig.',
'invalid_height' => 'Die von Ihnen festgelegte Bildhöhe, %s, ist ungültig.',
'invalid_dimensions' => 'Das festgelegte Format für %s ist ungültig.',
'invalid_master' => 'Die festgelegte Master-Dimension ist ungültig.',
'invalid_flip' => 'Die festgelegte Richtung der Spiegelung ist ungültig.',
'directory_unwritable' => 'Das Verzeichnis %s ist nicht beschreibbar.',
// ImageMagick specific messages
'imagemagick' => array
(
'not_found' => 'Das festgelegte ImageMagic-Verzeichnis enthält nicht das benötigte Programm %s.',
),
// ImageMagick specific messages
'imagemagick' => array
(
'not_found' => 'Das festgelegte ImageMagic-Verzeichnis enthält nicht das benötigte Programm %s.',
),
// GraphicsMagick specific messages
'graphicsmagick' => array
(
'not_found' => 'Das festgelegte GraphicsMagick-Verzeichnis enthält nicht das benötigte Programm %s.',
),
// GraphicsMagick specific messages
'graphicsmagick' => array
(
'not_found' => 'Das festgelegte GraphicsMagick-Verzeichnis enthält nicht das benötigte Programm %s.',
),
// GD specific messages
'gd' => array
(
'requires_v2' => 'Die Bildbibliothek erfordert GD2. Sehen Sie sich die Seite http://php.net/gd_info an, um weitere Informationen zu erhalten.',
),
// GD specific messages
'gd' => array
(
'requires_v2' => 'Die Bildbibliothek erfordert GD2. Sehen Sie sich die Seite http://php.net/gd_info an, um weitere Informationen zu erhalten.',
),
);

View File

@@ -1,3 +1,7 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
$lang['query_methods_not_allowed'] = 'Die Query-Methoden können nicht über ORM benutzt werden.';
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang['query_methods_not_allowed'] = 'Die Query-Methoden können nicht über ORM benutzt werden.';

View File

@@ -1,15 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'undefined_group' => 'Die Gruppe %s ist nicht in der Pagination-Konfiguration definiert worden.',
'page' => 'Seite',
'pages' => 'Seiten',
'item' => 'Element',
'items' => 'Elemente',
'of' => 'von',
'first' => 'Erste',
'last' => 'Letzte',
'previous' => 'Vorherige',
'next' => 'Nächste',
'undefined_group' => 'Die Gruppe %s ist nicht in der Pagination-Konfiguration definiert worden.',
'page' => 'Seite',
'pages' => 'Seiten',
'item' => 'Element',
'items' => 'Elemente',
'of' => 'von',
'first' => 'Erste',
'last' => 'Letzte',
'previous' => 'Vorherige',
'next' => 'Nächste',
);

View File

@@ -1,15 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'benchmarks' => 'Benchmark-Tests',
'post_data' => 'POST-Daten:',
'no_post' => 'Keine POST-Daten',
'session_data' => 'Session-Daten',
'no_session' => 'Keine Session-Daten',
'queries' => 'Datenbank-Anfragen',
'no_queries' => 'Keine Anfragen',
'no_database' => 'Datenbank nicht geladen',
'cookie_data' => 'Cookie-Daten',
'no_cookie' => 'Keine Cookie-Daten',
'benchmarks' => 'Benchmark-Tests',
'post_data' => 'POST-Daten:',
'no_post' => 'Keine POST-Daten',
'session_data' => 'Session-Daten',
'no_session' => 'Keine Session-Daten',
'queries' => 'Datenbank-Anfragen',
'no_queries' => 'Keine Anfragen',
'no_database' => 'Datenbank nicht geladen',
'cookie_data' => 'Cookie-Daten',
'no_cookie' => 'Keine Cookie-Daten',
);

View File

@@ -1,6 +1,10 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'invalid_session_name' => 'Der Sessionname %s ist ungültig. Dieser darf nur aus alphanumerischen Zeichen und mindestens einem Buchstaben bestehen.',
);
'invalid_session_name' => 'Der Sessionname %s ist ungültig. Dieser darf nur aus alphanumerischen Zeichen und mindestens einem Buchstaben bestehen.',
);

View File

@@ -1,6 +1,10 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'general_error' => 'Fehler beim Senden einer E-Mail aufgetreten.'
);
'general_error' => 'Fehler beim Senden einer E-Mail aufgetreten.'
);

View File

@@ -1,6 +1,10 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
'not_writable' => 'Das Verzeichnis für hochgeladene Dateien, %s, ist nicht beschreibbar.',
);
'not_writable' => 'Das Verzeichnis für hochgeladene Dateien, %s, ist nicht beschreibbar.',
);

View File

@@ -1,41 +1,45 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
// phpcs:disable PSR1.Files.SideEffects
defined('SYSPATH') or die('No direct access allowed.');
// phpcs:enable PSR1.Files.SideEffects
$lang = array
(
// Class errors
'invalid_rule' => 'Ungültige Validierungsregel benutzt: %s',
'i18n_array' => 'Der i18n-Schlüssel %s muss ein Array sein, um diesen in der in_array-Regel benutzen zu können',
'not_callable' => 'Die Callback-Funktion %s, die zur Validierung benutzt wird, ist nicht aufrufbar',
// Class errors
'invalid_rule' => 'Ungültige Validierungsregel benutzt: %s',
'i18n_array' => 'Der i18n-Schlüssel %s muss ein Array sein, um diesen in der in_array-Regel benutzen zu können',
'not_callable' => 'Die Callback-Funktion %s, die zur Validierung benutzt wird, ist nicht aufrufbar',
// General errors
'unknown_error' => 'Unbekannter Fehler bei der Validierungsregel von dem Feld %s aufgetreten.',
'required' => 'Das Feld %s ist erforderlich.',
'min_length' => 'Das Feld %s muss mindestens %d Zeichen lang sein.',
'max_length' => 'Das Feld %s darf höchstens %d Zeichen lang sein.',
'exact_length' => 'Das Feld %s muss genau %d Zeichen enthalten.',
'in_array' => 'Das Feld %s muss ausgewählt werden.',
'matches' => 'Das Feld %s muss mit dem Feld %s übereinstimmen.',
'valid_url' => 'Das Feld %s muss eine gültige URL beinhalten.',
'valid_email' => 'Das Feld %s muss eine gültige E-Mailadresse beinhalten.',
'valid_ip' => 'Das Feld %s muss eine gültige IP-Adresse beinhalten.',
'valid_type' => 'Das Feld %s darf nur %s beinhalten.',
'range' => 'Das Feld %s muss zwischen festgelegten Bereichen sein.',
'regex' => 'Das Feld %s entspricht nicht einer akzeptierten Eingabe.',
'depends_on' => 'Das Feld %s hängt vom Feld %s ab.',
// General errors
'unknown_error' => 'Unbekannter Fehler bei der Validierungsregel von dem Feld %s aufgetreten.',
'required' => 'Das Feld %s ist erforderlich.',
'min_length' => 'Das Feld %s muss mindestens %d Zeichen lang sein.',
'max_length' => 'Das Feld %s darf höchstens %d Zeichen lang sein.',
'exact_length' => 'Das Feld %s muss genau %d Zeichen enthalten.',
'in_array' => 'Das Feld %s muss ausgewählt werden.',
'matches' => 'Das Feld %s muss mit dem Feld %s übereinstimmen.',
'valid_url' => 'Das Feld %s muss eine gültige URL beinhalten.',
'valid_email' => 'Das Feld %s muss eine gültige E-Mailadresse beinhalten.',
'valid_ip' => 'Das Feld %s muss eine gültige IP-Adresse beinhalten.',
'valid_type' => 'Das Feld %s darf nur %s beinhalten.',
'range' => 'Das Feld %s muss zwischen festgelegten Bereichen sein.',
'regex' => 'Das Feld %s entspricht nicht einer akzeptierten Eingabe.',
'depends_on' => 'Das Feld %s hängt vom Feld %s ab.',
// Upload errors
'user_aborted' => 'Das Hochladen der Datei %s wurde abgebrochen.',
'invalid_type' => 'Die Datei %s entspricht nicht den erlaubten Dateitypen.',
'max_size' => 'Die Datei %s ist zu groß. Die maximale Größe beträgt %s.',
'max_width' => 'Die Datei %s ist zu groß. Die maximal erlaubte Breite betägt %spx.',
'max_height' => 'Die Datei %s ist zu groß. Die maximal erlaubte Höhe betägt %spx.',
'min_width' => 'Die Datei %s ist zu klein. Die minimal erlaubte Breite betägt %spx.',
'min_height' => 'Die Datei %s ist zu klein. Die minimal erlaubte Höhe betägt %spx.',
// Upload errors
'user_aborted' => 'Das Hochladen der Datei %s wurde abgebrochen.',
'invalid_type' => 'Die Datei %s entspricht nicht den erlaubten Dateitypen.',
'max_size' => 'Die Datei %s ist zu groß. Die maximale Größe beträgt %s.',
'max_width' => 'Die Datei %s ist zu groß. Die maximal erlaubte Breite betägt %spx.',
'max_height' => 'Die Datei %s ist zu groß. Die maximal erlaubte Höhe betägt %spx.',
'min_width' => 'Die Datei %s ist zu klein. Die minimal erlaubte Breite betägt %spx.',
'min_height' => 'Die Datei %s ist zu klein. Die minimal erlaubte Höhe betägt %spx.',
// Field types
'alpha' => 'alphabetische Zeichen',
'alpha_numeric' => 'alphabetische und numerische Zeichen',
'alpha_dash' => 'alphabetische Zeichen, Trennstriche und Unterstriche',
'digit' => 'Zahlen',
'numeric' => 'Nummern',
// Field types
'alpha' => 'alphabetische Zeichen',
'alpha_numeric' => 'alphabetische und numerische Zeichen',
'alpha_dash' => 'alphabetische Zeichen, Trennstriche und Unterstriche',
'digit' => 'Zahlen',
'numeric' => 'Nummern',
);

View File

@@ -1,10 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'undefined_group' => 'The %s group is not defined in your configuration.',
'extension_not_loaded' => 'The %s PHP extension must be loaded to use this driver.',
'unwritable' => 'The configured storage location, %s, is not writable.',
'resources' => 'Caching of resources is impossible, because resources cannot be serialized.',
'driver_error' => '%s',
);
'undefined_group' => 'The %s group is not defined in your configuration.',
'extension_not_loaded' => 'The %s PHP extension must be loaded to use this driver.',
'unwritable' => 'The configured storage location, %s, is not writable.',
'resources' => 'Caching of resources is impossible, because resources cannot be serialized.',
'driver_error' => '%s',
);

View File

@@ -1,59 +1,61 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
// Two letter days
'su' => 'Su',
'mo' => 'Mo',
'tu' => 'Tu',
'we' => 'We',
'th' => 'Th',
'fr' => 'Fr',
'sa' => 'Sa',
// Two letter days
'su' => 'Su',
'mo' => 'Mo',
'tu' => 'Tu',
'we' => 'We',
'th' => 'Th',
'fr' => 'Fr',
'sa' => 'Sa',
// Short day names
'sun' => 'Sun',
'mon' => 'Mon',
'tue' => 'Tue',
'wed' => 'Wed',
'thu' => 'Thu',
'fri' => 'Fri',
'sat' => 'Sat',
// Short day names
'sun' => 'Sun',
'mon' => 'Mon',
'tue' => 'Tue',
'wed' => 'Wed',
'thu' => 'Thu',
'fri' => 'Fri',
'sat' => 'Sat',
// Long day names
'sunday' => 'Sunday',
'monday' => 'Monday',
'tuesday' => 'Tuesday',
'wednesday' => 'Wednesday',
'thursday' => 'Thursday',
'friday' => 'Friday',
'saturday' => 'Saturday',
// Long day names
'sunday' => 'Sunday',
'monday' => 'Monday',
'tuesday' => 'Tuesday',
'wednesday' => 'Wednesday',
'thursday' => 'Thursday',
'friday' => 'Friday',
'saturday' => 'Saturday',
// Short month names
'jan' => 'Jan',
'feb' => 'Feb',
'mar' => 'Mar',
'apr' => 'Apr',
'may' => 'May',
'jun' => 'Jun',
'jul' => 'Jul',
'aug' => 'Aug',
'sep' => 'Sep',
'oct' => 'Oct',
'nov' => 'Nov',
'dec' => 'Dec',
// Short month names
'jan' => 'Jan',
'feb' => 'Feb',
'mar' => 'Mar',
'apr' => 'Apr',
'may' => 'May',
'jun' => 'Jun',
'jul' => 'Jul',
'aug' => 'Aug',
'sep' => 'Sep',
'oct' => 'Oct',
'nov' => 'Nov',
'dec' => 'Dec',
// Long month names
'january' => 'January',
'february' => 'February',
'march' => 'March',
'april' => 'April',
'mayl' => 'May',
'june' => 'June',
'july' => 'July',
'august' => 'August',
'september' => 'September',
'october' => 'October',
'november' => 'November',
'december' => 'December'
);
// Long month names
'january' => 'January',
'february' => 'February',
'march' => 'March',
'april' => 'April',
'mayl' => 'May',
'june' => 'June',
'july' => 'July',
'august' => 'August',
'september' => 'September',
'october' => 'October',
'november' => 'November',
'december' => 'December'
);

View File

@@ -1,33 +1,35 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'file_not_found' => 'The specified file, %s, was not found. Please verify that files exist by using file_exists() before using them.',
'requires_GD2' => 'The Captcha library requires GD2 with FreeType support. Please see http://php.net/gd_info for more information.',
'file_not_found' => 'The specified file, %s, was not found. Please verify that files exist by using file_exists() before using them.',
'requires_GD2' => 'The Captcha library requires GD2 with FreeType support. Please see http://php.net/gd_info for more information.',
// Words of varying length for the Captcha_Word_Driver to pick from
// Note: use only alphanumeric characters
'words' => array
(
'cd', 'tv', 'it', 'to', 'be', 'or',
'sun', 'car', 'dog', 'bed', 'kid', 'egg',
'bike', 'tree', 'bath', 'roof', 'road', 'hair',
'hello', 'world', 'earth', 'beard', 'chess', 'water',
'barber', 'bakery', 'banana', 'market', 'purple', 'writer',
'america', 'release', 'playing', 'working', 'foreign', 'general',
'aircraft', 'computer', 'laughter', 'alphabet', 'kangaroo', 'spelling',
'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders',
),
// Words of varying length for the Captcha_Word_Driver to pick from
// Note: use only alphanumeric characters
'words' => array
(
'cd', 'tv', 'it', 'to', 'be', 'or',
'sun', 'car', 'dog', 'bed', 'kid', 'egg',
'bike', 'tree', 'bath', 'roof', 'road', 'hair',
'hello', 'world', 'earth', 'beard', 'chess', 'water',
'barber', 'bakery', 'banana', 'market', 'purple', 'writer',
'america', 'release', 'playing', 'working', 'foreign', 'general',
'aircraft', 'computer', 'laughter', 'alphabet', 'kangaroo', 'spelling',
'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders',
),
// Riddles for the Captcha_Riddle_Driver to pick from
// Note: use only alphanumeric characters
'riddles' => array
(
array('Do you hate spam? (yes or no)', 'yes'),
array('Are you a robot? (yes or no)', 'no'),
array('Fire is... (hot or cold)', 'hot'),
array('The season after fall is...', 'winter'),
array('Which day of the week is it today?', strftime('%A')),
array('Which month of the year are we in?', strftime('%B')),
),
// Riddles for the Captcha_Riddle_Driver to pick from
// Note: use only alphanumeric characters
'riddles' => array
(
array('Do you hate spam? (yes or no)', 'yes'),
array('Are you a robot? (yes or no)', 'no'),
array('Fire is... (hot or cold)', 'hot'),
array('The season after fall is...', 'winter'),
array('Which day of the week is it today?', strftime('%A')),
array('Which month of the year are we in?', strftime('%B')),
),
);

View File

@@ -1,34 +1,36 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'there_can_be_only_one' => 'There can be only one instance of Kohana per page request',
'uncaught_exception' => 'Uncaught %s: %s in file %s on line %s',
'invalid_method' => 'Invalid method %s called in %s',
'invalid_property' => 'The %s property does not exist in the %s class.',
'log_dir_unwritable' => 'The log directory is not writable: %s',
'resource_not_found' => 'The requested %s, %s, could not be found',
'invalid_filetype' => 'The requested filetype, .%s, is not allowed in your view configuration file',
'view_set_filename' => 'You must set the the view filename before calling render',
'no_default_route' => 'Please set a default route in config/routes.php',
'no_controller' => 'Kohana was not able to determine a controller to process this request: %s',
'page_not_found' => 'The page you requested, %s, could not be found.',
'stats_footer' => 'Loaded in {execution_time} seconds, using {memory_usage} of memory. Generated by Kohana v{kohana_version}.',
'error_file_line' => '<tt>%s <strong>[%s]:</strong></tt>',
'stack_trace' => 'Stack Trace',
'generic_error' => 'Unable to Complete Request',
'errors_disabled' => 'You can go to the <a href="%s">home page</a> or <a href="%s">try again</a>.',
'there_can_be_only_one' => 'There can be only one instance of Kohana per page request',
'uncaught_exception' => 'Uncaught %s: %s in file %s on line %s',
'invalid_method' => 'Invalid method %s called in %s',
'invalid_property' => 'The %s property does not exist in the %s class.',
'log_dir_unwritable' => 'The log directory is not writable: %s',
'resource_not_found' => 'The requested %s, %s, could not be found',
'invalid_filetype' => 'The requested filetype, .%s, is not allowed in your view configuration file',
'view_set_filename' => 'You must set the the view filename before calling render',
'no_default_route' => 'Please set a default route in config/routes.php',
'no_controller' => 'Kohana was not able to determine a controller to process this request: %s',
'page_not_found' => 'The page you requested, %s, could not be found.',
'stats_footer' => 'Loaded in {execution_time} seconds, using {memory_usage} of memory. Generated by Kohana v{kohana_version}.',
'error_file_line' => '<tt>%s <strong>[%s]:</strong></tt>',
'stack_trace' => 'Stack Trace',
'generic_error' => 'Unable to Complete Request',
'errors_disabled' => 'You can go to the <a href="%s">home page</a> or <a href="%s">try again</a>.',
// Drivers
'driver_implements' => 'The %s driver for the %s library must implement the %s interface',
'driver_not_found' => 'The %s driver for the %s library could not be found',
// Drivers
'driver_implements' => 'The %s driver for the %s library must implement the %s interface',
'driver_not_found' => 'The %s driver for the %s library could not be found',
// Resource names
'config' => 'config file',
'controller' => 'controller',
'helper' => 'helper',
'library' => 'library',
'driver' => 'driver',
'model' => 'model',
'view' => 'view',
// Resource names
'config' => 'config file',
'controller' => 'controller',
'helper' => 'helper',
'library' => 'library',
'driver' => 'driver',
'model' => 'model',
'view' => 'view',
);

View File

@@ -1,15 +1,17 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'undefined_group' => 'The %s group is not defined in your configuration.',
'error' => 'There was an SQL error: %s',
'connection' => 'There was an error connecting to the database: %s',
'invalid_dsn' => 'The DSN you supplied is not valid: %s',
'must_use_set' => 'You must set a SET clause for your query.',
'must_use_where' => 'You must set a WHERE clause for your query.',
'must_use_table' => 'You must set a database table for your query.',
'table_not_found' => 'Table %s does not exist in your database.',
'not_implemented' => 'The method you called, %s, is not supported by this driver.',
'result_read_only' => 'Query results are read only.'
);
'undefined_group' => 'The %s group is not defined in your configuration.',
'error' => 'There was an SQL error: %s',
'connection' => 'There was an error connecting to the database: %s',
'invalid_dsn' => 'The DSN you supplied is not valid: %s',
'must_use_set' => 'You must set a SET clause for your query.',
'must_use_where' => 'You must set a WHERE clause for your query.',
'must_use_table' => 'You must set a database table for your query.',
'table_not_found' => 'Table %s does not exist in your database.',
'not_implemented' => 'The method you called, %s, is not supported by this driver.',
'result_read_only' => 'Query results are read only.'
);

View File

@@ -1,8 +1,10 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'undefined_group' => 'The %s group is not defined in your configuration.',
'requires_mcrypt' => 'To use the Encrypt library, mcrypt must be enabled in your PHP installation',
'no_encryption_key' => 'To use the Encrypt library, you must set an encryption key in your config file'
'undefined_group' => 'The %s group is not defined in your configuration.',
'requires_mcrypt' => 'To use the Encrypt library, mcrypt must be enabled in your PHP installation',
'no_encryption_key' => 'To use the Encrypt library, you must set an encryption key in your config file'
);

View File

@@ -1,15 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
E_KOHANA => array( 1, 'Framework Error', 'Please check the Kohana documentation for information about the following error.'),
E_PAGE_NOT_FOUND => array( 1, 'Page Not Found', 'The requested page was not found. It may have moved, been deleted, or archived.'),
E_DATABASE_ERROR => array( 1, 'Database Error', 'A database error occurred while performing the requested procedure. Please review the database error below for more information.'),
E_ERROR => array( 1, 'Fatal Error', ''),
E_USER_ERROR => array( 1, 'Fatal Error', ''),
E_PARSE => array( 1, 'Syntax Error', ''),
E_WARNING => array( 1, 'Warning Message', ''),
E_USER_WARNING => array( 1, 'Warning Message', ''),
E_STRICT => array( 2, 'Strict Mode Error', ''),
E_NOTICE => array( 2, 'Runtime Message', ''),
E_KOHANA => array( 1, 'Framework Error', 'Please check the Kohana documentation for information about the following error.'),
E_PAGE_NOT_FOUND => array( 1, 'Page Not Found', 'The requested page was not found. It may have moved, been deleted, or archived.'),
E_DATABASE_ERROR => array( 1, 'Database Error',
'A database error occurred while performing the requested procedure.' .
' Please review the database error below for more information.'),
E_ERROR => array( 1, 'Fatal Error', ''),
E_USER_ERROR => array( 1, 'Fatal Error', ''),
E_PARSE => array( 1, 'Syntax Error', ''),
E_WARNING => array( 1, 'Warning Message', ''),
E_USER_WARNING => array( 1, 'Warning Message', ''),
E_STRICT => array( 2, 'Strict Mode Error', ''),
E_NOTICE => array( 2, 'Runtime Message', ''),
);

View File

@@ -1,7 +1,9 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'invalid_subject' => 'Attempt to attach invalid subject %s to %s failed: Subjects must extend the Event_Subject class',
'invalid_observer' => 'Attempt to attach invalid observer %s to %s failed: Observers must extend the Event_Observer class',
'invalid_subject' => 'Attempt to attach invalid subject %s to %s failed: Subjects must extend the Event_Subject class',
'invalid_observer' => 'Attempt to attach invalid observer %s to %s failed: Observers must extend the Event_Observer class',
);

View File

@@ -1,33 +1,35 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php
defined('SYSPATH') or die('No direct access allowed.');
$lang = array
(
'getimagesize_missing' => 'The Image library requires the getimagesize() PHP function, which is not available in your installation.',
'unsupported_method' => 'Your configured driver does not support the %s image transformation.',
'file_not_found' => 'The specified image, %s, was not found. Please verify that images exist by using file_exists() before manipulating them.',
'type_not_allowed' => 'The specified image, %s, is not an allowed image type.',
'invalid_width' => 'The width you specified, %s, is not valid.',
'invalid_height' => 'The height you specified, %s, is not valid.',
'invalid_dimensions' => 'The dimensions specified for %s are not valid.',
'invalid_master' => 'The master dimension specified is not valid.',
'invalid_flip' => 'The flip direction specified is not valid.',
'directory_unwritable' => 'The specified directory, %s, is not writable.',
'getimagesize_missing' => 'The Image library requires the getimagesize() PHP function, which is not available in your installation.',
'unsupported_method' => 'Your configured driver does not support the %s image transformation.',
'file_not_found' => 'The specified image, %s, was not found. Please verify that images exist by using file_exists() before manipulating them.',
'type_not_allowed' => 'The specified image, %s, is not an allowed image type.',
'invalid_width' => 'The width you specified, %s, is not valid.',
'invalid_height' => 'The height you specified, %s, is not valid.',
'invalid_dimensions' => 'The dimensions specified for %s are not valid.',
'invalid_master' => 'The master dimension specified is not valid.',
'invalid_flip' => 'The flip direction specified is not valid.',
'directory_unwritable' => 'The specified directory, %s, is not writable.',
// ImageMagick specific messages
'imagemagick' => array
(
'not_found' => 'The ImageMagick directory specified does not contain a required program, %s.',
),
// GraphicsMagick specific messages
'graphicsmagick' => array
(
'not_found' => 'The GraphicsMagick directory specified does not contain a required program, %s.',
),
// GD specific messages
'gd' => array
(
'requires_v2' => 'The Image library requires GD2. Please see http://php.net/gd_info for more information.',
),
// ImageMagick specific messages
'imagemagick' => array
(
'not_found' => 'The ImageMagick directory specified does not contain a required program, %s.',
),
// GraphicsMagick specific messages
'graphicsmagick' => array
(
'not_found' => 'The GraphicsMagick directory specified does not contain a required program, %s.',
),
// GD specific messages
'gd' => array
(
'requires_v2' => 'The Image library requires GD2. Please see http://php.net/gd_info for more information.',
),
);

Some files were not shown because too many files have changed in this diff Show More