mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Text parser - usubstr() method fix (always returned empty string), utf8 parser methods lowercased
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
* Text processing and parsing functions
|
* Text processing and parsing functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
||||||
* $Revision: 1.90 $
|
* $Revision: 1.91 $
|
||||||
* $Date: 2010-01-09 13:17:45 $
|
* $Date: 2010-01-12 13:11:48 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -299,7 +299,7 @@ class e_parse
|
|||||||
* @param string $str The UTF-8 encoded string being measured for length.
|
* @param string $str The UTF-8 encoded string being measured for length.
|
||||||
* @return integer The length (amount of UTF-8 characters) of the string on success, and 0 if the string is empty.
|
* @return integer The length (amount of UTF-8 characters) of the string on success, and 0 if the string is empty.
|
||||||
*/
|
*/
|
||||||
public function uStrLen($str)
|
public function ustrlen($str)
|
||||||
{
|
{
|
||||||
switch($this->utfAction)
|
switch($this->utfAction)
|
||||||
{
|
{
|
||||||
@@ -321,7 +321,7 @@ class e_parse
|
|||||||
* @param string $str The UTF-8 encoded string to be lowercased.
|
* @param string $str The UTF-8 encoded string to be lowercased.
|
||||||
* @return string Specified string with all alphabetic characters converted to lowercase.
|
* @return string Specified string with all alphabetic characters converted to lowercase.
|
||||||
*/
|
*/
|
||||||
public function uStrToLower($str)
|
public function ustrtolower($str)
|
||||||
{
|
{
|
||||||
switch($this->utfAction)
|
switch($this->utfAction)
|
||||||
{
|
{
|
||||||
@@ -342,7 +342,7 @@ class e_parse
|
|||||||
* @param string $str The UTF-8 encoded string to be uppercased.
|
* @param string $str The UTF-8 encoded string to be uppercased.
|
||||||
* @return string Specified string with all alphabetic characters converted to uppercase.
|
* @return string Specified string with all alphabetic characters converted to uppercase.
|
||||||
*/
|
*/
|
||||||
public function uStrToUpper($str)
|
public function ustrtoupper($str)
|
||||||
{
|
{
|
||||||
switch($this->utfAction)
|
switch($this->utfAction)
|
||||||
{
|
{
|
||||||
@@ -368,7 +368,7 @@ class e_parse
|
|||||||
* The position returned is still relative to the beginning of haystack.
|
* The position returned is still relative to the beginning of haystack.
|
||||||
* @return integer|boolean Returns the position as an integer. If needle is not found, the function will return boolean FALSE.
|
* @return integer|boolean Returns the position as an integer. If needle is not found, the function will return boolean FALSE.
|
||||||
*/
|
*/
|
||||||
public function uStrPos($haystack, $needle, $offset = 0)
|
public function ustrpos($haystack, $needle, $offset = 0)
|
||||||
{
|
{
|
||||||
switch($this->utfAction)
|
switch($this->utfAction)
|
||||||
{
|
{
|
||||||
@@ -393,7 +393,7 @@ class e_parse
|
|||||||
* The position returned is still relative to the beginning of haystack.
|
* The position returned is still relative to the beginning of haystack.
|
||||||
* @return integer|boolean Returns the position as an integer. If needle is not found, the function will return boolean FALSE.
|
* @return integer|boolean Returns the position as an integer. If needle is not found, the function will return boolean FALSE.
|
||||||
*/
|
*/
|
||||||
public function uStrrPos($haystack, $needle, $offset = 0)
|
public function ustrrpos($haystack, $needle, $offset = 0)
|
||||||
{
|
{
|
||||||
switch($this->utfAction)
|
switch($this->utfAction)
|
||||||
{
|
{
|
||||||
@@ -420,7 +420,7 @@ class e_parse
|
|||||||
* (depending on the length of string). If length is omitted, the rest of string from start will be returned.
|
* (depending on the length of string). If length is omitted, the rest of string from start will be returned.
|
||||||
* @return string The extracted UTF-8 encoded part of input string.
|
* @return string The extracted UTF-8 encoded part of input string.
|
||||||
*/
|
*/
|
||||||
public function uSubStr($str, $start, $length = NULL)
|
public function usubstr($str, $start, $length = NULL)
|
||||||
{
|
{
|
||||||
switch($this->utfAction)
|
switch($this->utfAction)
|
||||||
{
|
{
|
||||||
@@ -429,11 +429,11 @@ class e_parse
|
|||||||
case 1:
|
case 1:
|
||||||
if(is_null($length))
|
if(is_null($length))
|
||||||
{
|
{
|
||||||
return mb_substr($haystack, $needle);
|
return mb_substr($str, $start);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return mb_substr($haystack, $needle, $offset);
|
return mb_substr($str, $start, $length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return utf8_substr($str, $start, $length);
|
return utf8_substr($str, $start, $length);
|
||||||
@@ -788,7 +788,7 @@ class e_parse
|
|||||||
*/
|
*/
|
||||||
function html_truncate($text, $length = 100, $ending = '...', $exact = true)
|
function html_truncate($text, $length = 100, $ending = '...', $exact = true)
|
||||||
{
|
{
|
||||||
if($this->uStrLen(preg_replace('/<.*?>/', '', $text)) <= $length)
|
if($this->ustrlen(preg_replace('/<.*?>/', '', $text)) <= $length)
|
||||||
{
|
{
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -796,9 +796,10 @@ class e_parse
|
|||||||
$openTags = array();
|
$openTags = array();
|
||||||
$truncate = '';
|
$truncate = '';
|
||||||
preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
|
preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
|
||||||
|
|
||||||
foreach($tags as $tag)
|
foreach($tags as $tag)
|
||||||
{
|
{
|
||||||
if(!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/si', $tag[2]))
|
if(!$tag[2] || !preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/si', $tag[2]))
|
||||||
{
|
{
|
||||||
if(preg_match('/<[\w]+[^>]*>/s', $tag[0]))
|
if(preg_match('/<[\w]+[^>]*>/s', $tag[0]))
|
||||||
{
|
{
|
||||||
@@ -814,7 +815,8 @@ class e_parse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$truncate .= $tag[1];
|
$truncate .= $tag[1];
|
||||||
$contentLength = $this->uStrLen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $tag[3]));
|
$contentLength = $this->ustrlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $tag[3]));
|
||||||
|
|
||||||
if($contentLength + $totalLength > $length)
|
if($contentLength + $totalLength > $length)
|
||||||
{
|
{
|
||||||
$left = $length - $totalLength;
|
$left = $length - $totalLength;
|
||||||
@@ -826,7 +828,7 @@ class e_parse
|
|||||||
if($entity[1] + 1 - $entitiesLength <= $left)
|
if($entity[1] + 1 - $entitiesLength <= $left)
|
||||||
{
|
{
|
||||||
$left--;
|
$left--;
|
||||||
$entitiesLength += $this->uStrLen($entity[0]);
|
$entitiesLength += $this->ustrlen($entity[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -834,7 +836,8 @@ class e_parse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$truncate .= $this->uSubStr($tag[3], 0, $left + $entitiesLength);
|
|
||||||
|
$truncate .= $this->usubstr($tag[3], 0, $left + $entitiesLength);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -849,10 +852,10 @@ class e_parse
|
|||||||
}
|
}
|
||||||
if(!$exact)
|
if(!$exact)
|
||||||
{
|
{
|
||||||
$spacepos = $this->uStrrPos($truncate, ' ');
|
$spacepos = $this->ustrrpos($truncate, ' ');
|
||||||
if(isset($spacepos))
|
if(isset($spacepos))
|
||||||
{
|
{
|
||||||
$bits = $this->uSubStr($truncate, $spacepos);
|
$bits = $this->usubstr($truncate, $spacepos);
|
||||||
preg_match_all('/<\/([a-z]+)>/i', $bits, $droppedTags, PREG_SET_ORDER);
|
preg_match_all('/<\/([a-z]+)>/i', $bits, $droppedTags, PREG_SET_ORDER);
|
||||||
if(!empty($droppedTags))
|
if(!empty($droppedTags))
|
||||||
{
|
{
|
||||||
@@ -864,7 +867,7 @@ class e_parse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$truncate = $this->uSubStr($truncate, 0, $spacepos);
|
$truncate = $this->usubstr($truncate, 0, $spacepos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$truncate .= $ending;
|
$truncate .= $ending;
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* Handler - general purpose validation functions
|
* Handler - general purpose validation functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
||||||
* $Revision: 1.17 $
|
* $Revision: 1.18 $
|
||||||
* $Date: 2009-11-18 01:04:43 $
|
* $Date: 2010-01-12 13:11:48 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ class e_validator
|
|||||||
case 'str':
|
case 'str':
|
||||||
case 'string':
|
case 'string':
|
||||||
$tmp = explode('-', $cond);
|
$tmp = explode('-', $cond);
|
||||||
$length = e107::getParser()->uStrLen($value);
|
$length = e107::getParser()->ustrlen($value);
|
||||||
if(is_numeric($tmp[0]) && (integer) $tmp[0] > $length)
|
if(is_numeric($tmp[0]) && (integer) $tmp[0] > $length)
|
||||||
{
|
{
|
||||||
$this->addValidateResult($name, self::ERR_TOO_SHORT);
|
$this->addValidateResult($name, self::ERR_TOO_SHORT);
|
||||||
@@ -843,7 +843,7 @@ class validatorClass
|
|||||||
}
|
}
|
||||||
$value = $newValue;
|
$value = $newValue;
|
||||||
}
|
}
|
||||||
if (!$errNum && isset($defs['minLength']) && ($tp->uStrLen($value) < $defs['minLength']))
|
if (!$errNum && isset($defs['minLength']) && ($tp->ustrlen($value) < $defs['minLength']))
|
||||||
{
|
{
|
||||||
if ($value == '')
|
if ($value == '')
|
||||||
{
|
{
|
||||||
@@ -857,7 +857,7 @@ class validatorClass
|
|||||||
$errNum = ERR_TOO_SHORT;
|
$errNum = ERR_TOO_SHORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$errNum && isset($defs['maxLength']) && $tp->uStrLen($value) > $defs['maxLength'])
|
if (!$errNum && isset($defs['maxLength']) && $tp->ustrlen($value) > $defs['maxLength'])
|
||||||
{
|
{
|
||||||
if (varsettrue($defs['longtrim']))
|
if (varsettrue($defs['longtrim']))
|
||||||
{
|
{
|
||||||
@@ -878,11 +878,11 @@ class validatorClass
|
|||||||
}
|
}
|
||||||
if (!$errNum && isset($defs['fixedBlock']))
|
if (!$errNum && isset($defs['fixedBlock']))
|
||||||
{
|
{
|
||||||
$newValue = $tp->uStrToLower($value);
|
$newValue = $tp->ustrtolower($value);
|
||||||
$temp = explode(',',$defs['fixedBlock']);
|
$temp = explode(',',$defs['fixedBlock']);
|
||||||
foreach ($temp as $t)
|
foreach ($temp as $t)
|
||||||
{
|
{
|
||||||
if ($newValue == $tp->uStrToLower($t))
|
if ($newValue == $tp->ustrtolower($t))
|
||||||
{
|
{
|
||||||
$errNum = ERR_INVALID_WORD;
|
$errNum = ERR_INVALID_WORD;
|
||||||
break;
|
break;
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/alt_auth_login_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/alt_auth_login_class.php,v $
|
||||||
* $Revision: 1.12 $
|
* $Revision: 1.13 $
|
||||||
* $Date: 2009-11-18 01:05:22 $
|
* $Date: 2010-01-12 13:11:48 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('AA_DEBUG',FALSE);
|
define('AA_DEBUG',FALSE);
|
||||||
@@ -221,16 +221,16 @@ class alt_login
|
|||||||
switch ($method)
|
switch ($method)
|
||||||
{
|
{
|
||||||
case 'bool1' :
|
case 'bool1' :
|
||||||
switch ($tp->uStrToUpper($word))
|
switch ($tp->ustrtoupper($word))
|
||||||
{
|
{
|
||||||
case 'TRUE' : return TRUE;
|
case 'TRUE' : return TRUE;
|
||||||
case 'FALSE' : return FALSE;
|
case 'FALSE' : return FALSE;
|
||||||
}
|
}
|
||||||
return $word;
|
return $word;
|
||||||
case 'ucase' :
|
case 'ucase' :
|
||||||
return $tp->uStrToUpper($word);
|
return $tp->ustrtoupper($word);
|
||||||
case 'lcase' :
|
case 'lcase' :
|
||||||
return $tp->uStrToLower($word);
|
return $tp->ustrtolower($word);
|
||||||
case 'ucfirst' :
|
case 'ucfirst' :
|
||||||
return ucfirst($word); // TODO: Needs changing to utf-8 function
|
return ucfirst($word); // TODO: Needs changing to utf-8 function
|
||||||
case 'ucwords' :
|
case 'ucwords' :
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* Comment menu shortcodes
|
* Comment menu shortcodes
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/comment_menu/comment_menu_shortcodes.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/comment_menu/comment_menu_shortcodes.php,v $
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.8 $
|
||||||
* $Date: 2009-11-18 01:05:28 $
|
* $Date: 2010-01-12 13:11:48 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -72,7 +72,7 @@ $COMMENT = '';
|
|||||||
if($menu_pref['comment_characters'] > 0)
|
if($menu_pref['comment_characters'] > 0)
|
||||||
{
|
{
|
||||||
$COMMENT = strip_tags($tp->toHTML($row['comment_comment'], TRUE, "emotes_off, no_make_clickable", "", e107::getPref('menu_wordwrap')));
|
$COMMENT = strip_tags($tp->toHTML($row['comment_comment'], TRUE, "emotes_off, no_make_clickable", "", e107::getPref('menu_wordwrap')));
|
||||||
if ($tp->uStrLen($COMMENT) > $menu_pref['comment_characters'])
|
if ($tp->ustrlen($COMMENT) > $menu_pref['comment_characters'])
|
||||||
{
|
{
|
||||||
$COMMENT = $tp->text_truncate($COMMENT, $menu_pref['comment_characters'],'').($row['comment_url'] ? " <a href='".$row['comment_url']."'>" : "").defset($menu_pref['comment_postfix'], $menu_pref['comment_postfix']).($row['comment_url'] ? "</a>" : "");
|
$COMMENT = $tp->text_truncate($COMMENT, $menu_pref['comment_characters'],'').($row['comment_url'] ? " <a href='".$row['comment_url']."'>" : "").defset($menu_pref['comment_postfix'], $menu_pref['comment_postfix']).($row['comment_url'] ? "</a>" : "");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user