首先抱歉我的英语不好
我制作了一个附加
的php脚本$code = "Redirect /".$shorted." ".$_POST['url'];
在.htaccess中
这是我的代码
function randWord($len = 3) {
$word = array_merge(range('a', 'z'), range('A', 'Z'));
shuffle($word);
return substr(implode($word), 0, $len);
}
$passwords = ['1st Pass','2nd Pass','3rd pass'];
if(isset($_POST['url']) && isset($_POST['password'])){
if(in_array($_POST['password'],$passwords)){
if(!isset($_COOKIE['password'])){
$cookie_name = "password";
$cookie_value = $_POST['password'];
setcookie($cookie_name,$cookie_value,time() + (86400 * 3),"/shortner.php");
}
if(!empty($_POST['url']) && !empty($_POST['password'])){
if(filter_var($_POST['url'], FILTER_VALIDATE_URL)){
$number = rand(0,999);
$shorted = randWord(1).$number.randWord(2);
$txt = "Redirect /".$shorted." ".$_POST['url'];
if(file_put_contents('.htaccess', $txt.PHP_EOL , FILE_APPEND | LOCK_EX)){
$status = "https://wstm.ir/".$shorted;
$error = false;
}else{
$status = "Something Went Wrong ...";
$error = true;
}
}else{
$status = "You Must Enter a valid URL ... ";
$error = true;
}
}else{
$status = "All Fields Must complete";
$error = true;
}
}else{
$status = "Password Is Wrong!";
$error = true;
}
}
我想知道使用它是否安全? 我不想让所有人都把它作为网址缩短器公开