代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
PHP
】
php+txt短网址压缩
作者:
xiaogg
/ 发布于
2012/3/6
/
537
短网址服务可以帮助你把一个长网址缩短,方便你在社交网络和微博上分享链接。
<div><?php header("content-Type: text/html; charset=utf-8");</div> <div>ob_start();?></div> <div><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></div> <div><html xmlns="http://www.w3.org/1999/xhtml"></div> <div><head></div> <div><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></div> <div><title>比特福短网址压缩,免费网址压缩!快速、稳定!|u.bitefu.net</title></div> <div><meta name="keywords" content="网址压缩,短网址压缩,url压缩" /></div> <div><meta name="description" content="比特福短网址压缩u.bitefu.net,是国内专业的网址压缩网站,免注册!快速、稳定。做最好的网站压缩网站!" /></div> <div><style type="text/css"></div> <div>body {font-family:Geneva, Arial, Helvetica, sans-serif;font-size:0.9em;text-align:center;} <div>a, a:hover, a:visited {color:#d20000;} <div>form {padding:15px;margin:0;border:1px solid #dddddd;width:75%;} <div>form label {font-weight:bold;padding-right:10px;} <div>form input {border:1px solid #dddddd;border-right:2px solid #cccccc;border-bottom:2px solid #cccccc;padding:4px;} <div>form input.button {background-color:#D20000;font-weight:bold;font-size:0.8em;color:#ffffff;border:1px solid #FF0505;border-right-color:#9E0000;border-bottom-color:#9E0000;font-family:Verdana, Arial, Helvetica, sans-serif;} <div></style></div> <div></head></div> <div><body></div> <div></div> <div><?php</div> <div>/*</div> <div>location of file to store URLS</div> <div>*/</div> <div>$file= 'urls.txt';/*</div> <div>use mod_rewrite: 0 - no or 1 - yes</div> <div>*/</div> <div>$use_rewrite= 1;/*</div> <div>language/style/output variables</div> <div>*/</div> <div>$l_url= 'URL';$l_nourl= '<strong>没有输入URL地址</strong>';</div> <div>$l_yoururl= '<strong>你的短网址:</strong>';</div> <div>$l_invalidurl= '<strong>无效的URL.</strong>';</div> <div>$l_createurl= '生成短网址';//////////////////// NO NEED TO EDIT BELOW ////////////////////</div> <div>$dir= dirname($_SERVER['PHP_SELF']);</div> if(!is_writable($file) || !is_readable($file))</div> <div>{die('Cannot write or read from file. Please CHMOD the url file (urls.txt) by default to 777 and make sure it is uploaded.');} <div></div> <div>$action= trim($_GET['id']);$action= (empty($action) || $action== '') ? 'create' : 'redirect';</div> <div>$valid= "^(https?|ftp)\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";$output= '';</div> if($action== 'create'){</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if(isset($_POST['create'])){$url= trim($_POST['url']);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>$urlsarr= file($file);foreach($urlsarr as $v){$urls[]=trim($v);}$urlsid=array_search($url,$urls);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if($urlsid){$urlid=$urlsid+1;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>$shorturl= ($use_rewrite== 1) ? "http://{$_SERVER['HTTP_HOST']}{$dir}{$urlid}" : "http://{$_SERVER['HTTP_HOST']}{$dir}{$filename}?id={$urlid}";</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>$output= "{$l_yoururl} <a href='{$shorturl}' target='_blank'>{$shorturl}</a>";</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>}else{if($url== ''){$output= $l_nourl;} <div><span class="Apple-tab-span" style="white-space:pre"> </span>else{if(eregi($valid, $url))</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>{$fp= fopen($file, 'a');fwrite($fp, "{$url}\r\n");fclose($fp);$id= count(file($file));$filename= explode('/', $_SERVER['PHP_SELF']);$filename= $filename[(count($filename) - 1)];$shorturl= ($use_rewrite== 1) ? "http://{$_SERVER['HTTP_HOST']}{$dir}{$id}" : "http://{$_SERVER['HTTP_HOST']}{$dir}{$filename}?id={$id}";$output= "{$l_yoururl} <a href='{$shorturl}' target='_blank'>{$shorturl}</a>";} <div><span class="Apple-tab-span" style="white-space:pre"> </span>else{$output= $l_invalidurl;} <div><span class="Apple-tab-span" style="white-space:pre"> </span>}}} <div>} if($action== 'redirect')</div> <div>{</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>$urls= file($file);$id= trim($_GET['id']) - 1;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if(isset($urls[$id]))</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>{header("Location: {$urls[$id]}");exit;}else{die('Script error');} <div>} <div>//////////////////// FEEL FREE TO EDIT BELOW ////////////////////</div> <div>?></div> <div><div align="center" style="margin-top:100px;"></div> <div><h2><a href="http://www.bitefu.net" target="_blank" title="比特福免费短网址压缩">比特福免费短网址压缩</a></h2></div> <div>短网址服务可以帮助你把一个长网址缩短,方便你在社交网络和微博上分享链接。</div> <div><!-- start html output --></div> <div><form action="<?=$_SERVER['PHP_SELF']?>" method="post"></div> <div><p class="response"><?=$output?></div> <div><label for="s-url">请输入URL地址:</label></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span><input name="url" type="text" id="s-url" size="60" /></div> <div><input type="submit" class="button" name="create" value="<?=$l_createurl?>" /></form></div> <div><script type="text/javascript">alimama_pid="mm_16329643_2337872_9044351";alimama_type="g";alimama_tks={};alimama_tks.style_i=1;alimama_tks.lg_i=0;</div> <div>alimama_tks.w_i=572;alimama_tks.h_i=45;alimama_tks.btn_i=1;alimama_tks.txt_s="";alimama_tks.hot_i=0;alimama_tks.hc_c="0065FF";alimama_tks.cid_i=0;alimama_tks.c_i=0;</script><script type="text/javascript" src="http://a.alimama.cn/inf.js"></script></div> <div><a href="http://www.bitefu.net" target="_blank">比特福精品汇聚</a> <a href="http://www.hbwanghai.com" target="_blank">网站建设</a></div> <div><?=date("Y")?> <a href="http://www.bitefu.net" target="_blank">@ bitefu.net</a></div> <div></div></div> <div><!-- end html output --></div> <div><div style="display:none"><script language="javascript" type="text/javascript" src="http://js.users.51.la/3729735.js"></script></div></div> <div></html></div> <div><?php ob_end_flush();?></div>
试试其它关键字
短网址
同语言下
.
用net匹配并替换iOS标准的emoji表情符号
.
处理带Emoji表情的的字符串
.
获取微信昵称时 过滤特殊字符
.
通过判断上传文件的头字符来判断文件的类型
.
模拟百度URL加密解密算法
.
以太坊检查地址是否合法
.
实现crontab解析类
.
获取每个月的开始和结束时间
.
图片上传工具类
.
APP手机应用信息采集
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
xiaogg
贡献的其它代码
(
2
)
.
在线生成二维码
.
php+txt短网址压缩
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3