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.