$envValue) { if (strpos($envKey, 'NP_CAM_') === 0) { array_push($camsInfo, [substr($envKey, strlen('NP_CAM_')), $envValue]); } } // Grabbing the other env variables. $pageTitle = $_ENV['NP_TITLE'] ?? 'NibblePoker\'s Mini CCTV NVR'; $pageFooter = $_ENV['NP_FOOTER'] ?? 'Made by BOZET Herwin on Github'; // Root location of all recordings. (Not used yet) $rootLocation = "./data/"; // Grabbing the requested cam's ID // The id should be the same as the sub-folder into which this camera's recordings are located. $camId = $_GET['cam'] ?? null; // Determining if the ID is valid and the name that should be shown. // If the ID is invalid, it is set back to `null`. if(is_null($camId)) { $camName = "None"; } else { $isCamValid = false; foreach ($camsInfo as $singleCamInfo) { if($singleCamInfo[0] == $camId) { $camName = $singleCamInfo[1]; $isCamValid = true; break; } } if(!$isCamValid) { $camName = "Unknown"; $camId = null; } } // Grabbing the list of recordings if needed. if(is_null($camId)) { // No cam selected, we just use empty variables. $basePath = "./"; $files = []; } else { $basePath = "/data/".$camId."/"; $files = array_values(array_diff(scandir("./data/".$camId."/"), array('.', '..'))); // Removing the newest one as it is highly likely to currently being written to by ffmpeg. array_pop($files); } // If we only need to send the JSON, we send it and don't go further. $returnJsonOnly = !is_null($_GET['json'] ?? null); if($returnJsonOnly) { header('Content-Type: application/json; charset=utf-8'); echo json_encode($files); exit(); } // Function used to calculate the disk space taken by recordings later on. function folderSize($dir){ $count_size = 0; $count = 0; $dir_array = scandir($dir); foreach($dir_array as $key=>$filename){ if($filename!=".." && $filename!="."){ if(is_dir($dir."/".$filename)){ $new_foldersize = foldersize($dir."/".$filename); $count_size = $count_size+ $new_foldersize; } else if(is_file($dir."/".$filename)) { $count_size = $count_size + filesize($dir."/".$filename); $count++; } } } return $count_size; } // Function used to format the disk space taken by recordings later on. function sizeFormat($bytes) { $kb = 1024; $mb = $kb * 1024; $gb = $mb * 1024; $tb = $gb * 1024; if (($bytes >= 0) && ($bytes < $kb)) { return $bytes . ' B'; } elseif (($bytes >= $kb) && ($bytes < $mb)) { return ceil($bytes / $kb) . ' KiB'; } elseif (($bytes >= $mb) && ($bytes < $gb)) { return ceil($bytes / $mb) . ' MiB'; } elseif (($bytes >= $gb) && ($bytes < $tb)) { return ceil($bytes / $gb) . ' GiB'; } elseif ($bytes >= $tb) { return ceil($bytes / $tb) . ' TiB'; } else { return $bytes . ' B'; } } ?> <?php echo($pageTitle); ?>



Camera:


Select one camera:

"); echo(""); } else { // We have selected one, we add the video, slider, jumpers and filename placeholder. echo("
"); echo(""); echo("
"); echo(""); echo("
"); echo("

"); echo("<<<< 25"); echo("<<< 10"); echo("<< 5"); echo("< 1"); echo("1 >"); echo("5 >>"); echo("10 >>>"); echo("25 >>>>"); echo("

"); echo("
"); echo("

File: Non définis (0/0)

"); echo("
"); echo("
"); } ?>