【源码】PHP无需数据库的短链接生成url
超级简单,复制直接使用http://cdn.u1.huluxia.com/g4/M03/16/40/rBAAdmKYlCGAKDAbAAB8hYN9wKM684.jpg
<div><a href="">短URL</a></div><?phpif ($_GET["U"]=="b") {$url=$_POST["url"];if ($url==null) {echo '';Header("Location: index.php?U=a");}else{$myfile = fopen("URL.txt", "a+") or die("Unable to open file!");$txt = $url."\n";fwrite($myfile, $txt);fclose($myfile);$host=$_SERVER['HTTP_HOST'];$f='URL.txt'; //文件名$a=file($f);//把文件的所有内容获取到数组里面$n=count($a); //获得总行数$v=$n-1;echo <<<EOF//$host/S/?k=$vEOF;}}if($_GET["U"]=="a") {$host=$_SERVER['HTTP_HOST'];$q=$_GET["f"];echo <<<EOF<form action="index.php?U=b" method="post" autocomplete="off"><label>请输入 URL 链接</label><inputname="url" type="url"/><input type="submit" value="生成" /><br><br></form><br><br>//$host/S/?k=$qEOF;}else{$f='URL.txt'; //文件名$a=file($f);//把文件的所有内容获取到数组里面$n=count($a); //获得总行数$rnd_line=$a[$_GET["k"]]; //获得随机行echo <<<EOF<div class="mdui-card mdui-container"><br><div class="mdui-grid-tile">$n正在跳转中:$rnd_line</div></div>EOF;Header("Location: $rnd_line");}?> 众里寻他千百度,蓦然回首在这里! LZ是天才,坚定完毕 专业抢沙发的!哈哈 为了三千积分!
页:
[1]