Exemplo n.º 1
0
$usr['newpm'] = 0;
$usr['messages'] = 0;
if (!empty($_COOKIE[$sys['site_id']]) || !empty($_SESSION[$sys['site_id']])) {
    $u = empty($_SESSION[$sys['site_id']]) ? explode(':', base64_decode($_COOKIE[$sys['site_id']])) : explode(':', base64_decode($_SESSION[$sys['site_id']]));
    $u_id = (int) cot_import($u[0], 'D', 'INT');
    $u_sid = $u[1];
    if ($u_id > 0) {
        $sql = $db->query("SELECT * FROM {$db_users} WHERE user_id = {$u_id}");
        if ($row = $sql->fetch()) {
            if ($u_sid == hash_hmac('sha1', $row['user_sid'], $cfg['secret_key']) && $row['user_maingrp'] > 3 && ($cfg['ipcheck'] == FALSE || $row['user_lastip'] == $usr['ip']) && $row['user_sidtime'] + $cfg['cookielifetime'] > $sys['now']) {
                $usr['id'] = (int) $row['user_id'];
                $usr['name'] = $row['user_name'];
                $usr['maingrp'] = $row['user_maingrp'];
                $usr['lastvisit'] = $row['user_lastvisit'];
                $usr['lastlog'] = $row['user_lastlog'];
                $usr['timezone'] = cot_timezone_offset($row['user_timezone'], true);
                $usr['timezonename'] = $row['user_timezone'];
                $usr['theme'] = $cfg['forcedefaulttheme'] ? $cfg['defaulttheme'] : $row['user_theme'];
                $usr['scheme'] = $row['user_scheme'];
                $usr['lang'] = $cfg['forcedefaultlang'] ? $cfg['defaultlang'] : $row['user_lang'];
                $usr['newpm'] = $row['user_newpm'];
                $usr['auth'] = unserialize($row['user_auth']);
                $usr['adminaccess'] = cot_auth('admin', 'any', 'R');
                $usr['level'] = $cot_groups[$usr['maingrp']]['level'];
                $usr['profile'] = $row;
                $sys['xk'] = $row['user_token'];
                if (!isset($_SESSION['cot_user_id'])) {
                    $_SESSION['cot_user_id'] = $usr['id'];
                }
                if ($usr['lastlog'] + $cfg['timedout'] < $sys['now']) {
                    $sys['comingback'] = TRUE;
Exemplo n.º 2
0
/**
 * Returns a list of timezones sorted by GMT offset.
 *
 * @param bool $withgmt Return 'GMT' as the first option, otherwise it won't be included
 * @param bool $dst Include DST in timezone offsets, if DST is in effect there right now
 * @return array Multidimensional array. Each timezone has the following keys:
 *  'identifier' - PHP timezone name, e.g. "America/El_Salvador"
 *  'offset' - GMT offset in seconds, e.g. -21600
 *  'title' - Localized timezone name, e.g. "America/El Salvador"
 *  'description' - Hourly GMT offset and localized name, e.g. "GMT-06:00 America/El Salvador"
 */
function cot_timezone_list($withgmt = false, $dst = false)
{
    global $Ltz;
    if (!$Ltz) {
        include cot_langfile('countries', 'core');
    }
    static $timezones = array();
    if (!$timezones) {
        $timezonelist = array();
        $regions = array('Africa', 'America', 'Antarctica', 'Asia', 'Atlantic', 'Europe', 'Indian', 'Pacific');
        $identifiers = DateTimeZone::listIdentifiers();
        foreach ($identifiers as $timezone) {
            list($region, $city) = explode('/', $timezone, 2);
            if (!in_array($region, $regions)) {
                continue;
            }
            $offset = cot_timezone_offset($timezone, false, $dst);
            $gmtoffset = cot_build_timezone($offset);
            $title = $Ltz[$timezone] ? $Ltz[$timezone] : $region . '/' . str_replace('_', ' ', $city);
            $timezonelist[] = array('identifier' => $timezone, 'offset' => $offset, 'title' => $title, 'description' => "{$gmtoffset} {$title}");
        }
        foreach ($timezonelist as $k => $tz) {
            $offsets[$k] = $tz['offset'];
            $names[$k] = $tz['name'];
        }
        array_multisort($offsets, SORT_ASC, $names, SORT_ASC, $timezonelist);
        $timezones = $timezonelist;
    }
    return $withgmt ? array_merge(array(array('name' => 'GMT', 'identifier' => 'GMT', 'offset' => 0, 'description' => 'GMT')), $timezones) : $timezones;
}