Avatar billede doomstone-dk- Nybegynder
19. april 2003 - 21:45 Der er 1 kommentar og
1 løsning

php program

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";

?>
Avatar billede doomstone-dk- Nybegynder
19. april 2003 - 21:46 #1
hehe glemte af forkalre mit problem!
det er at den ikke flytter sangne som den skal

$song5=$song4;
    $song4=$song3;
    $song3=$song2;
    $song1=$song; 

nej $song2-5 forbliver den samme mens $song1 bliver opdateret!
Avatar billede doomstone-dk- Nybegynder
19. april 2003 - 22:02 #2
Har selv fundet fejlen
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester