First commit

This commit is contained in:
pepa65 committed 2022-08-26 21:31:39 +07:00
commit 08a25f62af
5 files changed
+130

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Stream Upload</title>
<script>
function respond(){
const feedback = document.getElementById('response');
feedback.innerHTML = '<b>File is uploading</b>';
}
</script>
<div style="display:flex; justify-content:center; align-items:center; height:95vh;">
<form action="upload.php" method="post" enctype="multipart/form-data" onsubmit="respond()">
<table>
<tr><td colspan=2 align=center><h1>Video Upload Page</h1></td></tr>
<tr>
<td>Streamkey:</td>
<td><input type="text" name="streamkey" id="streamkey" required title="re_ followed by a string of 0-9, a-f or underscore characters (20 or longer)" pattern="re_[a-f0-9_]{20,}"></td></tr>
<tr>
<td>Date:</td>
<td><input type="date" name="date" id="date" required></td></tr>
<tr>
<td>Time:</td>
<td><input type="time" name="time" id="time" required></td></tr>
<tr>
<td>Video File:</td>
<td><input type="file" name="fileToUpload" id="fileToUpload" required accept=".mp4"></td></tr>
<tr><td><p></td></tr>
<tr><td align=center colspan="2"><input type="submit" value="Schedule Stream" name="submit"></td></tr>
<tr><td><p></td></tr>
<tr><td align=center colspan="2" id="response"></td></tr>
</table>
</form>
</div>
+59
View File
@@ -0,0 +1,59 @@
<?php
error_reporting(E_ALL);
set_time_limit(0);
//ob_implicit_flush(true);
//ob_end_flush();
if($_SERVER['REQUEST_METHOD']!=='POST'){
header('Location: /');
}
function back($msg){
print($msg);
print('<br><br>
<form action="/" method="post">
<input type="submit" value="Upload another file" name="submit">
</form>');
exit;
}
header('Content-type: text/html; charset=utf-8');
$upload=htmlspecialchars(basename($_FILES['fileToUpload']['name']));
$key=$_POST['streamkey'];
$date=$_POST['date'];
$time=$_POST['time'];
$dir='uploads/';
$name=$key.'.'.$date.'_'.$time;
$file=$dir.$name;
print('<!DOCTYPE html>
<meta charset="utf-8">
<title>Uploading</title>
<h3>Uploading</h3>
File: '.$upload.'<br>');
ob_flush();
flush();
$now=date('Y-m-dH:i');
if(strcmp($now, $date.$time)>0){
back('Scheduling '.$now.' in the past: '.$date.' '.$time);
}
$nextyear=date('Y-m-dH:i', strtotime('+1 year'));
if(strcmp($nextyear, $date.$time)<0){
back('Scheduling too far into the future: '.$date.' '.$time);
}
if($_FILES['fileToUpload']['error']!=UPLOAD_ERR_OK){
back('Error uploading the file');
}
if(!move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $file)){
back('Error moving the file');
}
$res=exec('../prep '.$name, $output, $ret);
if($ret==1){
back('Not a video file, but of type: '.$res);
}
if($ret==2){
back('Error with the encoding');
}
print('File uploaded as "'.$name.'"<br>
Scheduled for '.$date.' at '.$time);
?>