fedi-tumblr/status.php

46 lines
1.4 KiB
PHP
Raw Normal View History

2020-03-16 22:47:26 +00:00
<?php
ini_set('display_errors', 1);
ini_set("log_errors", 1);
error_reporting(E_ALL);
include "settings.php";
include "include/init.php";
include "include/functions.php";
$media_id = array();
if (!is_null($token) && (isset($_FILES['file']) || isset($_POST['status']))){
if(isset($_FILES['file'])){
$cnt = count($_FILES['file']['name']);
for ($n = 0; $n <= $cnt-1; $n++){
$video = 0;
$errors= array();
$file_name = $_FILES['file']['name'][$n];
$file_size =$_FILES['file']['size'][$n];
$file_tmp =$_FILES['file']['tmp_name'][$n];
$file_type=$_FILES['file']['type'][$n];
@$file_ext=strtolower(end(explode('.',$_FILES['file']['name'][$n])));
$expensions= array("jpeg","jpg","png","gif","mp4","webm");
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if(empty($errors)==true){
move_uploaded_file($file_tmp, $file_name);
$media_id[] = json_decode(uploadpic($file_name),true)[0];
unlink($file_name);
}else{
//print_r($errors);
//echo "error";
}
}
}
$result = sendpost(trim($_POST['status']),$media_id,$_POST['thread'],false,$_POST['scope'],(isset($_POST['sensitive']) ? $_POST['sensitive'] : false),(isset($_POST['spoiler']) && $_POST['spoiler'] != 'Title (optional)' ? $_POST['spoiler'] : false));
//file_put_contents("output.txt",var_export($media_id,true));
header('Location: '.$setting['url'].'?mode=home');
}
?>