Site A, site B, Site C, cross-domain, site B as a unified certification center, site A, Site C login requests forwarded to Site B, site B as a unified login, the registry, also known as a third-party identity certification Center; Users log in to the third-party certification center from different sites, and after completing the login verification, Will generate a user login information containing the encryption key, and generate a number of different sub-applications with the encryption key of the boot page, the user can freely choose to go to the Sub-Application Guide page, complete the Sub-page certification, so as not to log into the sub-application login portal, to see the effect:
Through a site login, login successfully entered the third-party login Boot interface:
Through the button, attach the Unified key, enter the A-station guide center
Through the button, attach the Unified key, enter the C Station Guide Center
has implemented B site proxy Landing, the implementation of A,c site landing, as long as the B center, add multiple sub-site list, you can achieve a login, registration center, a key to achieve all sub-application automatic landing, replacing the traditional sub-application alone landing problems, simplifying the user operation process!
Public functions
<?phpfunction Chksecret ($secret) {$key =decode ($secret), $arr = Explode (",", $key), if (Isset ($arr [3]) && $arr [3]== "Verifyok") {$_session[' username ']= $arr [1];$_session[' login ']= $arr [3];} else{$url =gethost (); echo "<script>alert (' Login failed! '); window.location.href= ' ". $url."; </script> ";}} function GetHost () {return "http://". $_server[' Http_host ');} function Chklogin () {if (Isset ($_session[' login ')) && $_session[' login ']== ' Verifyok ') {}else{$host =gethost () Header ("Location: $host");}} function decode ($string = ', $skey = ' lmj951753 ') {$STRARR = Str_split (Str_replace (' o0o0o ', ' o000o ', ' oo00o '), Array (' = ', ' + ', '/'), $string), 2); $strCount = count ($STRARR); foreach (Str_split ($skey) as $key = + $value) $key <= $strCount && $strArr [$key][1] = = = $value &&A mp $STRARR [$key] = $STRARR [$key][0]; Return Base64_decode (Join (', $STRARR));} function encode ($string = ', $skey = ' lmj951753 ') {$STRARR = Str_split (Base64_encode ($string)); $strCount = count ($STRARR); foreach (Str_split ($skey) as $key = + $value) $key < $strCount && $strArr [$key].= $value; return Str_replace (Array (' = ', ' + ', '/'), Array (' o0o0o ', ' o000o ', ' oo00o '), join (', $STRARR));}? >
A Station Login entry:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
A-Station Guide page:
<?phprequire_once (' function.php '); Session_Start (); $secret =isset ($_get[' key ']) trim ($_get[' key '): '; if ($ Secret) {Chksecret ($secret);} Else{chklogin ();}? ><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
SSO Login Center:
<?phpheader ("Content-type:text/html;charset=utf-8"), $refer =$_server[' http_referer ']; $username =isset ($_POST[ ' username ')? Trim ($_post[' username '): '; $password =isset ($_post[' password '])? Trim ($_post[' password ']): "; if ( Empty ($username) | | Empty ($password)) {GoBack ($refer);} $application =array (//According to the needs of the subweb, add the App list array (' name ' = ' to ' Enter a application ', ' url ' = ' http://www.a.com/'), Array (' name ' = = ') Enter C application ', ' url ' = = ' http://www.c.com/')), if ($username = = "Admin" && $password = = "123456") {$str =time (). ', '. $ Username. ",". $password. ", Verifyok,". $refer; $key =encode ($STR); echo "landed successfully! ". $username. ' <br/> '; foreach ($application as $k = + $v) {if ($refer = = $v [' url ']) {echo "<a target= ' _blank ' style= ' color:red;font-weight: Bold ' href= '. $v [' url ']. " home.php?key= $key ' > '. $v [' name ']. " </a> ";} Else{echo "<a target= ' _blank ' href= '". $v [' url ']. " home.php?key= $key ' > '. $v [' name ']. " </a> ";} }}else{echo "<script>alert (' Login failed! '); History.go ( -1);</script> "; exit();} function GoBack ($refer) {header ("Location: $refer"); exit ();} function decode ($string = ', $skey = ' lmj951753 ') {$STRARR = Str_split (Str_replace (' o0o0o ', ' o000o ', ' oo00o '), Array (' = ', ' + ', '/'), $string), 2); $strCount = count ($STRARR); foreach (Str_split ($skey) as $key = + $value) $key <= $strCount && $strArr [$key][1] = = = $value &&A mp $STRARR [$key] = $STRARR [$key][0]; Return Base64_decode (Join (', $STRARR));} function encode ($string = ', $skey = ' lmj951753 ') {$STRARR = Str_split (Base64_encode ($string)); $strCount = count ($STRARR); foreach (Str_split ($skey) as $key = + $value) $key < $strCount && $strArr [$key].= $value; return Str_replace (Array (' = ', ' + ', '/'), Array (' o0o0o ', ' o000o ', ' oo00o '), join (', $STRARR));}? >
C Station as a sub-site and the logical structure of a station almost, do not list, a simple PHP-based implementation of the SSO login authentication completed
PHP enables single sign-on SSO with unified release tickets