Void a Transaction: fixed GRN voiding.
[fa-stable.git] / admin / db / users_db.inc
index 221bc77c832d2e4399d82d5a3ae081cb856d6190..55b31d747714c506cc11f475a5c752f32a980908 100644 (file)
@@ -101,6 +101,20 @@ function get_user_by_login($user_id)
 
 //-----------------------------------------------------------------------------------------------
 
+function get_user_by_email($email)
+{
+       $sql = "SELECT * FROM ".TB_PREF."users WHERE email=".db_escape($email);
+
+       $result = db_query($sql, "could not get user for email $email");
+
+       if (db_num_rows($result) != 1)
+               return false;
+
+       return db_fetch($result);
+}
+
+//-----------------------------------------------------------------------------------------------
+
 function delete_user($id)
 {
        $sql="DELETE FROM ".TB_PREF."users WHERE id=".db_escape($id);
@@ -160,10 +174,10 @@ function check_user_activity($id)
 //-----------------------------------------------------------------------------------------------
 function show_users_online()
 {
-       global $show_users_online, $db;
-       
-       if (!isset($show_users_online) || $show_users_online == 0 || !defined('TB_PREF') || 
-               !isset($_SESSION['get_text']) || !isset($db))
+       global $db, $GetText, $SysPrefs;
+
+       if (!isset($SysPrefs->show_users_online) || $SysPrefs->show_users_online == 0 || !defined('TB_PREF') || 
+               !isset($GetText) || !isset($db))
                return "";
        $result = db_query("SHOW TABLES LIKE '".TB_PREF."useronline'"); 
        if (db_num_rows($result) == 1)
@@ -197,7 +211,7 @@ function show_users_online()
                }
 
                // Add user to database
-               db_query("INSERT INTO ".TB_PREF."useronline (timestamp, ip, file) VALUES ('". $timestamp ."','". $ip ."','". $_SERVER['PHP_SELF'] ."')");
+               db_query("INSERT INTO ".TB_PREF."useronline (timestamp, ip, file) VALUES ('". $timestamp ."',". db_escape($ip) .",". db_escape($_SERVER['PHP_SELF']) .")");
                //Remove users that were not online within $timeoutseconds.
                db_query("DELETE FROM ".TB_PREF."useronline WHERE timestamp<". $timeout);
 
@@ -210,4 +224,3 @@ function show_users_online()
        return "$users ".($users == 1 ? _("user online") : _("users online"));
 
 }
-?>
\ No newline at end of file