|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
VOTE POUR SHOUTCAST
Information sur la source
Description
// CODE "OUTDATED" \\|// Nouvelle version avec MYSQL beaucoup plus performante bientôt disponible. \\ Voici un script que j'ai fais. J'ai utilisé deux scripts pour le faire. Un script de vote et un script pour récupérer les informations d'un serveur shoutcast. Le script fais deux boutons exemple : Pour - Contre Puis le script regarde le titre de la pièce jouant sur votre webradio. Si c'est la première fois que une personne vote pour cette musique le script crée un fichier .txt avec ce nom : Nom de la chanson - Artiste b.txt Nom de la chanson - Artiste m.txt Si le vote est positif il change le nombre (+1) étant dans le fichier Nom de la chanson - Artiste b.txt Et si c'est négatif : il change le nombre (+1) étant dans le fichier Nom de la chanson - Artiste m.txt Puis l'affiche sur votre page. Rien n'empêche de faire un include.
Source
- <?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 = "votre ip";
- $port = "votre 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";
-
- ?>
<?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 = "votre ip";
$port = "votre 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";
?>
Conclusion
Bientôt une version SQL. Alors c'est mon premier bon code ^^ (je crois). Demo ici (si le serveur est en ligne) : http://www.rocksplash.com/ Ps : Désolé si il y a des fautes (j'essayerais de les corrigés).
Historique
- 17 mai 2007 18:39:24 :
- Correction d'un problème avec les fichiers txt.
- 28 août 2007 20:29:42 :
- Simple modification pour dire que ce code est "Outdated".
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Vote pour titre classement radio [ par radyonne ]
Bonjour,Je voudrais savoir comment faire un vote pour le site web de ma radio avec mon system de titrage et d'affichage de pochettes cd, pour faire vo
Systeme de vote pour radio ! [ par radyonne ]
Bonjour,je voudrais savoir si quelqu'un saurait faire un system de vote pour le site web de ma radio, un system de vote comme celui de radiowave "top
PB dans WINAMP avec shoutcast [ par letardiswebradio ]
Je viens de mettre Online une webradio généraliste nommée LETARDIS WEBRADIO sur letardis.eu La Music Top Pop Rock Des Années 60 à Nos Jours.Je renc
ajout de point apres un clic [ par olvean ]
Bonjour a tous alor voila je m'explique je voudrais donner des point au membre apres un clic sur un topla page pour les vote :<?phpsession_start();
recuperer un input de type radio dans ajax [ par moumourourou ]
Salut,j'ai un formulaire ou j'ai 2input radioje veux récupérer le input choisis pour faire une requête de sélection d'une base de donnéedonc si vous v
Rendre un champ obligatoire si 1 bouton radio coché [ par Frystie01 ]
Bonjour tout le monde,j'ai 2 boutons radio dans un document html et en dessous un champ à remplir que j'aimerais rendre obligatoire seulement si le 2e
1formulaire sur 2 pages .....? [ par caliche ]
Bonjour, je voudrait créer un mini-formulaire sur ma page d'accueil et que lorsqu'on clic sur "envoyer" cela redirige vers une autre page où se termin
Création de site de vote [ par casimodoo ]
Bonjour,Mon projet est la création un site web qui a pour but de classifier les différents endroits de ma ville (café, restaurant, théâtre, lieux pub
les boutons radio de html [ par lotfi213_b19 ]
bonsoir, priere de me dire ou m'indiquer comment arranger les boutons radio horizontalement,pour qu'ils soient sur la meme ligne j'ai utilisé style="f
Prise en compte d'un cookie et rafraichissement fenêtre [ par joel64 ]
bonjour,merci à celui ou celle qui me donnera la solution au problème suivant.il s'agit d'un script php de sondage qui affiche la possibilité de vote
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version

HTC Touch HD
Entre 25€ et 605€
|