php余址转换实现
php短址转换实现
从昨天下午到现在 推翻了一个又一个的信息存储方案,从mysql到加上内存不受限制的file_get_contents,再到格式化输入的fscanf,最终选择了比较成熟稳定的读取ini的方法。
允许转载,转载须注明出处。
整个主程序只有两个文件 zipurl.php、index.php
zipurl.php:
<?php #此文件用于转换url#整理urlfunction dealurl($url){ if($url[4]!=':')$url='http://'.$url; return $url;}function ranum(){$str="0123456789abcdefghijklmnopqrstuvwxyz";$tmp=$str[mt_rand(0,35)].$str[mt_rand(0,35)].$str[mt_rand(0,35)].$str[mt_rand(0,35)].$str[mt_rand(0,35)];return $tmp;}#存号function zipurl($urls){ #查号去重 $handle = fopen("url.tmp","r+"); $array=parse_ini_file("url.tmp",true); if(array_search($urls, $array))return array_search($urls, $array); $num=ranum(); fprintf($handle,"%s=%s\r",$num,$urls); fclose($handle); return $num;}function main(){ if($url=$_GET['url']) { $url=dealurl($url); $url=zipurl($url); echo "http://localhost/?".$url; }}main();?><meta charset="utf-8"><title>ZIP your URL</title><link rel="stylesheet" href="assets/css/amazeui.min.css"><div class="am-g"> <div class=" col-md-8 col-sm-centered"> <form class="am-form" action="zipurl.php" method="get"> <fieldset class="am-form-set"> <input type="text" id="url" name="url" placeholder="输入你想转换的网址"> </fieldset> <div><button type="submit" class="am-btn am-btn-primary am-btn-block">转换</button></div> </form> </div> </div>
<?php #查号 #短址访问部分function readfiles($strs){ $array=parse_ini_file("url.tmp",true); var_dump($array); return $array[$strs];}function main(){ #转到模块 if($str=$_SERVER['QUERY_STRING']) echo '<script language="javascript">location.href="'.readfiles($str).'";';}main();#统计部分?><meta charset="utf-8"><title>ZIP your URL</title><link rel="stylesheet" href="assets/css/amazeui.min.css"><div class="am-g"> <div class=" col-md-8 col-sm-centered"> <form class="am-form" action="zipurl.php" method="get"> <fieldset class="am-form-set"> <input type="text" id="url" name="url" placeholder="输入你想转换的网址"> </fieldset> <button type="submit" class="am-btn am-btn-primary am-btn-block">转换</button> </form> </div> </div>
临时文件url.tmp
aaaaa=http://baidu.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

PHP function introduction—get_headers(): Overview of obtaining the response header information of the URL: In PHP development, we often need to obtain the response header information of the web page or remote resource. The PHP function get_headers() can easily obtain the response header information of the target URL and return it in the form of an array. This article will introduce the usage of get_headers() function and provide some related code examples. Usage of get_headers() function: get_header

Concepts and instances of classes and methods Class (Class): used to describe a collection of objects with the same properties and methods. It defines the properties and methods common to every object in the collection. Objects are instances of classes. Method: Function defined in the class. Class construction method __init__(): The class has a special method (construction method) named init(), which is automatically called when the class is instantiated. Instance variables: In the declaration of a class, attributes are represented by variables. Such variables are called instance variables. An instance variable is a variable modified with self. Instantiation: Create an instance of a class, a specific object of the class. Inheritance: that is, a derived class (derivedclass) inherits the base class (baseclass)

Nowadays, many Windows users who love games have entered the Steam client and can search, download and play any good games. However, many users' profiles may have the exact same name, making it difficult to find a profile or even link a Steam profile to other third-party accounts or join Steam forums to share content. The profile is assigned a unique 17-digit id, which remains the same and cannot be changed by the user at any time, whereas the username or custom URL can. Regardless, some users don't know their Steamid, and it's important to know this. If you don't know how to find your account's Steamid, don't panic. In this article

The reason for the error is NameResolutionError(self.host,self,e)frome, which is an exception type in the urllib3 library. The reason for this error is that DNS resolution failed, that is, the host name or IP address attempted to be resolved cannot be found. This may be caused by the entered URL address being incorrect or the DNS server being temporarily unavailable. How to solve this error There may be several ways to solve this error: Check whether the entered URL address is correct and make sure it is accessible Make sure the DNS server is available, you can try using the "ping" command on the command line to test whether the DNS server is available Try accessing the website using the IP address instead of the hostname if behind a proxy

Use url to encode and decode the class java.net.URLDecoder.decode(url, decoding format) decoder.decoding method for encoding and decoding. Convert into an ordinary string, URLEncoder.decode(url, encoding format) turns the ordinary string into a string in the specified format packagecom.zixue.springbootmybatis.test;importjava.io.UnsupportedEncodingException;importjava.net.URLDecoder;importjava.net. URLEncoder

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Differences: 1. Different definitions, url is a uniform resource locator, and html is a hypertext markup language; 2. There can be many urls in an html, but only one html page can exist in a url; 3. html refers to is a web page, and url refers to the website address.
