/**
 * Smarty {confvarlayout} function plugin
 *
 * Type:     function<br>
 * Name:     confvarlayout<br>
 * Purpose:  PS3 method to display the statusText layout for the special config variable given
 * @version  1.0
 * @param array
 * @param Smarty
 */
function smarty_function_confvarinput($args, &$smarty)
{
    global $conf_layout, $form;
    $args += array('var' => '', 'xhtml' => 1);
    //	$var = $conf_layout[$args['var']];
    $var = $args['var'];
    $name = $var['id'];
    $value = $form->value($name);
    $output = "";
    $options = explode(',', $var['options']);
    $type = strtolower($var['type']);
    switch ($type) {
        case 'none':
            $output = ps_escape_html($var['value']);
            break;
        case 'checkbox':
            $output .= sprintf("<input name='opts[%s]' value='1' type='checkbox' class='field'%s%s>", ps_escape_html($name), $value ? ' checked ' : '', $args['xhtml'] ? ' /' : '');
            break;
        case 'select':
            $output = sprintf("<select name='opts[%s]' class='field'>", ps_escape_html($name));
            $labels = varinput_build_select($var['options']);
            foreach ($labels as $v => $label) {
                $output .= sprintf("<option value=\"%s\"%s>%s</option>\n", ps_escape_html($v), $v == $value ? ' selected ' : '', ps_escape_html($label));
            }
            $output .= "</select>";
            break;
        case 'boolean':
            $idx = 0;
            $labels = varinput_build_boolean($conf_layout[$var]['options']);
            foreach ($labels as $label => $v) {
                $for = 'for-' . $name . '-' . ++$idx;
                $output .= sprintf("<input id='%s' name='opts[%s]' value=\"%s\" type='radio'%s%s>&nbsp;" . "<label class='for' for='{$for}'>%s</label>\n", $for, ps_escape_html($name), ps_escape_html($v), $v == $value ? ' checked ' : '', $args['xhtml'] ? ' /' : '', ps_escape_html($label));
            }
            break;
        case 'textarea':
            $attr = varinput_build_attr($var['options']);
            $rows = $attr['rows'] ? $attr['rows'] : 3;
            $cols = $attr['cols'] ? $attr['cols'] : 40;
            $wrap = $attr['wrap'] ? $attr['wrap'] : 'virtual';
            $class = $attr['class'] ? $attr['class'] : 'field';
            //			unset($attr['size'], $attr['class']);
            $output = sprintf("<textarea name=\"opts[%s]\" cols=\"%s\" rows=\"%s\" wrap=\"%s\" class=\"%s\">%s</textarea>", ps_escape_html($name), $cols, $rows, $wrap, $class, ps_escape_html($value));
            break;
        case 'text':
        default:
            $attr = varinput_build_attr($var['options']);
            $size = $attr['size'] ? $attr['size'] : 40;
            $class = $attr['class'] ? $attr['class'] : 'field';
            //			unset($attr['size'], $attr['class']);
            $output = sprintf("<input name=\"opts[%s]\" value=\"%s\" type=\"text\" size=\"%s\" class=\"%s\"%s>", ps_escape_html($name), ps_escape_html($value), $size, $class, $args['xhtml'] ? ' /' : '');
            break;
    }
    return $output;
}
/**
 * Smarty {confsection} function plugin
 *
 * Type:     function<br>
 * Name:     confsection<br>
 * Purpose:  PS3 method to display a label or value text for the section given
 * @version  1.0
 * @param array
 * @param Smarty
 */
function smarty_function_confsection($args, &$smarty)
{
    global $cms, $section_labels;
    if (!is_array($section_labels)) {
        return 'unknown';
    }
    $args += array('var' => 'label', 'ct' => 'main', 'sec' => 'unknown');
    $text = $section_labels[$args['ct']][$args['sec']][$args['var']];
    if ($args['var'] == 'label') {
        if ($text == '') {
            $text = $args['sec'];
        }
        $text = ps_escape_html($text);
    } else {
        if ($text == '') {
            $text = $cms->trans("No description available");
        }
    }
    return $text;
}
Beispiel #3
0
 *
 *	Version: $Id: themes.php 402 2008-04-21 14:55:05Z lifo $
 */
