Replaced eregi() with preg_match() and get_class() for thirdparty

This commit is contained in:
abraar
2010-12-10 14:09:28 +00:00
parent 016eeae8a2
commit 96abdb996a
20 changed files with 50 additions and 51 deletions

View File

@@ -233,7 +233,7 @@ class Form extends XmlForm
}
}
foreach($this->fields as $k => $v){
if(is_object($this) && get_class($this->fields[$k])!='__PHP_Incomplete_Class'){
if(is_object($this->fields[$k]) && get_class($this->fields[$k])!='__PHP_Incomplete_Class'){
$this->fields[$k]->owner =& $this;
}
}

View File

@@ -228,7 +228,7 @@ class XML_ extends Tree {
}
else {
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlbranch")
if(is_object($node) && strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$attributeValue = $node->getTagAttribute($attributeName, $newTagPath);
@@ -255,7 +255,7 @@ class XML_ extends Tree {
$tagValue = $this->getXMLContent();
else {
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlbranch")
if(is_object($node) && strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$tagValue = $node->getTagContent($newTagPath);
@@ -337,7 +337,7 @@ class XML_ extends Tree {
function hasBranch() {
$hasBranch = false;
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlbranch") {
if(is_object($node) && strtolower(get_class($node)) == "xmlbranch") {
$hasBranch = true;
break;
}
@@ -353,7 +353,7 @@ class XML_ extends Tree {
function hasLeaf() {
$hasLeaf = false;
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlleaf") {
if(is_object($node) && strtolower(get_class($node)) == "xmlleaf") {
$hasLeaf = true;
break;
}
@@ -407,7 +407,7 @@ class XML_ extends Tree {
*/
function removeAllBranches() {
foreach($this->nodes as $key => $value) {
if(strtolower(get_class($value)) == "xmlbranch")
if(is_object($value) && strtolower(get_class($value)) == "xmlbranch")
unset($this->nodes[$key]);
}
}
@@ -418,7 +418,7 @@ class XML_ extends Tree {
*/
function removeAllLeafs() {
foreach($this->nodes as $key => $value) {
if(strtolower(get_class($value)) == "xmlleaf")
if(is_object($value) && strtolower(get_class($value)) == "xmlleaf")
unset($this->nodes[$key]);
}
}
@@ -469,7 +469,7 @@ class XML_ extends Tree {
*/
function setBranchTag($branchId, $tag) {
$success = true;
if(strtolower(get_class($this->nodes[$branchId])) == "xmlbranch" && strtolower(get_class($tag)) == "tag")
if(is_object($this->nodes[$branchId]) && (strtolower(get_class($this->nodes[$branchId])) == "xmlbranch" && strtolower(get_class($tag)) == "tag"))
$this->nodes[$branchId]->setTag($tag);
else
$success = false;
@@ -484,7 +484,7 @@ class XML_ extends Tree {
*/
function setTag($tag) {
$success = true;
if(strtolower(get_class($tag)) == "tag")
if(is_object($tag) && strtolower(get_class($tag)) == "tag")
$this->tag = $tag;
else
$success = false;
@@ -513,7 +513,7 @@ class XML_ extends Tree {
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
$node =& $this->nodes[$arrKeys[$index]];
if(strtolower(get_class($node)) == "xmlbranch")
if(is_object($node) && strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$success = $node->setTagAttribute($attributeName, $attributeValue, $newTagPath);
@@ -553,7 +553,7 @@ class XML_ extends Tree {
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
$node =& $this->nodes[$arrKeys[$index]];
if(strtolower(get_class($node)) == "xmlbranch")
if(is_object($node) && strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$success = $node->setTagContent($content, $newTagPath);

View File

@@ -59,7 +59,7 @@ class XMLBranch extends XML_ {
*/
function setParentXML(&$xml) {
$success = false;
if(strtolower(get_class($xml)) == "xml" || strtolower(get_class($xml)) == "xmlbranch") {
if(is_object($xml) == "xml" && (strtolower(get_class($xml)) == "xml" || strtolower(get_class($xml)) == "xmlbranch")) {
$this->parentXML = &$xml;
$success = true;
}

View File

@@ -61,7 +61,7 @@ class XMLLeaf extends Leaf {
*/
function setParentXML(&$xml) {
$success = false;
if(strtolower(get_class($xml)) == "xml" || strtolower(get_class($xml)) == "xmlbranch") {
if((is_object($xml) == "xml" && strtolower(get_class($xml)) == "xml" || strtolower(get_class($xml)) == "xmlbranch")) {
$this->parentXML = &$xml;
$success = true;
}

View File

@@ -171,7 +171,7 @@ function MakeFontDescriptor($fm,$symbolic)
//StemV
if(isset($fm['StdVW']))
$stemv=$fm['StdVW'];
elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight']))
elseif(isset($fm['Weight']) and preg_match('/(bold|black)/',$fm['Weight']))
$stemv=120;
else
$stemv=70;
@@ -289,9 +289,9 @@ function CheckTTF($file)
}
/*******************************************************************************
* $fontfile : chemin du fichier TTF (ou cha<68>ne vide si pas d'incorporation) *
* $fontfile : chemin du fichier TTF (ou cha<68>ne vide si pas d'incorporation) *
* $afmfile : chemin du fichier AFM *
* $enc : encodage (ou cha<68>ne vide si la police est symbolique) *
* $enc : encodage (ou cha<68>ne vide si la police est symbolique) *
* $patch : patch optionnel pour l'encodage *
* $type : type de la police si $fontfile est vide *
*******************************************************************************/

View File

@@ -234,7 +234,7 @@ function MakeFontDescriptor($fm,$symbolic) {
//StemV
if (isset($fm['StdVW'])) {
$stemv=$fm['StdVW'];
} elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight'])) {
} elseif(isset($fm['Weight']) and preg_match('/(bold|black)/',$fm['Weight'])) {
$stemv=120;
} else {
$stemv=70;

View File

@@ -37,7 +37,7 @@ function &traverse_dom_tree_pdf(&$root) {
function dump_tree(&$box, $level) {
print(str_repeat(" ", $level));
print(get_class($box).":".$box->uid."\n");
print(is_object($box) && get_class($box).":".$box->uid."\n");
if (isset($box->content)) {
for ($i=0; $i<count($box->content); $i++) {

View File

@@ -249,7 +249,7 @@ class OS_Guess
{
if (strcspn($fragment, '*?') < strlen($fragment)) {
$reg = '^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '$';
return eregi($reg, $value);
return preg_match($reg, $value);
}
return ($fragment == '*' || !strcasecmp($fragment, $value));
}

View File

@@ -254,7 +254,7 @@ class PEAR_Registry extends PEAR
*/
function _lock($mode = LOCK_EX)
{
if (!eregi('Windows 9', php_uname())) {
if (!preg_match('/Windows 9/', php_uname())) {
if ($mode != LOCK_UN && is_resource($this->lock_fp)) {
// XXX does not check type of lock (LOCK_SH/LOCK_EX)
return true;

View File

@@ -1300,12 +1300,13 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
return $token;
}
// If it's a string (of maximum 255 characters)
elseif (ereg("^\"[^\"]{0,255}\"$",$token))
//elseif (ereg("^\"[^\"]{0,255}\"$",$token))
elseif (preg_match("/{0,255}/",$token))
{
return $token;
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "("))
elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]/",$token) and ($this->_lookahead == "("))
{
return $token;
}
@@ -1582,7 +1583,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
return $result;
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))
elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]/",$this->_current_token))
{
$result = $this->_func();
return $result;

View File

@@ -376,7 +376,7 @@ class XML_Parser extends PEAR
/**
* check, if file is a remote file
*/
if (eregi('^(http|ftp)://', substr($file, 0, 10))) {
if (preg_match('/(http|ftp):///', substr($file, 0, 10))) {
if (!ini_get('allow_url_fopen')) {
return $this->raiseError('Remote files cannot be parsed, as safe mode is enabled.', XML_PARSER_ERROR_REMOTE);
}
@@ -429,7 +429,7 @@ class XML_Parser extends PEAR
return true;
}
// see if it's an absolute URL (has a scheme at the beginning)
elseif (eregi('^[a-z]+://', substr($fp, 0, 10))) {
elseif (preg_match('/[a-z]+:///', substr($fp, 0, 10))) {
return $this->setInputFile($fp);
}
// see if it's a local file

View File

@@ -311,7 +311,7 @@ class soap_server extends nusoap_base {
// get the character encoding of the incoming request
if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -340,7 +340,7 @@ class soap_server extends nusoap_base {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
if (preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -374,7 +374,7 @@ class soap_server extends nusoap_base {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
if (preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -791,7 +791,7 @@ class soap_server extends nusoap_base {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';

View File

@@ -442,7 +442,7 @@ class soapclient extends nusoap_base {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';

View File

@@ -3340,7 +3340,7 @@ class soap_server_colosa extends nusoap_base_colosa {
// get the character encoding of the incoming request
if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3369,7 +3369,7 @@ class soap_server_colosa extends nusoap_base_colosa {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
if (preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3403,7 +3403,7 @@ class soap_server_colosa extends nusoap_base_colosa {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
if (preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3629,7 +3629,7 @@ class soap_server_colosa extends nusoap_base_colosa {
function serialize_return() {
$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
// if fault
if (isset($this->methodreturn) && (get_class($this->methodreturn) == 'soap_fault_colosa')) {
if (isset($this->methodreturn) && (is_object($this->methodreturn) && get_class($this->methodreturn) == 'soap_fault_colosa')) {
$this->debug('got a fault object from method');
$this->fault = $this->methodreturn;
return;
@@ -3820,7 +3820,7 @@ class soap_server_colosa extends nusoap_base_colosa {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -6832,7 +6832,7 @@ class soapclient_colosa extends nusoap_base_colosa {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';

View File

@@ -3343,7 +3343,7 @@ class soap_server extends nusoap_base {
// get the character encoding of the incoming request
if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3372,7 +3372,7 @@ class soap_server extends nusoap_base {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
if (preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3406,7 +3406,7 @@ class soap_server extends nusoap_base {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
if (preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3823,7 +3823,7 @@ class soap_server extends nusoap_base {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -6829,7 +6829,7 @@ class soapclient extends nusoap_base {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
if(preg_match('/(ISO-8859-1|US-ASCII|UTF-8)/',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';