Sublime directory Surf the web anonymous Pagerank Monitor


get_user_info and non protected pages

myphotomojo
Fri 29 December 2006, 01:18 pm GMT +0100
Hi Olaf,

I ran into a small problem when trying to use the get_user_info() function on a page that's not protected.  Since this function is only valid on pages which are protected (i.e. access_page() called prior to get_user_info()), if you want to get the user info for non protected pages, it returns nothing.

Therefore, in your class I added a method called get_nonprotected_user_info() which is very similar to the get_user_info().  You can see it below:

function get_nonprotected_user_info() {
  if (isset($_SESSION['user']) && isset($_SESSION['pw'])) {
  $this->user = $_SESSION['user'];
  $this->user_pw = $_SESSION['pw'];
  }
  //$sql_info = sprintf("SELECT real_name, extra_info, email, id FROM %s WHERE login = '%s' AND pw = '%s'", $this->table_name, $this->user, $this->user_pw);
  $sql_info = sprintf("SELECT real_name, extra_info, email, id FROM %s WHERE %s = '%s' AND pw = '%s'", $this->table_name, $this->logtyp, $this->user, $this->user_pw);
  $res_info = mysql_query($sql_info);
  $this->id = mysql_result($res_info, 0, "id");
  $this->user_full_name = mysql_result($res_info, 0, "real_name");
  $this->user_info = mysql_result($res_info, 0, "extra_info");
  $this->user_email = mysql_result($res_info, 0, "email");
}

Basically I just added a check to see if the user is valid.  This way I can call get_nonprocted_user_info() on any page that doesn't need to be protected.  Works good, but wanted to hear your comments as I might be using the class wrong.

Thanks for a great class.

Eric


olaf
Fri 29 December 2006, 01:27 pm GMT +0100
:) the latest version has this function already, now you need only to create an object and both variables are created

myphotomojo
Fri 29 December 2006, 01:40 pm GMT +0100
hmmm, I thought I was using the lastest version.  In the header for the access_user_class.php it says v.1.94.  Is there something later?  If so, where do I get it?

Thanks for the quick response.

olaf
Fri 29 December 2006, 01:49 pm GMT +0100
oeps...

it looks like I need to release this version first :D

myphotomojo
Fri 29 December 2006, 01:51 pm GMT +0100
Ok, you had me going there for second  ;D.  Anyway, great class by the way.  I have a couple of other questions that I will be posting in new threads shortly.

kweiss
Sun 7 January 2007, 01:45 pm GMT +0100
Hi Olaf any chance you can post only the code that takes care of this feature?

BTW
the sample Eric submitted does not deal with the situation when there is no user logged in. The SQL will return 0 rows.

olaf
Sun 7 January 2007, 03:15 pm GMT +0100
Hi Olaf any chance you can post only the code that takes care of this feature?

BTW
the sample Eric submitted does not deal with the situation when there is no user logged in. The SQL will return 0 rows.

I know I need to hurry :D
Will try it soon...

myphotomojo
Mon 8 January 2007, 05:30 am GMT +0100
kweiss,

I'm not sure I understand what your talking about with regards to not getting the user info if a user is not logged in.  How do you propose to do that?  If a user is not logged in, how does one go about determining who the user is and then doing the appropriate db lookup. 

Would be interested in hearing your thoughts because it could be really helpful to be able to do this.

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional