Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattpiwik <matthieu.aubry@gmail.com>2009-02-13 05:31:47 +0300
committermattpiwik <matthieu.aubry@gmail.com>2009-02-13 05:31:47 +0300
commit8ffdb091d5ae1328a333eb473c415ff85e7f05b2 (patch)
tree11d3c6c3ecc3232acd58678ef0e5c1b070d2716c /libs/upgradephp
parentc70195fdc0438b8662c72cef6ca542b408c5f8c1 (diff)
- adding ctype_* emulation from upgradephp library; we don't have to require ctype extension
git-svn-id: http://dev.piwik.org/svn/trunk@900 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/upgradephp')
-rw-r--r--libs/upgradephp/upgrade.php46
1 files changed, 44 insertions, 2 deletions
diff --git a/libs/upgradephp/upgrade.php b/libs/upgradephp/upgrade.php
index 349c0e6672..671fb65592 100644
--- a/libs/upgradephp/upgrade.php
+++ b/libs/upgradephp/upgrade.php
@@ -382,6 +382,48 @@ if (!function_exists("htmlspecialchars_decode")) {
}
}
+/*
+ These functions emulate the "character type" extension, which is
+ present in PHP first since version 4.3 per default. In this variant
+ only ASCII and Latin-1 characters are being handled. The first part
+ is eventually faster.
+*/
+
+
+#-- regex variants
+if (!function_exists("ctype_alnum")) {
+ function ctype_alnum($text) {
+ return preg_match("/^[A-Za-z\d\300-\377]+$/", $text);
+ }
+ function ctype_alpha($text) {
+ return preg_match("/^[a-zA-Z\300-\377]+$/", $text);
+ }
+ function ctype_digit($text) {
+ return preg_match("/^\d+$/", $text);
+ }
+ function ctype_xdigit($text) {
+ return preg_match("/^[a-fA-F0-9]+$/", $text);
+ }
+ function ctype_cntrl($text) {
+ return preg_match("/^[\000-\037]+$/", $text);
+ }
+ function ctype_space($text) {
+ return preg_match("/^\s+$/", $text);
+ }
+ function ctype_upper($text) {
+ return preg_match("/^[A-Z\300-\337]+$/", $text);
+ }
+ function ctype_lower($text) {
+ return preg_match("/^[a-z\340-\377]+$/", $text);
+ }
+ function ctype_graph($text) {
+ return preg_match("/^[\041-\176\241-\377]+$/", $text);
+ }
+ function ctype_punct($text) {
+ return preg_match("/^[^0-9A-Za-z\000-\040\177-\240\300-\377]+$/", $text);
+ }
+ function ctype_print($text) {
+ return ctype_punct($text) && ctype_graph($text);
+ }
-
-?>
+}