Online Short address service
G ($ pageb); if (! $ Dangqian) {$ dangqian = 1; $ MUM-> s ($ pageb, 1);} // Current urlif ($ _ POST ['URL']) {$ wz = mima ($ _ POST ['URL']); if ($ MUM-> g ($ wz )) {$ zhi = $ MUM-> g ($ wz); echo $ mbox. URL. $ zhi;} else {$ danzhi = dechex ($ dangqian); $ url = mima ('@'. $ danzhi); $ MUM-> s ($ url, $ _ POST ['URL']); $ MUM-> s ($ wz, $ danzhi ); $ MUM-> j ($ pageb, 1); echo $ mbox. URL. $ danzhi; $ dangqian + = 1 ;}} if ($ _ POST ['yuanyuan ']) {$ urlv = $ MUM-> g (mima ('@'. $ _ POST ['yuanyuan ']); if ($ urlv) {$ urlv = str_replace ("script", '', strtolower ($ urlv )); echo 'restored URL :'. $ urlv;} else echo 'URL not compressed ';} function arr2file ($ filename, $ arr = '') {if (is_array ($ arr )) {$ con = var_export ($ arr, true);} else {$ con = $ arr;} $ con ="
';foreach($args as $arg){if(is_array($arg)){ print_r($arg); echo '
'; }else if(is_string($arg)){echo $arg.'
'; }else{var_dump($arg);echo '
'; }} echo '
';} Class Mem {// Memcache // r (name, value) replace value // s (name, value, time) set value // g (name) obtain the value // a (name, value, time). if a new value is not created, false is returned. // d (name); delete the value // f (); clear // ja (name, quantity); // quantity to be deleted // j (name, quantity); // add quantity // gS (); get the statistical value // gV (); get the private $ md = null version; function _ construct () {$ md = new Pxhc; $ this-> md = $ md ;} public function r ($ key, $ value) {// Obtain the object return $ this-> md-> replace ($ key, $ value);} public function s ($ key, $ value, $ time = 0) {// set the return $ this-> md-> set ($ Key, $ value, MEMCACHE_COMPRESSED, $ time);} public function g ($ key) {// get the return $ this-> md-> get ($ key);} public function a ($ key, $ value, $ time = 0) {return $ this-> md-> add ($ key, $ value, MEMCACHE_COMPRESSED, $ time);} public function d ($ key) {// delete a value return $ this-> md-> delete ($ key); // delete a value} public function f () {// clear all flush return $ this-> md-> flush ();} public function ja ($ key, $ num = 1 ){ // Addition operation return $ this-> md-> decrement ($ key, $ num);} public function j ($ key, $ num = 1) {// budget subtraction return $ this-> md-> increment ($ key, $ num);} public function gS () {// Obtain the running system statistics of all processes in the process pool. return $ this-> md-> getExtendedStats ();} public function gV () {// version return $ this-> md-> getVersion ();} public function error () {// determine whether to enable $ stats = $ this-> md-> getStats (); if (empty ($ stats) return false; else r Eturn true ;}} class Pxhc {// text cache public function replace ($ key, $ value) {// replacement rule $ pat = Txpath. $ key. '. php '; if (file_exists ($ pat) {arr2file ($ pat, $ value); return $ value;} else return false;} public function add ($ key, $ value, $ num = '', $ time) {// if $ pat = Txpath exists. ($ key ). '. php '; if (file_exists ($ pat) return false; else {arr2file ($ pat, $ value); return $ value ;}} public function increment ($ key, $ num ){// Add entry $ pat = Txpath. urlencode ($ key ). '. php '; if (file_exists ($ pat) {$ value = include $ pat; $ value = $ value * 1 + $ num; arr2file ($ pat, $ value ); return $ value;} else return false;} public function getExtendedStats () {$ zzz = Txpath; $ nums = 0; $ mydir = dir ($ zzz ); // read the configuration file while ($ file = $ mydir-> read () {if ($ file! = ".") And ($ file! = ".. ") And (strstr ($ file ,". php ") {$ file = str_replace (". php ",'', $ file); $ files [] = $ file; $ nums ++ ;}$ mydir-> close (); $ files ['nums'] = 'variable count :'. $ nums. '; return $ files;} public function decrement ($ key, $ num) {// subtract entry $ pat = Txpath. $ key. '. php '; if (file_exists ($ pat) {$ value = include $ pat; $ value = $ value * 1-$ num; arr2file ($ pat, $ value ); return $ value;} else return false;} public function get ($ key ){ // Obtain the value $ pat = Txpath. $ key. '. php '; if (file_exists ($ pat) {return include $ pat;} else return false;} public function delete ($ key) {// delete value $ pat = Txpath. urlencode ($ key ). '. php '; if (file_exists ($ pat) {unlink ($ pat); return true;} else return false;} public function flush () {// delete all $ zzz = Txpath; $ mydir = dir ($ zzz); // read the configuration file while ($ file = $ mydir-> read ()) {if ($ file! = ".") And ($ file! = ".. ") {$ Files = $ zzz. $ file; unlink ($ files) ;}}$ mydir-> close (); return true;} public function set ($ key, $ value, $ ss, $ time) {// set the value $ pat = Txpath. $ key. '. php'; if (! Is_array ($ value) $ value = "'". $ value. "'"; arr2file ($ pat, $ value); return $ value;} public function getVersion () {return '0. 0.1 '; }}$ PATHINFOS = ltrim (strtolower ($ _ SERVER ['path _ info']),'/'); $ urlv = $ MUM-> g (mima ('@'. $ PATHINFOS); if ($ urlv) {header ('http/1.1 302 found'); header ("Location: $ urlv"); die ;}?>
The above is the content of the online short address service. For more information, see The PHP Chinese website (www.php1.cn )!