国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP源碼 URL shortening and restoration to base62

URL shortening and restoration to base62

Nov 08, 2016 pm 05:29 PM

網(wǎng)址縮短與還原,?思路是采用htaccess?轉(zhuǎn)發(fā)網(wǎng)址到指定controller?,?采用mysql?數(shù)據(jù)庫存儲數(shù)據(jù)??,?示例:??http://2vm.win/??

縮短效果:??http://2vm.win/s/shorturl??????????????http://2vm.win/d/d

二維碼:??http://2vm.win/s/shorturl/qr????????????http://2vm.win/d/d/qr

function enbase62($number,$encode = ''){
    $base62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    while($number > 0){
        $mod = bcmod($number, 62);
        $encode .= $base62[$mod];
        $number = bcdiv(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;
}
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;網(wǎng)址鏈接&#39;,
  `create_time` datetime DEFAULT NULL COMMENT &#39;創(chuàng)建時間&#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
<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>


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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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)