define("PSYCHOSTATS_PAGE", true);
include dirname(__FILE__) . "/includes/common.php";
$cms->init_theme($ps->conf['main']['theme'], $ps->conf['theme']);
$ps->theme_setup($cms->theme);
$cms->theme->page_title('PsychoStats - Theme Gallery');
// collect url parameters ...
$validfields = array('t');
$cms->theme->assign_request_vars($validfields, true);
$t = trim($t);
$themes = $cms->theme->get_theme_list();
// update the user's theme if they selected one from the list
if ($t) {
    if ($cms->theme->is_theme($t, true)) {
        $cms->session->opt('theme', $t);
        $cms->session->save_session_options();
    } else {
        // report an error?
        // na... just silently ignore the language
        //		trigger_error("Invalid theme specified!", E_USER_WARNING);
    }
    previouspage($PHP_SELF . "#" . ps_escape_html($t));
}
// assign variables to the theme
$cms->theme->assign(array('themes' => $themes, 'theme' => $cms->theme->theme));
// display the output
$basename = basename(__FILE__, '.php');
//$cms->theme->add_js('js/themes.js');
$cms->full_page($basename, $basename, $basename . '_header', $basename . '_footer');
Beispiel #4
0
    $ps->player_roles_table_mod($rtable);
    $cms->filter('player_role_table_object', $rtable);
}
// build player victim table
$vtable = $cms->new_table($player['victims']);
$vtable->if_no_data($cms->trans("No Victims Found"));
$vtable->attr('class', 'ps-table ps-player-table');
$vtable->sort_baseurl(array('id' => $id, '_anchor' => 'victims'));
$vtable->start_and_sort($vstart, $vsort, $vorder, 'v');
$vtable->columns(array('+' => '#', 'rank' => array('label' => $cms->trans("Rank"), 'callback' => 'dash_if_empty'), 'name' => array('label' => $cms->trans("Victim"), 'callback' => 'ps_table_victim_link'), 'kills' => array('label' => $cms->trans("Kills"), 'modifier' => 'commify', 'tooltip' => $cms->trans("Kills")), 'deaths' => array('label' => $cms->trans("Deaths"), 'modifier' => 'commify', 'tooltip' => $cms->trans("Deaths")), 'killsperdeath' => array('label' => $cms->trans("K:D"), 'tooltip' => $cms->trans("Kills Per Death")), 'skill' => $cms->trans("Skill")));
$vtable->column_attr('name', 'class', 'left');
$vtable->column_attr('skill', 'class', 'right');
$ps->player_victims_table_mod($wtable);
$cms->filter('player_victim_table_object', $vtable);
$cms->theme->assign_by_ref('plr', $player);
$cms->theme->assign(array('hitbox_url' => ps_escape_html("weaponxml={$PHP_SELF}") . "&amp;id={$id}" . '&amp;' . ps_escape_html("imgpath=" . dirname($PHP_SELF) . '/img/weapons/' . $ps->conf['main']['gametype'] . '/' . $ps->conf['main']['modtype']), 'weapons_table' => $wtable->render(), 'sessions_table' => $stable->render(), 'maps_table' => $mtable->render(), 'roles_table' => $rtable ? $rtable->render() : '', 'victims_table' => $vtable->render(), 'sessionpager' => $sessionpager, 'mappager' => $mappager, 'rolepager' => $rolepager, 'victimpager' => $victimpager, 'totalranked' => $totalranked, 'max_plr_ids' => $MAX_PLR_IDS, 'top10percentile' => $player['rank'] ? $player['rank'] < $totalranked * 0.1 : false, 'top1percentile' => $player['rank'] ? $player['rank'] < $totalranked * 0.01 : false));
$basename = basename(__FILE__, '.php');
if ($player['plrid']) {
    // allow mods to have their own section on the left side bar
    $ps->player_left_column_mod($player, $cms->theme);
    if ($ps->conf['main']['gametype'] == 'halflife' and $ps->conf['main']['uniqueid'] == 'worldid') {
        $steamid = $player['ids_worldid'][0]['worldid'];
        if ($steamid and strtoupper(substr($steamid, 0, 5)) == 'STEAM') {
            include_once PS_ROOTDIR . "/includes/class_valve.php";
            $v = new Valve_AuthId();
            $friendid = $v->get_friend_id($steamid);
            $player['friend_id'] = $friendid;
            $player['steam_community_url'] = $v->steam_community_url($friendid);
            $player['steam_add_friend_url'] = $v->steam_add_friend_url($friendid);
        }
    }
Beispiel #5
0
 /**
  * DEBUG handler. Outputs as much debugging information possible
  * somewhere within the current theme output. 
  */
 function ps_debug(&$buffer)
 {
     global $cms, $ps;
     $str = '';
     // output all queries sent
     $str .= "<ul class='ps-debug'>\n";
     foreach ($ps->db->queries as $q) {
         $str .= "<li>" . ps_escape_html($q) . "</li>\n";
     }
     $str .= "</ul>\n";
     // output any errors that occured
     if ($ps->db->errors) {
         $str .= "<ul class='ps-debug'>\n";
         foreach ($ps->db->errors as $e) {
             $str .= "\t<li><span class='error'>" . $e['error'] . "</span>\n\t<span class='query'>" . $e['query'] . "</span></li>\n";
         }
         $str .= "</ul>\n";
     }
     $buffer = str_replace('</body>', $str . '</body>', $buffer);
 }
Beispiel #6
0
            $set = array_merge($set, $iplist[$ip]);
        }
        unset($set['ip'], $set['ipaddr']);
        $set['onlinetime'] = compacttime($set['onlinetime']);
        //		$set['activity_bar'] = pct_bar(array('pct' => $set['activity'], 'width' => 215, 'title' => "Activity: " . $set['activity'] . "%" ));
        if (!empty($set['lat']) and !empty($set['lng'])) {
            $markers[$ip] = $set;
        }
    }
    // now, spew out the markers XML
    $xml = "<markers>\n";
    $markers = array_merge($profiles, $markers);
    foreach ($markers as $m) {
        $node = "  <marker ";
        foreach ($m as $key => $val) {
            $node .= "{$key}=\"" . ps_escape_html($val) . "\" ";
        }
        $node .= "/>\n";
        $xml .= $node;
    }
    $xml .= "</markers>\n";
    header("Content-Type: text/xml");
    print $xml;
    exit;
} elseif ($ofc) {
    switch ($ofc) {
        case 'day':
            return_ofc_day();
            break;
        case 'h24':
            return_ofc_24();
Beispiel #7
0
 function flagimg($cc, $args = array())
 {
     $args += array('alt' => NULL, 'height' => NULL, 'width' => NULL, 'path' => '', 'noimg' => '', 'urlonly' => false, 'style' => '', 'class' => '', 'id' => '', 'extra' => '');
     if (empty($cc)) {
         return '';
     }
     $cc = strtolower($cc);
     $path = !empty($args['path']) ? $args['path'] : '';
     $basedir = catfile($this->conf['theme']['flags_dir'], $path);
     $baseurl = catfile($this->conf['theme']['flags_url'], $path);
     $alt = ps_escape_html($args['alt'] !== NULL ? $args['alt'] : $cc);
     $label = $alt;
     $ext = array_map('trim', explode(',', str_replace('.', '', $this->conf['theme']['images']['search_ext'])));
     $name = rawurlencode($cc);
     $img = "";
     $file = "";
     $url = "";
     foreach ($ext as $e) {
         $file = catfile($basedir, $cc) . '.' . $e;
         $url = catfile($baseurl, $name) . '.' . $e;
         if (@file_exists($file)) {
             break;
         }
         $file = "";
     }
     if (!@file_exists($file)) {
         // we're done...
         return $args['noimg'] !== NULL ? $args['noimg'] : $label;
     }
     if ($args['urlonly']) {
         return $url;
     }
     $attrs = "";
     if (is_numeric($args['width'])) {
         $attrs .= " width='" . $args['width'] . "'";
     }
     if (is_numeric($args['height'])) {
         $attrs .= " height='" . $args['height'] . "'";
     }
     if (!empty($args['style'])) {
         $attrs .= " style='" . $args['style'] . "'";
     }
     if (!empty($args['class'])) {
         $attrs .= " class='" . $args['class'] . "'";
     }
     if (!empty($args['id'])) {
         $attrs .= " id='" . $args['id'] . "'";
     }
     if (!empty($args['extra'])) {
         $attrs .= " " . $args['extra'];
     }
     $img = "<img src='{$url}' title='{$label}' alt='{$alt}'{$attrs} />";
     return $img;
 }
Beispiel #8
0
 function meta_tags()
 {
     if (!is_array($this->meta_tags)) {
         return '';
     }
     $out = '';
     foreach ($this->meta_tags as $meta) {
         $out .= "\t<meta ";
         foreach ($meta as $key => $val) {
             $out .= "{$key}='" . ps_escape_html($val) . "' ";
         }
         $out .= "/>\n";
     }
     return $out;
 }
Beispiel #9
0
if (!in_array($t, array('csv', 'xml', 'dom', 'img'))) {
    $t = 'img';
}
$list = array();
// first build a list of icons from our local directory
$dir = $ps->conf['theme']['icons_dir'];
$url = $ps->conf['theme']['icons_url'];
if ($dh = @opendir($dir)) {
    while (($file = @readdir($dh)) !== false) {
        if (substr($file, 0, 1) == '.') {
            continue;
        }
        // skip dot files
        $fullfile = catfile($dir, $file);
        if (is_dir($fullfile)) {
            continue;
        }
        // skip directories
        if (is_link($fullfile)) {
            continue;
        }
        // skip symlinks
        $info = getimagesize($fullfile);
        $size = @filesize($fullfile);
        $list[$file] = array('filename' => rawurlencode($file), 'url' => catfile($url, rawurlencode($file)), 'desc' => ps_escape_html(sprintf("%s - %dx%d - %s", $file, $info[0], $info[1], abbrnum($size))), 'size' => $size, 'width' => $info[0], 'height' => $info[1], 'attr' => $info[3]);
    }
    @closedir($dh);
}
ksort($list);
$fields = array('filename', 'url', 'size', 'width', 'height');
output_list($t, $list, $fields, $idstr);
Beispiel #10
0
$pager = pagination(array('baseurl' => ps_url_wrapper($baseurl), 'total' => $total['ranked'], 'start' => $start, 'perpage' => $limit, 'pergroup' => 5, 'separator' => ' ', 'force_prev_next' => true, 'next' => $cms->trans("Next"), 'prev' => $cms->trans("Previous")));
// build a dynamic table that plugins can use to add custom columns of data
$table = $cms->new_table($players);
$table->if_no_data($cms->trans("No Players Found"));
$table->attr('class', 'ps-table ps-player-table');
$table->sort_baseurl($search ? array('search' => $search) : array('q' => $q));
$table->start_and_sort($start, $sort, $order);
$table->columns(array('rank' => array('label' => $cms->trans("Rank"), 'callback' => 'dash_if_empty'), 'prevrank' => array('nolabel' => true, 'callback' => 'rankchange'), 'name' => array('label' => $cms->trans("Player"), 'callback' => 'ps_table_plr_link'), 'kills' => array('label' => $cms->trans("Kills"), 'modifier' => 'commify'), 'deaths' => array('label' => $cms->trans("Deaths"), 'modifier' => 'commify'), 'killsperdeath' => array('label' => $cms->trans("K:D"), 'tooltip' => $cms->trans("Kills Per Death")), 'headshotkills' => array('label' => $cms->trans("HS"), 'modifier' => 'commify', 'tooltip' => $cms->trans("Headshot Kills")), 'headshotkillspct' => array('label' => $cms->trans("HS%"), 'modifier' => '%s%%', 'tooltip' => $cms->trans("Headshot Kills Percentage")), 'onlinetime' => array('label' => $cms->trans("Online"), 'modifier' => 'compacttime'), 'activity' => array('label' => $cms->trans("Activity"), 'modifier' => 'activity_bar'), 'skill' => array('label' => $cms->trans("Skill"), 'callback' => 'plr_skill')));
$table->column_attr('name', 'class', 'left');
$table->column_attr('skill', 'class', 'right');
//$table->column_attr('rank', 'class', 'left');
$table->header_attr('rank', 'colspan', '2');
$ps->index_table_mod($table);
$cms->filter('players_table_object', $table);
// assign variables to the theme
$cms->theme->assign(array('q' => $q, 'search' => $search, 'results' => $results, 'search_blurb' => $cms->trans('Search criteria "<em>%s</em>" matched %d ranked players out of %d total', ps_escape_html($q), $total['ranked'], $total['absolute']), 'players' => $players, 'players_table' => $table->render(), 'total' => $total, 'pager' => $pager, 'language_list' => $cms->theme->get_language_list(), 'theme_list' => $cms->theme->get_theme_list(), 'language' => $cms->theme->language));
// display the output
$basename = basename(__FILE__, '.php');
//$cms->theme->add_js('js/index.js');
$cms->full_page($basename, $basename, $basename . '_header', $basename . '_footer');
function activity_bar($pct)
{
    $out = pct_bar(array('pct' => $pct));
    return $out;
}
function dash_if_empty($val)
{
    return !empty($val) ? $val : '-';
}
function rankchange($val, $plr)
{
Beispiel #11
0
function htmlentities_all(&$ary, $trimtags = 0)
{
    if (!is_array($ary)) {
        $ary = ps_escape_html($ary);
        return;
    }
    reset($ary);
    while (list($key, $val) = each($ary)) {
        $ary[$key] = ps_escape_html($ary[$key]);
    }
}
Beispiel #12
0
    /*
    	$xml = '<?xml version="1.0"?><ajaxresponse>';
    	foreach ($list as $p) {
    		$xml .= sprintf("<item><text><![CDATA[%s]]></text><value><![CDATA[%s]]></value><plrid>%d</plrid></item>\n", 
    			"<b>" . $p['name'] . "</b><br/><small>" . $p['uniqueid'] . "</small>",
    			$p['name'],
    			$p['plrid']
    		);
    	}
    	$xml .= "</ajaxresponse>\n";
    	header("Content-Type: text/xml");
    	print $xml;
    */
    $html = "";
    foreach ($list as $p) {
        $html .= sprintf("<option value='%d'>%s %s</option>\n", $p['plrid'], $ps->conf['main']['uniqueid'] != 'name' ? ps_escape_html($p['uniqueid']) . ':' : '', ps_escape_html($p['name']));
    }
    print $html;
    //str_replace('  ', '&nbsp;&nbsp;', $html);
    exit;
}
if ($cancel) {
    previouspage(ps_url_wrapper(array('_amp' => '&', '_base' => 'clans.php')));
}
$clan = array();
$members = array();
// load the matching clan if an ID was given
if ($id) {
    // load the clan based on their clanid
    $clan = $ps->get_clan_profile($id);
    if ($clan and $clan['profile_clantag'] == null) {
Beispiel #13
0
function load_admins()
{
    global $cms, $filter;
    $list = $cms->user->get_user_list(false, $filter);
    $admin_list = array();
    foreach ($list as $u) {
        $admin_list[] = "<a href='javascript:void(0)'>" . ps_escape_html($u['username']) . "</a>";
    }
    return $admin_list ? join(', ', $admin_list) : '';
}