Php user authentication base64 verification method. Php Tutorial user verification base64 verification method cookie processing functiondsetcookie ($ var, $ value, $ life0, $ prefix1) {global $ cookiedomain, $ cookiepath, $ addtime, $ _ server; setcooki php Tutorial user verification base64 verification method
// Cookie processing
Function dsetcookie ($ var, $ value, $ life = 0, $ prefix = 1 ){
Global $ cookiedomain, $ cookiepath, $ addtime, $ _ server;
Setcookie ($ var, $ value, $ life? $ Addtime + $ life: 0, $ cookiepath, $ cookiedomain, $ _ server ['server _ port'] = 443? 1: 0 );
}
Function authcode ($ string, $ operation = 'Decode', $ key = '', $ expiry = 0 ){
Global $ webaddr;
$ Auth_key = md5 ($ webaddr );
$ Ckey_length = 4;
$ Key = md5 ($ key? $ Key: $ auth_key );
$ Keya = md5 (substr ($ key, 0, 16 ));
$ Keyb = md5 (substr ($ key, 16, 16 ));
$ Keyc = $ ckey_length? ($ Operation = 'decode '? Substr ($ string, 0, $ ckey_length): substr (md5 (microtime (),-$ ckey_length )):'';
$ Cryptkey = $ keya. md5 ($ keya. $ keyc );
$ Key_length = strlen ($ cryptkey );
$ String = $ operation = 'decode '? Base64_decode (substr ($ string, $ ckey_length): sprintf ('% 010d', $ expiry? $ Expiry + time (): 0). substr (md5 ($ string. $ keyb), 0, 16). $ string;
$ String_length = strlen ($ string );
$ Result = '';
$ Box = range (1, 0,255 );
$ Rndkey = array ();
For ($ I = 0; $ I <= 255; $ I ++ ){
$ Rndkey [$ I] = ord ($ cryptkey [$ I % $ key_length]);
}
For ($ j = $ I = 0; I I <256; $ I ++ ){
$ J = ($ j + $ box [$ I] + $ rndkey [$ I]) % 256;
$ Tmp = $ box [$ I];
$ Box [$ I] = $ box [$ j];
$ Box [$ j] = $ tmp;
}
For ($ a = $ j = $ I = 0; $ I <$ string_length; $ I ++ ){
$ A = ($ a + 1) % 256;
$ J = ($ j + $ box [$ a]) % 256;
$ Tmp = $ box [$ a];
$ Box [$ a] = $ box [$ j];
$ Box [$ j] = $ tmp;
$ Result. = chr (ord ($ string [$ I]) ^ ($ box [($ box [$ a] + $ box [$ j]) % 256]);
}
If ($ operation = 'decode '){
If (substr ($ result, 0, 10) = 0 | substr ($ result, 0, 10)-time ()> 0) & substr ($ result, 10, 16) = substr (md5 (substr ($ result, 26 ). $ keyb), 0, 16 )){
Return substr ($ result, 26 );
} Else {
Return '';
}
} Else {
Return $ keyc. str_replace ('=', '', base64_encode ($ result ));
}
}
?>
Users user verification base64 verification method // cookie processing function dsetcookie ($ var, $ value, $ life = 0, $ prefix = 1) {global $ cookiedomain, $ cookiepath, $ addtime, $ _ server; setcooki...