Some php problems after update to 5.3

BLTYNR

Verified User
Joined
May 9, 2008
Messages
15
Location
Netherlands
I have updated my php version to PHP 5.3.10 (cli)
I have a php script i get some problems after update php, i have fixed some problems like Deprecated features in PHP 5.3.x
But i cant fix this error.
Can anybody help me please?

This is the error:
Code:
Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /home/xxx/domains/xxx.com/public_html/radyo/gosterge/kaynak.php on line 81

This is the whole script php:

PHP:
<?php

/* MusicTicker - XML version 1.4.2                           */
/* MAD props to Tom Pepper and Tag Loomis for all their help */
/* --------------------------------------------------------- */
/* SCXML object version 0.4.2                                */
/* December 01 2004 01:05 EST                                */

error_reporting (E_ALL ^ E_NOTICE);

class SCXML {

  var $host="ip"; // host or ip of shoutcast server
  var $port="port"; // port of shoutcast server
  var $password="password"; // password for shoutcast server

/* DO NOT CHANGE ANYTHING FROM THIS POINT ON - THIS MEANS YOU !!! */

  var $depth = 0;
  var $lastelem= array();
  var $xmlelem = array();
  var $xmldata = array();
  var $stackloc = 0;

  var $parser;

  function set_host($host) {
    $this->host=$host;
  }

  function set_port($port) {
    $this->port=$port;
  }

  function set_password($password) {
    $this->password=$password;
  }

  function startElement($parser, $name, $attrs) {
    $this->stackloc++;
    $this->lastelem[$this->stackloc]=$name;
    $this->depth++;
  }

  function endElement($parser, $name) {
    unset($this->lastelem[$this->stackloc]);
    $this->stackloc--;
  }

  function characterData($parser, $data) {
    $data=trim($data);
    if ($data) {
      $this->xmlelem[$this->depth]=$this->lastelem[$this->stackloc];
      $this->xmldata[$this->depth].=$data;
    }
  }

  function retrieveXML() {
    $rval=1;

    $sp=@fsockopen($this->host,$this->port,&$errno,&$errstr,10);
    if (!$sp) $rval=0;
    else {

      stream_set_blocking($sp,false);

      // request xml data from sc server

      fputs($sp,"GET /admin.cgi?pass=$this->password&mode=viewxml HTTP/1.1\nUser-Agent:Mozilla\n\n");

      // if request takes > 15s then exit

      for($i=0; $i<30; $i++) {
    if(feof($sp)) break; // exit if connection broken
    $sp_data.=fread($sp,31337);
    usleep(500000);
      }

      // strip useless data so all we have is raw sc server XML data

      $sp_data=preg_match("^.*<!DOCTYPE","<!DOCTYPE",$sp_data);

      // plain xml parser

      $this->parser = xml_parser_create();
      xml_set_object($this->parser,&$this);
      xml_set_element_handler($this->parser, "startElement", "endElement");
      xml_set_character_data_handler($this->parser, "characterData");

      if (!xml_parse($this->parser, $sp_data, 1)) {
    $rval=-1;
      }

      xml_parser_free($this->parser);

    }
    return $rval;
  }

  function debugDump(){
    reset($this->xmlelem);
    while (list($key,$val) = each($this->xmlelem)) {
      echo "$key. $val -> ".$this->xmldata[$key]."\n";
    }

  }

  function fetchMatchingArray($tag){
    reset($this->xmlelem);
    $rval = array();
    while (list($key,$val) = each($this->xmlelem)) {
      if ($val==$tag) $rval[]=$this->xmldata[$key];
    }
    return $rval;
  }

  function fetchMatchingTag($tag){
    reset($this->xmlelem);
    $rval = "";
    while (list($key,$val) = each($this->xmlelem)) {
      if ($val==$tag) $rval=$this->xmldata[$key];
    }
    return $rval;
  }

}

?>
 
Looking at whats going on in the script, you probably need preg_replace instead of match. Also the fix for ereg functions to preg functions is usally just adding / / at start and end. The correct line in this case is this:

PHP:
$sp_data=preg_replace("/^.*<!DOCTYPE/","<!DOCTYPE",$sp_data);
 
Back
Top