Beispiel #1
0
    }
    function nav()
    {
        global $db, $nav, $ums, $user;
        $nav = str_replace('<a href="index.php?var=login">Login</a><br>', "", $nav);
        $nav = str_replace('<a href="index.php?var=register">Register</a><br>', "", $nav);
        $nav .= '<h1>' . $user['username'] . '</h1>';
    }
    function logout()
    {
        global $config, $db;
        $hash = $_COOKIE[$config['cookie']];
        $db->query("DELETE FROM `{PREFIX}ums_sessions` WHERE `hash` = '{$hash}'");
        setcookie($config['cookie'], "ended", time() - 100);
        return "You are now logged out! We hope to see you again";
    }
    function guest()
    {
        global $nav;
        $nav = str_replace('<a href="index.php?var=logout">Logout</a><br>', "", $nav);
    }
}
$ums = new ums();
if ($ums->init()) {
    if (isset($_COOKIE[$config['cookie']])) {
        $user = $ums->load($db->getvalue('user', 'ums_sessions', 'hash', $_COOKIE[$config['cookie']]));
        $ums->nav();
    } else {
        $ums->guest();
    }
}
Beispiel #2
0
        }
        //Session maintence
        $cutoff = time() - 86400;
        $db->query("DELETE FROM `{PREFIX}sessions` WHERE `time` <= {$cutoff}");
        return $user;
    }
    function load($id)
    {
        global $db;
        //First the static variables
        $user['id'] = $id;
        $user['name'] = $db->getvalue('name', 'users', 'id', $id);
        $user['email'] = $db->getvalue('email', 'users', 'id', $id);
        $user['group'] = $db->getvalue('group', 'users', 'id', $id);
        //Dynamic stufffffff
        return $user;
    }
    function cansee($page)
    {
        global $user, $db, $ums;
        $group = $user['group'];
        $result = $db->query("SELECT * FROM `{PREFIX}page_permissions` WHERE `page` = {$page} AND `group` = {$group} LIMIT 1");
        while ($row = mysql_fetch_array($result)) {
            $out = $row['cansee'];
        }
        return $out;
    }
}
$ums = new ums();
$user = $ums->init();