Permalink
Browse files

Add stripos() compatibility function (report #100)

  • Loading branch information...
1 parent f6570dc commit 2232eb5794322e866115ff38a5a68409ca15bb37 @haraldpdl haraldpdl committed Nov 7, 2010
Showing with 30 additions and 1 deletion.
  1. +30 −1 catalog/includes/functions/compatibility.php
View
31 catalog/includes/functions/compatibility.php
@@ -5,7 +5,7 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2009 osCommerce
+ Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
@@ -67,4 +67,33 @@ function checkdnsrr($host, $type) {
return false;
}
}
+
+/*
+ * stripos() natively supported from PHP 5.0
+ * From Pear::PHP_Compat
+ */
+
+ if (!function_exists('stripos')) {
+ function stripos($haystack, $needle, $offset = null) {
+ $fix = 0;
+
+ if (!is_null($offset)) {
+ if ($offset > 0) {
+ $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
+ $fix = $offset;
+ }
+ }
+
+ $segments = explode(strtolower($needle), strtolower($haystack), 2);
+
+// Check there was a match
+ if (count($segments) == 1) {
+ return false;
+ }
+
+ $position = strlen($segments[0]) + $fix;
+
+ return $position;
+ }
+ }
?>

0 comments on commit 2232eb5

Please sign in to comment.