Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New Administrator Table in RC2


nikikelly

Recommended Posts

Posted

Hello,

I see that RC2 has a new administrator table and I'm thinking that since I can set up multiple logins, wouldn't it make sense to have different entry points for those different logins?

 

Basically I'd like to direct one adminstrative user (say $username = "xyz") to the FILENAME_DEFAULT and all other $username(s) to a new page FILENAME_DEFAULT_AFFILIATE that is located at admin/affiliate/orders_affiliate.php.

 

Looks like this is the code I need to modify in admin/login.php but every time I try, I end up breaking the page:

	  case 'process':
	$username = tep_db_prepare_input($HTTP_POST_VARS['username']);
	$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

	$check_query = tep_db_query("select id, user_name, user_password from " . TABLE_ADMINISTRATORS . " where user_name = '" . tep_db_input($username) . "'");

	if (tep_db_num_rows($check_query) == 1) {
	  $check = tep_db_fetch_array($check_query);

	  if (tep_validate_password($password, $check['user_password'])) {
		tep_session_register('admin');

		$admin = array('id' => $check['id'],
					   'username' => $check['user_name']);

		if (tep_session_is_registered('redirect_origin')) {
		  $page = $redirect_origin['page'];
		  $get_string = '';

		  if (function_exists('http_build_query')) {
			$get_string = http_build_query($redirect_origin['get']);
		  }

		  tep_session_unregister('redirect_origin');

		  tep_redirect(tep_href_link($page, $get_string));
		} else {
		  tep_redirect(tep_href_link(FILENAME_DEFAULT));
		}
	  }
	}

 

Can anyone offer me advice on this?

Posted

Shouldn't just changing that last redirect work? ie

 

from

			} else {
			tep_redirect(tep_href_link(FILENAME_DEFAULT));
		  }

 

to

			} else {
			if ($username == 'xyz'){
			  tep_redirect(tep_href_link(FILENAME_DEFAULT));
			} else {
			  tep_redirect(tep_href_link(FILENAME_DEFAULT_AFFILIATE));
			}
		 }

Posted
Shouldn't just changing that last redirect work? ie

 

from

			} else {
			tep_redirect(tep_href_link(FILENAME_DEFAULT));
		  }

 

to

			} else {
			if ($username == 'xyz'){
			  tep_redirect(tep_href_link(FILENAME_DEFAULT));
			} else {
			  tep_redirect(tep_href_link(FILENAME_DEFAULT_AFFILIATE));
			}
		 }

Thanks for your response. I know, one would think that is all it would take. I tried that and it still directed to the default (index) page no matter what. I'm missing something.....any other ideas, let me know! Thanks!

Posted

oh, I got it.. it's the tep_redirect above the else. I think maybe the section we thought is more a 'failsafe' so that it doesn't come back to login.php on success if redirect_origin happens to not be set.

 

So that line tries to put you back/or towards where you were trying to go before it made you login.

 

So try something like:

		 if ($username == 'xyz'){
	   tep_redirect(tep_href_link(FILENAME_DEFAULT_AFFIILIATE));
	 } else {
	   tep_redirect(tep_href_link($page, $get_string));
	 }

Posted
oh, I got it.. it's the tep_redirect above the else. I think maybe the section we thought is more a 'failsafe' so that it doesn't come back to login.php on success if redirect_origin happens to not be set.

 

So that line tries to put you back/or towards where you were trying to go before it made you login.

 

So try something like:

		 if ($username == 'xyz'){
	   tep_redirect(tep_href_link(FILENAME_DEFAULT_AFFIILIATE));
	 } else {
	   tep_redirect(tep_href_link($page, $get_string));
	 }

 

Hmmm....I think you were right the first time. I was just not closing my browser and closing my session properly or something. So, here's what I have:

case 'process':
	$username = tep_db_prepare_input($HTTP_POST_VARS['username']);
	$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

	$check_query = tep_db_query("select id, user_name, user_password from " . TABLE_ADMINISTRATORS . " where user_name = '" . tep_db_input($username) . "'");

	if (tep_db_num_rows($check_query) == 1) {
	  $check = tep_db_fetch_array($check_query);

	  if (tep_validate_password($password, $check['user_password'])) {
		tep_session_register('admin');

		$admin = array('id' => $check['id'],
					   'username' => $check['user_name']);

		if (tep_session_is_registered('redirect_origin')) {
		  $page = $redirect_origin['page'];
		  $get_string = '';

		  if (function_exists('http_build_query')) {
			$get_string = http_build_query($redirect_origin['get']);
		  }

		  tep_session_unregister('redirect_origin');

		  tep_redirect(tep_href_link($page, $get_string));

		} else {
			if ($username == 'xyz'){
			  tep_redirect(tep_href_link(FILENAME_DEFAULT));
			} else {
			  tep_redirect(tep_href_link(FILENAME_DEFAULT_AFFILIATE, 'aID=' . $HTTP_GET_VARS['aID']));
			}	
		}
	  }
	}

 

Now I'm wondering how I can pass the querystring variables along the way. So, I have entrypoint store.com/catalog/admin/affiliate/orders_affiliate.php?aID=2 which redirects me to login (and loses the aID). Any idea what I need to change to carry this value through to the ultimate redirect after login?

 

Thanks for your help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...