Complete date/time split

This commit is contained in:
pepa65 2022-09-17 02:40:50 +07:00
parent f3242174d3
commit 6bc25889b8
3 changed files with 58 additions and 56 deletions

View File

@ -37,10 +37,9 @@ function filename(){
<option value="YouTube">YouTube</option>
</select>
<input type="text" name="streamkey" placeholder="Stream Key" required title="Enter a string of 0-9, a-z, A-Z, underscore or dash characters" pattern="[a-zA-Z0-9_-]+">
<!--input type="datetime-local" name="datetime" title="Click on the date to get a popup" required-->
<div class="datetime">
<input type="date" name="date" title="Click on the date to get a popup" required>
<input type="time" name="time" title="Click on the time to get a popup" required></div>
<input type="date" name="date" title="Enter the date" required>
<input type="time" name="time" title="Enter the time" required></div>
<input type="email" name="email" placeholder="Email to notify" title="Not required">
<input type="submit" value="Schedule Stream" name="schedule">
<p id="response"></p>

View File

@ -37,6 +37,47 @@ h4 {
background-color:red;
padding:.9em;
}
::file-selector-button {
-moz-opacity:0;
filter:alpha(opacity:0);
opacity:0;
}
.fileinput {
position:relative;
max-width:fit-content(325px);
}
#name {
padding-top:5px;
font-weight:bold;
width:100%;
text-align:center;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
input.abs {
background-color:#cfc;
padding:14px 20px;
margin:8px 0;
border:1px solid #aaa;
border-radius:4px;
box-sizing:border-box;
cursor:pointer;
font-size:16px
}
.abs {
position:absolute;
top:0px;
left:0px;
z-index:1;
}
#input {
position:relative;
-moz-opacity:0;
filter:alpha(opacity:0);
opacity:0;
z-index:2;
}
input,select {
background-color:#fff;
text-align:center;
@ -75,15 +116,6 @@ input[type=submit] {
border:none;
cursor:pointer;
}
::file-selector-button {
-moz-opacity:0;
filter:alpha(opacity:0);
opacity:0;
}
.fileinput {
position:relative;
max-width:fit-content(325px);
}
.datetime {
display:flex;
flex-direction:rows;
@ -100,35 +132,3 @@ input[type=time] {
padding-left:0;
padding-right:0;
}
#name {
padding-top:5px;
font-weight:bold;
width:100%;
text-align:center;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
input.abs {
background-color:#cfc;
padding:14px 20px;
margin:8px 0;
border:1px solid #aaa;
border-radius:4px;
box-sizing:border-box;
cursor:pointer;
font-size:16px
}
.abs {
position:absolute;
top:0px;
left:0px;
z-index:1;
}
#input {
position:relative;
-moz-opacity:0;
filter:alpha(opacity:0);
opacity:0;
z-index:2;
}

View File

@ -23,22 +23,22 @@ foreach($mh as $line){
}
$upload=htmlspecialchars(basename($_FILES['file']['name']));
$key=$_POST['streamkey'];
$datetime=$_POST['datetime'];
$date=$_POST['date'];
$time=$_POST['time'];
$email=$_POST['email'];
$user=$_SESSION['user'];
$target=$_POST['target'];
if($email){
$to=$email;
$email=':'.$email;
}else{
$to=$mails[$user];
}
$date=substr($datetime, 0, 10);
$hour=substr($datetime, 11, 2);
$min=substr($datetime, 14, 2);
$time=$hour.$min;
$target=$_POST['target'];
$hour=substr($time, 0, 2);
$min=substr($time, 3, 2);
$tme=$hour.$min;
$dir='streams/';
$name=$key.'.'.$date.'_'.$time.'_'.$user.$email.'@'.$target;
$name=$key.'.'.$date.'_'.$tme.'_'.$user.$email.'@'.$target;
$file=$dir.$name.'.upload';
print('<!DOCTYPE html>
<meta charset="utf-8">
@ -51,15 +51,18 @@ print('<!DOCTYPE html>
</form></div><div class="container">
<h1>Encoding</h1>
<p>Uploaded <b>'.$upload.'</b></p>');
if(preg_match('/20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]/', $datetime)===false){
Back('Date/time somehow incorrect: '.$datetime);
if(preg_match('/20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]/', $date)===false){
Back('Date somehow incorrect: '.$date);
}
if(preg_match('/[0-2][0-9]:[0-6][0-9]/', $time)===false){
Back('Time somehow incorrect: '.$time);
}
$now=date('Y-m-dHi');
if(strcmp($now, $date.$time)>0){
if(strcmp($now, $date.$tme)>=0){
Back('Scheduling '.$now.' in the past: '.$date.' '.$time);
}
$nextyear=date('Y-m-dHi', strtotime('+1 year'));
if(strcmp($nextyear, $date.$time)<0){
if(strcmp($nextyear, $date.$tme)<0){
Back('Scheduling too far into the future: '.$date.' '.$time);
}
if($_FILES['file']['error']!=UPLOAD_ERR_OK){
@ -71,5 +74,5 @@ if(!move_uploaded_file($_FILES['file']['tmp_name'], $file)){
print('<p>Streaming <b>'.$name.'.mp4</b></p>');
print('<p>When done encoding, email <b>'.$to.'</b></p>');
Back('Streaming on <b>'.$date.'</b> at <b>'.$hour.':'.$min.'</b>h on <b>'.$target.'</b>');
Back('Streaming on <b>'.$date.'</b> at <b>'.$time.'</b>h on <b>'.$target.'</b>');
?>