Пример #1
0
    function draw($result, $numitems, $width = 100, $align = 'center')
    {
        global $g_options, $game, $realgame, $db;
        $numpages = ceil($numitems / $this->numperpage);
        ?>

<div class="subblock" style="width:<?php 
        echo $width;
        ?>
%;text-align:<?php 
        echo $align;
        ?>
;">

<table class="data-table">

		<tr class="data-table-head">
<?php 
        $totalwidth = 0;
        if ($this->showranking) {
            $totalwidth += 5;
            echo "<td style=\"width:5%;text-align=:right;\" class=\"fSmall\">Rank</td>\n";
        }
        foreach ($this->columns as $col) {
            $totalwidth += $col->width;
            echo "<td style=\"width:{$col->width}%;text-align:{$col->align};\" class=\"fSmall\">";
            if ($col->sort != 'no') {
                echo getSortArrow($this->sort, $this->sortorder, $col->name, $col->title, $this->var_sort, $this->var_sortorder, $this->sorthash, $this->ajax);
            } else {
                echo $col->title;
            }
            echo "</td>\n";
        }
        ?>
		</tr>

<?php 
        if ($totalwidth != 100) {
            error("Warning: Column widths do not add to 100%! (={$totalwidth}%)", false);
        }
        $rank = ($this->page - 1) * $this->numperpage + 1;
        while ($rowdata = $db->fetch_array($result)) {
            echo "<tr>\n";
            $i = 0;
            if ($this->showranking) {
                $c = $i % 2 + 1;
                $i++;
                echo "<td style=\"text-align:right;\" class=\"bg{$c}\">{$rank}</td>\n";
            }
            foreach ($this->columns as $col) {
                $c = $i % 2 + 1;
                $class = "";
                $cellbody = '';
                $colval = $rowdata[$col->name];
                if ($col->align != 'left') {
                    $colalign = " style=\"text-align:{$col->align};\"";
                } else {
                    $colalign = "";
                }
                $class = "bg{$c}";
                if ($col->icon || $col->flag) {
                    $cellbody = '&nbsp;';
                }
                if ($col->link) {
                    if (strpos($col->link, 'javascript:') === false) {
                        $link = str_ireplace('%k', urlencode($rowdata[$this->keycol]), $col->link);
                        $cellbody .= "<a href=\"" . $g_options['scripturl'] . "?{$link}\">";
                    } else {
                        $col->link = str_replace('\\\\', '', $col->link);
                        $link = str_ireplace('%k', $rowdata[$this->keycol], $col->link);
                        $cellbody .= "<a href=\"{$link}\">";
                    }
                }
                if ($col->icon) {
                    $image = getImage("/{$col->icon}");
                    if ($image) {
                        $cellbody .= '<img src="' . $image['url'] . "\" class=\"tableicon\" alt=\"{$col->icon}\" />";
                    }
                } elseif ($col->flag) {
                    #$link = ereg_replace("%f", $col->link);
                    if ($g_options['countrydata'] == 1) {
                        if ($rowdata['flag'] == '') {
                            $rowdata['flag'] = '0';
                            $alt_text = 'No Country';
                        } else {
                            $alt_text = ucfirst(strtolower($rowdata['country']));
                        }
                        $cellbody .= '<img src="' . getFlag($rowdata['flag']) . "\" class=\"tableicon\" alt=\"{$alt_text}\" title=\"{$alt_text}\" />";
                    } else {
                        $col->flag = 'player';
                        $cellbody .= '<img src="' . IMAGE_PATH . "/{$col->flag}.gif\" class=\"tableicon\" alt=\"{$col->icon}.gif\" />";
                    }
                }
                switch ($col->type) {
                    case 'timestamp':
                        $cellbody = timestamp_to_str($colval);
                        break;
                    case 'roleimg':
                        $image = getImage("/games/{$game}/roles/" . strtolower($colval));
                        // check if image exists for game -- otherwise check realgame
                        if ($image) {
                            $cellbody .= '<img src="' . $image['url'] . '" alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" />&nbsp;';
                        } elseif ($image = getImage("/games/{$realgame}/roles/" . strtolower($colval))) {
                            $cellbody .= '<img src="' . $image['url'] . '" alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" />&nbsp;';
                        }
                        if ($col->fname[$colval] != '') {
                            $cellbody .= '<b>' . $col->fname[$colval] . '</b>';
                        } else {
                            $cellbody .= '<b>' . ucwords(preg_replace('/_/', ' ', $colval)) . '</b>';
                        }
                        break;
                    case 'weaponimg':
                        // Check if game has the image -- if not, failback to real game.  If not, no image.
                        $image = getImage("/games/{$realgame}/weapons/" . strtolower($colval));
                        if ($image) {
                            $cellbody .= '<img src="' . $image['url'] . '" ' . $image['size'] . ' alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" />';
                        } elseif ($image = getImage("/games/{$realgame}/weapons/" . strtolower($colval))) {
                            $cellbody .= '<img src="' . $image['url'] . '" ' . $image['size'] . ' alt="' . $col->fname[$colval] . '" title="' . $col->fname[$colval] . '" />';
                        } else {
                            $cellbody .= '<b>' . ($col->fname[$colval] != '' ? $col->fname[$colval] : ucwords(preg_replace('/_/', ' ', $colval))) . '</b>';
                        }
                        break;
                    case 'bargraph':
                        $cellbody .= '<img src="' . IMAGE_PATH . '/bar';
                        if ($colval > 40) {
                            $cellbody .= '6';
                        } elseif ($colval > 30) {
                            $cellbody .= '5';
                        } elseif ($colval > 20) {
                            $cellbody .= '4';
                        } elseif ($colval > 10) {
                            $cellbody .= '3';
                        } elseif ($colval > 5) {
                            $cellbody .= '2';
                        } else {
                            $cellbody .= '1';
                        }
                        $cellbody .= '.gif" style="width:';
                        if ($colval < 1) {
                            $cellbody .= '1';
                        } elseif ($colval > 100) {
                            $cellbody .= '100';
                        } else {
                            $cellbody .= sprintf("%d", $colval + 0.5);
                        }
                        $cellbody .= "%;\" class=\"bargraph\" alt=\"{$colval}%\" />";
                        break;
                    case 'heatmap':
                        $heatmap = getImage("/games/{$game}/heatmaps/{$colval}-kill");
                        $heatmapthumb = getImage("/games/{$game}/heatmaps/{$colval}-kill-thumb");
                        if ($heatmap) {
                            $cellbody .= "<span style=\"text-align: center;\"><a href=\"" . $heatmap['url'] . "\" rel=\"boxed\"><img width=\"20\" height=\"16\" src=\"" . $heatmapthumb['url'] . "\" /></a></span>";
                        } else {
                            $cellbody .= "&nbsp;";
                        }
                        break;
                    default:
                        if ($this->showranking && $rank == 1 && $i == 1) {
                            $cellbody .= '<b>';
                        }
                        if (is_numeric($colval) && $colval >= 1000) {
                            $colval = number_format($colval);
                        }
                        $colval = nl2br(htmlspecialchars($colval, ENT_COMPAT));
                        if ($col->embedlink == 'yes') {
                            $colval = preg_replace(array('/%A%([^ %]+)%/', '/%\\/A%/'), array("<a href=\"\$1\">", '</a>'), $colval);
                        }
                        $cellbody .= $colval;
                        if ($this->showranking && $rank == 1 && $i == 1) {
                            $cellbody .= '</b>';
                        }
                        break;
                }
                if ($col->link) {
                    $cellbody .= '</a>';
                }
                if ($col->append) {
                    $cellbody .= $col->append;
                }
                if ($col->skill_change) {
                    if ($rowdata['last_skill_change'] == '') {
                        $rowdata['last_skill_change'] = 0;
                    }
                    if ($rowdata['last_skill_change'] == 0) {
                        $cellbody .= "&nbsp;<img src=\"" . IMAGE_PATH . "/t1.gif\" alt=\"" . $rowdata['last_skill_change'] . " Points\" />";
                    } elseif ($rowdata['last_skill_change'] > 0) {
                        $cellbody .= "&nbsp;<img src=\"" . IMAGE_PATH . "/t0.gif\" alt=\"" . $rowdata['last_skill_change'] . " Points\" />";
                    } elseif ($rowdata['last_skill_change'] < 0) {
                        $cellbody .= "&nbsp;<img src=\"" . IMAGE_PATH . "/t2.gif\" alt=\"" . $rowdata['last_skill_change'] . " Points\" />";
                    }
                }
                echo "<td{$colalign} class=\"{$class}\">" . $cellbody . "</td>\n";
                $i++;
            }
            echo "</tr>\n\n";
            $rank++;
        }
        ?>
		</table>
</div><br /><br />
<?php 
        if ($numpages > 1) {
            ?>
<div class="subblock" style="text-align:right;">
	<span style="text-align:right;">
<?php 
            echo 'Page: ';
            $start = $this->page - intval($this->maxpagenumbers / 2);
            if ($start < 1) {
                $start = 1;
            }
            $end = $numpages;
            if ($end > $this->maxpagenumbers + $start - 1) {
                $end = $this->maxpagenumbers + $start - 1;
            }
            if ($end - $start + 1 < $this->maxpagenumbers) {
                $start = $end - $this->maxpagenumbers + 1;
            }
            if ($start < 1) {
                $start = 1;
            }
            if ($start > 1) {
                if ($start > 2) {
                    $this->_echoPageNumber(1, "First page", "", " ...");
                } else {
                    $this->_echoPageNumber(1, 1);
                }
            }
            for ($i = $start; $i <= $end; $i++) {
                if ($i == $this->page) {
                    echo "<b>{$i}</b> ";
                } else {
                    $this->_echoPageNumber($i, $i);
                }
                if ($i == $end && $i < $numpages) {
                    if ($i < $numpages - 1) {
                        $this->_echoPageNumber($numpages, "Last page", "... ");
                    } else {
                        $this->_echoPageNumber($numpages, 10);
                    }
                }
            }
            ?>
	</span>
</div><br /><br />
<?php 
        }
    }
