Hello everyone i have code with ereg_replace but ereg it's deprecated and i don't know how to replace with preg_replace i tryed:
$pageed = ereg_replace(".<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.", "", $pageed);
$pageed = preg_replace("/.<SONGHISTORY>", "", $page);
$pageed = preg_replace("<SONGHISTORY>./", "", $pageed);
But i've got a lot of errors.
Could anybody help me and fixing my whole script or just show me how to.
The script:
<?php
require_once "maincore.php";
require_once THEMES."templates/header.php";
$scdef = "Grojarascio nera"; // Kai serveris isjungtas rodo
$scip = "**"; // shoutcast serverio IP be porto
$scport = "***"; // shoutcast serverio portas
$scpass = "****"; // shoutcast serverio pasvordas
$maxusers = "50"; //Kiek vienu sykiu klausosi zmoniu
//End configuration
$scsuccs = NULL;
$page = NULL;
$scfp = fsockopen($scip, $scport, $errno, $errstr, 01);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' ';
}
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);
}
#############Pagamino Dj_Dede, www.upofm.wu.lt##...
#####################konfiguracija 01#####################
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "AIM");
$y=0;
while (isset($loop[$y])) {
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if (($loop[$y] == "SERVERGENRE") || ($loop[$y] == "SERVERTITLE") || ($loop[$y] == "SONGTITLE") || ($loop[$y] == "SERVERTITLE") || ($loop[$y] == "AIM"))
$$scphp = urldecode($$scphp);
// echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
#####################///konfiguracija 02#####################
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while (isset($songatime[$r])) {
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
$Grojo = str_replace('_',' ',substr ($song[0],0,200));
$Grojo2 = str_replace('_',' ',substr ($song[1],0,200));
$Grojo3 = str_replace('_',' ',substr ($song[2],0,200));
$Grojo4 = str_replace('_',' ',substr ($song[3],0,200));
$Grojo5 = str_replace('_',' ',substr ($song[4],0,200));
$Grojo6 = str_replace('_',' ',substr ($song[5],0,200));
$Grojo7 = str_replace('_',' ',substr ($song[6],0,200));
$Grojo8 = str_replace('_',' ',substr ($song[7],0,200));
$Grojo9 = str_replace('_',' ',substr ($song[8],0,200));
$Grojo10 = str_replace('_',' ',substr ($song[9],0,200));
$laikas = showdate("%H:%M:%S", $playedat[0]);
$laikas2 = showdate("%H:%M:%S", $playedat[1]);
$laikas3 = showdate("%H:%M:%S", $playedat[2]);
$laikas4 = showdate("%H:%M:%S", $playedat[3]);
$laikas5 = showdate("%H:%M:%S", $playedat[4]);
$laikas6 = showdate("%H:%M:%S", $playedat[5]);
$laikas7 = showdate("%H:%M:%S", $playedat[6]);
$laikas8 = showdate("%H:%M:%S", $playedat[7]);
$laikas9 = showdate("%H:%M:%S", $playedat[8]);
$laikas10 = showdate("%H:%M:%S", $playedat[9]);
$y = '<a href="http://www.youtube.com/results?search_query='.$Grojo.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y2 = '<a href="http://www.youtube.com/results?search_query='.$Grojo2.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y3 = '<a href="http://www.youtube.com/results?search_query='.$Grojo3.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y4 = '<a href="http://www.youtube.com/results?search_query='.$Grojo4.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y5 = '<a href="http://www.youtube.com/results?search_query='.$Grojo5.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y6 = '<a href="http://www.youtube.com/results?search_query='.$Grojo6.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y7 = '<a href="http://www.youtube.com/results?search_query='.$Grojo7.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y8 = '<a href="http://www.youtube.com/results?search_query='.$Grojo8.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y9 = '<a href="http://www.youtube.com/results?search_query='.$Grojo9.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
$y10 = '<a href="http://www.youtube.com/results?search_query='.$Grojo10.'" target="_blank"> <img src="http://s.ytimg.com/yt/favicon-vflZlzSbU.ico"></a>';
//end song info
fclose($scfp);
}
#####################//Muzikos rikevimas#####################
if($streamstatus == "1"){
$_SESSION['songtitle'] = $song;
opentable("Grojaraštis");
echo'<div align="left">
<table cellpadding="0" cellspacing="0" width="1">
<!-- MSTa*aš*ype="nolayout" -->
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>1. </b> <i>'.$laikas.'</i> '.$y.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>2. </b> <i>'.$laikas2.'</i> '.$y2.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo2.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>3. </b> <i>'.$laikas3.'</i> '.$y3.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo3.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>4. </b> <i>'.$laikas4.'</i> '.$y4.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo4.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>5. </b> <i>'.$laikas5.'</i> '.$y5.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo5.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>6. </b> <i>'.$laikas6.'</i> '.$y6.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo6.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>7. </b> <i>'.$laikas7.'</i> '.$y7.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo7.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>8. </b> <i>'.$laikas8.'</i> '.$y8.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo8.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>9. </b> <i>'.$laikas9.'</i> '.$y9.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo9.'</font></td>
<br>
<font face="Tahoma" style="font-size: 8pt" color="#3E1710"><b>10. </b> <i>'.$laikas10.'</i> '.$y10.' - </font>
<font face="Tahoma" style="font-size: 8pt" color="#000000">'.$Grojo10.'</font></td>
</table>';
closetable();
}
require_once THEMES."templates/footer.php";
?>