[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/ -> compat.php5xx.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  /**
  20   * Replace stripos()
  21   *
  22   * @category    PHP
  23   * @package     PHP_Compat
  24   * @link        http://php.net/function.stripos
  25   * @author      Aidan Lister <aidan@php.net>
  26   * @version     $Revision: 1.13 $
  27   * @since       PHP 5
  28   * @require     PHP 4.0.0 (user_error)
  29   */
  30  if (!function_exists('stripos')) {
  31      function stripos($haystack, $needle, $offset = null)
  32      {
  33          if (!is_scalar($haystack)) {
  34              user_error('stripos() expects parameter 1 to be string, ' .
  35                  gettype($haystack) . ' given', E_USER_WARNING);
  36              return false;
  37          }
  38  
  39          if (!is_scalar($needle)) {
  40              user_error('stripos() needle is not a string or an integer.', E_USER_WARNING);
  41              return false;
  42          }
  43  
  44          if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) {
  45              user_error('stripos() expects parameter 3 to be long, ' .
  46                  gettype($offset) . ' given', E_USER_WARNING);
  47              return false;
  48          }
  49  
  50          // Manipulate the string if there is an offset
  51          $fix = 0;
  52          if (!is_null($offset)) {
  53              if ($offset > 0) {
  54                  $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
  55                  $fix = $offset;
  56              }
  57          }
  58  
  59          $segments = explode(strtolower($needle), strtolower($haystack), 2);
  60  
  61          // Check there was a match
  62          if (count($segments) === 1) {
  63              return false;
  64          }
  65  
  66          $position = strlen($segments[0]) + $fix;
  67          return $position;
  68      }
  69  }
  70  ?>