Пример #2
0
    function draw($result, $numitems, $width = 100, $align = "center")
    {
        global $g_options, $game;
        $numpages = ceil($numitems / $this->numperpage);
        ?>

<table width="<?php 
        echo $width;
        ?>
%" align="<?php 
        echo $align;
        ?>
" border="0" cellspacing="0" cellpadding="0" bgcolor="<?php 
        echo $g_options["table_border"];
        ?>
">

<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="4">

	<tr valign="bottom" bgcolor="<?php 
        echo $g_options["table_head_bgcolor"];
        ?>
">
<?php 
        $totalwidth = 0;
        if ($this->showranking) {
            $totalwidth += 5;
            echo "<td width=\"5%\" align=\"right\">" . "<font color=\"" . $g_options["table_head_text"] . "\">" . $g_options["font_small"] . l("Rank") . "</font>" . $g_options["fontend_small"] . "</td>\n";
        }
        foreach ($this->columns as $col) {
            $totalwidth += $col->width;
            echo "<td width=\"" . $col->width . "%\" align=\"{$col->align}\">";
            if ($col->translate) {
                $col->title = l($col->title);
            }
            if ($col->sort != "no") {
                echo getSortArrow($this->sort, $this->sortorder, $col->name, $col->title, $this->var_sort, $this->var_sortorder, $this->sorthash);
            } else {
                echo $g_options["font_small"];
                echo "<font color=\"" . $g_options["table_head_text"] . "\">";
                echo $col->title;
                echo "</font>";
                echo $g_options["fontend_small"];
            }
            echo "</td>\n";
        }
        ?>
	</tr>

<?php 
        if ($totalwidth != 100) {
            error("Warning: Column widths do not add to 100%! (={$totalwidth}%)", false);
        }
        $rank = ($this->page - 1) * $this->numperpage + 1;
        while ($rowdata = mysql_fetch_assoc($result)) {
            echo "<tr>\n";
            $i = 0;
            if ($this->showranking) {
                $c = $i % 2 + 1;
                $i++;
                echo "<td align=\"right\" bgcolor=\"" . $g_options["table_bgcolor{$c}"] . "\">" . $g_options["font_normal"] . "{$rank}." . $g_options["fontend_normal"] . "</td>\n";
            }
            foreach ($this->columns as $col) {
                $c = $i % 2 + 1;
                $cellbody = "";
                $colval = $rowdata[$col->name];
                if ($col->align != "left") {
                    $colalign = " align=\"{$col->align}\"";
                } else {
                    $colalign = "";
                }
                $bgcolor = $g_options["table_bgcolor{$c}"];
                if ($col->icon) {
                    $cellbody = "&nbsp;";
                }
                // this needs to be changed.
                // remove table class and do it for every table manually
                // this way to do not have those if masages
                if ($col->name == "skill") {
                    // check if we have a top or flop
                    if (empty($rowdata['oldSkill'])) {
                        $rowdata['oldSkill'] = $rowdata['skill'];
                    }
                    if ($rowdata['skill'] > $rowdata['oldSkill']) {
                        $cellbody .= "<img src=\"" . $g_options["imgdir"] . "/skill_up.gif\" width='16' height='16' hspace='4' " . "border='0' align=\"middle\" alt=\"{$col->icon}.gif\">";
                    } elseif ($rowdata['skill'] < $rowdata['oldSkill']) {
                        $cellbody .= "<img src=\"" . $g_options["imgdir"] . "/skill_down.gif\" width='16' height='16' hspace='4' " . "border='0' align=\"middle\" alt=\"{$col->icon}.gif\">";
                    } else {
                        $cellbody .= "<img src=\"" . $g_options["imgdir"] . "/skill_stay.gif\" width='16' height='16' hspace='4' " . "border='0' align=\"middle\" alt=\"{$col->icon}.gif\">";
                    }
                }
                if ($col->link) {
                    $link = ereg_replace("%k", urlencode($rowdata[$this->keycol]), $col->link);
                    $cellbody .= "<a href=\"index.php?{$link}\">";
                }
                if ($col->icon) {
                    $pic = $col->icon . ".gif";
                    if ($col->icon == "player") {
                        if (isset($rowdata['active']) && $rowdata['active'] == "0") {
                            $pic = "player_inactive.gif";
                        }
                    }
                    $cellbody .= "<img src='" . $g_options["imgdir"] . $pic . "' width='16' height='16' hspace='4' " . "border='0' align=\"middle\" alt=\"{$col->icon}\">";
                }
                switch ($col->type) {
                    case "weaponimg":
                        $colval = strtolower(ereg_replace("[ \r\n\t]*", "", $colval));
                        $bgcolor = $g_options["table_wpnbgcolor"];
                        $image = getImage("/weapons/{$game}/{$colval}");
                        // check if image exists
                        if ($image) {
                            $cellbody .= "<img src=\"" . $image["url"] . "\" " . $image["size"] . " border='0' title='" . $rowdata['name'] . "' alt=\"" . $rowdata['name'] . "\">";
                        } else {
                            $cellbody .= $g_options["font_small"];
                            $cellbody .= "<font color=\"#FFFFFF\" class=\"weapon\"><b>";
                            $cellbody .= strToUpper($colval);
                            $cellbody .= "</b></font>";
                            $cellbody .= $g_options["fontend_small"];
                        }
                        break;
                    case "bargraph":
                        $cellbody .= "<img src=\"" . $g_options["imgdir"] . "/bar";
                        if ($colval > 40) {
                            $cellbody .= "6";
                        } elseif ($colval > 30) {
                            $cellbody .= "5";
                        } elseif ($colval > 20) {
                            $cellbody .= "4";
                        } elseif ($colval > 10) {
                            $cellbody .= "3";
                        } elseif ($colval > 5) {
                            $cellbody .= "2";
                        } else {
                            $cellbody .= "1";
                        }
                        $cellbody .= ".gif\" width=\"";
                        if ($colval < 1) {
                            $cellbody .= "1%";
                        } elseif ($colval > 100) {
                            $cellbody .= "100%";
                        } else {
                            $cellbody .= sprintf("%d%%", $colval + 0.5);
                        }
                        $cellbody .= "\" height=10 border='0' alt=\"{$colval}%\">";
                        break;
                    case 'roleimg':
                        $cellbody .= $colval;
                        $rowdata['rolecode'] = str_replace('#', '', $rowdata['rolecode']);
                        if (file_exists($g_options["imgdir"] . '/roles/' . $game . '/' . $rowdata['rolecode'] . '.png')) {
                            $cellbody .= '<img src="' . $g_options["imgdir"] . '/roles/' . $game . '/' . $rowdata['rolecode'] . '.png"
										hspace="10" border="0" align="middle" alt="' . $rowdata['rolecode'] . '">';
                        }
                        break;
                    default:
                        if ($this->showranking && $rank == 1 && $i == 1) {
                            $cellbody .= "<b>";
                        }
                        #$colval = nl2br(htmlentities($colval, ENT_COMPAT, "UTF-8"));
                        $colval = nl2br(ereg_replace(" ", "&nbsp;", htmlspecialchars($colval)));
                        if ($col->embedlink == "yes") {
                            $colval = ereg_replace("%A%([^ %]+)%", "<a href=\"\\1\">", $colval);
                            $colval = ereg_replace("%/A%", "</a>", $colval);
                        }
                        $cellbody .= $colval;
                        if ($this->showranking && $rank == 1 && $i == 1) {
                            $cellbody .= "</b>";
                        }
                        break;
                }
                if (!empty($col->link)) {
                    $cellbody .= "</a>";
                }
                if (!empty($col->append)) {
                    $cellbody .= $col->append;
                }
                echo "<td{$colalign} bgcolor=\"{$bgcolor}\">" . $g_options["font_normal"] . $cellbody . $g_options["fontend_normal"] . "</td>\n";
                $i++;
            }
            echo "</tr>\n\n";
            $rank++;
        }
        ?>
	</table></td>
</tr>

</table>
<?php 
        if ($numpages > 1) {
            ?>
<p>
<table width="<?php 
            echo $width;
            ?>
%" align="<?php 
            echo $align;
            ?>
" border="0" cellspacing="0" cellpadding="0">

<tr valign="top">
<td width="100%" align="right"><?php 
            echo $g_options["font_normal"];
            echo "Page: ";
            $start = $this->page - intval($this->maxpagenumbers / 2);
            if ($start < 1) {
                $start = 1;
            }
            $end = $numpages;
            if ($end > $this->maxpagenumbers + $start - 1) {
                $end = $this->maxpagenumbers + $start - 1;
            }
            if ($end - $start + 1 < $this->maxpagenumbers) {
                $start = $end - $this->maxpagenumbers + 1;
            }
            if ($start < 1) {
                $start = 1;
            }
            if ($start > 1) {
                if ($start > 2) {
                    $this->_echoPageNumber(1, "First page", "", " ...");
                } else {
                    $this->_echoPageNumber(1, 1);
                }
            }
            for ($i = $start; $i <= $end; $i++) {
                if ($i == $this->page) {
                    echo "<b>{$i}</b> ";
                } else {
                    $this->_echoPageNumber($i, $i);
                }
                if ($i == $end && $i < $numpages) {
                    if ($i < $numpages - 1) {
                        $this->_echoPageNumber($numpages, "Last page", "... ");
                    } else {
                        $this->_echoPageNumber($numpages, 10);
                    }
                }
            }
            echo $g_options["fontend_normal"];
            ?>
</td>
</tr>

</table><p>
<?php 
        }
    }
