[SCRIPT] Cтатистика по кланам

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

  1. root

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

    Регистрация:
    23 авг 2014
    Сообщения:
    253
    Симпатии:
    56
    Баллы:
    11
    Код:
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <? 
    $mssql_server = '';    // your mssql server host 
    $mssql_user = '';    // your mssql user name 
    $mssql_pass = '';    // your mssql user password 
    
    
    mssql_connect($mssql_server,$mssql_user,$mssql_pass); 
    mssql_select_db($mssql_db); 
      
    $result = mssql_query(" 
              SELECT * , a.pledge_id, a.ruler_id AS Expr2, a.name AS pledge_name, a.alliance_id AS Expr4,  
                         a.challenge_time AS Expr5, a.root_name_value AS Expr6, a.now_war_id AS Expr7,  
                                             a.oust_time AS Expr8, a.skill_level AS Expr9, a.castle_id AS Expr10, a.agit_id AS Expr11,  
                                             a.rank AS Expr12, name_value AS Expr13, a.status AS Expr14, a.private_flag AS Expr15,  
                                             a.crest_id AS pledge_crest_id, a.is_guilty AS Expr17, a.dismiss_reserved_time AS Expr18,  
                                             a.alliance_withdraw_time AS Expr19, a.alliance_dismiss_time AS Expr20,  
                                             a.alliance_ousted_time AS Expr21, b.char_name, c.name as ally_name, c.crest_id as ally_crest_id 
              from pledge as a 
              left join user_data as b on a.ruler_id=b.char_id 
              left join alliance as c on a.alliance_id=c.id 
              where a.name not in (".("'".join("','",$exclude_clans)."'").") 
              order by a.skill_level desc"); 
      
    $online_users=array(); 
    for($x=0;($online_users[$x]=mssql_fetch_assoc($result));$x++){ }; 
    unset($online_users[count($online_users)-1]); 
      
    for($x=0;$x<count($online_users);$x++) 
     { 
      $result = mssql_query(" 
                SELECT pledge_id, lev 
                from user_data 
                where pledge_id=".$online_users[$x]["pledge_id"]); 
      
      $member_count=mssql_num_rows($result); 
      $s=0; 
      for($i=0;$s1=mssql_fetch_assoc($result);$i++) 
       { 
        $s=$s+$s1["lev"]; 
       } 
      $online_users[$x]["membercount"]=$member_count; 
      $online_users[$x]["avglevel"]=round($s*10/$member_count, 1)/10; 
     }; 
      
    function avglevelsort($clanlist) 
     { 
      for ($i=0;$i<count($clanlist);$i++) 
       { 
        for ($j=count($clanlist)-1;$j>$i;$j--) 
         { 
          if (($clanlist[$j-1]["avglevel"]<$clanlist[$j]["avglevel"]) && ($clanlist[$j-1]["skill_level"]<=$clanlist[$j]["skill_level"])) 
           { 
                $a=$clanlist[$j-1]; 
            $clanlist[$j-1]=$clanlist[$j]; 
            $clanlist[$j]=$a; 
           } 
         } 
       } 
      return $clanlist; 
     } 
      
    function avglevelsort1($clanlist) 
     { 
      for ($i=0;$i<count($clanlist);$i++) 
       { 
        $a=$clanlist[$i]; 
        $j=$i-1; 
        while ($a<$clanlist[$j]) 
         { 
          $clanlist[$j+1]=$clanlist[$j]; 
          $j--; 
          if ($j<0) break; 
         } 
        $clanlist[$j+1]=$a; 
       } 
      return $clanlist; 
     } 
      
    $online_users=avglevelsort($online_users); 
    ?> 
      
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="sort"> 
     <thead> 
      <tr class="h-cell"> 
       <td width="30" class="b-tbl">№</td> 
       <td width="16" class="b-tbl">&nbsp;</td> 
       <td class="b-tbl">Название</td> 
       <td width="50" class="b-tbl">Уров.</td> 
       <td class="b-tbl">Лидер</td> 
       <td width="105" class="b-tbl">Кол-во членов</td> 
       <td width="70" class="b-tbl">Ср. уров.</td> 
       <td width="120" class="b-tbl">Альянс</td> 
      </tr> 
     </thead> 
     <tbody> 
    <?  
    $y=0; 
    for($x=0;$x<count($online_users);$x++) 
     { 
      if ($online_users[$x]["membercount"] <= 0) continue; 
    ?> 
      <tr class="n-cell"> 
       <td class="b-bl p-2 ac"><?=$y+1?></td> 
    <?  
      if ($online_users[$x]["pledge_crest_id"]<>0)  
       echo '<td class="b-bl ac"><img src="pages/show_pledge_crest.php?id='.$online_users[$x]["pledge_crest_id"].'" width=16></td>'; 
      else  
       echo '<td class="b-bl ac">&nbsp;</td>'; 
    ?> 
       <td class="b-bl p-2 al"> 
        <a href=index.php?act=show_clan_info&indx=<?=$online_users[$x]["pledge_id"]?>><?=$online_users[$x]["pledge_name"]?></a> 
       </td> 
       <td class="b-bl p-2 ac"><?=$online_users[$x]["skill_level"]?></td> 
       <td class="b-bl p-2 ac"><?=$online_users[$x]["char_name"]?></td> 
       <td class="b-bl p-2 ac"><?=$online_users[$x]["membercount"]?></td> 
       <td class="b-bl p-2 ac"><?=$online_users[$x]["avglevel"]?></td> 
    <?  
      if ($online_users[$x]["ally_name"]<>"")  
       echo '<td class="b-blr p-2 ac"><img src="pages/show_pledge_crest.php?id='.$online_users[$x]["ally_crest_id"].'" width=8 align=left>'.$online_users[$x]["ally_name"].'</td>'; 
      else  
       echo '<td class="b-blr p-2 ac">&nbsp;</td>'; 
    ?> 
      </tr> 
    <? $y++;} ?> 
     </tbody> 
    </table>