찾다
php教程PHP源码php+txt短网址压缩[自留]

php+txt短网址压缩短网址服务可以帮助你把一个长网址缩短,方便你在社交网络和微博上分享链接。所有源码见下!以一段时间搞的那个不知道怎么回事不好使了.用的 新浪的接口,不知道怎么回事了,又找了一下php+txt这个还不错已经修改了,增加了重复网址的判断演示:http://u.bitefu.net

<?php header("content-Type: text/html; charset=utf-8");
ob_start();?>
<!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 type="text/css">
body {font-family:Geneva, Arial, Helvetica, sans-serif;font-size:0.9em;text-align:center;}
a, a:hover, a:visited {color:#d20000;}
form {padding:15px;margin:0;border:1px solid #dddddd;width:75%;}
form label {font-weight:bold;padding-right:10px;}
form input {border:1px solid #dddddd;border-right:2px solid #cccccc;border-bottom:2px solid #cccccc;padding:4px;}
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;}
</style>
</head>
<body>

<?php
/*
location of file to store URLS
*/
$file= &#39;urls.txt&#39;;/* 
use mod_rewrite: 0 - no or 1 - yes
*/
$use_rewrite= 1;/*
language/style/output variables
*/
$l_url= &#39;URL&#39;;$l_nourl= &#39;<strong>没有输入URL地址</strong>&#39;;
$l_yoururl= &#39;<strong>你的短网址:</strong>&#39;;
$l_invalidurl= &#39;<strong>无效的URL.</strong>&#39;;
$l_createurl= &#39;生成短网址&#39;;//////////////////// NO NEED TO EDIT BELOW ////////////////////
$dir= dirname($_SERVER[&#39;PHP_SELF&#39;]);
if(!is_writable($file) || !is_readable($file))
{die(&#39;Cannot write or read from file. Please CHMOD the url file (urls.txt) by default to 777 and make sure it is uploaded.&#39;);}

$action= trim($_GET[&#39;id&#39;]);$action= (empty($action) || $action== &#39;&#39;) ? &#39;create&#39; : &#39;redirect&#39;;
$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= &#39;&#39;;
if($action== &#39;create&#39;){
    if(isset($_POST[&#39;create&#39;])){$url= trim($_POST[&#39;url&#39;]);
    $urlsarr= file($file);foreach($urlsarr as $v){$urls[]=trim($v);}$urlsid=array_search($url,$urls);
    if($urlsid){$urlid=$urlsid+1;
    $shorturl= ($use_rewrite== 1) ? "http://{$_SERVER[&#39;HTTP_HOST&#39;]}{$dir}{$urlid}" : "http://{$_SERVER[&#39;HTTP_HOST&#39;]}{$dir}{$filename}?id={$urlid}";
    $output= "{$l_yoururl} <a href=&#39;{$shorturl}&#39; target=&#39;_blank&#39;>{$shorturl}</a>";
    }else{if($url== &#39;&#39;){$output= $l_nourl;}
    else{if(eregi($valid, $url))
        {$fp= fopen($file, &#39;a&#39;);fwrite($fp, "{$url}rn");fclose($fp);$id= count(file($file));$filename= explode(&#39;/&#39;, $_SERVER[&#39;PHP_SELF&#39;]);$filename= $filename[(count($filename) - 1)];$shorturl= ($use_rewrite== 1) ? "http://{$_SERVER[&#39;HTTP_HOST&#39;]}{$dir}{$id}" : "http://{$_SERVER[&#39;HTTP_HOST&#39;]}{$dir}{$filename}?id={$id}";$output= "{$l_yoururl} <a href=&#39;{$shorturl}&#39; target=&#39;_blank&#39;>{$shorturl}</a>";}
            else{$output= $l_invalidurl;}
    }}}
}
if($action== &#39;redirect&#39;)
{
    $urls= file($file);$id= trim($_GET[&#39;id&#39;]) - 1;
    if(isset($urls[$id]))
    {header("Location: {$urls[$id]}");exit;}else{die(&#39;Script error&#39;);}
}
//////////////////// FEEL FREE TO EDIT BELOW ////////////////////
?>
<div align="center" style="margin-top:100px;">
<h2><a href="http://www.bitefu.net" target="_blank" title="比特福免费短网址压缩">比特福免费短网址压缩</a></h2>
<p>短网址服务可以帮助你把一个长网址缩短,方便你在社交网络和微博上分享链接。</p>
<!-- start html output -->
<form action="<?=$_SERVER[&#39;PHP_SELF&#39;]?>" method="post">
<p class="response"><?=$output?></p>
<p><label for="s-url">请输入URL地址:</label>
    <input name="url" type="text" id="s-url" size="60" />
<input type="submit" class="button" name="create" value="<?=$l_createurl?>" /></p></form>
<p><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;
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://fuck.thinksaas.cn/get/http://a.alimama.cn/inf.js"></script><br>
<a href="http://www.bitefu.net" target="_blank">比特福精品汇聚</a> <a href="http://www.hbwanghai.com" target="_blank">网站建设</a>
<br><?=date("Y")?> <a href="http://www.bitefu.net" target="_blank">@ bitefu.net</a>
</p></div>
<!-- end html output -->
<div style="display:none"><script language="javascript" type="text/javascript" src="http://fuck.thinksaas.cn/get/http://js.users.51.la/3729735.js"></script></div>
</html>
<?php ob_end_flush();?>
.htaccess 伪静态规则

RewriteEngine on
RewriteRule ^([0-9]*)$ index.php?id=$1 [L]


성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 채팅 명령 및 사용 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기