Table of Contents
" >2. [SQL]代码 
3.[C/C++]代码 
Home php教程 PHP源码 网址缩短与还原base62

网址缩短与还原base62

May 26, 2016 am 08:18 AM

网址缩短与还原base62

function enbase62($number,$encode = ''){
    $base62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    while($number > 0){
        $mod = bcmod($number, 62);
        $encode .= $base62[$mod];
        $number = bcp(bcsub($number, $mod), 62);
    }
    return strrev($encode);
}

function debase62($encode, $number = 0){
    $base62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $length = strlen($encode);
    $baselist = array_flip(str_split($base62));
    for($i = 0; $i < $length; $i++){
        $number = bcadd($number, bcmul($baselist[$encode[$i]], bcpow(62, $length - $i - 1)));
    }
    return $number;
}
Copy after login

2. [SQL]代码

CREATE TABLE `waoo_shorturl` (
  `short_id` int(12) NOT NULL AUTO_INCREMENT COMMENT &#39;自增id&#39;,
  `short_name` varchar(50) DEFAULT NULL COMMENT &#39;别名&#39;,
  `title` varchar(100) DEFAULT NULL COMMENT &#39;标题&#39;,
  `link` varchar(800) DEFAULT NULL COMMENT &#39;网址链接&#39;,
  `create_time` datetime DEFAULT NULL COMMENT &#39;创建时间&#39;,
  `uid` int(10) DEFAULT NULL COMMENT &#39;拥有者&#39;,
  `status` tinyint(1) DEFAULT &#39;1&#39; COMMENT &#39;1有效, 0封禁 -1删除&#39;,
  `top_domain` varchar(100) DEFAULT NULL COMMENT &#39;顶级域名&#39;,
  `all_domain` varchar(100) NOT NULL COMMENT &#39;域名全文&#39;,
  `create_ip` varchar(15) NOT NULL COMMENT &#39;ip&#39;,
  PRIMARY KEY (`short_id`),
  UNIQUE KEY `short_name` (`short_name`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8
Copy after login

3.[C/C++]代码

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  RewriteRule /d/(?!index)(.*) /d/index/?short_id=$1 [L,NC]
  RewriteRule /s/(?!index)(.*) /s/index/?short_name=$1 [L,NC]
  
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
Copy after login

           

 以上就是网址缩短与还原base62的内容,更多相关内容请关注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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
How to enter the URL in steam? How to open a website on steam How to enter the URL in steam? How to open a website on steam Mar 14, 2024 pm 12:10 PM

If you want to check some relevant information in Steam or share some website links with friends, how do you do it? Can I enter a URL into steam? Of course it is possible. Below I will teach you how to open a URL in Steam. Specific methods: 1. First, we open steam. 2. Click the Settings option. 3. Then switch to the interface tab. 4. Check Show address bar. 5. Then enter the URL in the address bar to use the browser.

What does php detect URL mean? What does php detect URL mean? Jul 18, 2023 am 11:02 AM

PHP URL detection refers to using the PHP programming language to verify whether the input string conforms to the format of the URL. Methods to detect URLs: 1. Use regular expressions for URL verification. You can use the "preg_match" function to perform regular matching, if the URL matches the pattern; 2. Use built-in functions for URL verification, use the "filter_var" function and "FILTER_VALIDATE_URL" ” filter to verify.

Teach you how to use PHP to remove the suffix of the URL path Teach you how to use PHP to remove the suffix of the URL path Mar 21, 2024 pm 03:39 PM

Teach you how to use PHP to remove the suffix of the URL path. In website development, you often encounter the need to remove the suffix of the URL path to achieve a more beautiful and standardized URL. Today we will learn how to use PHP to remove the suffix of the URL path, let us explore this issue together. First, we need to clarify what effect we want to achieve. Usually, the URL path suffix refers to the file extension in the URL, such as .php, .html, etc. Our goal is to automatically go to the URL when the user accesses the URL with the suffix

ok trading platform website 2023 ok trading platform official website update link ok trading platform website 2023 ok trading platform official website update link Feb 07, 2024 am 11:10 AM

New users download and win blind boxes up to 60,000 yuan. The official website of OK Exchange is a website with one of the largest accounts among virtual currency exchanges. Its rich trading modes and multiple digital asset types allow you to enjoy different trading experiences. If you need it, you can click on the OK exchange URL at the top of the page to enter and download. AndroidOKX6.4.0 has been released to the official website (update time: 2023.3.4) Trading: – Commission aggregation of all order types – K-line buying and selling points 2nd period – Contract DCA – Copying Square online search function Web3: – Import wallet list to increase address display – gasPrice multiple adjustment – ​​Gas gas station supports Tron chain – Farm increases Pool income Fin

What is the URL for downloading the win10 image? What is the URL for downloading the win10 image? Jul 10, 2023 am 09:25 AM

Where can I download genuine Microsoft win10 image system iso? Nowadays, win10 system software has gradually become a popular operating system, and many users will choose this system software. So next, the editor will tell you about the website where you can download the win10 image system. What is there? What is the win10 image download website? 1. Go to Microsoft Windows 10 official download tool page, enter the query to download the tool and click to download. Website: https://www.microsoft.com/zhcn/softwaredownload/windows10. 2. Start downloading the excellent Windows 10 download tool. If you only want to download the system image, then

How to set the URL for tplink router How to set the URL for tplink router Mar 06, 2024 pm 04:10 PM

Setting method: 1. First open the browser and enter "192.168.0.1, 192.168.1.1"; 2. Enter the password and username account behind the router; 3. After logging in to the setting interface, you can follow the wizard steps; 4. , then you can set the Internet access method, there are three methods available; 5. Select pppoe Internet access and you need to fill in the account password to operate; 6. Perform wireless settings according to needs; 7. Wait for success.

How to replace link address in php How to replace link address in php Sep 22, 2021 am 09:29 AM

How to replace the link address in PHP: 1. Obtain the current script URL through the "function GetCurUrl(){...}" method; 2. Obtain the current script URL through the "function url_set_value($url,$key,$value) {...}" Just use the method to implement link replacement.

USB boot master website USB boot master website Feb 10, 2024 pm 11:18 PM

Tutorial on how to use the u master U disk boot disk creation tool 1. Insert the U disk into the computer, open the downloaded u master U disk startup disk creation tool: www.uzhuangji.net, select the U disk 2. Directly click one-click to create the U disk according to the default mode 3. A prompt message will appear. Making a U disk boot disk will clear all data on the U disk and back up the U disk data. Click OK. 4. Then wait for the U disk to be formatted. 5. After waiting, the U disk boot disk production will appear. Tips for completion

See all articles