Exemple #1
0
function prefs_smarty_show($user_id)
{
    assert(is_numeric($user_id));
    global $_RUN;
    global $_USER;
    $template = new Smarty();
    help_set_template_vars($template, "PREFERENCES");
    $template->debugging = true;
    $result = sql_query("SELECT * FROM perihelion.t_themes");
    while ($row = sql_fetchrow($result)) {
        $tmpvar['ids'][] = $row['id'];
        $tmpvar['names'][] = $row['name'];
    }
    $template->assign("themes_ids", $tmpvar['ids']);
    $template->assign("themes_names", $tmpvar['names']);
    $user = user_get_perihelion_user($_USER['id']);
    if (SmartyValidate::is_init()) {
        $template->assign($_POST);
    } else {
        SmartyValidate::init();
        SmartyValidate::register_criteria("validate_email_is_ours_or_does_not_exists");
        SmartyValidate::register_criteria("validate_passwd");
        $template->assign("name", $user['name']);
        $template->assign("email", $user['email']);
        $template->assign("inform", $user['inform']);
        $template->assign("gender", $user['gender']);
        $template->assign("country", $user['country']);
        $template->assign("city", $user['city']);
        $template->assign("tag", $user['tag']);
        $tmp = split('-', $user['birthday']);
        $template->assign("dob_Day", $tmp[2]);
        $template->assign("dob_Month", $tmp[1]);
        $template->assign("dob_Year", $tmp[0]);
        $template->assign("theme", $user['theme_id']);
    }
    $template->assign("uid", encrypt_get_vars($user_id));
    $template->assign("cmd", encrypt_get_vars("post"));
    $template->assign("frmid", encrypt_get_vars(get_form_id()));
    $template->display($_RUN['theme_path'] . "/preferences.tpl");
}
function print_users()
{
    global $_CONFIG;
    global $_RUN;
    // Hmm, this should be a decent mysql query which filters out the last login_time and login_date per user_id actually... :(
    $user = array();
    $result = sql_query("SELECT * FROM perihelion.u_access ORDER BY logout DESC");
    while ($row = sql_fetchrow($result)) {
        if (!array_key_exists($row['user_id'], $user)) {
            $user[$row['user_id']]['user_id'] = $row['user_id'];
            $user[$row['user_id']]['login'] = $row['login'];
            $user[$row['user_id']]['logout'] = $row['logout'];
        } else {
            if ($user[$row['user_id']]['logout'] < $row['logout']) {
                $user[$row['user_id']]['login'] = $row['login'];
                $user[$row['user_id']]['logout'] = $row['logout'];
            }
        }
    }
    foreach ($user as $row) {
        $account = user_get_perihelion_user($row['user_id']);
        list($idle, $timestamp) = create_idle_time($row['logout']);
        // Don't show invisible users..
        if (user_is_invisible($row['user_id'])) {
            continue;
        }
        if ($timestamp < $_CONFIG['MAX_SECONDS_IDLE']) {
            $tmpvar[] = array('href' => "user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($row['user_id']), 'user' => $account['name'], 'idle' => $idle);
        }
    }
    // Output it...
    $template = new Smarty();
    $template->debugging = true;
    $template->assign("onlineusers", $tmpvar);
    $template->display($_RUN['theme_path'] . "/whoisonline.tpl");
}
function message_show_alliance($user_id)
{
    assert(is_numeric($user_id));
    global $_CONFIG;
    $user = user_get_user($user_id);
    $result = sql_query("SELECT * FROM m_alliance WHERE deleted=0 AND alliance_id = " . $user['alliance_id'] . " ORDER BY DATETIME DESC");
    while ($message = sql_fetchrow($result)) {
        if ($message['from_uid'] == UID_NOBODY) {
            $from_user['avatar'] = "default.gif";
        } else {
            $from_user = user_get_perihelion_user($message['from_uid']);
        }
        $template = new Smarty();
        $template->debugging = true;
        $template->assign("from", $message['msg_from']);
        $template->assign("datetime", $message['datetime']);
        $template->assign("subject", $message['msg_subject']);
        $template->assign("image", $_CONFIG['IMAGE_URL'] . '/users/' . $from_user['avatar']);
        $template->assign("body", convert_px_to_html_tags($message['text']));
        $template->display($_RUN['theme_path'] . "/messages-alliance-msg.tpl");
    }
}
function user_has_flag($user_id, $flag)
{
    assert(is_numeric($user_id));
    assert(is_string($flag));
    $user = user_get_perihelion_user($user_id);
    $userflags = split(",", $user['flags']);
    if (in_array($flag, $userflags)) {
        return true;
    }
    return false;
}