Who can help me translate php code into java code. Hurry up.
Who can help me translate php code into java code. Hurry up.
Load-> model ('Share');} function iflogin ($ redirect = true, $ forward = '') {$ this-> share-> cncn_session_start (); $ uid = 0; // check whether the SESSION is consistent with the uch_auth in the COOKIE. ensure that the SESSION is the same person $ still_login = false; if (isset ($ _ SESSION ['uch _ auth']) & isset ($ _ COOKIE ['uch _ auth']) & ($ _ SESSION ['uch _ auth'] =$ _ COOKIE ['uch _ auth']) {$ still_login = true ;} if (isset ($ _ SESSION ['uid']) & $ _ SESSION ['uid'] & $ still_login) {$ uid = $ _ SESSION ['uid' ]; // When no related cache is available, the exit operation is performed. is.cncn.net will not perform separate synchronization and exit if (empty ($ _ COOKIE ['uch _ auth ']). {$ this-> doexit ();} // checks whether the logon process has been deleted every 5 minutes (for example, the password has been changed for other processes) if ($ this-> chk_auth_session ($ uid) <0) {$ this-> doexit ();} // replace session_idif (empty ($ _ SESSION ['last _ sess_time ']) every 60 seconds) {$ _ SESSION ['last _ sess_time'] = time ();} elseif (time ()-$ _ SESSION ['last _ sess_time ']> 60) {session_regenerate_id (TRUE); $ _ SESSION ['last _ sess_time'] = Time () ;}} else {if (isset ($ _ COOKIE ['uch _ auth']) & $ _ COOKIE ['uch _ auth']) {$ uid = $ this-> chk_auth_cookie (); // when the cookie information passes verification, the logon status will be restored from the cookie // ------------------------------------------ if ($ uid> 0) {// Generate session, cookie $ this-> set_login ($ uid); // add session values related to logon process detection, for subsequent session detection $ _ SESSION ['last _ uc_check_time '] = time (); // ------------------------------------------------------} else {$ uid = 0;} if (! $ Uid & $ redirect) {// if it is a request from ajax, no jump will be made, otherwise, ajax receives the html code $ ajax = $ this-> input-> get_post ('Ajax '); if (empty ($ ajax) of the logon page )) {if (empty ($ forward) {$ forward = empty ($ _ SERVER ['request _ URI '])? $ This-> uri-> uri_string: '$ _ SERVER ['http _ host']. $ _ SERVER ['request _ URI '];} header ('Location :'. NET_URL. 'login? Forward = '. urlencode ($ forward); exit;} else {$ this-> share-> cncn_exit ('You have not logged on ');} return $ uid ;} /** verify that the cookie used to log on is correct * @ param string $ check_type ): * cookie verification performed when the cookie is used to resume logon * session verification performed when the session has been restored after logon. in this case, the validity period of the logon permission is not verified (because the cookie may have expired, but the session is still in the situation) * @ return mixed returns the UID corresponding to the cookie during login verification. if the cookie fails, FALSE */function chk_auth_cookie ($ check_type = 'cookies') is returned ') {if ($ check_type = 'cookies') {if (empty ($ _ cookie ['uch _ auth ']) {return-1 ;} $ auth_code = $ _ COOKIE ['uch _ auth']; $ uid = 0;} else {if (empty ($ _ SESSION ['uch _ auth']) {return-1 ;}$ auth_code =$ _ SESSION ['uch _ auth']; $ uid =$ _ SESSION ['uid'];} $ info = array ('uid' => $ uid, 'auth _ code' => $ auth_code, 'client _ IP' => $ _ SERVER ['remote _ ADDR '], 'Client _ info' => $ this-> get_client_info (), 'user _ agent' => $ this-> get_client_info (FALSE), 'Check _ type' => $ check_type,); static $ checked; if ($ checked [$ auth_code]) {return $ checked [$ auth_code];} if (CURRENT_ENV = 'production ') {$ uc_key = '6e1a233d3c9d4677a617096d70e0c612 ';} else {$ uc_key = 'adc0a1d842a7545633b06f451aa3a74c ';} $ info = array ('sign' =>$ this-> authcode (serialize ($ info), 'encode', $ uc_key ), 'from' => 'finance ',); // initiate a verification request to the server if (CURRENT_ENV = 'production') {$ url =' http://www.cncn.net/homepage/check_uc_session ';} Else {$ url =' http://192.168.1.158:876/homepage/check_uc_session ';}$ Info = http_build_query ($ info); $ ch = curl_init ($ url); curl_setopt ($ ch, CURLOPT_HEADER, 0); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_TIMEOUT, 10); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ info ); $ r = curl_exec ($ ch); curl_close ($ ch); $ return = unserialize ($ this-> authcode ($ r, 'Decode', $ uc_key )); if (empty ($ return ['uid']) {return '-997';} $ Uid = $ checked [$ auth_code] = $ return ['uid']; // if ($ uid <0) {return $ uid ;} // Determine whether the returned verification result is invalid. if (time ()-$ return ['Time']> 300) {return '-996';} return $ uid ;} /** check whether the logon process has been deleted every five minutes (for example, other processes have changed their passwords) * @ param int $ uid: The current logon user, uid stored in session ** @ return mixed returns the UID corresponding to the cookie during login verification. if the cookie fails, FALSE */function chk_auth_session ($ uid) is returned) {if (isset ($ _ SESSION ['last _ uc_check_time ']) & time ()-$ _ SESSION ['last _ Uc_check_time ']> 300) {$ uid = $ this-> chk_auth_cookie ('session'); if ($ uid <0) {// after the logon credential verification fails, delete the current session if (session_id ()! = '') {// Check login is called multiple times .. So here we need to add a judge session_destroy () ;}} else {$ _ SESSION ['last _ uc_check_time '] = time () ;}} if (empty ($ uid) | $ uid <0) {$ uid = 0;} return $ uid;} function authcode ($ string, $ operation = 'Decode', $ key = '', $ expiry = 0) {$ ckey_length = 4; $ key = md5 ($ key? $ Key: CNCN_API_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 (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 <$ str Ing_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) ;}}/** get the user's browser information, after md5 encryption, ** @ return string */function get_client_info ($ md5 = TRUE) is returned) {$ info = array ('agent' => empty ($ _ SERVER ['http _ USER_AGENT '])? 'User _ agent': $ _ SERVER ['http _ USER_AGENT '], 'Lang' => empty ($ _ SERVER ['http _ ACCEPT_LANGUAGE '])? 'Gbk': strtolower ($ _ SERVER ['http _ ACCEPT_LANGUAGE ']),); $ info = join ('', $ info); return $ md5? Md5 ($ info): $ info;} function doexit () {$ this-> share-> cncn_session_start (); $ syn = ''; // clear the session $ _ SESSION = array (); if (ini_get ("session. use_cookies ") {$ params = session_get_cookie_params (); setcookie (session_name (),'', time ()-42000, $ params ["path"], $ params ["domain"], $ params ["secure"], $ params ["httponly"]);} session_destroy (); setcookie ("uc_auth ","", time ()-3600, '/', config_item ('Cookiedomain '); setcookie ("uch_auth", "", time ()-3600,'/', config_item ('cookiedomain'); echo $ syn. 'script location. href = "/"; script '; exit;}/*** obtain the uid to obtain the corresponding field information ** @ param mixed $ uids the uid of the field to be obtained, multiple fields are allowed. if more than one field exists, use an array to pass the * @ param $ type to obtain the field type */public function get_value_byid ($ uids, $ type, $ table = 'member ') {if (! $ Is_array = is_array ($ uids) {$ uids = array ($ uids);} $ return = array (); $ this-> cncndb = $ this-> load-> database ('cndb', TRUE); $ query = $ this-> cncndb-> select ('uid ,'. $ type)-> from ($ table)-> where_in ('uid', $ uids)-> get (); foreach ($ query-> result_array () as $ k => $ v) {$ return [$ v ['uid'] = $ v [$ type];} return $ is_array? $ Return: array_pop ($ return);}/** process the user logon session * @ param int $ uid user id * @ param string $ nickname user nickname, if not passed, obtain * @ param int $ expire cookie storage time from the member table based on the uid. the unit is seconds. the default value is NULL, that is, the browser will expire after it is closed * @ return void */function set_login ($ uid, $ nickname = '', $ expire = NULL) {// save session $ this-> share-> cncn_session_start (); $ _ SESSION = array (); // you should clear the previous session before logging on to the session, avoid users joining together $ _ SESSION ['uid'] = $ uid; $ _ SESSION ['nickname'] = $ nickname; // you need to obtain $ _ SESSION ['contact _ name'] = $ contact_name from the user library when the request is not passed; // you need to obtain $ _ SESSION ['User _ type'] = $ user_type from the user library when the parameter is not passed; // you need to obtain $ _ SESSION ['login _ time'] = time () ;}} from the user library when the request is not passed ();}}
Who can help me translate php code into java code. Please wait for more urgent contentOffFor more information, see PHP Chinese website (www.php1.cn )!