Rumah > php教程 > PHP源码 > 超简单php短网址压缩免注册

超简单php短网址压缩免注册

PHP中文网
Lepaskan: 2016-05-25 17:12:06
asal
1437 orang telah melayarinya

php短网址压缩 
本站短网址压缩可以帮你做什么?可以帮你把很长的网址压缩成  http://u.bitefu.net/wiHDH这样短的网址,使用方便,免注册! 
代码超级简单,以下是全部代码! 

[文件] index.php

<?php
header("content-Type: text/html; charset=utf-8");
$type = 1; // 0为bit.ly  1为goo.gl  2为is.gd  3为tinyurl.com  建议选1
$wjt = 1; //1为开启伪静态,0为关闭伪静态。开启伪静态后需要添加伪静态规则,规则请看说明
 
$urlarr = array(&#39;bit.ly&#39;,&#39;goo.gl&#39;,&#39;is.gd&#39;,&#39;tinyurl.com&#39;);
$myurl = &#39;http://&#39;.$_SERVER[&#39;SERVER_NAME&#39;].$_SERVER["SCRIPT_NAME"];
$myurl1 = $myurl;
$myurl = str_replace(&#39;index.php&#39;,&#39;&#39;,$myurl);
if($wjt == 0){$myurl = $myurl.&#39;?&#39;;}
 
function get_content($url){
    $chenqinghua_contents = file_get_contents($url);
    return $chenqinghua_contents;
}
$urlstr = $_SERVER[&#39;QUERY_STRING&#39;];
if(strlen($urlstr)>3 && strlen($urlstr)<7 ){
    header("HTTP/1.1 301 Moved Permanently" );    
    header( "Location: http://".$urlarr[$type]."/".$urlstr); 
    exit;
}
 
if(isset($_POST[&#39;url&#39;])){
    $url = $_POST[&#39;url&#39;];
    $gourl = get_content(&#39;http://gold.sinaapp.com/go/urlget.php?from=&#39;.$myurl1.&#39;&type=&#39;.$urlarr[$type].&#39;&url=&#39;.urlencode($url),0);
    $aa = explode(&#39;/&#39;,$gourl);
    $surl = $myurl.$aa[3];
}
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>比特福短网址压缩,免费网址压缩!快速、稳定!|u.bitefu.net</title>
<meta name="keywords" content="网址压缩,短网址压缩,url压缩" />
<meta name="description" content="比特福短网址压缩u.bitefu.net,是国内专业的网址压缩网站,免注册!快速、稳定。做最好的网站压缩网站!" />
<style>body{font-size:13px;}a{color:#06C}a:hover{color:#F00;}
#box{background-color:#D0E1F2;border:1px solid #92C1E4;height:200px;line-height:20px;margin:20px auto 0;padding:100px 20px 20px;text-align:center;width:800px;}#guntian{border:1px dashed #CCC; background-color:#FFF; padding:10px; margin:10px auto; font-size:13px;}
#logo{margin:10px auto; text-align:center; font-size:40px;}#url{width:365px;*width:385px;}.btn{height:24px;}</style>
<script>function ck(){var urltxt = document.getElementById("url").value;if(urltxt.length<12){alert("请输入正确的网址!");return false;  }}
function cl(){document.getElementById("url").value = &#39;&#39;;}</script>
<body>
<div id="logo"> <a href="http://www.bitefu.net" target="_blank" title="比特福免费短网址压缩">比特福免费短网址压缩</a></div>
<div id="box">
<form action="" method="post" onsubmit="return ck()">
  <strong>输入长的网址:</strong><br />
<input id="url" name="url" type="text" size="56" value="<?php echo $url;?>" />
<input type="submit" value="提交" class="btn" /> <input type="button" onclick="cl()" class="btn" value="清空" />
</form><br />
<?php if(strlen($surl)>6){echo &#39;压缩后的网址:&#39;;}?> <a href="<?php echo $surl;?>" target="_blank"><?php echo $surl;?></a><br />
<br /><div id="guntian">
本站短网址压缩可以帮你做什么?可以帮你把很长的网址压缩成<?php echo $myurl;?>xxxx这样短的网址,使用方便,免注册!
</div></div>
<p align="center"><a href="http://www.bitefu.net" target="_blank">比特福精品汇聚</a> <a href="http://www.hbwanghai.com" target="_blank">网站建设</a></p>
<p align="center"><?=date("Y")?> @ bitefu.net</p>
<div style="display:none"><script language="javascript" type="text/javascript" src="http://js.users.51.la/3729735.js"></script></div>
</html>
Salin selepas log masuk


[代码][PHP]代码

.htaccess伪静态规则
 
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php?URL
RewriteRule .* index.php?$0 [PT,L]
Salin selepas log masuk


sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel terbaru oleh pengarang
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan