Files
zoff/save.php
Kasper Rynning-Tønnesen 31dbbf01e3 g
2014-08-08 18:25:55 +02:00

30 lines
556 B
PHP

<script>
console.log("utenfor if")
</script>
<?php
if(isset($_POST['thisUrl']))
{
$string = $_POST['thisUrl'];
$file = file_get_contents('videos.json');
$data = json_decode($file);
unset($file);//prevent memory leaks for large json.
//insert data here
?>
<script>
console.log("in save.php");
</script><?php
if($data[0] == $string)
{
array_push($data, $string);
array_shift($data);
}
file_put_contents("videos.json", json_encode($data));
echo $data;
unset($data);
}else
{
echo "You're a bad boy";
}
die();
?>