[SCRIPT] Статус семи печатей

Тема в разделе "Веб скрипты (WEB)", создана пользователем root, 30 сен 2014.

  1. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    253
    Симпатии:
    56
    Баллы:
    11
    ssq_status.php:
    Код:
    
    
    Код:
    
    
    Код:
    <? 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"]; 
    ?> 
    <br> 
    <table width="100%" cellpadding="0" cellspacing="0" border="0"> 
    <tr> 
      <td>Статус эвента</td> 
    </tr> 
    </table> 
    <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"]))*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"]))*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> 
    <? 
    } 
    
    ?>
    pb.php:
    Код:
    <? $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; 
    ?>