1
0
Fork 0
wmdeit_kaform/upload.php

125 lines
3.0 KiB
PHP
Raw Permalink Normal View History

2020-02-20 13:45:47 +00:00
<?php
session_start();
2021-06-12 17:43:05 +00:00
#error_log("Here is upload.php");
2021-11-23 11:55:00 +00:00
include "config.php";
2021-06-12 17:43:05 +00:00
2020-02-20 13:45:47 +00:00
function xvar_dump ($x) {
ob_start();
var_dump($x);
return ob_get_clean();
}
2021-11-25 00:12:01 +00:00
$fff = xvar_dump($_FILES);
file_put_contents("/tmp/log.txt", "uploader\n", FILE_APPEND | LOCK_EX);
file_put_contents("/tmp/log.txt", "$fff\n", FILE_APPEND | LOCK_EX);
if (!count($_FILES)){
file_put_contents("/tmp/log.txt", "ERRORZWEIK\n", FILE_APPEND | LOCK_EX);
$jo = array(
"type" => "error"
);
$j = json_encode ($jo);
echo $j;
$x = xvar_dump($j);
file_put_contents("/tmp/log.txt", "$j\n", FILE_APPEND | LOCK_EX);
file_put_contents("/tmp/log.txt", "$x\n", FILE_APPEND | LOCK_EX);
return;
}
2020-02-20 13:45:47 +00:00
$jo = array();
foreach ($_FILES as $key=>$files){
2021-11-25 00:12:01 +00:00
file_put_contents("/tmp/log.txt", "MIME: tester\n", FILE_APPEND | LOCK_EX);
2020-02-20 13:45:47 +00:00
for ($i=0; $i < count($files['name']); $i++){
$tmpname = $files['tmp_name'][$i];
2020-09-18 14:18:08 +00:00
$ft = mime_content_type($tmpname);
2021-11-23 12:44:08 +00:00
file_put_contents("/tmp/log.txt", "MIME: $ft\n", FILE_APPEND | LOCK_EX);
if ($ft == "application/pdf"){
2020-09-18 14:18:08 +00:00
$jo ["file-$key-$i"] = array(
"url" => "url.txt",
"name" => $files['name'][$i],
"id" => $tmpname,
"size" => sprintf("%0.1fK",$files['size'][$i]/1024.0)
);
2021-06-12 17:43:05 +00:00
file_put_contents("/tmp/log.txt", "file-$key-$i\n", FILE_APPEND | LOCK_EX);
2021-11-25 00:12:01 +00:00
file_put_contents("/tmp/log.txt", $files['name'][$i]."\n", FILE_APPEND | LOCK_EX);
2021-06-12 17:43:05 +00:00
$_SESSION['files'][$tmpname]['content']=file_get_contents($tmpname);
$_SESSION['files'][$tmpname]['row']=$_GET['row'];
2020-02-20 13:45:47 +00:00
2021-11-25 00:12:01 +00:00
}else if (
$ft == "image/jpeg" ||
$ft == "image/png" ||
$ft == "image/tiff" ||
$ft == "image/bmp" ||
$ft == "image/gif"
){
2021-11-23 12:44:08 +00:00
$jo ["file-$key-$i"] = array(
"url" => "url.txt",
"name" => $files['name'][$i],
"id" => $tmpname,
"size" => sprintf("%0.1fK",$files['size'][$i]/1024.0)
);
2021-11-25 00:12:01 +00:00
file_put_contents("/tmp/log.txt", "BILD detected\n", FILE_APPEND | LOCK_EX);
2021-11-23 12:44:08 +00:00
file_put_contents("/tmp/log.txt", "file-$key-$i\n", FILE_APPEND | LOCK_EX);
file_put_contents("/tmp/log.txt", $files['name'][$i], FILE_APPEND | LOCK_EX);
$tmpfname = tempnam("/tmp", "FOO");
2021-11-23 12:49:17 +00:00
$cmd = "$CONVERT_CMD $tmpname PDF:$tmpfname";
2021-11-23 12:44:08 +00:00
exec ($cmd);
file_put_contents("/tmp/log.txt", "\n$cmd\n");
$_SESSION['files'][$tmpname]['content']=file_get_contents($tmpfname);
$_SESSION['files'][$tmpname]['row']=$_GET['row'];
2021-11-25 00:12:01 +00:00
unlink ($tmpfname);
2021-11-23 12:44:08 +00:00
2021-11-25 00:12:01 +00:00
}else {
2021-11-23 12:44:08 +00:00
file_put_contents("/tmp/log.txt", "ERRORZWEIK\n", FILE_APPEND | LOCK_EX);
$jo = array(
"type" => "error"
);
$j = json_encode ($jo);
echo $j;
2021-11-25 00:12:01 +00:00
$x = xvar_dump($j);
file_put_contents("/tmp/log.txt", "$j\n", FILE_APPEND | LOCK_EX);
file_put_contents("/tmp/log.txt", "$x\n", FILE_APPEND | LOCK_EX);
2021-11-23 12:44:08 +00:00
return;
}
2020-02-20 13:45:47 +00:00
}
}
$files = "";
foreach ($_SESSION['files'] as $key => $val) {
$files .= "$key\n";
}
$j = json_encode ($jo);
echo $j;
2021-06-12 17:43:05 +00:00
file_put_contents("/tmp/log.txt", $j, FILE_APPEND | LOCK_EX);
2020-09-18 14:18:08 +00:00
#error_log("\n\n ----- files ----- \n\n$files\n\n\n");
#$xp = xvar_dump($_FILES);
#error_log("\n\n ----- FILES ----- \n\n$$xp\n\n\n");
2020-02-20 13:45:47 +00:00