Viewing file: delete_radio.php (1.17 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?PHP
$un = $_COOKIE['user'];
if(strlen($un)==0)
{
header("Location: index.php");
exit();
}
$whichTo = 2 + $_POST['whichToDelete'];
//start hte reading process,
//go down the line adding to a new array list each item
//if it has a "<" sign in it count+1
//if count = whichTo number
//skip it
//add every other array
//send it all to a strink
$count = 0;
//$tempArray[];
if($myFile = fopen("playlist.xml","r"))
{
$myFile = file("playlist.xml");
$length = sizeof($myFile);
for($i=0;$i<($length);$i++)
{
$myString = " " . $myFile[$i];
$tester="<mp3";
$pos = strpos($myString,$tester);
if($pos !== false)
{
$count++;
if($count != $whichTo)
{
$tempArray[] = $myFile[$i];
}
else //if it has writing after the line ---- delete that too
{
//make sure it get everthing after it
}
}
else
{
$tempArray[] = $myFile[$i];
}
}
}
//print($finalString);
if($myFile = fopen("playlist.xml","w"))//this time write the file
{
for($i=0;$i<($length);$i++)
{
$finalString .= $tempArray[$i];
}
fwrite($myFile,$finalString);
$sentOk = true;
echo "sentOk=" . $sentOk;
}
?>
|