fixed empty files array?

This commit is contained in:
Kasper Rynning-Tønnesen
2014-10-10 14:05:38 +02:00
parent 7198fa08b5
commit 9bb907ef54

View File

@@ -12,9 +12,9 @@ $list = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
if($list[1]==""||!isset($list[1])||count($list)<=1)$list="videos";
else $list=$list[1];
$list="lists/".$list.".json";
$array = array("nowPlaying" => array(), "songs" => array(), "conf" => array("startTime" => time(), "views" => 0, "skips" => array()));
$f = @fopen($list,"x");
if($f){ fwrite($f,"[[],[".time()."],[],[],[],[]]"); fclose($f); }
if($f){ fwrite($f,$array); fclose($f); }
$file = file_get_contents($list);
$data = json_decode($file, TRUE);
$songs = $data["songs"];