Web site Shorten and restore base62-PHP source code

Source: Internet
Author: User
URL shortening and restoration base62 URL shortening and restoration 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;}
2.[SQL] code
Create table 'waoo _ empty url' ('Short _ id' int (12) not null AUTO_INCREMENT COMMENT 'auto-incrementing ID', 'short _ name' varchar (50) default null comment 'Alias ', 'title' varchar (100) default null comment' title', 'link' varchar (800) default null comment' URL link ', 'create _ time' datetime default null comment' creation time', 'uid' int (10) default null comment 'owner ', 'status' tinyint (1) DEFAULT '1' COMMENT '1 valid, 0 block-1 delete', 'Top _ domain' varchar (100) default null comment 'top-level domain name ', 'All _ domain 'varchar (100) not null comment 'domain name full', 'create _ IP' varchar (15) not null comment 'IP ', primary key ('Short _ id'), unique key 'short _ name' ('Short _ name') ENGINE = MyISAM AUTO_INCREMENT = 12 default charset = utf8
3.[C/C ++] code
 
    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]
 

The above is the content for shortening and restoring base62 on the website. For more information, see The PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.