Added sorting on creation/modification time

This commit is contained in:
Kasper Rynning-Tønnesen
2015-02-12 17:01:02 +01:00
parent 948bfbe211
commit 9785539e27

View File

@@ -11,19 +11,24 @@ $all_channels = array();
$time = 60*60*24*4; //4 dager $time = 60*60*24*4; //4 dager
$to = 60*60*24*2; $to = 60*60*24*2;
$i = 0; $i = 0;
foreach($dir as $files){
$dir = "./lists";
chdir($dir);
array_multisort(array_map('filemtime', ($fil = glob("*.json"))), SORT_DESC, $fil);
foreach($fil as $files){
if(strpos($files, '.json') !== FALSE){ if(strpos($files, '.json') !== FALSE){
$time_lasted = time() - filemtime('./lists/'.$files); $time_lasted = time() - filemtime($files);
if($time_lasted > $to) if($time_lasted > $to)
{ {
$file = file_get_contents('./lists/'.$files); $file = file_get_contents($files);
$data = json_decode($file, TRUE); $data = json_decode($file, TRUE);
$q = array_values($data["nowPlaying"]); $q = array_values($data["nowPlaying"]);
if($q[0]["id"] == "30H2Z8Lr-4c"); if($q[0]["id"] == "30H2Z8Lr-4c");
unlink("./lists/".$files); unlink("./lists/".$files);
} }
if($time_lasted < $time){ if($time_lasted < $time){
$file = file_get_contents('./lists/'.$files); //Checking if the channel has the setting for showing on the frontpage set to true. $file = file_get_contents($files); //Checking if the channel has the setting for showing on the frontpage set to true.
$data = json_decode($file, TRUE); $data = json_decode($file, TRUE);
if(!array_key_exists("frontpage", $data['conf']) || $data['conf']['frontpage'] == "true"){ //If it is true, the channelname will be shown on the frontpage if(!array_key_exists("frontpage", $data['conf']) || $data['conf']['frontpage'] == "true"){ //If it is true, the channelname will be shown on the frontpage
array_push($channels, ucfirst(str_replace(".json", "", $files))); array_push($channels, ucfirst(str_replace(".json", "", $files)));
@@ -41,7 +46,7 @@ foreach($dir as $files){
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://ogp.me/ns/fb#"> xmlns:fb="http://ogp.me/ns/fb#">
<head> <head>
<?php include("php/header.php"); ?> <?php include("header.php"); ?>
</head> </head>
<body> <body>
<div class="bgimage" id="bgimage"></div> <div class="bgimage" id="bgimage"></div>