insert-coin/private/beam.php

47 lines
1.0 KiB
PHP
Raw Normal View History

2018-10-09 19:39:09 -05:00
<?php
2019-02-14 09:39:29 -06:00
include("../res/config.php");
include("../res/library/main.php");
2018-10-09 19:39:09 -05:00
$file_name = $_FILES["uploadcoin"]["name"];
$file_ext = file_extension($file_name);
if (!empty($_POST["desired_filename"])) {
$file_name = $_POST["desired_filename"];
if (!file_extension($file_name)) {
2018-10-09 19:42:44 -05:00
$file_name = $file_name . "." . $file_ext;
2018-10-09 19:39:09 -05:00
}
}
$file_name = sanitize_filename($file_name);
$dest_name = $GLOBALS["file_beam_dir"] . $file_name;
2019-02-14 19:20:06 -06:00
$dest_file = root("/" . $dest_name);
2018-10-09 19:39:09 -05:00
switch (true) {
case (empty($file_name) || empty($dest_name)):
redirect(make_url("result/beam.php?error=1"));
break;
2018-10-09 19:39:09 -05:00
case (file_exists($dest_file)):
redirect(make_url("result/beam.php?error=2"));
break;
2018-10-09 19:39:09 -05:00
case (move_uploaded_file($_FILES["uploadcoin"]["tmp_name"], $dest_file)
&& write_metadata($dest_file, $_POST["file_source"])):
2019-01-27 01:51:11 -06:00
if (is_image($dest_file)) {
sanitize_image($dest_file);
}
2018-10-09 19:39:09 -05:00
redirect(make_url("result/beam.php?success="
. $file_name));
break;
default:
redirect(make_url("result/beam.php?error=3"));
2018-10-09 19:39:09 -05:00
break;
}
?>