summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-10-30 19:44:57 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-10-30 19:45:46 +0100
commit6589c60cca0146ef5c4f606105e1c2ed9cf23cbd (patch)
tree68d0c0626d8fe6fe055a34f009ef633205159bae /inc
parent9269d0b1fb78c217069efd497734c183df9937be (diff)
downloadrpg-6589c60cca0146ef5c4f606105e1c2ed9cf23cbd.tar.gz
rpg-6589c60cca0146ef5c4f606105e1c2ed9cf23cbd.tar.bz2
compatibility functions for missing ctype extension FS#2873
Diffstat (limited to 'inc')
-rw-r--r--inc/compatibility.php36
-rw-r--r--inc/load.php1
2 files changed, 37 insertions, 0 deletions
diff --git a/inc/compatibility.php b/inc/compatibility.php
new file mode 100644
index 000000000..ae780e5ac
--- /dev/null
+++ b/inc/compatibility.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * compatibility functions
+ *
+ * This file contains a few functions that might be missing from the PHP build
+ */
+
+if(!function_exists('ctype_space')) {
+ /**
+ * Check for whitespace character(s)
+ *
+ * @see ctype_space
+ * @param string $text
+ * @return bool
+ */
+ function ctype_space($text) {
+ if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars
+ if(trim($text) === '') return true;
+ return false;
+ }
+}
+
+if(!function_exists('ctype_digit')) {
+ /**
+ * Check for numeric character(s)
+ *
+ * @see ctype_digit
+ * @param string $text
+ * @return bool
+ */
+ function ctype_digit($text) {
+ if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars
+ if(preg_match('/^\d+$/', $text)) return true;
+ return false;
+ }
+} \ No newline at end of file
diff --git a/inc/load.php b/inc/load.php
index 923671296..c5b40ffd8 100644
--- a/inc/load.php
+++ b/inc/load.php
@@ -35,6 +35,7 @@ require_once(DOKU_INC.'inc/template.php');
require_once(DOKU_INC.'inc/toolbar.php');
require_once(DOKU_INC.'inc/utf8.php');
require_once(DOKU_INC.'inc/auth.php');
+require_once(DOKU_INC.'inc/compatibility.php');
/**
* spl_autoload_register callback