Home php教程 PHP源码 在线短地址服务

在线短地址服务

May 25, 2016 pm 05:08 PM

在线短地址服务

<?php
header("Content-Type:text/html;charset=utf-8");

define(&#39;Txpath&#39;, dirname(__FILE__).&#39;/aytemp/&#39;);  //缓存目录

define(&#39;URL&#39;,&#39;http://127.0.0.4/&#39;); //程序主域名

define(&#39;ANYOUAPI&#39;,&#39;anyou&#39;);

$pageb = mima(&#39;当前页码&#39;);

$mbox = &#39;压缩后的网址:&#39;;

$MUM = new Mem();

$dangqian = $MUM -> g( $pageb);

if( !$dangqian ){
  $dangqian = 1 ;$MUM -> s( $pageb,1);
}  //当前url



if($_POST[&#39;url&#39;]){ 
$wz = mima($_POST[&#39;url&#39;]);

if($MUM -> g($wz)){ $zhi =  $MUM -> g($wz); echo  $mbox.URL.$zhi; 
}
else{$danzhi =   dechex($dangqian); $url = mima(&#39;@&#39;.$danzhi); $MUM -> s($url,$_POST[&#39;url&#39;]);
 $MUM -> s($wz,   $danzhi); 
$MUM -> j( $pageb,1);  echo   $mbox.URL.$danzhi;
$dangqian+=1;
}

}


	
if($_POST[&#39;yuan&#39;]){
		
$urlv = $MUM -> g(mima(&#39;@&#39;.$_POST[&#39;yuan&#39;]));
		
if($urlv){
$urlv = str_replace("script",&#39;&#39;,strtolower($urlv));
 
	echo &#39;还原后的网址:&#39;.$urlv ;

}else
  echo &#39;网址没有压缩&#39;;


}



function arr2file($filename, $arr=&#39;&#39;){
	if(is_array($arr)){
		$con = var_export($arr,true);
	} else{
		$con = $arr;
	}
	$con = "<?php \nreturn $con;\n";
        file_put_contents($filename, $con);
}

function mima($var){  

   $varstr = strlen($var);
   $hash = md5(md5(base64_encode($var.&#39;13yd~!@#$%^&*(){}[1500]&#39;).$varstr));
   return substr($hash,6,16);
	 
 }


function p(){
	 $args=func_get_args();
	 if(count($args)<1) return;
	 echo &#39;<p style="width:100%;text-align:left"><pre class="brush:php;toolbar:false">&#39;;

	foreach($args as $arg){
		if(is_array($arg)){  
			  print_r($arg);
			  echo &#39;<br>&#39;;
		  }else if(is_string($arg)){
			echo $arg.&#39;<br>&#39;;
		  }else{
			var_dump($arg);
			echo &#39;<br>&#39;;
		  }
		}
		    echo &#39;

'; } class Mem{ //Memcache //r(名,值) 替换值 //s(名,值,时间) 设置值 //g(名) 获取值 //a(名,值,时间) 新建立值 没有就新建 有就返回 false; //d(名);删除值 //f(); 清空 //ja(名,数量);//减的数量 //j(名,数量);//加的数量 //gS();获取统计值 //gV();获得版本 private $md = null; function __construct(){ $md = new Pxhc; $this->md=$md; } public function r($key, $value){ //获取对象 return $this -> md -> replace( $key, $value); } public function s($key,$value,$time=0){ //设置值 return $this -> md -> set( $key, $value, MEMCACHE_COMPRESSED, $time); } public function g($key){ //获取值 return $this -> md -> get( $key); } public function a( $key, $value, $time=0){ return $this -> md -> add( $key, $value, MEMCACHE_COMPRESSED, $time); } public function d( $key){ //删除一个值 return $this -> md -> delete( $key); //删除一个值 } public function f(){ //清空全部flush return $this -> md -> flush(); } public function ja( $key, $num=1){ //加法运算 return $this -> md -> decrement( $key, $num); } public function j( $key, $num=1){ //减法预算 return $this -> md -> increment( $key, $num); } public function gS(){ //获取进程池中所有进程的运行系统统计 return $this -> md -> getExtendedStats(); } public function gV(){ //版本 return $this -> md -> getVersion(); } public function error(){ //判断是否开启 $stats = $this -> md -> getStats(); if( empty( $stats )) return false; else return true; } } class Pxhc{ //文本缓存 public function replace($key, $value){ //替换规则 $pat = Txpath.$key.'.php'; if(file_exists( $pat)){ arr2file( $pat,$value); return $value; } else return false; } public function add($key, $value, $num='', $time){ //如果存在 $pat = Txpath.($key).'.php'; if(file_exists( $pat)) return false; else{ arr2file( $pat,$value); return $value;} } public function increment($key,$num){ //加 条目 $pat = Txpath.urlencode($key).'.php'; if(file_exists($pat)){ $value = include $pat; $value = $value*1+$num; arr2file($pat,$value); return $value; }else return false; } public function getExtendedStats(){ $zzz = Txpath; $nums = 0; $mydir = dir($zzz); //读取配置文件 while($file = $mydir->read()){ if(($file != ".") and ($file != "..") and (strstr($file,".php"))){ $file = str_replace(".php",'',$file); $files[] = $file; $nums++; } } $mydir -> close(); $files['Nums'] = '变量数:'.$nums.'个'; return $files; } public function decrement($key,$num){ //减 条目 $pat = Txpath.$key.'.php'; if(file_exists( $pat)){ $value = include $pat; $value = $value*1-$num; arr2file($pat,$value); return $value; }else return false; } public function get($key){ //获取值 $pat = Txpath.$key.'.php'; if(file_exists($pat)){ return include $pat; }else return false; } public function delete($key){ //删除值 $pat = Txpath.urlencode($key).'.php'; if(file_exists($pat)){ unlink($pat); return true; }else return false; } public function flush(){ //删除全部 $zzz = Txpath; $mydir = dir($zzz); //读取配置文件 while($file = $mydir -> read()){ if(($file!=".") and ($file!="..")){ $files=$zzz.$file; unlink($files); } } $mydir->close(); return true; } public function set($key, $value, $ss, $time){ //设置值 $pat = Txpath.$key.'.php'; if(!is_array($value))$value="'".$value."'"; arr2file($pat,$value); return $value; } public function getVersion(){ return '0.0.1'; } } $PATHINFOS = ltrim(strtolower($_SERVER['PATH_INFO']),'/'); $urlv = $MUM -> g(mima('@'.$PATHINFOS)); if($urlv){ header('HTTP/1.1 302 Found'); header("Location: $urlv"); die; } ?>
以压缩个网址 网址压缩: 网址还原:
Copy after login

 以上就是在线短地址服务的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix 'Service is not responding' error in Windows. How to fix 'Service is not responding' error in Windows. Apr 27, 2023 am 08:16 AM

The NETSTART command is a built-in command in Windows that can be used to start and stop services and other programs. Sometimes, you may encounter NetHelpmsg2186 error while running this command. Most users who encounter this error try to restart the Windows Update service by running the NETSTARTWUAUSERV command. If the Windows Update service is disabled or not running, your system may be at risk as you will not be able to get the latest updates. Let’s explore in detail why this error occurs and how to bypass it. Okay? What is error 2186? Windows Update service installs the latest critical updates and security features

How to develop an online restaurant reservation system using Laravel How to develop an online restaurant reservation system using Laravel Nov 02, 2023 pm 01:48 PM

How to use Laravel to develop an online restaurant reservation system In recent years, with the rapid development of the Internet and mobile Internet, online reservations have become an indispensable part of modern people's lives. The catering industry is no exception. More and more restaurants are beginning to provide online reservation services to improve user experience and expand market share. This article will introduce how to use the Laravel framework to develop a simple but fully functional online restaurant reservation system, and provide specific code examples to facilitate readers to learn and practice. Environment setup First, we need

Solution to Windows 10 Security Center service being disabled Solution to Windows 10 Security Center service being disabled Jul 16, 2023 pm 01:17 PM

The Security Center service is a built-in computer protection function in the win10 system, which can protect computer security in real time. However, some users encounter a situation where the Security Center service is disabled when booting the computer. What should they do? It's very simple. You can open the service panel, find the SecurityCenter item, then right-click to open its properties window, set the startup type to automatic, and then click Start to start the service again. What to do if the Win10 Security Center service is disabled: 1. Press "Win+R" to open the "Operation" window. 2. Then enter the "services.msc" command and press Enter. 3. Then find the "SecurityCenter" item in the right window and double-click it to open its properties window.

How to open Remote Desktop Connection Service using command How to open Remote Desktop Connection Service using command Dec 31, 2023 am 10:38 AM

Remote desktop connection has brought convenience to many users' daily lives. Some people want to use commands to connect remotely, which is more convenient to operate. So how to connect? Remote Desktop Connection Service can help you solve this problem by using a command to open it. How to set up the remote desktop connection command: Method 1. Connect remotely by running the command 1. Press "Win+R" to open "Run" and enter mstsc2, then click "Show Options" 3. Enter the IP address and click "Connect". 4. It will show that it is connecting. Method 2: Connect remotely through the command prompt 1. Press "Win+R" to open "Run" and enter cmd2. In the "Command Prompt" enter mstsc/v:192.168.1.250/console

How to enable audio service in win7 How to enable audio service in win7 Jul 10, 2023 pm 05:13 PM

Computers have many system services to support the application of various programs. If the computer has no sound and most audio services are not turned on after troubleshooting hardware problems, how do you enable audio services in win7? Many friends are confused, so for the question of how to enable the audio service in win7, the editor below will introduce how to enable the audio service in win7. How to enable audio service in win7. 1. Find the computer on the computer desktop under Windows 7 system, right-click and select the management option. 2. Find and open the service item under Services and Applications in the computer management interface that opens. Find WindowsAudio on the service interface on the right and double-click to open the modification. 4. Switch to the regular project and click Start to enable the function.

What is the correct way to restart a service in Linux? What is the correct way to restart a service in Linux? Mar 15, 2024 am 09:09 AM

What is the correct way to restart a service in Linux? When using a Linux system, we often encounter situations where we need to restart a certain service, but sometimes we may encounter some problems when restarting the service, such as the service not actually stopping or starting. Therefore, it is very important to master the correct way to restart services. In Linux, you can usually use the systemctl command to manage system services. The systemctl command is part of the systemd system manager

Verification codes can't stop robots! Google AI can accurately identify blurry text, while GPT-4 pretends to be blind and asks for help Verification codes can't stop robots! Google AI can accurately identify blurry text, while GPT-4 pretends to be blind and asks for help Apr 12, 2023 am 09:46 AM

“The most annoying thing is all kinds of weird (or even perverted) verification codes when you log into a website.” Now, there is good news and bad news. The good news is: AI can do this for you. If you don’t believe me, here are three real cases of increasing recognition difficulty: And these are the answers given by a model called “Pix2Struct”: Are they all accurate and word for word? Some netizens lamented: Sure, the accuracy is better than mine. So can it be made into a browser plug-in? ? Yes, some people said: Even though these cases are relatively simple, if you just fine-tune it, I can't imagine how powerful the effect will be. So, the bad news is - the verification code will soon be unable to stop the robots! (Danger danger danger...) How to do it? Pix2St

Online Invoice Management System Development Guide in PHP Online Invoice Management System Development Guide in PHP Jun 11, 2023 am 08:38 AM

With the popularity of e-commerce, more and more businesses are adopting online invoice management systems to manage sales and invoices. When developing an online invoice management system, it is important to choose the right tools and technology. This article will introduce how to use PHP language to develop an online invoice management system and provide some useful development guidelines. Determine system requirements Before starting development, the specific requirements for an online invoice management system need to be determined. This may include the following aspects: Invoice management: saving, querying and editing invoice information; Customer information management: saving, querying and editing customers

See all articles