Example #1
0
 /**
  * Get comment's country that was detected by IP address
  *
  * @param string String to display before country, if country_ID is defined
  * @param string String to display after country, if country_ID is defined
  * @return string Country with flag
  */
 function get_ip_country($before = '', $after = '')
 {
     $country = '';
     if (!empty($this->IP_ctry_ID)) {
         // Country ID is defined
         load_funcs('regional/model/_regional.funcs.php');
         load_class('regional/model/_country.class.php', 'Country');
         $CountryCache =& get_CountryCache();
         if ($Country = $CountryCache->get_by_ID($this->IP_ctry_ID, false)) {
             $country .= $before;
             $country .= country_flag($Country->get('code'), $Country->get_name(), 'w16px', 'flag', '', false);
             $country .= ' ' . $Country->get_name();
             $country .= $after;
         }
     }
     return $country;
 }
function CreateMedal($qry, $rowname, $orderby, $decimal, $unit = "")
{
    global $coddb;
    global $t;
    //table names
    global $w;
    global $minkills;
    global $minrounds;
    global $maxdays;
    global $text;
    global $exclude_ban;
    $current_time = gmdate("U");
    $query = $qry;
    $query .= "AND (({$t['players']}.kills > {$minkills})\r\n        OR ({$t['players']}.rounds > {$minrounds}))\r\n        AND ({$t['players']}.hide = 0)\r\n        AND ({$current_time} - {$t['b3_clients']}.time_edit  < {$maxdays}*60*60*24)";
    if ($exclude_ban) {
        $query .= " AND {$t['b3_clients']}.id NOT IN (\r\n        SELECT distinct(target.id)\r\n        FROM {$t['b3_penalties']} as penalties, {$t['b3_clients']} as target\r\n        WHERE (penalties.type = 'Ban' OR penalties.type = 'TempBan')\r\n        AND inactive = 0\r\n        AND penalties.client_id = target.id\r\n        AND ( penalties.time_expire = -1 OR penalties.time_expire > UNIX_TIMESTAMP(NOW()) )\r\n    )";
    }
    $query .= " GROUP BY {$t['players']}.id\r\n      ORDER BY {$orderby}\r\n      LIMIT 1 ";
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    $name = $row['fixed_name'] ? $row['fixed_name'] : $row['name'];
    $score = number_format(abs($row[$rowname]), $decimal) . $unit;
    $playerid = $row['id'];
    $query = str_replace("LIMIT 1", "LIMIT 0, 10", $query);
    $result = $coddb->sql_query($query);
    while ($row = $coddb->sql_fetchrow($result)) {
        $names = $row['fixed_name'] ? $row['fixed_name'] : $row['name'];
        $players[] = $names;
        $scores[] = number_format(abs($row[$rowname]), $decimal) . $unit;
        $playerids[] = $row['id'];
        $flags[] = country_flag($row['ip']);
    }
    if (!isset($playerids, $flags, $players, $scores)) {
        $playerids = "";
        $flags = "";
        $players = "";
        $scores = "";
    }
    return array($score, $playerid, $name, $players, $scores, $playerids, $flags);
}
Example #3
0
/**
 * Get a flag of registration country with a link to user's sessions page
 *
 * @param integer User ID
 * @param string Country code
 * @param string Country name
 * @return string
*/
function user_reg_country($user_ID, $country_code, $country_name)
{
    global $current_User, $admin_url;
    $flag = country_flag($country_code, $country_name, 'w16px', 'flag', '', false, true, '', false);
    if (empty($flag)) {
        // No flag or registration country
        $flag = '?';
    }
    if ($current_User->check_perm('users', 'edit')) {
        // Only users with edit all users permission can see the 'Sessions' tab
        $flag = '<a href="' . $admin_url . '?ctrl=user&amp;user_tab=sessions&amp;user_ID=' . $user_ID . '">' . $flag . '</a>';
    }
    return $flag;
}
function shame_medal_careless()
{
    $link = baselink();
    global $coddb;
    global $separatorline;
    global $t;
    //table names
    global $a_name;
    //award names
    global $a_desc;
    //award descriptions
    global $w;
    global $minkills;
    global $minrounds;
    global $maxdays;
    global $wp_accidents;
    global $text;
    global $exclude_ban;
    $current_time = gmdate("U");
    $query = " SELECT {$t['b3_clients']}.name, {$t['players']}.id, ip, {$t['b3_clients']}.time_edit, {$t['players']}.fixed_name, rounds, (SUM({$t['weaponusage']}.suicides) / {$t['players']}.rounds) AS total_suicides\n      FROM {$t['weaponusage']}\n      JOIN {$t['players']} ON {$t['weaponusage']}.player_id = {$t['players']}.id\n      JOIN {$t['b3_clients']} ON {$t['players']}.client_id = {$t['b3_clients']}.id\n      WHERE ({$t['weaponusage']}.weapon_id IN {$wp_accidents})\n      AND (({$t['players']}.kills > {$minkills})\n      OR ({$t['players']}.rounds > {$minrounds}))\n      AND ({$t['players']}.hide = 0)\n      AND ({$current_time} - {$t['b3_clients']}.time_edit  < {$maxdays}*60*60*24)";
    if ($exclude_ban) {
        $query .= " AND {$t['b3_clients']}.id NOT IN (\n      SELECT distinct(target.id)\n      FROM {$t['b3_penalties']} as penalties, {$t['b3_clients']} as target\n      WHERE (penalties.type = 'Ban' OR penalties.type = 'TempBan')\n      AND inactive = 0\n      AND penalties.client_id = target.id\n      AND ( penalties.time_expire = -1 OR penalties.time_expire > UNIX_TIMESTAMP(NOW()) )\n    )";
    }
    $query .= " GROUP BY {$t['players']}.id\n      ORDER BY total_suicides DESC\n      LIMIT 1 ";
    $result = $coddb->sql_query($query);
    $row = $coddb->sql_fetchrow($result);
    $name = $row['fixed_name'] ? $row['fixed_name'] : $row['name'];
    $score = sprintf("%.2f", $row['total_suicides']);
    $playerid = $row['id'];
    $query = str_replace("LIMIT 1", "LIMIT 0, 10", $query);
    $result = $coddb->sql_query($query);
    while ($row = $coddb->sql_fetchrow($result)) {
        $names = $row['fixed_name'] ? $row['fixed_name'] : $row['name'];
        $players[] = $names;
        $scores[] = sprintf("%.2f", $row['total_suicides']);
        $playerids[] = $row['id'];
        $flags[] = country_flag($row['ip']);
    }
    if (!isset($playerids, $flags, $players, $scores)) {
        $playerids = "";
        $flags = "";
        $players = "";
        $scores = "";
    }
    $fname = __FUNCTION__;
    ShowMedal($text["accidenthero"], $text["blindasbat"], $score, $playerid, $name, "xlr_shame_blind.png", $text["mostaccdeath"], $players, $scores, $fname, $playerids, $flags);
}
Example #5
0
    /**
     * AJAX callback to load country.
     *
     * @param array Associative array of parameters
     *   - 'user_ID': User ID
     */
    function htsrv_load_country($params)
    {
        global $debug, $debug_jslog;
        // Do not append Debuglog to response!
        $debug = false;
        // Do not append Debug JSlog to response!
        $debug_jslog = false;
        $user_ID = $params['user_ID'];
        if (empty($user_ID)) {
            // Bad request
            return;
        }
        $UserCache =& get_UserCache();
        if (!($User =& $UserCache->get_by_ID($user_ID))) {
            // No user exists
            return;
        }
        global $UserSettings;
        // Get Country by IP address
        $Country = $this->get_country_by_IP(int2ip($UserSettings->get('created_fromIPv4', $User->ID)));
        if (empty($Country)) {
            // No found country
            echo sprintf(T_('No country found for IP address %s'), int2ip($UserSettings->get('created_fromIPv4', $User->ID)));
        } else {
            // Display country name with flag and Update user's field 'From Country'
            load_funcs('regional/model/_regional.funcs.php');
            country_flag($Country->get('code'), $Country->get_name());
            echo ' ' . $Country->get_name();
            // Update user
            global $DB;
            $DB->query('UPDATE T_users
					  SET user_reg_ctry_ID = ' . $DB->quote($Country->ID) . '
					WHERE user_ID = ' . $DB->quote($User->ID));
        }
    }
Example #6
0
if ($messages_received > 0 && $current_User->check_perm('perm_messaging', 'abuse')) {
    $messages_received .= ' - <a href="' . $admin_url . '?ctrl=abuse&amp;colselect_submit=Filter+list&amp;u=' . $edited_User->login . '" class="roundbutton middle" title="' . format_to_output(T_('Go to abuse management'), 'htmlattr') . '">' . get_icon('magnifier', 'imgtag', array('title' => T_('Go to abuse management'))) . '</a>';
}
$Form->info_field(T_('# of private messages received'), $messages_received);
$edited_user_lastseen = $edited_User->get('lastseen_ts');
$Form->info_field(T_('Last seen on'), empty($edited_user_lastseen) ? '' : mysql2localedatetime($edited_user_lastseen));
$Form->info_field(T_('On IP'), $edited_User->get_last_session_param('ipaddress'));
$Form->end_fieldset();
$from_country = '';
if (!empty($edited_User->reg_ctry_ID)) {
    // Get country that was defined by GeoIP Plugin on registration
    load_class('regional/model/_country.class.php', 'Country');
    load_funcs('regional/model/_regional.funcs.php');
    $CountryCache =& get_CountryCache();
    $Country = $CountryCache->get_by_ID($edited_User->reg_ctry_ID);
    $from_country = country_flag($Country->get('code'), $Country->get_name(), 'w16px', 'flag', '', false, true, 'margin-bottom:3px;vertical-align:middle;') . ' ' . $Country->get_name();
}
// Get field suffix for a field 'From Country' from the Plugins
$user_from_country_suffix = '';
$Plugins->restart();
while ($loop_Plugin =& $Plugins->get_next()) {
    $user_from_country_suffix .= $loop_Plugin->GetUserFromCountrySuffix($tmp_params = array('User' => &$edited_User));
}
$Form->begin_fieldset(T_('Registration info') . get_manual_link('user-admin-registration'));
$Form->info_field(T_('Account registered on'), $edited_User->dget('datecreated'), array('note' => '(' . date_ago(strtotime($edited_User->get('datecreated'))) . ')'));
$Form->info_field(T_('From IP'), format_to_output(int2ip($UserSettings->get('created_fromIPv4', $edited_User->ID))));
// Get status and name of IP range
$IPRangeCache =& get_IPRangeCache();
if ($IPRange =& $IPRangeCache->get_by_ip(int2ip($UserSettings->get('created_fromIPv4', $edited_User->ID)))) {
    // IP range exists in DB
    $iprange_status = $IPRange->get('status');