insert-coin/private/create.php
2019-02-14 19:20:25 -06:00

39 lines
937 B
PHP

<?php
include("../res/config.php");
include("../res/library/main.php");
$url_target = $_POST["url_target"];
$url_alias = sanitize_filename($_POST["url_alias"]);
$visible_name = $url_alias . $GLOBALS["url_aliasize_visible_suffix"];
$visible_dest = $GLOBALS["url_aliasize_dir"] . $visible_name;
$dest_name = $GLOBALS["url_aliasize_dir"] . $url_alias
. $GLOBALS["url_aliasize_suffix"];
$dest_file = root("/" . $dest_name);
switch (true) {
case (empty($url_target) || empty($url_alias)):
redirect(make_url("result/create.php?error=1"));
break;
case (file_exists($dest_file)):
redirect(make_url("result/create.php?error=2"));
break;
case (!valid_url($url_target)):
redirect(make_url("result/create.php?error=3"));
break;
case (write_alias($dest_file, $url_target)):
redirect(make_url("result/create.php?success="
. $visible_name));
break;
default:
redirect(make_url("result/create.php"));
break;
}
?>