Hey. I need a way to check if an user is online, on an external page WITHOUT adding the phpbb session to the page. I'm adding this on a Wordpress page, and the phpbb session causes conflicts with wordpress, since they have functions with the exact same name.. (like make_clickable)
So i kindof.. need to manually check if an user is online or not.
I made this code below, and it works. However, I have no idea if it has any flaws, or if it's safe
$cookie_id = $_COOKIE['phpbb3_token_sid'];
$cookie_user = $_COOKIE['phpbb3_token_u'];
if($cookie_user!=1) {
$query = mysql_query("SELECT * FROM phpbb3_sessions WHERE session_id LIKE '".mysql_real_escape_string($cookie_id)."'");
if(mysql_num_rows($query)==1) {
$find_name = mysql_query("SELECT * FROM phpbb3_users WHERE user_id LIKE '".mysql_real_escape_string($cookie_user)."'");
if(mysql_num_rows($find_name)==1) {
while($row=mysql_fetch_array($find_name)) {
echo "Welcome, " . $row['username'] . "!";
}
}
}
} else {
echo "Not logged in";
}
- $cookie_id = $_COOKIE['phpbb3_token_sid'];
- $cookie_user = $_COOKIE['phpbb3_token_u'];
-
- if($cookie_user!=1) {
- $query = mysql_query("SELECT * FROM phpbb3_sessions WHERE session_id LIKE '".mysql_real_escape_string($cookie_id)."'");
- if(mysql_num_rows($query)==1) {
- $find_name = mysql_query("SELECT * FROM phpbb3_users WHERE user_id LIKE '".mysql_real_escape_string($cookie_user)."'");
- if(mysql_num_rows($find_name)==1) {
- while($row=mysql_fetch_array($find_name)) {
- echo "Welcome, " . $row['username'] . "!";
- }
- }
- }
- } else {
- echo "Not logged in";
- }
What do you think?
thanks
