Jump to content

PHP Deprecated: Function ereg_replace() is deprecated in


rastaman46

Recommended Posts

How to solve this error out

 

PHP Deprecated: Function ereg_replace() is deprecated in

 

using this code

 

$shoutcast_on_off ='';
$scsuccs = '';
$listenlink = ''.$scdef.'';
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
  $scsuccs=1;
}
$page = '';
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
  $page .= fgets($scfp, 1000);
}
$loop = array("STREAMSTATUS");
$y=0;
while($loop[$y]!=''){
  $pageed = ereg_replace(".*<$loop[$y]>", "", $page);
  $scphp = strtolower($loop[$y]);
  $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
  $y++;
}
fclose($scfp);
}
$online1 = '';
if ($streamstatus == "1") {
$online1 = '<center><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/DJ.png" border="0" height="150"></center><br>
	<center><a href="'.$BASEURL.':'.$scport.'/listen.pls"><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/klausom.png" width="150px" height="auto"></a></center>';
}
else
{
$online2 = '';
$online2 = '<center><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/off.png" border="0" height="150"></center>';
}

// BEGIN Plugin: shoutcast_on_off
$shoutcast_on_off = $online1.$online2;
// END Plugin: shoutcast_on_off

eval("\$shoutcast = \"".$TSUE['TSUE_Template']->LoadTemplate('shoutcast')."\";");
return $shoutcast;

Link to comment
Share on other sites

Correct, the function is deprecated -- which means that the PHP team has decided to remove it entirely from the language in the future.  For now, this is only a warning, and you can turn down the errorlevel to not display or log warnings.  You could also find a corresponding preg_ function and recode to it if you want to correct the problem going forward.

Link to comment
Share on other sites

The regex for the preg_* functions requires a delimitter character around the regex.  Most people start with '/'.  So for example, from the code, the first replacement would be:

 

 

$pageed = preg_replace("/.*/", "", $page);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.