Пример #3
0
?>
">
						Name<?php 
echo getSortArrow('username', $sort, $direction);
?>
					</a>
				</div>
			</th>
			<th>
				<div align="center">
					<a href="javascript:;" onclick="<?php 
echo getSortLink('email', $sort, $direction);
?>
">
						Email<?php 
echo getSortArrow('email', $sort, $direction);
?>
					</a>
				</div>
			</th>
			<th>
				<div align="center">
					Space
				</div>
			</th>
			<th>
				<div align="center">
					Actions
				</div>
			</th>
		</tr>
Пример #4
0
					<a href="javascript:;" onclick="<?=getSortLink('id', $sort, $direction)?>">
						ID #<?=getSortArrow('id', $sort, $direction)?>
					</a>
				</div>
			</th>
			<th>
				<div align="center">
					<a href="javascript:;" onclick="<?=getSortLink('username', $sort, $direction)?>">
						Name<?=getSortArrow('username', $sort, $direction)?>
					</a>
				</div>
			</th>
			<th>
				<div align="center">
					<a href="javascript:;" onclick="<?=getSortLink('email', $sort, $direction)?>">
						Email<?=getSortArrow('email', $sort, $direction)?>
					</a>
				</div>
			</th>
			<th>
				<div align="center">
					Space
				</div>
			</th>
			<th>
				<div align="center">
					Actions
				</div>
			</th>
		</tr>
		<?php
Пример #5
0
				<a href="javascript:;" onclick="<?php 
echo getSortLink('size', $sort, $direction);
?>
">
					Size<?php 
echo getSortArrow('size', $sort, $direction);
?>
				</a>
			</th>
			<th>
				<a href="javascript:;" onclick="<?php 
echo getSortLink('time', $sort, $direction);
?>
">
					Date<?php 
echo getSortArrow('time', $sort, $direction);
?>
				</a>
			</th>
			<th>
				Actions
			</th>
		</tr>
		<?php 
foreach ($files->result() as $file) {
    $links = $this->files_db->getLinks('', $file);
    ?>
			
			<tr <?php 
    echo alternator('class="odd"', 'class="even"');
    ?>