Php + txt short URL compression [left]-PHP source code

Source: Internet
Author: User
Php + txt short URL compression [self-saving] php + txt short URL compression short URL service can help you shorten a long URL, so that you can share links on social networks and Weibo. For all source code, see! I don't know what's going on for a while. with Sina interface, I don't know what's going on, and find the php + txt this is not bad has been modified, added the repeat URL judgment demonstration: http://u.bitefu.net

 
 Bitford short URL compression, free URL compression! Fast and stable! | U.bitefu.net
 
 
 No URL entered'; $ L_yoururl ='Your short URL:'; $ L_invalidurl ='Invalid URL.'; $ L_createurl = 'generate short website '; /// // no need to edit below /////////////// //// $ dir = dirname ($ _ SERVER ['php _ SELF ']); if (! Is_writable ($ file) |! Is_readable ($ file) {die ('cannot write or read from file. please CHMOD the url file (urls.txt) by default to 777 and make sure it is uploaded. ') ;}$ action = trim ($ _ GET ['id']); $ action = (empty ($ action) | $ action = '')? 'Create': 'redirect'; $ valid = "^ (https? | Ftp): // ([a-z0-9 +! *(),;? & =$ _.-] + (: [A-z0-9 +! *(),;? & =$ _.-] + )? @)? [A-z0-9 + $ _-] + (. [a-z0-9 + $ _-] +) * (: [0-9 })? (/([A-z0-9 + $ _-].?) + )*/? (? [A-z + & $ _.-] [a-z0-9;: @/& % = + $ _.-] *)? (# [A-z _.-] [a-z0-9 + $ _.-] *)? $ "; $ Output =''; if ($ action = 'create') {if (isset ($ _ POST ['create']) {$ url = trim ($ _ POST ['URL']); $ urlsarr = file ($ file); foreach ($ urlsarr as $ v) {$ urls [] = trim ($ v) ;}$ urlsid = array_search ($ url, $ urls); if ($ urlsid) {$ urlid = $ urlsid + 1; $ export url = ($ use_rewrite = 1 )? "Http: // {$ _ SERVER ['http _ host']} {$ dir} {$ urlid}": "HTTP: // {$ _ SERVER ['http _ host']} {$ dir} {$ filename }? Id = {$ urlid} "; $ output =" {$ l_yoururl} {$ url} ";} else {if ($ url = '') {$ output = $ l_nourl;} else {if (eregi ($ valid, $ url) {$ fp = fopen ($ file, 'A'); fwrite ($ fp, "{$ url} rn"); fclose ($ fp); $ id = count (file ($ file); $ filename = explode ('/', $ _ SERVER ['php _ SELF ']); $ filename = $ filename [(count ($ filename)-1)]; $ response url = ($ use_rewrite = 1 )? "Http: // {$ _ SERVER ['http _ host'] }{$ dir} {$ id}": "HTTP: // {$ _ SERVER ['http _ host']} {$ dir} {$ filename }? Id = {$ id} "; $ output =" {$ l_yoururl} {$ invalid URL} ";} else {$ output = $ l_invalidurl ;}}}}} if ($ action = 'redirect') {$ urls = file ($ file); $ id = trim ($ _ GET ['id'])-1; if (isset ($ urls [$ id]) {header ("Location: {$ urls [$ id]}"); exit ;} else {die ('script error ');}} ///// // feel free to edit below /////////////// /// //?>

Bitford free short URL compression

The short website service can help you shorten a long website so that you can share links on social networks and Weibo.

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.