Tags:
php
Jeg har et problem met et program jeg har lavet!
Den finder hvilken sang en server spille!
det vriker fint bare ikke den nye function jeg har lavet som skal genne de sidste 5 sage!
<------
Det er bunder af scriptet! $song1-5
------>
<?
global $songs;
$song1="none";
$song2="none";
$song3="none";
$song4="none";
$song5="none";
include "setup.ini";
function splicedata($sourcefile, $start, $end)
{
error_reporting(0);
$temp=split($start, $sourcefile);
$temp=split($end, $temp[1]);
error_reporting(1);
return $temp[0];
}
function splicemultidata($sourcefile, $start, $end)
{
error_reporting(0);
$targetdata = array();
$sourcedata = split($start, $sourcefile);
foreach ($sourcedata as $indsplit)
{
$target = split($end, $indsplit);
$targetdata[] = $target[0];
}
error_reporting(1);
return $targetdata;
}
echo "This scrip is maid by DoomEngineer\\n\\n";
set_time_limit(0);
while (1) {
$fp = implode('',file("http://www.gridstream.com/gsp_playing.asp"));
if (!$fp) {
echo "Cannot connect to server\\n";
}
else {
$webside = $fp; // reading anser
$data = splicemultidata($webside, "<b class=\\"gridlink\\">", "</b>");
$song=$data[1];
$station=$data[2];
$text="/text GridStream is playing \\"".$song."\\" at the station (".$station.")";
if(!$file){
$file="gridstream";
}
IF(file_exists($file)){
unlink($file);
}
touch($file);
$fil = fopen($file, "w");
fwrite($fil, $text);
fclose($fil);
echo "Conneced, and file is created as \\"".$file."\\" and the file wil be updated in ".$sek." sek\\n";
#if($song != $songs[1] && $last5=="yes"){
$song5=$song4;
$song4=$song3;
$song3=$song2;
$song1=$song;
echo "\\n".$song1;
echo "\\n".$song2;
echo "\\n".$song3;
echo "\\n".$song4;
echo "\\n".$song5;
$text="";
IF($songs[5])$text.="/text #5: ".$songs[5]."\\n";
IF($songs[4])$text.="/text #4: ".$songs[4]."\\n";
IF($songs[3])$text.="/text #3: ".$songs[3]."\\n";
IF($songs[2])$text.="/text #2: ".$songs[2]."\\n";
$text.="/text Right Now: ".$songs[1]."\\n";
$file5=$file."5";
IF(file_exists($file5)){
unlink($file5);
}
touch($file5);
$fil = fopen($file5, "w");
fwrite($fil, $text);
fclose($fil);
#}
}
flush();
sleep($sek); // the sleep function
} // loop end
?>
Hvis i manger nogle af variablerne er det fordi de er i setup.ini
<------- Setup.ini -------->
<?
#This is the name of the script.
#If it is "gridstream" then the script will run in AO by typing "/gridstream" (REMEMBER NO SPACES).
$file="gridstream";
#You must specify the time between automatic updates. I recommende a default of 60 secs.
#WARNING: if you set this parameter too low then it will take too much CPU power!
#This will only happen is you set it to less than 15 sek.
$sek="10";
#set it to "yes" if you want the script to make a last 5 list.
#if it is yes will the script make 2 files, the name of the last 5 songs script will
#be "(the name you have given the normal script)5", if you use the standart will it be "/gridstream5"
$last5="yes";
?>
----------------------
DoomStone@DoomStone.dk
2 svar postet i denne tråd vises herunder
0 indlæg har modtaget i alt 0 karma
0
har selv funder fejlen[Redigeret d. 19/04-03 22:00:40 af Kasper Søgaard]
0
Den 19-04-03 21:57 skrev Kasper Søgaard følgende:
-----------------------------------------------------------------------------
har selv funder fejlen[Redigeret d. 19/04-03 22:00:40 af Kasper Søgaard]
-----------------------------------------------------------------------------
----------------------
DoomStone@DoomStone.dk