Index: C:/Program Files/EditPlus 2/sources/typo3_src-4.1/t3lib/class.t3lib_div.php =================================================================== --- C:/Program Files/EditPlus 2/sources/typo3_src-4.1/t3lib/class.t3lib_div.php (revision 2438) +++ C:/Program Files/EditPlus 2/sources/typo3_src-4.1/t3lib/class.t3lib_div.php (working copy) @@ -556,7 +556,7 @@ function breakTextForEmail($str,$implChar="\n",$charWidth=76) { $lines = explode(chr(10),$str); $outArr=array(); - while(list(,$lStr)=each($lines)) { + foreach ($lines as $lStr) { $outArr[] = t3lib_div::breakLinesForEmail($lStr,$implChar,$charWidth); } return implode(chr(10),$outArr); @@ -610,7 +610,7 @@ */ function cmpIP($baseIP, $list) { if ($list==='*') return TRUE; - if (strstr($baseIP, ':') && t3lib_div::validIPv6($baseIP)) { + if ((strpos($baseIP, ':') !== false) && t3lib_div::validIPv6($baseIP)) { return t3lib_div::cmpIPv6($baseIP, $list); } else { return t3lib_div::cmpIPv4($baseIP, $list); @@ -645,8 +645,7 @@ // "192.168.*.*" $IPparts = explode('.',$test); $yes = 1; - reset($IPparts); - while(list($index,$val)=each($IPparts)) { + foreach ($IPparts as $index => $val) { $val = trim($val); if (strcmp($val,'*') && strcmp($IPpartsReq[$index],$val)) { $yes=0; @@ -834,7 +833,7 @@ * @return boolean true if $item is in $list */ function inList($list,$item) { - return strstr(','.$list.',', ','.$item.',') ? true : false; + return strpos(' ,'.$list.',', ','.$item.',') ? true : false; } /** @@ -847,7 +846,7 @@ */ function rmFromList($element,$list) { $items = explode(',',$list); - while(list($k,$v)=each($items)) { + foreach ($items as $k => $v) { if ($v==$element) {unset($items[$k]);} } return implode(',',$items); @@ -864,7 +863,7 @@ function expandList($list) { $items = explode(',',$list); $list = array(); - while(list(,$item)=each($items)) { + foreach ($items as $item) { $range = explode('-',$item); if (isset($range[1])) { $runAwayBrake = 1000; @@ -878,7 +877,6 @@ $list[] = $item; } } - return implode(',',$list); } @@ -1230,9 +1228,9 @@ $number=0; $Msign='+'; $err=''; - $buffer=doubleval(current($reg[2])); - next($reg[2]); // Advance pointer - while(list($k,$v)=each($reg[2])) { + $buffer=doubleval(array_shift($reg[2])); + + foreach ($reg[2] as $k => $v) { $v=doubleval($v); $sign = $reg[1][$k]; if ($sign=='+' || $sign=='-') { @@ -1350,7 +1348,7 @@ */ function validEmail($email) { $email = trim ($email); - if (strstr($email,' ')) return FALSE; + if (strpos($email,' ')) return FALSE; return ereg('^[A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+$',$email) ? TRUE : FALSE; } @@ -1396,7 +1394,7 @@ */ function inArray($in_array,$item) { if (is_array($in_array)) { - while (list(,$val)=each($in_array)) { + foreach ($in_array as $val) { if (!is_array($val) && !strcmp($val,$item)) return true; } } @@ -1413,8 +1411,8 @@ */ function intExplode($delim, $string) { $temp = explode($delim,$string); - while(list($key,$val)=each($temp)) { - $temp[$key]=intval($val); + foreach ($temp as $key => $val) { + $temp[$key] = intval($val); } reset($temp); return $temp; @@ -1432,7 +1430,7 @@ */ function revExplode($delim, $string, $count=0) { $temp = explode($delim,strrev($string),$count); - while(list($key,$val)=each($temp)) { + foreach ($temp as $key => $val) { $temp[$key]=strrev($val); } $temp=array_reverse($temp); @@ -1453,7 +1451,7 @@ function trimExplode($delim, $string, $onlyNonEmptyValues=0) { $temp = explode($delim,$string); $newtemp=array(); - while(list($key,$val)=each($temp)) { + foreach ($temp as $key => $val) { if (!$onlyNonEmptyValues || strcmp('',trim($val))) { $newtemp[]=trim($val); } @@ -1486,7 +1484,7 @@ function removeArrayEntryByValue($array,$cmpValue) { if (is_array($array)) { reset($array); - while(list($k,$v)=each($array)) { + foreach ($array as $k => $v) { if (is_array($v)) { $array[$k] = t3lib_div::removeArrayEntryByValue($v,$cmpValue); } else { @@ -1588,8 +1586,7 @@ */ function addSlashesOnArray(&$theArray) { if (is_array($theArray)) { - reset($theArray); - while(list($Akey,$AVal)=each($theArray)) { + foreach ($theArray as $Akey => $AVal) { if (is_array($AVal)) { t3lib_div::addSlashesOnArray($theArray[$Akey]); } else { @@ -1612,8 +1609,7 @@ */ function stripSlashesOnArray(&$theArray) { if (is_array($theArray)) { - reset($theArray); - while(list($Akey,$AVal)=each($theArray)) { + foreach ($theArray as $kAkey => $AVal) { if (is_array($AVal)) { t3lib_div::stripSlashesOnArray($theArray[$Akey]); } else { @@ -1650,8 +1646,7 @@ * @return array Resulting array where $arr1 values has overruled $arr0 values */ function array_merge_recursive_overrule($arr0,$arr1,$notAddKeys=0,$includeEmtpyValues=true) { - reset($arr1); - while(list($key,$val) = each($arr1)) { + foreach ($arr1 as $key => $val) { if(is_array($arr0[$key])) { if (is_array($arr1[$key])) { $arr0[$key] = t3lib_div::array_merge_recursive_overrule($arr0[$key],$arr1[$key],$notAddKeys,$includeEmtpyValues); @@ -1762,7 +1757,7 @@ $name = ''; // attribute name is stored here $valuemode = ''; if (is_array($components)) { - while (list($key,$val) = each ($components)) { + foreach ($components as $key => $val) { if ($val != '=') { // Only if $name is set (if there is an attribute, that waits for a value), that valuemode is enabled. This ensures that the attribute is assigned it's value if ($valuemode) { if ($name) { @@ -2646,9 +2641,8 @@ // Sort them: if ($order) { asort($sortarray); - reset($sortarray); $newArr=array(); - while(list($k,$v)=each($sortarray)) { + foreach ($sortarray as $k => $v) { $newArr[$k]=$filearray[$k]; } $filearray=$newArr; @@ -2811,7 +2805,7 @@ if (is_array($array_in)) { $result=''; if (!count($array_in)) {$result.= '';} - while (list($key,$val)=each($array_in)) { + foreach ($array_in as $key => $val) { $result.= '
'.htmlspecialchars("EMPTY!").'
'.htmlspecialchars((string)$key).''; if (is_array($array_in[$key])) { $result.=t3lib_div::view_array($array_in[$key]); @@ -3157,7 +3151,7 @@ $SN_A = explode('/',strrev(t3lib_div::getIndpEnv('SCRIPT_NAME'))); $SFN_A = explode('/',strrev($SFN)); $acc = array(); - while(list($kk,$vv)=each($SN_A)) { + foreach ($SN_A as $kk => $vv) { if (!strcmp($SFN_A[$kk],$vv)) { $acc[] = $vv; } else break; @@ -3227,8 +3221,7 @@ REMOTE_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE',1); - reset($envTestVars); - while(list(,$v)=each($envTestVars)) { + foreach ($envTestVars as $v) { $out[$v]=t3lib_div::getIndpEnv($v); } reset($out); @@ -3262,13 +3255,13 @@ $bInfo=array(); // Which browser? - if (strstr($useragent,'Konqueror')) { + if (strpos($useragent,'Konqueror') !== false) { $bInfo['BROWSER']= 'konqu'; - } elseif (strstr($useragent,'Opera')) { + } elseif (strpos($useragent,'Opera') !== false) { $bInfo['BROWSER']= 'opera'; } elseif (preg_match('/MSIE [4567]/', $useragent)) { $bInfo['BROWSER']= 'msie'; - } elseif (strstr($useragent,'Mozilla/4') || strstr($useragent,'Mozilla/5')) { + } elseif ((strpos($useragent,'Mozilla/4')) !== false || (strpos($useragent,'Mozilla/5') !== false)) { $bInfo['BROWSER']='net'; } if ($bInfo['BROWSER']) { @@ -3276,9 +3269,9 @@ switch($bInfo['BROWSER']) { case 'net': $bInfo['VERSION']= doubleval(substr($useragent,8)); - if (strstr($useragent,'Netscape6/')) {$bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape6/'),10));} // Will we ever know if this was a typo or intention...?! :-( - if (strstr($useragent,'Netscape/6')) {$bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape/6'),10));} - if (strstr($useragent,'Netscape/7')) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape/7'),9));} + if (strpos($useragent,'Netscape6/') !== false) {$bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape6/'),10));} // Will we ever know if this was a typo or intention...?! :-( + if (strpos($useragent,'Netscape/6') !== false) {$bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape/6'),10));} + if (strpos($useragent,'Netscape/7') !== false) {$bInfo['VERSION']=doubleval(substr(strstr($useragent,'Netscape/7'),9));} break; case 'msie': $tmp = strstr($useragent,'MSIE'); @@ -3294,11 +3287,11 @@ break; } // Client system - if (strstr($useragent,'Win')) { + if (strpos($useragent,'Win') !== false) { $bInfo['SYSTEM'] = 'win'; - } elseif (strstr($useragent,'Mac')) { + } elseif (strpos($useragent,'Mac') !== false) { $bInfo['SYSTEM'] = 'mac'; - } elseif (strstr($useragent,'Linux') || strstr($useragent,'X11') || strstr($useragent,'SGI') || strstr($useragent,' SunOS ') || strstr($useragent,' HP-UX ')) { + } elseif ((strpos($useragent,'Linux') !== false) || (strpos($useragent,'X11') !== false) || (strpos($useragent,'SGI') !== false) || (strpos($useragent,' SunOS ') !== false) || (strpos($useragent,' HP-UX ') !== false)) { $bInfo['SYSTEM'] = 'unix'; } } @@ -3413,7 +3406,7 @@ * @todo Possible improvement: Should it rawurldecode the string first to check if any of these characters is encoded ? */ function validPathStr($theFile) { - if (!strstr($theFile,'//') && !strstr($theFile,'\\') && !preg_match('#(?:^\.\.|/\.\./)#',$theFile)) return true; + if ((strpos($theFile,'//') === false) && (strpos($theFile,'\\') === false) && !preg_match('#(?:^\.\.|/\.\./)#',$theFile)) return true; } /** @@ -3549,8 +3542,7 @@ $recCopy_temp=array(); if ($fields) { $fieldArr = t3lib_div::trimExplode(',',$fields,1); - reset($fieldArr); - while(list($k,$v)=each($fieldArr)) { + foreach ($fieldArr as $k => $v) { $recCopy_temp[$k]=$uid_or_record[$v]; } } else { @@ -3913,7 +3905,7 @@ } // Check file-reference prefix; if found, require_once() the file (should be library of code) - if (strstr($funcName,':')) { + if (strpos($funcName,':') !== false) { list($file,$funcRef) = t3lib_div::revExplode(':',$funcName,2); $requireFile = t3lib_div::getFileAbsFileName($file); if ($requireFile) t3lib_div::requireOnce($requireFile); @@ -4004,7 +3996,7 @@ } else { // Check file-reference prefix; if found, require_once() the file (should be library of code) - if (strstr($classRef,':')) { + if (strpos($classRef,':') !== false) { list($file,$class) = t3lib_div::revExplode(':',$classRef,2); $requireFile = t3lib_div::getFileAbsFileName($file); if ($requireFile) t3lib_div::requireOnce($requireFile); @@ -4286,7 +4278,7 @@ */ function encodeHeader($line,$enc='quoted-printable',$charset='ISO-8859-1') { // Avoid problems if "###" is found in $line (would conflict with the placeholder which is used below) - if (strstr($line,'###')) return $line; + if (strpos($line,'###') !== false) return $line; // Check if any non-ASCII characters are found - otherwise encoding is not needed if (!preg_match('/[^'.chr(32).'-'.chr(127).']/',$line)) return $line; @@ -4332,8 +4324,7 @@ // Substitute URLs with shorter links: foreach (array('http','https') as $protocol) { $urlSplit = explode($protocol.'://',$message); - reset($urlSplit); - while (list($c,$v) = each($urlSplit)) { + foreach ($urlSplit as $c => $v) { if ($c) { $newParts = preg_split('/\s|[<>"{}|\\\^`()\']/', $v, 2); $newURL = $protocol.'://'.$newParts[0]; @@ -4574,7 +4565,7 @@ } return $str; } - +