Changeset 592 for trunk/pages/guildy.php


Ignore:
Timestamp:
May 18, 2009, 9:31:31 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Poopravena stránka seznamu spolků.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pages/guildy.php

    r583 r592  
    11<?php
    2 // razeni
    3   $order_by = (isset($_GET["order"])) ? $db->real_escape_string($_GET["order"]) : "name";
    4  
    5   $dir = (isset($_GET["dir"])) ? $db->real_escape_string($_GET["dir"]) : "down";
    6   $order_dir = ($dir == "up") ? "ASC" : "DESC";
    7   $dir = ($dir == "down") ? "up" : "down";
    8   $dir_img = ($dir == "down") ? "<img src=\"imgs/inc/up.gif\">" : "<img src=\"imgs/inc/down.gif\">";
     2
     3$order_by = (isset($_GET['order'])) ? $_GET['order'] : 'name';
     4$dir = (isset($_GET['dir'])) ? $_GET['dir'] : 'down';
     5$order_dir = ($dir == 'up') ? 'ASC' : 'DESC';
     6$dir = ($dir == 'down') ? 'up' : 'down';
     7$dir_img = ($dir == 'down') ? '<img src="imgs/inc/up.gif" alt="nahoru">' : '<img src="imgs/inc/down.gif" alt="dolu" />';
    98
    109 
    11 function MakeLink ($show,$sort)
     10function MakeLink($show, $sort)
    1211{
    13   global $dir , $dir_img;
    14   if (isset($_GET["order"]) AND $_GET["order"] == $sort)
    15   {
    16     $arrow = $dir_img."";
    17   }
    18   else
    19   {
    20     $arrow = "";
    21   }
    22   return $arrow."<a href=\"?page=guildy&amp;order=".$sort."&amp;dir=".$dir."\">".$show."</a>";
     12  global $dir, $dir_img;
     13  if (isset($_GET['order']) and $_GET['order'] == $sort) $arrow = $dir_img;
     14  else $arrow = '';
     15  return($arrow.'<a href="?page=guildy&amp;order='.$sort.'&amp;dir='.$dir.'">'.$show.'</a>');
    2316}
    24 function GuildPages ($row,$name)
     17
     18function GuildPages($row, $name)
    2519{
    2620  global $server;
    27   if ($row != "")
    28   {
    29     return "<a href=\"http://".$row."/\" target=\"_blank\">www</a>";
    30   }
    31   else
    32   {
    33     // return "<a href=\"http://www.parime.eu/guilda/?=".$server -> SeoUrl($name)."\" target=\"_blank\">".$name."</a>";
    34   }
     21 
     22  if($row != '') return('<a href="http://'.$row.'/" target="_blank">www</a>');
     23  else return('');
    3524}
    36 function FrakceImg ($frakce)
     25
     26function FrakceImg($frakce)
    3727{
    38   if ($frakce == 0)
    39   {
    40     return "<img src=\"imgs/inc/h.gif\">";
    41   }
    42   else
    43   {
    44     return "<img src=\"imgs/inc/a.gif\">";
    45   }
     28  if($frakce == 0) return('<img src="imgs/inc/h.gif" alt="horda" />');
     29  else return('<img src="imgs/inc/a.gif" alt="aliance" />');
    4630}
    4731
    48 echo('<table class="BaseTable">
     32echo('<h3 class="PageTitle">Seznam guild</h3>');
     33echo('<table class="BaseTable" style="font-size: small;">
    4934  <tr>
    5035    <th>'.MakeLink('', 'fraction').'</th>
     
    5944$db->select_db($Config['Mangos']['DatabaseCharacters']);
    6045
    61 $sql = $db -> query('SELECT `guild`.homepage, `guild`.name, `guild`.guildid, `guild`.createdate, COUNT(`guild_member`.`guildid`) AS member_count ,`leader`.`race` IN (1, 3, 4, 7, 11) AS fraction , `leader`.`guid` AS leader FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `characters` AS `memebers` ON `memebers`.`guid`= `guild_member`.`guid` JOIN `characters` AS `leader` ON `leader`.`guid`= `guild`.`leaderguid` GROUP BY guild.name ORDER BY '.$order_by.' '.$order_dir.';');
    62 while($row = $sql -> fetch_array())
     46$sql = $db->query('SELECT `guild`.homepage, `guild`.name, `guild`.guildid, `guild`.createdate, COUNT(`guild_member`.`guildid`) AS member_count ,`leader`.`race` IN (1, 3, 4, 7, 11) AS fraction , `leader`.`guid` AS leader FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `characters` AS `memebers` ON `memebers`.`guid`= `guild_member`.`guid` JOIN `characters` AS `leader` ON `leader`.`guid`= `guild`.`leaderguid` GROUP BY guild.name ORDER BY '.$order_by.' '.$order_dir.';');
     47while($row = $sql->fetch_assoc())
    6348{
    64   $online_mem = $db -> query("SELECT count(*) AS online_mem  FROM `guild_member`, `characters`, `guild` WHERE guild.guildid = ".$row["guildid"]." AND guild_member.guildid = guild.guildid AND guild_member.guid = characters.guid AND characters.online = 1;") -> fetch_array();;
    65   $date_arr = explode(" ",$row["createdate"]);
    66   $date = explode("-",$date_arr[0]);
    67   $time_stp = explode(":",$date_arr[1]);
    68   $time = mktime($time_stp[0],$time_stp[1],$time_stp[2],$date[1],$date[2],$date[0]);
    69   $human_date = date ("d.m.Y H:i:s",$time);
    70 echo "
    71   <tr>
    72     <td align=\"center\">".FrakceImg($row["fraction"])."</td>
    73     <td align=\"center\"><a href=\"?page=guilda&id=".$row["guildid"]."\">".$row["name"]."</a></td>
    74     <td align=\"center\">".$row["member_count"]."</td>
    75     <td align=\"center\">".$online_mem["online_mem"]."</td>
    76     <td align=\"center\">".$server -> GuidToCharName($row["leader"])."</td>
    77     <td align=\"center\">".GuildPages($row["homepage"],$row["name"])."</td>
    78     <td align=\"center\">".$human_date."</td>
    79   </tr>
    80 ";
    81 
     49  $DbResult = $db->query('SELECT count(*) AS online_mem  FROM `guild_member`, `characters`, `guild` WHERE guild.guildid = '.$row['guildid'].' AND guild_member.guildid = guild.guildid AND guild_member.guid = characters.guid AND characters.online = 1');
     50  $online_mem = $DbResult->fetch_assoc();
     51  $date_arr = explode(' ', $row['createdate']);
     52  $date = explode('-', $date_arr[0]);
     53  $time_stp = explode(':', $date_arr[1]);
     54  $time = mktime($time_stp[0], $time_stp[1], $time_stp[2], $date[1], $date[2], $date[0]);
     55  $human_date = date('d.m.Y H:i:s', $time);
     56  echo('<tr>
     57    <td align="center">'.FrakceImg($row['fraction']).'</td>
     58    <td align="center"><a href="?page=guilda&id='.$row['guildid'].'">'.$row['name'].'</a></td>
     59    <td align="center">'.$row['member_count'].'</td>
     60    <td align="center">'.$online_mem['online_mem'].'</td>
     61    <td align="center">'.$server->GuidToCharName($row['leader']).'</td>
     62    <td align="center">'.GuildPages($row['homepage'],$row['name']).'</td>
     63    <td align="center">'.$human_date.'</td>
     64  </tr>');
    8265}
    83 
    8466echo('</table>');
    8567
Note: See TracChangeset for help on using the changeset viewer.