tech929rr Posted December 31, 2008 Share Posted December 31, 2008 Ok I am trying to migrate a script from php4 to php5. For the most part i am not worried about the small chances because it works fine right now, so I will do them later. I have a log in page problem and it is driving me crazy. I keep getting a redirect loop back to the log in.. Ok here is a few of the pages I need to migrate to php5 <?php $phrase['groups'] = array( 'administration' ); define('LOCATION','admin'); define('MD5_INCLUDE','md5'); require_once('./../functions/core.config.inc.php'); $navcrumb = array("$ilpage[login]" => $ilcrumbs["$ilpage[login]"]); $subnav_settings = print_admincp_subnav('login', $ilpage['login'], $_SESSION['ilancedata']['user']['slng']); $cmd = ''; // #### ADMIN REQUESTS LOGOUT ################################################## if (isset($ilance->GPC['cmd']) AND $ilance->GPC['cmd'] == '_logout') { $area_title = $phrase['_logging_out_of_marketplace']; $page_title = $phrase['_logging_out_of_marketplace']; // keep last visit and last activity cookie .-) setcookie($ilconfig['globalsecurity_cookiename'].'[admin][lastvisit]', DATETIME24H, TIMESTAMPNOW+31556926, '/', ''); setcookie($ilconfig['globalsecurity_cookiename'].'[admin][lastactivity]', DATETIME24H, TIMESTAMPNOW+31622400, '/', ''); // expire member specific cookies so the marketplace doesn't re-login admin in automatically // leave username cookie alone so the marketplace can greet the admin by username (login, breadcrumb, etc) setcookie($ilconfig['globalsecurity_cookiename'].'[admin][userid]', '', 0, '/', ''); setcookie($ilconfig['globalsecurity_cookiename'].'[admin][password]', '', 0, '/', ''); // destroy member specific sessions $ilance->sessions->sess_destroy(session_id()); session_destroy(); refresh($ilpage['login'], HTTPS_SERVER_ADMIN . $ilpage['login']); exit(); } // #### ADMIN RENEW PASSWORD ################################################### else if (isset($ilance->GPC['cmd']) AND $ilance->GPC['cmd'] == "_renew-password" AND isset($ilance->GPC['username']) ) { $area_title = 'Attempting to Reset Admin Password'; $page_title = SITE_NAME.' - Attempting to Reset Admin Password'; $admin_cookie = ""; if (!empty($_COOKIE[$ilconfig['globalsecurity_cookiename']]['admin']['username'])) { $admin_cookie = $ilance->crypt->three_layer_decrypt($_COOKIE[$ilconfig['globalsecurity_cookiename']]['admin']['username'], $ilconfig['key1'], $ilconfig['key2'], $ilconfig['key3']); } $sql = $ilance->db->query("SELECT admin_id, email, username FROM ".DB_PREFIX."admin WHERE username = '".mysql_real_escape_string($ilance->GPC['username'])."' AND status = 'active' LIMIT 1"); if ($ilance->db->num_rows($sql) > 0) { $res = $ilance->db->fetch_array($sql); $error_login = 0; $salt = construct_password_salt($length = 5); $newp = construct_password(; $pass = md5(md5($newp) . $salt); $ilance->db->query("UPDATE ".DB_PREFIX."admin SET password = '".mysql_real_escape_string($pass)."', salt = '".mysql_real_escape_string($salt)."' WHERE admin_id = '".intval($res['admin_id'])."' AND status = 'active' LIMIT 1"); $subject = "New password generated for ".SITE_NAME." CP login"; $message = "Administrator,\n\nYou or someone else has requested to renew the administration password for your account on ".DATETIME24H.". Please find the following information below to log-in: Username: ".stripslashes($res['username'])." New Password: ".$newp." ------------------------------------------ Changed from IP: ".$_SERVER['REMOTE_ADDR']." Changed from Agent: ".$_SERVER['HTTP_USER_AGENT']." ".SITE_NAME." ".HTTP_SERVER; api_email($res['email'], $subject, $message, SITE_EMAIL); $password_renewed = 1; } else { $error_login = 1; $password_renewed = 0; } $formid = "1"; #################################### ## MAKE THE SECURE FORM KEY HASH-MD5 $key = insert_form_key($formid); $securekey_hidden = '<input type="hidden" name="secureid" value="'.$key.'" />'; $subnav_settings = print_admincp_subnav('login', $ilpage['login'], $_SESSION['ilancedata']['user']['slng']); $ilance->template->load_file('header', 'header.admin.html', 1); $ilance->template->load_file('main', 'login_pwrenew.html', 1); $ilance->template->load_file('footer', 'footer.admin.html', 1); $ilance->template->parse_hash('main', array('ilpage' => $ilpage)); $ilance->template->parse_hash('header', array('ilpage' => $ilpage)); $ilance->template->parse_hash('footer', array('ilpage' => $ilpage)); $ilance->template->parse_loop('header', 'v3nav'); $ilance->template->parse_loop('main', 'subnav_settings'); $ilance->template->parse_if('main', 'error_login'); $ilance->template->parse_if('main', 'password_renewed'); $ilance->template->parse_if_blocks('header'); $ilance->template->parse_if_blocks('main'); $ilance->template->parse_if_blocks('footer'); $ilance->template->pprint('header', array('ilanceversion','login_include_admin','headinclude','onload','area_title','page_title','site_name','https_server','http_server','lanceads_header','lanceads_footer','meta_desc','meta_keyw','official_time')); $ilance->template->pprint('main', array('clientip','cmd','remember_checked','formid','input_style','redirect','referer','securekey_hidden','rid','login','admin_cookie', 'enter_username','enter_password','login_include','onload','area_title','page_title','site_name', 'https_server','http_server','lanceads_header','lanceads_footer')); $ilance->template->pprint('footer', array('headinclude','onload','area_title','page_title','site_name','https_server','http_server','lanceads_header','lanceads_footer','finaltime','finalqueries')); exit(); } else if (isset($ilance->GPC['cmd']) AND $ilance->GPC['cmd'] == '_pw-renew') { $area_title = 'Admin Password Renewal Menu'; $page_title = SITE_NAME.' - Admin Password Renewal Menu'; $admin_cookie = ""; if (!empty($_COOKIE[$ilconfig['globalsecurity_cookiename']]['admin']['username'])) { $admin_cookie = $ilance->crypt->three_layer_decrypt($_COOKIE[$ilconfig['globalsecurity_cookiename']]['admin']['username'], $ilconfig['key1'], $ilconfig['key2'], $ilconfig['key3']); } $error_login = 0; $password_renewed = 0; if (isset($ilance->GPC['error']) AND $ilance->GPC['error'] == '1') { $error_login = 1; } $formid = "1"; $key = insert_form_key($formid); $securekey_hidden = '<input type="hidden" name="secureid" value="'.$key.'" />'; $subnav_settings = print_admincp_subnav('login', $ilpage['login'], $_SESSION['ilancedata']['user']['slng']); $ilance->template->load_file('header', 'header.admin.html', 1); $ilance->template->load_file('main', 'login_pwrenew.html', 1); $ilance->template->load_file('footer', 'footer.admin.html', 1); $ilance->template->parse_hash('main', array('ilpage' => $ilpage)); $ilance->template->parse_hash('header', array('ilpage' => $ilpage)); $ilance->template->parse_hash('footer', array('ilpage' => $ilpage)); $ilance->template->parse_loop('header', 'v3nav'); $ilance->template->parse_loop('main', 'subnav_settings'); $ilance->template->parse_if('main', 'error_login'); $ilance->template->parse_if('main', 'password_renewed'); $ilance->template->parse_if_blocks('header'); $ilance->template->parse_if_blocks('main'); $ilance->template->parse_if_blocks('footer'); $ilance->template->pprint('header', array('ilanceversion','login_include_admin','headinclude','onload','area_title','page_title','site_name','https_server','http_server','lanceads_header','lanceads_footer','meta_desc','meta_keyw','official_time')); $ilance->template->pprint('main', array('clientip','cmd','remember_checked','formid','input_style','redirect','referer','securekey_hidden','rid','login','admin_cookie', 'enter_username','enter_password','login_include','onload','area_title','page_title','site_name', 'https_server','http_server','lanceads_header','lanceads_footer')); $ilance->template->pprint('footer', array('headinclude','onload','area_title','page_title','site_name','https_server','http_server','lanceads_header','lanceads_footer','finaltime','finalqueries')); exit(); } else { $area_title = $phrase['_login_area_menu']; $page_title = SITE_NAME.' - '.$phrase['_login_area_menu']; $admin_cookie = ''; $redirect = ''; $formid = '1'; $cmd = ''; if(empty($_COOKIE['ilancedata']['admin']['username'])) $onload='document.login.username.focus();'; else $onload='document.login.password.focus();'; if (!empty($_COOKIE[$ilconfig['globalsecurity_cookiename']]['admin']['username'])) { $admin_cookie = $ilance->crypt->three_layer_decrypt($_COOKIE[$ilconfig['globalsecurity_cookiename']]['admin']['username'], $ilconfig['key1'], $ilconfig['key2'], $ilconfig['key3']); } if (!empty($ilance->GPC['redirect'])) { $redirect = trim($ilance->GPC['redirect']); } $ilance->template->load_file('header', 'header.admin.html', 1); $ilance->template->load_file('main', 'login.html', 1); $ilance->template->load_file('footer', 'footer.admin.html', 1); $ilance->template->parse_hash('main', array('ilpage' => $ilpage)); $ilance->template->parse_hash('header', array('ilpage' => $ilpage)); $ilance->template->parse_hash('footer', array('ilpage' => $ilpage)); $ilance->template->parse_loop('header', 'v3nav'); $ilance->template->parse_loop('main', 'subnav_settings'); $ilance->template->parse_if('main', 'session_error'); $ilance->template->parse_if('main', 'suspended'); $ilance->template->parse_if('main', 'error_login'); $ilance->template->parse_if('main', 'iprestrict'); $ilance->template->parse_if_blocks('header'); $ilance->template->parse_if_blocks('main'); $ilance->template->parse_if_blocks('footer'); $ilance->template->pprint('header', array('ilanceversion','login_include_admin','headinclude','onload','area_title','page_title','site_name','https_server','http_server','lanceads_header','lanceads_footer','meta_desc','meta_keyw','official_time')); $ilance->template->pprint('main', array('clientip','cmd','remember_checked','formid','input_style','redirect','referer','securekey_hidden','rid','login','admin_cookie', 'enter_username','enter_password','login_include','onload','area_title','page_title','site_name', 'https_server','http_server','lanceads_header','lanceads_footer')); $ilance->template->pprint('footer', array('headinclude','onload','area_title','page_title','site_name','https_server','http_server','lanceads_header','lanceads_footer','finaltime','finalqueries')); exit(); } /*======================================================================*\ || #################################################################### || # CVS: $RCSfile: login.php,v $ - $Revision: 1.00 $ || #################################################################### \*======================================================================*/ ?> Link to comment https://forums.phpfreaks.com/topic/139047-help-with-php4-to-php5/ Share on other sites More sharing options...
redbrad0 Posted January 1, 2009 Share Posted January 1, 2009 Can you describe better what it is doing other then redirecting? Have you checked to see if the cookies are being enabled? Added test text on the page (or logging if you have it built in) to know where it is redirecting? I would think the best way to fix this problem is look for any of the redirects and add echo "redirecting"; die; before the redirect. and see where on the site its redirecting. then you can look at the reason why. Link to comment https://forums.phpfreaks.com/topic/139047-help-with-php4-to-php5/#findComment-727468 Share on other sites More sharing options...
tech929rr Posted January 1, 2009 Author Share Posted January 1, 2009 Thanks The script redirects to the admin area and checks the login info. If good it should set session to 1 and allow admin access. Something is going worng with this php4 script on a php5 server to where when it checks for login info it redirects to the admin bashboard and then no verification is made so it redirects back to the login screen. Is there anything off the top of your head that was changed during the move to php5 that would cause a session or cookie problem using a php4 script Link to comment https://forums.phpfreaks.com/topic/139047-help-with-php4-to-php5/#findComment-727636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.