Forum Clubic

Php shoutcast

Salut voila j ai trouver sur le net un script pour voter pour la chanson en cours sur une webradio .
J ai tester le code et j ai une erreur ligne 12 , je pense que c est au niveau de ( $port = "ici le port; )

l’erreur afficher sur mon navigateur et : Parse error: parse error, unexpected T_STRING in ligne 12

Je met le code ci-dessous , ci quelqu un peut m aider se serait super !

<?php
// simple.php - shoutcast 7.html information display utility
// version 0.1.5
// To use this script, save this page save simple.php then edit the information below as noted, uncomment what you need
// To imbed the information on your php site use the include function on the page you wish to display the information
// Edit the next two lines with your server information
$host = "IP DE LA WEBRADIO";
$port = "ICI LE PORT;
// Connect to server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
 if (!$fp) {
    echo "Erreur";
  } else {
// Get data from server
 fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");
// exit if connection broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
 }
// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);
// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);
$trackpattern = "/^[0-9][0-9] /";
$trackreplace = "";
$song = preg_replace($trackpattern, $trackreplace, $song);
if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE
// echo "<html>\n<head>\n<title></title>\n</head>\n<body>\nCurrent Listeners: $current<br>\nServer Status: $status<br>\nListener Peak: $peak<br>\nMaximum Listener: $max<br>\nReported Listeners: $reported<br>\nBroadcast Bitrate: $bit<br>\nCurrent Song: $song\n</body>\n</html>";
// Below is a basic one line value of the current song, perfect for front pages of sites
    } else {
 } }
// the questions and the answers
$pool_question="";
$pool_option[1]="Pour";
$pool_option[2]="Contre";
// If counter files are not available,they will be created
// You may remove next lines after the first use of the script
        if (!file_exists($song.'b.txt')){
                // next two lines will not work if writing permissions are not available
                // you may create the files bellow manualy with "0" as their unique content
                file_put_contents ($song.'b.txt',0);
                file_put_contents ($song.'m.txt',0);
        }
// retrieve data saved in files
        $pool_responses[1]=file_get_contents($song.'b.txt');
        $pool_responses[2]=file_get_contents($song.'m.txt');
// if user votes, increase corresponding value
        if ($_POST["7680777"] and $_POST["7680777b"]==""){
                if ($_POST["7680777"]==1) {$pool_responses[1]++;file_put_contents($song.'b.txt',$pool_responses[1]);}
                if ($_POST["7680777"]==2) {$pool_responses[2]++;file_put_contents($song.'m.txt',$pool_responses[2]);}
        }
// get percentajes for each answer in the pool
        // get total number of answers
        $total_responses=$pool_responses[1]+$pool_responses[2];
        if ($total_responses==0){$total_responses=1;}  // to avoid errors at start
        // compute percentajes (with one decimal number)
        $pool_percentaje[1] = round((100*$pool_responses[1])/$total_responses,1);
        $pool_percentaje[2] = round((100*$pool_responses[2])/$total_responses,1);
                                                                
// print the form, which includes de answers and the percentajes
print "<left>\n";
print "<form method=post action=".$_SERVER["PHP_SELF"].">\n";
// print "<b>".$pool_question."</b>\n";
print "<center><table cellpadding=4>\n";
// answer 1
print "<tr>\n";
print "<td><input bgcolor=B70702 type=radio name=7680777 value=1>  ".$pool_option[1]."</td>\n";
print "<td bgcolor=B70702>".$pool_responses[1]." (".$pool_percentaje[1]."%)</td>\n";
print "</tr>\n";
// answer 2
print "<tr>\n";
print "<td><input bgcolor=B70702 type=radio name=7680777 value=2>  ".$pool_option[2]."</td>\n";
print "<td bgcolor=B70702>".$pool_responses[2]." (".$pool_percentaje[2]."%)</td>\n";
print "</tr>\n";
print "</table>\n";
// a simple control to avoid one user to vote several times
if ($_POST["7680777"]){
        print "<input type=hidden name=7680777b value=1>\n";
}
print "</left><center><input TYPE=submit value=Add>\n";
print "</form>\n";
print "</center>\n";
?>

$host = “IP DE LA WEBRADIO”;
$port = "ICI LE PORT;

Il manque un " :
$host = “IP DE LA WEBRADIO”;
$port = “ICI LE PORT”;

Oui sa c regler , arf il m enerve se script mais j en ai vraiment besoin …

1er probleme regler , maintenant j ai sa el ligne 47 :

Fatal error: Call to undefined function: file_put_contents() in

??

Je crois qu’il s’agit d’une fonction PHP5.
Si tu as une version inférieure, il faut utiliser fopen, fwrite et fclose :
fr3.php.net…

Je viens réagir :wink:

Alors s’il faut utiliser fopen etc…

ou faut-il modifier?

Merci