View Single Post
Old 26.03.2007, 14:08   #2
DFS
Архивный участник
 
Join Date: Mar 2007
Posts: 54
Default

выдернул из своего сайта
файл ssq.php
Quote:
<?
mssql_connect($db_ip, $db_user, $db_pass);
mssql_select_db("lin2world");

$ssq_s = array("Не задан", "Период борьбы", "Период подсчета очков", "Период действия печатей");
$ssq_w = array("Не определена", "Revolutionary Army of Dusk", "Lords of Dawn");

$result = mssql_query("SELECT TOP 1 *
FROM ssq_data
ORDER BY round_number DESC;");
$ssq = mssql_fetch_assoc($result);

$result = mssql_query("SELECT TOP 1 *
FROM ssq_join_data
WHERE round_number=".$ssq["round_number"]." AND type=1
ORDER BY round_number DESC;");
$ssq_dusk = mssql_fetch_assoc($result);

$result = mssql_query("SELECT TOP 1 *
FROM ssq_join_data
WHERE round_number=".$ssq["round_number"]." AND type=2
ORDER BY round_number DESC;");
$ssq_dawn = mssql_fetch_assoc($result);

if ($ssq["round_number"]==0)
$ssq["round"] = "Не задан";
else
$ssq["round"] = $ssq["round_number"];
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="border-tl"> </td>
<td class="border-t h-cell t-bold">Статистика Семи Печатей</td>
<td class="border-tr"> </td>
</tr>
<tr><td class="border-l"> </td><td class="n-cell">
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td> Текущий раунд:</td>
<td width="165"><?=$ssq["round"]?> </td>
</tr>
<tr>
<td> Текущий период:</td>
<td><?=$ssq_s[$ssq["status"]]?> </td>
</tr>
<?
if ($ssq["round_number"]>0)
{
?>
<tr>
<td> Победившая сторона:</td>
<td><?=$ssq_w[$ssq["winner"]]?> </td>
</tr>
<tr>
<td> Дата и время начала и конца периода борьбы:</td>
<td><?=date("d/m/y H:m", $ssq["event_start_time"])?> - <?=date("d/m/y H:m", $ssq["event_end_time"])?> </td>
</tr>
<tr>
<td> Дата и время начала и конца периода действия печатей:</td>
<td><?=date("d/m/y H:m", $ssq["seal_effect_time"])?> - <?=date("d/m/y H:m", $ssq["seal_effect_end_time"])?> </td>
</tr>
<?
}
?>
</table>
<?
if ($ssq["round_number"]>0)
{
?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td>Количество очков, заработанных каждой стороной</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td> <?=$ssq_w[1]?></td>
<td width="60"><?=$ssq_dusk["collected_point"]?> </td>
<td width="150"><img src="pb.php?v=<?=$ssq_dusk["collected_point"]?>&m=<?=$ssq_dusk["collected_point"]+$ssq_dawn["collected_point"]?>&w=150&h=12&c=1"></td>
<td width="40"><?=round(($ssq_dusk["collected_point"]/($ssq_dusk["collected_point"]+$ssq_dawn["collected_point"]+1))*100, 2)?>% </td>
</tr>
<tr>
<td> <?=$ssq_w[2]?></td>
<td><?=$ssq_dawn["collected_point"]?> </td>
<td><img src="pb.php?v=<?=$ssq_dawn["collected_point"]?>&m=<?=$ssq_dusk["collected_point"]+$ssq_dawn["collected_point"]?>&w=150&h=12&c=2"></td>
<td><?=round(($ssq_dawn["collected_point"]/($ssq_dusk["collected_point"]+$ssq_dawn["collected_point"]+1))*100, 2)?>% </td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td>Общее количество голосов, отданных за каждую сторону</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td> <?=$ssq_w[1]?></td>
<td width="60"><?=$ssq_dusk["member_count"]?> </td>
<td width="150"><img src="pb.php?v=<?=$ssq_dusk["member_count"]?>&m=<?=$ssq_dusk["member_count"]+$ssq_dawn["member_count"]?>&w=150&h=12&c=1"></td>
<td width="40"><?=round(($ssq_dusk["member_count"]/($ssq_dusk["member_count"]+$ssq_dawn["member_count"]))*100, 2)?>% </td>
</tr>
<tr>
<td> <?=$ssq_w[2]?></td>
<td><?=$ssq_dawn["member_count"]?> </td>
<td><img src="pb.php?v=<?=$ssq_dawn["member_count"]?>&m=<?=$ssq_dusk["member_count"]+$ssq_dawn["member_count"]?>&w=150&h=12&c=2"></td>
<td><?=round(($ssq_dawn["member_count"]/($ssq_dusk["member_count"]+$ssq_dawn["member_count"]))*100, 2)?>% </td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td>Распределение голосов по печатям</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td>Seal of Avarice</td>
<td>Seal of Gnosis</td>
<td>Seal of Strife</td>
</tr>
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td> <?=$ssq_dusk["seal1_selection_count"]?></td>
<td width="100"><img src="pb.php?v=<?=$ssq_dusk["seal1_selection_count"]?>&m=<?=$ssq_dusk["member_count"]?>&w=100&h=12&c=1"></td>
<td width="40"><?=round(($ssq_dusk["seal1_selection_count"]/$ssq_dusk["member_count"])*100,2)?>% </td>
</tr>
<tr>
<td> <?=$ssq_dawn["seal1_selection_count"]?></td>
<td width="100"><img src="pb.php?v=<?=$ssq_dawn["seal1_selection_count"]?>&m=<?=$ssq_dawn["member_count"]?>&w=100&h=12&c=2"></td>
<td><?=round(($ssq_dawn["seal1_selection_count"]/$ssq_dawn["member_count"])*100,2)?>% </td>
</tr>
</table>
</td>
<td>
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td> <?=$ssq_dusk["seal2_selection_count"]?></td>
<td width="100"><img src="pb.php?v=<?=$ssq_dusk["seal2_selection_count"]?>&m=<?=$ssq_dusk["member_count"]?>&w=100&h=12&c=1"></td>
<td width="40"><?=round(($ssq_dusk["seal2_selection_count"]/$ssq_dusk["member_count"])*100,2)?>% </td>
</tr>
<tr>
<td> <?=$ssq_dawn["seal2_selection_count"]?></td>
<td width="100"><img src="pb.php?v=<?=$ssq_dawn["seal2_selection_count"]?>&m=<?=$ssq_dawn["member_count"]?>&w=100&h=12&c=2"></td>
<td><?=round(($ssq_dawn["seal2_selection_count"]/$ssq_dawn["member_count"])*100,2)?>% </td>
</tr>
</table>
</td>
<td>
<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td> <?=$ssq_dusk["seal3_selection_count"]?></td>
<td width="100"><img src="pb.php?v=<?=$ssq_dusk["seal3_selection_count"]?>&m=<?=$ssq_dusk["member_count"]?>&w=100&h=12&c=1"></td>
<td width="40"><?=round(($ssq_dusk["seal3_selection_count"]/$ssq_dusk["member_count"])*100,2)?>% </td>
</tr>
<tr>
<td> <?=$ssq_dawn["seal3_selection_count"]?></td>
<td width="100"><img src="pb.php?v=<?=$ssq_dawn["seal3_selection_count"]?>&m=<?=$ssq_dawn["member_count"]?>&w=100&h=12&c=2"></td>
<td><?=round(($ssq_dawn["seal3_selection_count"]/$ssq_dawn["member_count"])*100,2)?>% </td>
</tr>
</table>
</td>
</tr>
</table></td> <td class="border-r"> </td>
</tr>
<tr>
<td class="border-bl"> </td>
<td class="border-b h-cell"><img src="skins/dark_blue/images/line.gif"></td>
<td class="border-br"> </td>
</tr><?=$sep?>
</table>
<?
}
?>
файл pb.php
Quote:
<?
$c = $_GET["c"];
$w = $_GET["w"];
$v = $_GET["v"];
$m = $_GET["m"];
$h = $_GET["h"];

$img = @ImageCreate($w+2, $h) or die ("Cannot Initialize new GD image stream");

$background_color = ImageColorAllocate ($img, 42, 42, 42);
$border_color = ImageColorAllocate ($img, 127, 127, 127);
if ($c==1)
$bar_color = ImageColorAllocate($img, 255, 75, 75);
else
$bar_color = ImageColorAllocate($img, 75, 75, 255);

imagesetthickness($img, 1);
imagerectangle($img, 0, 0, $w+1, $h-1, $border_color);
if (round(($v/$m)*$w)>0)
{
imagerectangle($img, 1, 1, round(($v/$m)*$w), $h-2, $bar_color);
if (round(($v/$m)*$w)>2)
imagefilltoborder($img, 2, 2, $bar_color, $bar_color);
}

ob_start();
imagepng($img);
$content=ob_get_contents();
ob_end_flush();

Header("Accept-ranges: bytes");
Header("Content-length: ".strlen($content));
Header("Content-type: image/png");
echo $content;
?>
DFS is offline