Add readme

This commit is contained in:
pepa65 committed 2022-08-29 15:24:26 +07:00
1 parent e57458dcab
commit f571c2bca7
6 files changed
+84 -45

No files matched your search

+13 -4
View File
@@ -11,9 +11,18 @@ function respond(){
<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>Target:</td>
<td>
<select name="target" id="target" required>
<option value="Restream">Restream</option>
<option value="Facebook">Facebook</option>
<option value="YouTube">YouTube</option>
</select>
</td></tr>
<tr>
<td>Streamkey:</td>
<td><input type="text" name="streamkey" id="streamkey" required title="string of 0-9, a-z or underscore characters" pattern="[a-z0-9_]+"></td></tr>
<td><input type="text" name="streamkey" id="streamkey" required title="string of 0-9, a-z, A-Z or underscore characters" pattern="[a-zA-Z0-9_]+"></td></tr>
<tr>
<td>Date:</td>
<td><input type="date" name="date" id="date" required></td></tr>
@@ -23,9 +32,9 @@ function respond(){
<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><br></td></tr>
<tr><td></td><td><input type="submit" value="Schedule Stream" name="submit"></td></tr>
<tr><td><br></td></tr>
<tr><td align=center colspan="2" id="response"></td></tr>
</table>
</form>
+21 -22
View File
@@ -1,18 +1,15 @@
<?php
error_reporting(E_ALL);
set_time_limit(0);
//ob_implicit_flush(true);
//ob_end_flush();
//set_time_limit(0);
if($_SERVER['REQUEST_METHOD']!=='POST'){
header('Location: /');
}
function back($msg){
print($msg);
print('<br><br>
function Back($msg){
print('<br>&nbsp;<br>'.$msg.'<br>&nbsp;<br>
<form action="/" method="post">
<input type="submit" value="Upload another file" name="submit">
</form>');
</form></div>');
exit;
}
@@ -20,32 +17,34 @@ header('Content-type: text/html; charset=utf-8');
$upload=htmlspecialchars(basename($_FILES['fileToUpload']['name']));
$key=$_POST['streamkey'];
$date=$_POST['date'];
$time=$_POST['time'];
$hour=substr($_POST['time'], 0, 2);
$min=substr($_POST['time'], 3, 2);
$time=$hour.$min;
$target=$_POST['target'];
$dir='streams/';
$name=$key.'.'.$date.'_'.$time;
$name=$key.'.'.$date.'_'.$time.'@'.$target;
$file=$dir.$name.'.upload';
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');
<title>Encoding</title>
<div style="display:flex; flex-direction:column; justify-content:center; text-align:center; align-items:center; height:95vh;">
<h3>Encoding</h3>
File: '.$upload);
$now=date('Y-m-dHi');
if(strcmp($now, $date.$time)>0){
back('Scheduling '.$now.' in the past: '.$date.' '.$time);
Back('Scheduling '.$now.' in the past: '.$date.' '.$time);
}
$nextyear=date('Y-m-dH:i', strtotime('+1 year'));
$nextyear=date('Y-m-dHi', strtotime('+1 year'));
if(strcmp($nextyear, $date.$time)<0){
back('Scheduling too far into the future: '.$date.' '.$time);
Back('Scheduling too far into the future: '.$date.' '.$time);
}
if($_FILES['fileToUpload']['error']!=UPLOAD_ERR_OK){
back('Error uploading the file');
Back('Error uploading the file');
}
if(!move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $file)){
back('Error moving the file');
Back('Error moving the file');
}
back('File is now being encoded to "'.$name.'.mp4"<br>
Scheduled for '.$date.' at '.$time);
Back('File is now being encoded to "'.$name.'.mp4"<br>&nbsp;<br>
Scheduling for '.$date.' at '.$hour.':'.$min.'h on '.$target);
?>