302 lines
10 KiB
PHP
Executable File
302 lines
10 KiB
PHP
Executable File
<?php
|
|
include('config.inc.php');
|
|
|
|
$datei = basename(__FILE__);
|
|
|
|
|
|
$mode = isset($_GET['mode']) ? $_GET['mode'] : 'motion';
|
|
if($mode!="motion" and $mode!="live") $mode="motion";
|
|
|
|
|
|
if( isset($_GET['n']) ){
|
|
if (in_array($_GET['n'], $inc_array_n)) $n = $_GET['n'];
|
|
else $n = reset($inc_array_n);
|
|
}else{
|
|
$n = reset($inc_array_n);
|
|
}
|
|
if( isset($_GET['m']) ){
|
|
if (in_array($_GET['m'], $inc_array_m)) $m = $_GET['m'];
|
|
else $m = reset($inc_array_m);
|
|
}else{
|
|
$m = reset($inc_array_m);
|
|
}
|
|
|
|
|
|
$heute = date("Y-m-d");
|
|
$gestern = date("Y-m-d",strtotime("-1 days"));
|
|
$vorgestern = date("Y-m-d",strtotime("-2 days"));
|
|
$vorvorgestern = date("Y-m-d",strtotime("-3 days"));
|
|
|
|
|
|
if($mode=="motion") $seiten_refresh=$inc_index_letztes_refresh;
|
|
if($mode=="live") $seiten_refresh=$inc_index_aktuell_refresh;
|
|
|
|
|
|
if($mode=="live"){
|
|
$boldl1="<b>";
|
|
$boldl2="</b>";
|
|
$boldm1="";
|
|
$boldm2="";
|
|
}elseif($mode=="motion"){
|
|
$boldl1="";
|
|
$boldl2="";
|
|
$boldm1="<b>";
|
|
$boldm2="</b>";
|
|
}else{
|
|
$boldl1="";
|
|
$boldl2="";
|
|
$boldm1="<b>";
|
|
$boldm2="</b>";
|
|
}
|
|
|
|
|
|
#phpinfo();
|
|
echo "<!DOCTYPE HTML>\n";
|
|
echo "<html>\n";
|
|
echo "<head>\n";
|
|
echo "<title>".htmlentities($inc_label_titel, ENT_QUOTES)."</title>\n";
|
|
echo "<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">\n";
|
|
echo "<meta http-equiv=\"refresh\" content=\"$seiten_refresh\">\n";
|
|
#echo "<style type=\"text/css\">\n";
|
|
#echo "td { font-family: sans-serif; font-size: 16px; }\n";
|
|
#echo "table { background-color:#FFFFFF;border-collapse:collapse;border:2px solid #000000;color:#000000; }\n";
|
|
#echo "</style>\n";
|
|
echo "</head>\n";
|
|
echo "<body>\n";
|
|
#echo "<div style=\"margin-left: 3%;margin-right: 3%;\">\n";
|
|
|
|
# outer Geruest
|
|
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
|
|
echo "<tr>\n";
|
|
echo "<td>\n";
|
|
|
|
# Kopf
|
|
echo "<header>\n";
|
|
echo "<div id=\"divheader\">\n";
|
|
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
|
echo "<tr>";
|
|
echo "<td>";
|
|
echo "<span id=\"spanheader\">".htmlentities($inc_label_kopf, ENT_QUOTES)."</span>\n";
|
|
echo " ( ";
|
|
echo "<a id=\"abtnlm\" href=\"$datei?mode=live\">".$boldl1."live($inc_index_aktuell_refresh)".$boldl2."</a>";
|
|
echo " / ";
|
|
echo "<a id=\"abtnlm\" href=\"$datei?mode=motion\">".$boldm1."motion($inc_index_letztes_refresh)".$boldm2."</a>";
|
|
echo " )";
|
|
echo "</td>";
|
|
echo "<td align=\"right\">";
|
|
echo "<img src=\"./$inc_logo\" width=\"$inc_logo_breite\">";
|
|
echo "</td>";
|
|
echo "</tr>\n";
|
|
echo "</table>\n";
|
|
echo "</div>\n";
|
|
echo "</header>\n";
|
|
|
|
|
|
# inner Geruest
|
|
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"100%\">\n";
|
|
echo "<tr>\n";
|
|
echo "<td>\n";
|
|
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"10\">\n";
|
|
#echo "<table border=\"0\" id=\"tableinner2\" width=\"100%\">\n";
|
|
#echo "<tr>\n";
|
|
#echo "<td>\n";
|
|
|
|
|
|
$array_hauptordner = scandir_folders_yyyymmdd($inc_pfad_www);
|
|
#print_r($array_hauptordner);
|
|
|
|
# keine unsinnigen Werte für Cams pro zeile
|
|
if( $inc_index_cam_pro_zeile > 0 ) $max_cam_pro_zeile=$inc_index_cam_pro_zeile;
|
|
else $max_cam_pro_zeile=2;
|
|
|
|
$l=0;
|
|
$c=0;
|
|
|
|
#Cam Name und Buttons
|
|
#echo "<tr>\n";
|
|
foreach($inc_cams AS $cam)
|
|
{
|
|
if( $c == $max_cam_pro_zeile ) $c=0;
|
|
if( $c == 0 ) echo "<tr>\n";
|
|
|
|
#echo "$cam $c $l $max_cam_pro_zeile<br>";
|
|
|
|
if( $inc_cams_label[$l] != "" ) $cam_label=$inc_cams_label[$l];
|
|
else $cam_label=$cam;
|
|
|
|
$camampelfarbe=camampel($inc_pfad_www.$heute."/".$cam."/",$inc_cam_ampel);
|
|
#echo $camampelfarbe;
|
|
echo "<td id=tdtop>\n";
|
|
#echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n";
|
|
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">\n";
|
|
|
|
# CamX 40 Bilder 20 min heute 80 Bilder 60 min gestern
|
|
echo "<tr>\n";
|
|
echo "<td rowspan=\"2\" width=\"20\" align=\"center\"><span id="."abtnampel".$camampelfarbe."2> </span></td>\n";
|
|
#echo "<td rowspan=\"2\" width=\"*\" align=\"center\"><span id=abtn3big><b>$cam_label</b></span></td>\n";
|
|
echo "<td rowspan=\"2\" style=\"width:auto;\" align=\"center\"><span id=abtn3big><b>$cam_label</b></span></td>\n";
|
|
echo "<td rowspan=\"2\" width=\"30\">\n";
|
|
#echo "<select style=\"width:30px;\" id=slctbig onchange=\"location.href=this.options[this.selectedIndex].value\">\n";
|
|
echo "<select style=\"width:30px;\" id=slctbig onchange=\"location.href=this.options[this.selectedIndex].value\">\n";
|
|
#echo "<option value=\"\" selected>weitere</option>\n";
|
|
#echo "<option value=\"\" selected> weitere</option>\n";
|
|
echo "<option value=\"\" selected>+</option>\n";
|
|
foreach($array_hauptordner AS $eintrag)
|
|
{
|
|
#echo "<option value=\"allebilder.php?cam=$cam&datum=$eintrag&linkvon=$datei\">$eintrag</option>\n";
|
|
echo "<option value=\"allebilder.php?cam=$cam&datum=$eintrag&linkvon=$datei&n=$n&m=$m\"> $eintrag</option>\n";
|
|
}
|
|
echo "</select>\n";
|
|
echo "</td>\n";
|
|
echo "<td width=\"15%\"><a id=abtn2small href=\"letztenbilder.php?anzahl=$inc_letzten_bilder&cam=$cam&linkvon=$datei&n=$n&m=$m\"><span id=span14>$inc_letzten_bilder Bilder</span></a></td>\n";
|
|
echo "<td width=\"15%\"><a id=abtn2small href=\"letztenbildermin.php?min=$inc_letzten_min&cam=$cam&linkvon=$datei&n=$n&m=$m\"><span id=span14>$inc_letzten_min min</span></a></td>\n";
|
|
echo "<td width=\"15%\"><a id=abtn2small href=\"allebilder.php?cam=$cam&datum=$heute&linkvon=$datei&n=$n&m=$m\"><span id=span14>heute</span></a></td>\n";
|
|
echo "</tr>\n";
|
|
|
|
echo "<tr>\n";
|
|
echo "<td width=\"12%\"><a id=abtn2small href=\"letztenbilder.php?anzahl=$inc_letzten_bilder2&cam=$cam&linkvon=$datei&n=$n&m=$m\"><span id=span14>$inc_letzten_bilder2 Bilder</span></a></td>\n";
|
|
echo "<td width=\"12%\"><a id=abtn2small href=\"letztenbildermin.php?min=$inc_letzten_min2&cam=$cam&linkvon=$datei&n=$n&m=$m\"><span id=span14>$inc_letzten_min2 min</span></a></td>\n";
|
|
echo "<td width=\"12%\"><a id=abtn2small href=\"allebilder.php?cam=$cam&datum=$gestern&linkvon=$datei&n=$n&m=$m\"><span id=span14>gestern</span></a></td>\n";
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
echo "<td colspan=\"6\" id=tdbild>";
|
|
#Cam Bild
|
|
if($mode=="live") {
|
|
|
|
clearstatcache();
|
|
|
|
$bild = scandir_files_live($inc_pfad_www."live/",$cam);
|
|
$livebild="live/".$bild;
|
|
$livebildlink="live/".$bild;
|
|
$arg="&mode=live";
|
|
|
|
# bei nur Snapshot den letzten vom Snapshot nehmen
|
|
if($bild==""){
|
|
$letzte_jpg_heute=explode($inc_pfad_www, last_jpg_in_folder($inc_pfad_www.$heute."/".$cam."/"));
|
|
$livebildlink = $letzte_jpg_heute[1];
|
|
$livebild = $letzte_jpg_heute[1];
|
|
$arg="";
|
|
}
|
|
echo "<div id=divimg>";
|
|
#echo "<a href=\"einzelbild.php?bild=$livebildlink&cam=$cam&mode=live&linkvon=$datei\" title=\"".htmlentities("aktuelles Bild von ".$cam, ENT_QUOTES)."\">";
|
|
echo "<a href=\"einzelbild.php?bild=$livebildlink&cam=$cam".$arg."&linkvon=$datei&n=$n&m=$m\" title=\"".htmlentities("aktuelles Bild von ".$cam, ENT_QUOTES)."\">";
|
|
echo "<img id=imgindex src=\"".$livebild."\" style=\"width:".$inc_index_bild_breite."px;\">";
|
|
echo "</a>";
|
|
echo "</div>";
|
|
}else{
|
|
$letzte_jpg_heute=explode($inc_pfad_www, last_jpg_in_folder($inc_pfad_www.$heute."/".$cam."/"));
|
|
echo "<div id=divimg>";
|
|
echo "<a href=\"einzelbild.php?bild=$letzte_jpg_heute[1]&cam=$cam&linkvon=$datei&n=$n&m=$m\" title=\"".htmlentities("letztes Bild von ".$cam, ENT_QUOTES)."\">";
|
|
echo "<img id=imgindex src=\"".$letzte_jpg_heute[1]."\" style=\"width:".$inc_index_bild_breite."px;\">";
|
|
echo "</a>";
|
|
echo "</div>";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
echo "</table>\n";
|
|
echo "</td>\n";
|
|
$l++;
|
|
$c++;
|
|
|
|
if( $c > $max_cam_pro_zeile ) echo "</tr>\n";
|
|
}
|
|
#echo "</tr>\n";
|
|
|
|
#echo "</table>\n";
|
|
|
|
|
|
|
|
# Ende Geruest
|
|
echo "</table>\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
echo "</table>\n";
|
|
|
|
|
|
echo "</body>\n";
|
|
echo "</html>\n";
|
|
|
|
|
|
|
|
# gibt pfad+dateiname der letzten jpg in dem ordner
|
|
function last_jpg_in_folder($d) {
|
|
$files = glob($d."*.jpg");
|
|
#$files = array_combine($files, array_map("filemtime", $files));
|
|
#arsort($files);
|
|
#$latest_file = key($files);
|
|
return end(array_values($files));
|
|
}
|
|
|
|
# gib array mit dateinamen zurück die sich im ordner befinden
|
|
function scandir_nofolders($d) {
|
|
return array_filter(scandir($d), function ($f) use($d) {
|
|
return ! is_dir($d . DIRECTORY_SEPARATOR . $f);
|
|
});
|
|
}
|
|
|
|
# gib array mit ordnernamen zurück die sich im ordner befinden
|
|
function scandir_folders($d) {
|
|
return array_filter(scandir($d), function ($f) use($d) {
|
|
return is_dir($d . DIRECTORY_SEPARATOR . $f);
|
|
});
|
|
}
|
|
|
|
# gib array mit ordnernamen zurück die sich im ordner befinden (. .. ausgeschlossen)
|
|
function scandir_folders_nopoint($d) {
|
|
return array_filter(scandir($d), function ($f) use($d) {
|
|
if($f == ".") return false;
|
|
elseif($f == "..") return false;
|
|
else return is_dir($d . DIRECTORY_SEPARATOR . $f);
|
|
});
|
|
}
|
|
|
|
# gib array mit ordnernamen zurück mit dem typ yyyy-mm-dd die sich im ordner befinden
|
|
function scandir_folders_yyyymmdd($d) {
|
|
return array_filter(scandir($d), function ($f) use($d) {
|
|
if( preg_match("/20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]/", $f) ) return is_dir($d . DIRECTORY_SEPARATOR . $f);
|
|
else return false;
|
|
});
|
|
}
|
|
|
|
|
|
function camampel($dir,$min) {
|
|
$sek = $min * 60;
|
|
$mydir = opendir($dir);
|
|
$gefunden="red";
|
|
while($file = readdir($mydir)) {
|
|
if($file != "." && $file != "..") {
|
|
if(!is_dir($dir.$file)) {
|
|
if(date("U",filemtime($dir.$file)) >= time() - $sek) $gefunden="green";
|
|
}
|
|
}
|
|
}
|
|
closedir($mydir);
|
|
return $gefunden;
|
|
}
|
|
|
|
|
|
# gibt pfad+dateiname der letzten x jpg in dem ordner
|
|
function last_x_jpg_in_folder($d,$x) {
|
|
$files = glob($d."*.jpg");
|
|
return array_slice($files, -$x);
|
|
}
|
|
|
|
|
|
#
|
|
function scandir_files_live($d,$cam) {
|
|
$array = array_filter(scandir($d), function ($f) use($d,$cam) {
|
|
if($f == ".") return false;
|
|
elseif($f == "..") return false;
|
|
elseif( preg_match("/".$cam."_[0-9]+/", $f) and date("U",filemtime($d.$f)) >= time() - 3) return is_file($d . DIRECTORY_SEPARATOR . $f);
|
|
else return false;
|
|
});
|
|
$array = array_values($array);
|
|
return $array[count($array)-2];
|
|
}
|
|
|
|
#clearstatcache();
|
|
#$test = scandir_files_live($inc_pfad_www."live/","cam1");
|
|
|
|
?>
|
|
|