114 lines
4.1 KiB
PHP
114 lines
4.1 KiB
PHP
<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>RIP config</title>
|
|
<link rel="stylesheet" href="./css/normalize.css" ></link>
|
|
<link rel="stylesheet" href="./css/bootstrap.min.css" type="text/css"></link>
|
|
<link rel="stylesheet" href="./css/main.css" ></link>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1><?php echo(gethostname()); ?> Config utility</h1>
|
|
</div>
|
|
<div class="container-main">
|
|
<?php
|
|
# have we got a video_file
|
|
if (isset($_POST['Video'])){
|
|
echo '<pre>' . $_FILES['video_file']['name'] . '</pre>';
|
|
|
|
$currentDirectory = getcwd();
|
|
$uploadDirectory = "/../data/";
|
|
|
|
|
|
$errors = []; // Store errors here
|
|
$fileExtensionsAllowed = ['mp4','mov']; // These will be the only file extensions allowed
|
|
|
|
$fileName = $_FILES['video_file']['name'];
|
|
$fileSize = $_FILES['video_file']['size'];
|
|
$fileTmpName = $_FILES['video_file']['tmp_name'];
|
|
$fileType = $_FILES['video_file']['type'];
|
|
$fileExtension = strtolower(end(explode('.',$fileName)));
|
|
|
|
|
|
$uploadPath = $currentDirectory . $uploadDirectory . 'video1.' . $fileExtension;
|
|
if (isset($_POST['Video'])) {
|
|
if (!in_array($fileExtension,$fileExtensionsAllowed)) {
|
|
$errors[] = "<pre>This file extension is not allowed. Please upload a mp4 or mov file</pre>";
|
|
}
|
|
|
|
if (empty($errors)) {
|
|
$didUpload = move_uploaded_file($fileTmpName, $uploadPath);
|
|
if ($didUpload) {
|
|
echo '<div class="container-fluid">The file ' . basename($fileName) . " has been uploaded</div>";
|
|
echo '<div class="container-fluid message">The file ' . basename($fileName) . " to " . $uploadPath . " has been uploaded</div>";
|
|
echo '<pre>Rebooting please wait ...';
|
|
system("(sleep 2 ; sudo /sbin/reboot ) > /dev/null 2>&1 & echo ' DONE !!!'");
|
|
echo '</pre>';
|
|
} else {
|
|
echo "<pre>An error occurred. Please contact the administrator.</pre>";
|
|
}
|
|
} else {
|
|
echo '<pre>';
|
|
foreach ($errors as $error) {
|
|
echo $error;
|
|
}
|
|
echo '</pre>';
|
|
}
|
|
}
|
|
}
|
|
## we've got a new slpash_screen
|
|
if (isset($_POST['Splash'])){
|
|
echo '<pre>file = ' . $_FILES['splash_screen']['name'] . '</pre>';
|
|
|
|
$currentDirectory = getcwd();
|
|
$uploadDirectory = "/../data/";
|
|
|
|
|
|
$errors = []; // Store errors here
|
|
$fileExtensionsAllowed = ['jpg', 'JPEG', 'jpeg', 'JPG']; // These will be the only file extensions allowed
|
|
|
|
$fileName = $_FILES['splash_screen']['name'];
|
|
$fileSize = $_FILES['splash_screen']['size'];
|
|
$fileTmpName = $_FILES['splash_screen']['tmp_name'];
|
|
$fileType = $_FILES['splash_screen']['type'];
|
|
$fileExtension = strtolower(end(explode('.',$fileName)));
|
|
|
|
|
|
$uploadPath = $currentDirectory . $uploadDirectory . 'splash.jpg';
|
|
if (isset($_POST['Splash'])) {
|
|
if (!in_array($fileExtension,$fileExtensionsAllowed)) {
|
|
echo '<pre> File Extension = ' . $fileExtension . '</pre>';
|
|
$errors[] = "<pre>This file extension is not allowed. Please upload a JPEG file</pre>";
|
|
}
|
|
|
|
if (empty($errors)) {
|
|
$didUpload = move_uploaded_file($fileTmpName, $uploadPath);
|
|
if ($didUpload) {
|
|
echo '<div class="container-fluid message">The file ' . basename($fileName) . " to " . $uploadPath . " has been uploaded</div>";
|
|
echo '<pre>Rebooting please wait ...';
|
|
system("(sleep 2 ; sudo /sbin/reboot ) > /dev/null 2>&1 & echo ' DONE !!!'");
|
|
echo '</pre>';
|
|
} else {
|
|
echo "<pre>An error occurred. Please contact the administrator.</pre>";
|
|
}
|
|
} else {
|
|
echo '<pre>';
|
|
foreach ($errors as $error) {
|
|
echo $error;
|
|
}
|
|
echo '</pre>';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
</div>
|
|
<div><a href="/" class="btn btn-primary">BACK</a></div>
|
|
<script src="js/jquery-3.3.1.slim.min.js" ></script>
|
|
<script src="js/popper.min.js" ></script>
|
|
<script src="js/bootstrap.min.js" ></script>
|
|
</body>
|
|
</html>
|