I have a PHP page that does a couple of different things depending on what action is set to in the GET data. Depending, it is supposed to return some JSON, but instead of doing anything it is supposed to it returns the bottom half of the code document itself, starting in the middle of the line. Heres the snippit from where it starts:
...
} elseif ($_GET['action'] == 'addtop') {
if (!isset($_GET['pname']) || !isset($_GET['url']) || !isset($_GET['artist']) || !isset($_GET['album']) || !isset($_GET['file'])) {
die('Error: Incomplete data!');
}
if (!file_exists($_GET['pname'].".txt")) {
die('Error: No such playlist!');
}
$plist = json_decode(file_get_contents($_GET['pname'].".txt"), true);
$fh = fopen($_GET['pname'].".txt", 'w') or die('Could not open playlist!');
array_push($plist, array("artist" => $_GET['artist'], "album" => $_GET['album'], "file" => $_GET['file'], "url" => $_GET['url']));
fwrite($fh,json_encode($plist));
} elseif ($_GET['action'] == 'delfromp') {
...
And here is what I get when I go to the page:
$_GET['artist'], "album" =
$_GET['album'], "file" =
$_GET['file'], "url" =
$_GET['url']));
fwrite($fh,json_encode($plist)); }
elseif ($_GET['action'] == 'delfromp')
{ if (!isset($_GET['pname']) ||
!isset($_GET['id'])) { die('Error:
Incomplete data!'); } if
(!file_exists($_GET['pname'].".txt"))
{ die('Error: No such playlist!'); }
$plist =
json_decode(file_get_contents($_GET['pname'].".txt"),
true); $fh =
fopen($_GET['pname'].".txt", 'w') or
die('Could not open playlist!');
unset($plist[$_GET['id']]); $plist =
array_values($plist);
fwrite($fh,json_encode($plist)); }
elseif ($_GET['action'] == 'readp') {
if
(!file_exists($_GET['pname'].".txt"))
{ die('Error: No such playlist!'); }
$plist =
json_decode(file_get_contents($_GET['pname'].".txt"),
true); $arr = array("entries" =
$plist); $json = json_encode($arr);
echo $json; } elseif ($_GET['action']
== 'getps') { $plists = array(); if ($handle = opendir('Playlists')) {
while (false !== ($playlist =
readdir($handle))) { if ($playlist !=
"." && $playlist != "..") {
array_push($plists, substr($playlist,
0, strripos($playlist, '.')-1)); } } }
else { die('Error: Can\'T open
playlists!'); } $arr =
array("entries"=$plists); $json =
json_encode($arr); echo $json; } else
{ die('Error: No such action!'); } ?
It starts in the middle of the array_push(... line.
I really can't think of what it is doing. Theres no echos anywhere around it. Any ideas?