Guest User

guilds.php

a guest
May 26th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 223.90 KB | None | 0 0
  1. <?php
  2.        ini_set("display_errors",1);
  3.        error_reporting(E_ALL);
  4.         //code goes here
  5. ?>
  6.  
  7. <?php
  8. if(!defined('INITIALIZED'))
  9.     exit;
  10.  
  11. if($action == "") {
  12.  
  13.     $guilds_list = new DatabaseList('Guild');
  14.     $guilds_list->addOrder(new SQL_Order(new SQL_Field('name'), SQL_Order::ASC));
  15.    
  16.     $main_content .= '
  17.         <div class="TableContainer" >
  18.             <table class="Table3" cellpadding="0" cellspacing="0" >
  19.                 <div class="CaptionContainer" >
  20.                     <div class="CaptionInnerContainer" >
  21.                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  22.                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  23.                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  24.                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  25.                         <div class="Text" >Active Guilds on ' .htmlspecialchars($config['server']['serverName']). '</div>
  26.                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  27.                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  28.                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  29.                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  30.                     </div>
  31.                 </div>
  32.                 <tr>
  33.                     <td><div class="InnerTableContainer" >
  34.                             <table style="width:100%;" >
  35.                                 <tr>
  36.                                     <td><div class="TableShadowContainerRightTop" >
  37.                                             <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);" ></div>
  38.                                         </div>
  39.                                         <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);" >
  40.                                             <div class="TableContentContainer" >
  41.                                                 <table class="TableContent" width="100%" >
  42.                                                     <TR BGCOLOR=#D4C0A1>
  43.                                                         <TD WIDTH=64><B>Logo</B></TD>
  44.                                                         <TD WIDTH=100%><B>Description</B></TD>
  45.                                                         <TD WIDTH=56><B>&#160;</B></TD>
  46.                                                     </TR>';
  47.                                                 $showed_guilds = 1;
  48.                                                 if(count($guilds_list) > 0)
  49.                                                 {
  50.                                                     foreach($guilds_list as $guild)
  51.                                                     {
  52.                                                         if(is_int($showed_guilds / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_guilds++;
  53.                                                         $description = $guild->getDescription();
  54.                                                         $newlines   = array("\r\n", "\n", "\r");
  55.                                                         $description_with_lines = str_replace($newlines, '<br />', $description, $count);
  56.                                                         if($count < $config['site']['guild_description_lines_limit'])
  57.                                                             $description = $description_with_lines;
  58.                                                         $main_content .= '
  59.                                                             <TR BGCOLOR='.$bgcolor.'>
  60.                                                                 <TD><IMG SRC="'. $guild->getGuildLogoLink() .'" WIDTH=64 HEIGHT=64></TD>
  61.                                                                 <TD><B>'.htmlspecialchars($guild->getName()).'</B><BR>'.$description.'</TD>
  62.                                                                 <TD>
  63.                                                                     <table border="0" cellspacing="0" cellpadding="0" >
  64.                                                                         <form action="?subtopic=guilds&action=view" method="post" >
  65.                                                                             <tr>
  66.                                                                                 <td style="border:0px;" ><input type="hidden" name=GuildName value="'.htmlspecialchars($guild->getName()).'" >
  67.                                                                                     <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  68.                                                                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  69.                                                                                             <input class="ButtonText" type="image" name="View" alt="View" src="'.$layout_name.'/images/global/buttons/_sbutton_view.gif" >
  70.                                                                                         </div>
  71.                                                                                     </div>
  72.                                                                                 </td>
  73.                                                                             </tr>
  74.                                                                         </form>';
  75.                                                                     if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  76.                                                                         $main_content .= '
  77.                                                                         <form action="?subtopic=guilds&action=deletebyadmin" method="post">
  78.                                                                             <tr>
  79.                                                                                 <td style="border:0px;" >
  80.                                                                                     <input type="hidden" name="guild" value="'.$guild->getId().'">
  81.                                                                                     <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_red.gif)" >
  82.                                                                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_red_over.gif);" ></div>
  83.                                                                                             <input class="ButtonText" type="image" name="Delete" alt="Delete" src="'.$layout_name.'/images/global/buttons/_sbutton_delete.gif" >
  84.                                                                                         </div>
  85.                                                                                     </div>
  86.                                                                                 </td>
  87.                                                                             </tr>
  88.                                                                         </form>';
  89.                                                                     $main_content .= '
  90.                                                                     </table>
  91.                                                                 </TD>
  92.                                                             </TR>';
  93.                                                     }
  94.                                                 }
  95.                                                 $main_content .= '
  96.                                                 </table>
  97.                                             </div>
  98.                                         </div>
  99.                                         <div class="TableShadowContainer" >
  100.                                             <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bm.gif);" >
  101.                                                 <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bl.gif);" ></div>
  102.                                                 <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-br.gif);" ></div>
  103.                                             </div>
  104.                                         </div>
  105.                                     </td>
  106.                                 </tr>
  107.                             </table>
  108.                         </div>
  109.                     </td>
  110.                 </tr>
  111.             </table>
  112.         </div>
  113.         <BR>
  114.         <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
  115.             <TR>
  116.                 <TD>No guild found that suits your needs?</TD>
  117.             </TR>
  118.             <TR>
  119.                 <TD><table border="0" cellspacing="0" cellpadding="0" >
  120.                         <form action="?subtopic=guilds&action=create" method="post" >
  121.                             <tr>
  122.                                 <td style="border:0px;" >
  123.                                     <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  124.                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  125.                                             <input class="ButtonText" type="image" name="FoundGuild" alt="FoundGuild" src="'.$layout_name.'/images/global/buttons/_sbutton_foundguild.gif" >
  126.                                         </div>
  127.                                     </div>
  128.                                 </td>
  129.                             </tr>
  130.                         </form>
  131.                     </table>
  132.                 </TD>
  133.             </TR>
  134.         </TABLE>';
  135. }
  136. if($action == "view")
  137. {
  138.     $guild_name = (string) $_REQUEST['GuildName'];
  139.     $guild = new Guild();
  140.     $guild->loadByName($guild_name);
  141.     if(!$guild->isLoaded())
  142.         $guild_errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
  143.    
  144.     if(!empty($guild_errors))
  145.     {
  146.         //errors
  147.             $main_content .= '
  148.                 <div class="TableContainer" >
  149.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  150.                         <div class="CaptionContainer" >
  151.                             <div class="CaptionInnerContainer" >
  152.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  153.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  154.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  155.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  156.                                 <div class="Text" >Error</div>
  157.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  158.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  159.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  160.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  161.                             </div>
  162.                         </div>
  163.                         <tr>
  164.                             <td>
  165.                                 <div class="InnerTableContainer" >
  166.                                     <table style="width:100%;" >
  167.                                         <tr>
  168.                                             <td>';
  169.                                             foreach($guild_errors as $guild_error)
  170.                                                 $main_content .= '<p>'.$guild_error;
  171.                                         $main_content .= '
  172.                                             </td>
  173.                                         </tr>
  174.                                     </table>
  175.                                 </div>
  176.                             </td>
  177.                         </tr>
  178.                     </table>
  179.                 </div><BR>
  180.                 <TABLE BORDER=0 WIDTH=100%>
  181.                     <TR>
  182.                         <TD ALIGN=center>
  183.                             <table border="0" cellspacing="0" cellpadding="0" >
  184.                                 <form action="?subtopic=guilds" method="post" >
  185.                                     <tr>
  186.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  187.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  188.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  189.                                                 </div>
  190.                                             </div>
  191.                                         </td>
  192.                                     </tr>
  193.                                 </form>
  194.                             </table>
  195.                         </TD>
  196.                     </TR>
  197.                 </TABLE>';
  198.         //show errors
  199.     }
  200.     else
  201.     {
  202.         //check is it vice or/and leader account (leader has vice + leader rights)
  203.         $guild_leader_char = $guild->getOwner();
  204.         $rank_list = $guild->getGuildRanksList();
  205.         $guild_leader = FALSE;
  206.         $guild_vice = FALSE;
  207.         if($logged)
  208.         {
  209.             $account_players = $account_logged->getPlayers();
  210.             foreach($account_players as $player)
  211.             {
  212.                 $players_from_account_ids[] = $player->getId();
  213.                 $player_rank = $player->getRank();
  214.                 if(!empty($player_rank))
  215.                     foreach($rank_list as $rank_in_guild)
  216.                         if($rank_in_guild->getId() == $player_rank->getId())
  217.                         {
  218.                             $players_from_account_in_guild[] = $player->getName();
  219.                             if($player_rank->getLevel() > 1)
  220.                             {
  221.                                 $guild_vice = TRUE;
  222.                                 $level_in_guild = $player_rank->getLevel();
  223.                             }
  224.                             if($guild->getOwner()->getId() == $player->getId())
  225.                             {
  226.                                 $guild_vice = TRUE;
  227.                                 $guild_leader = TRUE;
  228.                             }
  229.                         }
  230.             }
  231.         }
  232.        
  233.         //show guild page
  234.         $description = $guild->getDescription();
  235.         $newlines   = array("\r\n", "\n", "\r");
  236.         $description_with_lines = str_replace($newlines, '<br />', $description, $count);
  237.         if($count < $config['site']['guild_description_lines_limit'])
  238.             $description = $description_with_lines;
  239.         $guild_owner = $guild->getOwner();
  240.         if($guild_owner->isLoaded())
  241.             $guild_owner = $guild_owner->getName();    
  242.        
  243.         $main_content .= '
  244.             <TABLE BORDER=0 WIDTH=100%>
  245.                 <TR>
  246.                     <TD WIDTH=64><IMG SRC="' . $guild->getGuildLogoLink() . '" WIDTH=64 HEIGHT=64></TD>
  247.                     <TD ALIGN=center WIDTH=100%><H1>'.htmlspecialchars($guild->getName()).'</H1></TD>
  248.                     <TD WIDTH=64><IMG SRC="' . $guild->getGuildLogoLink() . '" WIDTH=64 HEIGHT=64></TD>
  249.                 </TR>
  250.             </TABLE>
  251.             <BR>
  252.             <TABLE Width=100%>
  253.                 <colgroup>
  254.                 <col width="90%">
  255.                 <col width="10%">
  256.                 </colgroup>
  257.                 <TR>
  258.                     <TD style="vertical-align:top; padding-right: 5px;"><div class="TableContainer" >
  259.                             <table class="Table1" cellpadding="0" cellspacing="0" >
  260.                                 <div class="CaptionContainer" >
  261.                                     <div class="CaptionInnerContainer" >
  262.                                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  263.                                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  264.                                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  265.                                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                                   
  266.                                         <div class="Text" >Guild Information</div>
  267.                                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  268.                                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  269.                                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  270.                                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  271.                                     </div>
  272.                                 </div>
  273.                                 <tr>
  274.                                     <td><div class="InnerTableContainer" >';
  275.                                     //show guild page
  276.                                     $description = $guild->getDescription();
  277.                                     $newlines   = array("\r\n", "\n", "\r");
  278.                                     $description_with_lines = str_replace($newlines, '<br />', $description, $count);
  279.                                     if($count < $config['site']['guild_description_lines_limit'])
  280.                                         $description = $description_with_lines;
  281.                                         $main_content .= '
  282.                                             <table style="width:100%;" >
  283.                                                 <TR>
  284.                                                     <TD>
  285.                                                         <div id="GuildInformationContainer">
  286.                                                             '.$description.'<br><br>
  287.                                                             The guild was founded on '.$config['server']['serverName'].' on '.date("M d Y",$guild->getCreateDate()).'.<BR>
  288.                                                             It is currently active.<BR>
  289.                                                         </div>
  290.                                                     </TD>
  291.                                                 </TR>
  292.                                             </table>
  293.                                         </div>
  294.                                     </td>
  295.                                 </tr>
  296.                             </table>
  297.                         </div>
  298.                     </TD>
  299.                     <TD style="vertical-align:top;">
  300.                         <div class="TableContainer" >
  301.                             <table class="Table1" cellpadding="0" cellspacing="0" >
  302.                                 <div class="CaptionContainer" >
  303.                                     <div class="CaptionInnerContainer" >
  304.                                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  305.                                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  306.                                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  307.                                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  308.                                         <div class="Text" >Navigation</div>
  309.                                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  310.                                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  311.                                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  312.                                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  313.                                     </div>
  314.                                 </div>
  315.                                 <tr>
  316.                                     <td>
  317.                                         <div class="InnerTableContainer" >
  318.                                             <table style="width:100%;" >
  319.                                                 <tr>
  320.                                                     <td align="center"><div id="NavigationContainer">
  321.                                                             <table border="0" cellspacing="0" cellpadding="0" >
  322.                                                                 <form action="?subtopic=guilds" method="post" >
  323.                                                                     <tr>
  324.                                                                         <td style="border:0px;" >
  325.                                                                             <input type="hidden" name=action value=guildwars >
  326.                                                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  327.                                                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  328.                                                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  329.                                                                                     <input class="ButtonText" type="image" name="Guild Wars" alt="Guild Wars" src="'.$layout_name.'/images/global/buttons/_sbutton_guildwars.gif" >
  330.                                                                                 </div>
  331.                                                                             </div>
  332.                                                                         </td>
  333.                                                                     </tr>
  334.                                                                 </form>
  335.                                                             </table>
  336.                                                             <div style="font-size:1px;height:4px;" ></div>
  337.                                                             <table border="0" cellspacing="0" cellpadding="0" >
  338.                                                                 <form action="?subtopic=guilds" method="post" >
  339.                                                                     <tr>
  340.                                                                         <td style="border:0px;" >
  341.                                                                             <input type="hidden" name=action value=guildevents >
  342.                                                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  343.                                                                             <input type="hidden" name=world value="Neptera" >
  344.                                                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  345.                                                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  346.                                                                                     <input class="ButtonText" type="image" name="Guild Events" alt="Guild Events" src="'.$layout_name.'/images/global/buttons/_sbutton_guildevents.gif" >
  347.                                                                                 </div>
  348.                                                                             </div>
  349.                                                                         </td>
  350.                                                                     </tr>
  351.                                                                 </form>
  352.                                                             </table>
  353.                                                             <div style="font-size:1px;height:4px;" ></div>
  354.                                                         </div>
  355.                                                     </td>
  356.                                                 </tr>
  357.                                             </table>
  358.                                         </div>
  359.                                     </td>
  360.                                 </tr>
  361.                             </table>
  362.                         </div>';
  363.                 if($guild_leader)
  364.                     $main_content .= '
  365.                         <div style="font-size:1px;height:6px;" ></div>
  366.                         <div class="TableContainer" >
  367.                             <table class="Table1" cellpadding="0" cellspacing="0" >
  368.                                 <div class="CaptionContainer" >
  369.                                     <div class="CaptionInnerContainer" >
  370.                                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  371.                                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  372.                                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  373.                                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                                       
  374.                                         <div class="Text" >Administration</div>
  375.                                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  376.                                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  377.                                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  378.                                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  379.                                     </div>
  380.                                 </div>
  381.                                 <tr>
  382.                                     <td><div class="InnerTableContainer" >
  383.                                             <table style="width:100%;" >
  384.                                                 <TR>
  385.                                                     <TD align="center">
  386.                                                         <div id="AdministrationContainer">
  387.                                                             <table border="0" cellspacing="0" cellpadding="0" >
  388.                                                                 <form action="?subtopic=guilds" method="post" >
  389.                                                                     <tr>
  390.                                                                         <td style="border:0px;" >
  391.                                                                             <input type="hidden" name=action value=description >
  392.                                                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  393.                                                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  394.                                                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  395.                                                                                     <input class="ButtonText" type="image" name="Edit Description" alt="Edit Description" src="'.$layout_name.'/images/global/buttons/_sbutton_editdescription.gif" >
  396.                                                                                 </div>
  397.                                                                             </div>
  398.                                                                         </td>
  399.                                                                     </tr>
  400.                                                                 </form>
  401.                                                             </table>                                                           
  402.                                                             <div style="font-size:1px;height:4px;" ></div>                                                 
  403.                                                             <table border="0" cellspacing="0" cellpadding="0" >
  404.                                                                 <form action="?subtopic=guilds" method="post" >
  405.                                                                     <tr>
  406.                                                                         <td style="border:0px;" >
  407.                                                                             <input type="hidden" name=action value=disband >
  408.                                                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  409.                                                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  410.                                                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  411.                                                                                     <input class="ButtonText" type="image" name="Disband Guild" alt="Disband Guild" src="'.$layout_name.'/images/global/buttons/_sbutton_disbandguild.gif" >
  412.                                                                                 </div>
  413.                                                                             </div>
  414.                                                                         </td>
  415.                                                                     </tr>
  416.                                                                 </form>
  417.                                                             </table>
  418.                                                             <div style="font-size:1px;height:4px;" ></div>
  419.                                                             <table border="0" cellspacing="0" cellpadding="0" >
  420.                                                                 <form action="?subtopic=guilds" method="post" >
  421.                                                                     <tr>
  422.                                                                         <td style="border:0px;" >
  423.                                                                             <input type="hidden" name=action value=resignleadership >
  424.                                                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  425.                                                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  426.                                                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  427.                                                                                     <input class="ButtonText" type="image" name="Resign Leadership" alt="Resign Leadership" src="'.$layout_name.'/images/global/buttons/_sbutton_resignleadership.gif" >
  428.                                                                                 </div>
  429.                                                                             </div>
  430.                                                                         </td>
  431.                                                                     </tr>
  432.                                                                 </form>
  433.                                                             </table>
  434.                                                         </div>
  435.                                                     </td>
  436.                                                 </tr>
  437.                                             </table>
  438.                                         </div>
  439.                                     </td>
  440.                                 </tr>
  441.                             </table>
  442.                         </div>';
  443.                 $main_content .= '
  444.                     </TD>
  445.                 </TR>
  446.             </TABLE>
  447.             <script type="text/javascript" >
  448.             $(document).ready(function() {
  449.                 var g_GuildInformationContainerHeight = $(\'#GuildInformationContainer\').height();
  450.                 if($(\'#AdministrationContainer\').length > 0) {
  451.                   var g_AdministrationContainerHeight = $(\'#AdministrationContainer\').height() + 28;
  452.                   var g_NavigationContainerHeight = $(\'#NavigationContainer\').height() + 28;
  453.                 } else {
  454.                   var g_NavigationContainerHeight = $(\'#NavigationContainer\').height();
  455.                   var g_AdministrationContainerHeight = 0;
  456.                 }
  457.                 //alert(g_GuildInformationContainerHeight+\' \'+g_NavigationContainerHeight+\' \'+g_AdministrationContainerHeight);
  458.                 if(g_GuildInformationContainerHeight < g_NavigationContainerHeight + g_AdministrationContainerHeight) {
  459.                   $(\'#GuildInformationContainer\').css(\'height\', g_NavigationContainerHeight + g_AdministrationContainerHeight);
  460.                 } else {
  461.                   if($(\'#AdministrationContainer\').length > 0) {
  462.                     $(\'#NavigationContainer\').css(\'height\', g_GuildInformationContainerHeight * 0.7 - 28);
  463.                     $(\'#AdministrationContainer\').css(\'height\', g_GuildInformationContainerHeight * 0.3 - 28);
  464.                   } else {
  465.                     $(\'#NavigationContainer\').css(\'height\', g_GuildInformationContainerHeight);
  466.                   }
  467.                 }
  468.               });</script>
  469.             <BR>
  470.             <div class="TableContainer" >
  471.                 <table class="Table3" cellpadding="0" cellspacing="0" >
  472.                     <div class="CaptionContainer" >
  473.                         <div class="CaptionInnerContainer" > <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" />
  474.                                 </span>
  475.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" />
  476.                                 </span>
  477.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span> <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" />
  478.                                 </span>
  479.                            
  480.                             <div class="Text" >Guild Members</div>
  481.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" />
  482.                                 </span>
  483.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span> <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" />
  484.                                 </span>
  485.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" />
  486.                                 </span>
  487.                         </div>
  488.                     </div>
  489.                     <tr>
  490.                             <td>
  491.                         <div class="InnerTableContainer" >
  492.                             <table style="width:100%;" >
  493.                                 <tr><td>
  494.                                     <div class="TableShadowContainerRightTop" >
  495.                                         <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);" ></div>
  496.                                     </div>
  497.                                     <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);" >
  498.                                         <div class="TableContentContainer" >
  499.                                             <table class="TableContent" width="100%" >
  500.                                                 <tr class="LabelH">
  501.                                                     <td>Rank <small style="font-weight:normal;" >[<a href="#" >sort</a>]</small>
  502.                                                     <img class="sortarrow" src="'.$layout_name.'/images/global/content/order_desc.gif" /></td>
  503.                                                     <td>Name and Title</td>
  504.                                                     <td>Vocation <small style="font-weight:normal;" >[<a href="#" >sort</a>]</small>
  505.                                                     <img class="sortarrow" src="'.$layout_name.'/images/global/general/blank.gif" /></td>
  506.                                                     <td>Level <small style="font-weight:normal;" >[<a href="#" >sort</a>]</small>
  507.                                                     <img class="sortarrow" src="'.$layout_name.'/images/global/general/blank.gif" /></td>
  508.                                                     <td>Status</td>
  509.                                                 </tr>';
  510.                                             #show players
  511.                                             $showed_players = 1;
  512.                                             foreach($rank_list as $rank) {
  513.                                                 $oi = 0;
  514.                                                 if(!isset($_REQUEST['onlyshowonline']) || $_REQUEST['onlyshowonline'] == 0)
  515.                                                     $players_with_rank = $rank->getPlayersList();
  516.                                                 else
  517.                                                     $players_with_rank = $rank->getOnlinePlayersList();
  518.                                                 $players_with_rank_number = count($players_with_rank);
  519.                                                 if($players_with_rank_number > 0) {
  520.                                                     if(is_int($showed_players / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; }
  521.                                                     $showed_players++;
  522.                                                     foreach($players_with_rank as $player) {
  523.                                                         $oi++;
  524.                                                         $main_content .= '
  525.                                                             <TR BGCOLOR='.$bgcolor.'>
  526.                                                                 <TD>'.(($oi == 1) ? htmlspecialchars($rank->getName()) : '').'</TD>
  527.                                                                 <TD>
  528.                                                                     <A HREF="?subtopic=characters&name='.urlencode($player->getName()).'">'.htmlspecialchars($player->getName()).'</A>';
  529.                                                                     if ($player->getGuildNick() != "")
  530.                                                                         $main_content .= ' (' . $player->getGuildNick() . ')';
  531.                                                             $main_content .= '
  532.                                                                 </TD>
  533.                                                                     <TD>' . htmlspecialchars(Website::getVocationName($player->getVocation())) . '</TD>
  534.                                                                     <TD>' . htmlspecialchars($player->getLevel()) . '</TD>
  535.                                                                     <TD class="onlinestatus"><span '.((!$player->isOnline()) ? 'class="red"' : 'class="green"').'>'.((!$player->isOnline()) ? 'offline' : '<strong>online</strong>').'</span>
  536.                                                                 </TD>
  537.                                                             </TR>';
  538.                                                     }
  539.                                                 }
  540.                                             }
  541.                                             $main_content .= '
  542.                                             </table>
  543.                                         </div>
  544.                                     </div>
  545.                                     <div class="TableShadowContainer" >
  546.                                         <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bm.gif);" >
  547.                                             <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bl.gif);" ></div>
  548.                                             <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-br.gif);" ></div>
  549.                                         </div>
  550.                                     </div>
  551.                                         </td>
  552.                                 </tr>
  553.                                 <tr>
  554.                                     <td>';
  555.                                 if(!isset($_REQUEST['onlyshowonline']) || $_REQUEST['onlyshowonline'] == 0)
  556.                                     $main_content .= '
  557.                                         <table class="InnerTableButtonRow" cellpadding="0" cellspacing="0" >
  558.                                             <tr>
  559.                                                 <td></td>
  560.                                                 <td align="right" style="padding-right:7px;width:100%;" >
  561.                                                     <form action="?subtopic=guilds" method="post" style="padding:0px;margin:0px;" >
  562.                                                         <input type="hidden" name="action" value="view" >
  563.                                                         <input type="hidden" name="onlyshowonline" value="1" >
  564.                                                         <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'" >
  565.                                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  566.                                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  567.                                                                 <input class="ButtonText" type="image" name="Show Online" alt="Show Online" src="'.$layout_name.'/images/global/buttons/_sbutton_showonline.gif" >
  568.                                                             </div>
  569.                                                         </div>
  570.                                                     </form>
  571.                                                 </td>
  572.                                             </tr>
  573.                                         </table>';
  574.                                 else
  575.                                     $main_content .= '
  576.                                         <table class="InnerTableButtonRow" cellpadding="0" cellspacing="0" >
  577.                                             <tr>
  578.                                                 <td></td>
  579.                                                 <td align="right" style="padding-right:7px;width:100%;" >
  580.                                                     <form action="?subtopic=guilds" method="post" style="padding:0px;margin:0px;" >
  581.                                                         <input type="hidden" name="action" value="view" >
  582.                                                         <input type="hidden" name="onlyshowonline" value="0" >
  583.                                                         <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'" >
  584.                                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  585.                                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  586.                                                                 <input class="ButtonText" type="image" name="Show All" alt="Show All" src="'.$layout_name.'/images/global/buttons/_sbutton_showall.gif" >
  587.                                                             </div>
  588.                                                         </div>
  589.                                                     </form>
  590.                                                 </td>
  591.                                             </tr>
  592.                                         </table>';
  593.                                 $main_content .= '
  594.                                     </td>
  595.                                 </tr>
  596.                             </table>
  597.                         </div>
  598.                         </td>
  599.                     </tr>
  600.                 </table>
  601.             </div>';
  602.         if($logged) {
  603.             $main_content .= '
  604.                 <TABLE BORDER=0 class="fixed">
  605.                     <TR>
  606.                     <col width="140px">
  607.                     <col width="140px">
  608.                     <col width="140px">
  609.                     <col width="140px">
  610.                     <col width="140px">
  611.                     <col width="140px">';
  612.                 if($guild_vice)
  613.                     $main_content .= '                 
  614.                         <TD>
  615.                             <table border="0" cellspacing="0" cellpadding="0" >
  616.                                 <form action="?subtopic=guilds" method="post" >
  617.                                     <tr>
  618.                                         <td style="border:0px;" >
  619.                                             <input type="hidden" name=action value=members >
  620.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  621.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  622.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  623.                                                     <input class="ButtonText" type="image" name="Edit Members" alt="Edit Members" src="'.$layout_name.'/images/global/buttons/_sbutton_editmembers.gif" >
  624.                                                 </div>
  625.                                             </div>
  626.                                         </td>
  627.                                     </tr>
  628.                                 </form>
  629.                             </table>
  630.                         </TD>';
  631.                     if($guild_leader)
  632.                     #Edit players ranks
  633.                         $main_content .= '
  634.                             <TD>
  635.                                 <table border="0" cellspacing="0" cellpadding="0" >
  636.                                     <form action="?subtopic=guilds" method="post" >
  637.                                         <tr>
  638.                                             <td style="border:0px;" >
  639.                                                 <input type="hidden" name=action value=ranks >
  640.                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  641.                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  642.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  643.                                                         <input class="ButtonText" type="image" name="Edit Ranks" alt="Edit Ranks" src="'.$layout_name.'/images/global/buttons/_sbutton_editranks.gif" >
  644.                                                     </div>
  645.                                                 </div>
  646.                                             </td>
  647.                                         </tr>
  648.                                     </form>
  649.                                 </table>
  650.                             </TD>';
  651.                 if($players_from_account_in_guild > 0)
  652.                         $main_content .= '
  653.                             <TD>
  654.                                 <table border="0" cellspacing="0" cellpadding="0" >
  655.                                     <form action="?subtopic=guilds" method="post" >
  656.                                         <tr>
  657.                                             <td style="border:0px;" >
  658.                                                 <input type="hidden" name=action value=leave >
  659.                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  660.                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  661.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  662.                                                         <input class="ButtonText" type="image" name="Leave Guild" alt="Leave Guild" src="'.$layout_name.'/images/global/buttons/_sbutton_leaveguild.gif" >
  663.                                                     </div>
  664.                                                 </div>
  665.                                             </td>
  666.                                         </tr>
  667.                                     </form>
  668.                                 </table>
  669.                             </TD>';
  670.                 $main_content .= '
  671.                     </TR>
  672.                 </TABLE>';
  673.         }
  674.         $main_content .= '
  675.         <BR>
  676.             <div class="TableContainer" >
  677.                 <table class="Table3" cellpadding="0" cellspacing="0" >
  678.                     <div class="CaptionContainer" >
  679.                         <div class="CaptionInnerContainer" >
  680.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  681.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  682.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  683.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  684.                             <div class="Text" >Invited Characters</div>
  685.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  686.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  687.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  688.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  689.                         </div>
  690.                     </div>
  691.                     <tr>
  692.                         <td><div class="InnerTableContainer" >
  693.                                 <table style="width:100%;" >
  694.                                     <tr>
  695.                                         <td>
  696.                                             <div class="TableShadowContainerRightTop" >
  697.                                                 <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);" ></div>
  698.                                             </div>
  699.                                             <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);" >
  700.                                                 <div class="TableContentContainer" >
  701.                                                     <table class="TableContent" width="100%" >';
  702.                                                 $invited_list = $guild->listInvites();
  703.                                                 if(count($invited_list) == 0)
  704.                                                     $main_content .= '
  705.                                                         <TR BGCOLOR=#F1E0C6>
  706.                                                             <TD>No invited characters found.</TD>
  707.                                                         </TR>';
  708.                                                 else {
  709.                                                     $main_content .= '
  710.                                                         <TR BGCOLOR=#D4C0A1>
  711.                                                             <TD WIDTH=70%><B>Name</B></TD>
  712.                                                             <TD WIDTH=30%><B>Invitation Date</B></TD>
  713.                                                         </TR>';
  714.                                                     $show_accept_invite = 0;
  715.                                                     $showed_invited = 1;
  716.                                                     foreach($invited_list as $invited_player) {
  717.                                                         if(count($account_players) > 0)
  718.                                                             foreach($account_players as $player_from_acc)
  719.                                                                 if($player_from_acc->getName() == $invited_player->getName())
  720.                                                                     $show_accept_invite++;
  721.                                                         if(is_int($showed_invited / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_invited++;
  722.                                                         $main_content .= '
  723.                                                             <TR BGCOLOR='.$bgcolor.'>
  724.                                                                 <TD><A HREF="?subtopic=characters&name='.urlencode($invited_player->getName()).'">'.htmlspecialchars($invited_player->getName()).'</A></TD>';
  725.                                                             $invitedID = $invited_player->getId();
  726.                                                             $getInviteDate = filter_var($getInviteDate, FILTER_SANITIZE_STRING);
  727.                                                             $getInviteDate = $SQL->query("SELECT `date` FROM `guild_invites` WHERE `player_id` = '$invitedID'")->fetch();
  728.                                                             $main_content .= '
  729.                                                                 <TD>'.date("M d Y",$getInviteDate['date']).'</TD>
  730.                                                             </TR>';
  731.                                                     }
  732.                                                    
  733.                                                 }
  734.                                                 $main_content .= '
  735.                                                     </table>
  736.                                                 </div>
  737.                                             </div>
  738.                                             <div class="TableShadowContainer" >
  739.                                                 <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bm.gif);" >
  740.                                                     <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bl.gif);" ></div>
  741.                                                     <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-br.gif);" ></div>
  742.                                                 </div>
  743.                                             </div>
  744.                                         </td>
  745.                                     </tr>
  746.                                 </table>
  747.                             </div>
  748.                         </td>
  749.                     </tr>
  750.                 </table>
  751.             </div>';
  752.        
  753.             $main_content .= '
  754.                 <TABLE BORDER=0 class="fixed">
  755.                     <col width="140px">
  756.                     <col width="140px">
  757.                     <col width="140px">
  758.                     <col width="140px">
  759.                     <col width="140px">
  760.                     <TR>';
  761.                 if($guild_vice)
  762.                     $main_content .= '
  763.                         <TD><table border="0" cellspacing="0" cellpadding="0" >
  764.                                 <form action="?subtopic=guilds" method="post" >
  765.                                     <tr>
  766.                                         <td style="border:0px;" >
  767.                                             <input type="hidden" name=action value=invite >
  768.                                             <input type="hidden" name=GuildName value="'.$guild->getName().'" >
  769.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  770.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  771.                                                     <input class="ButtonText" type="image" name="Invite Character" alt="Invite Character" src="'.$layout_name.'/images/global/buttons/_sbutton_invitecharacter.gif" >
  772.                                                 </div>
  773.                                             </div>
  774.                                         </td>
  775.                                     </tr>
  776.                                 </form>
  777.                             </table>
  778.                         </TD>';
  779.                 if($show_accept_invite > 0)
  780.                     $main_content .= '
  781.                         <TD>
  782.                             <table border="0" cellspacing="0" cellpadding="0" >
  783.                                 <form action="?subtopic=guilds" method="post" >
  784.                                     <tr>
  785.                                         <td style="border:0px;" >
  786.                                             <input type="hidden" name=action value=join >
  787.                                             <input type="hidden" name=GuildName value="'.$guild->getName().'" >
  788.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  789.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  790.                                                     <input class="ButtonText" type="image" name="Join Guild" alt="Join Guild" src="'.$layout_name.'/images/global/buttons/_sbutton_joinguild.gif" >
  791.                                                 </div>
  792.                                             </div>
  793.                                         </td>
  794.                                     </tr>
  795.                                 </form>
  796.                             </table>
  797.                         </TD>';
  798.                 $main_content .= '
  799.                     </TR>
  800.                 </TABLE>';
  801.         $main_content .= '
  802.             <BR>
  803.             <TABLE BORDER=0 WIDTH=100%>
  804.                 <TR>
  805.                     <TD ALIGN=center><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD>                   
  806.                     <TD ALIGN="center">
  807.                         <form action="?subtopic=guilds" method="post" style="padding:0px;margin:0px;" >
  808.                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  809.                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  810.                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  811.                                 </div>
  812.                             </div>
  813.                         </form>
  814.                     </TD>
  815.                     <TD ALIGN=center><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD>
  816.                 </TR>
  817.             </TABLE>';
  818.     }
  819. }
  820. if($action == "create") {
  821.     $guild_name = trim($_REQUEST['name']);
  822.     $leader = $_REQUEST['leader'];
  823.     $todo = $_REQUEST['todo'];
  824.     $guild_password = trim($_REQUEST['password']); 
  825.     if(!$logged)
  826.         $guild_errors[] = 'You are not logged in. You can\'t create guild.';
  827.     if(empty($guild_errors))
  828.     {
  829.         $account_players = $account_logged->getPlayers();
  830.         foreach($account_players as $player)
  831.         {
  832.             $player_rank = $player->getRank();
  833.             if(empty($player_rank))
  834.                 if($player->getLevel() >= $config['site']['guild_need_level'])
  835.                     if(!$config['site']['guild_need_pacc'] || $account_logged->isPremium())
  836.                         $array_of_player_nig[] = $player->getName();
  837.         }
  838.     }
  839.     if(count($array_of_player_nig) == 0)
  840.         $guild_errors[] = 'On your account all characters are in guilds or have too low level to create new guild.';
  841.     if($todo == "save") {
  842.         if(!check_guild_name($guild_name)) {
  843.             $guild_errors[] = 'Invalid guild name format.';
  844.         }
  845.         if(!check_name($leader)) {
  846.             $guild_errors[] = 'Invalid character name format.';
  847.         }
  848.         if(empty($guild_errors)) {
  849.             $player = new Player();
  850.             $player->find($leader);
  851.             if(!$player->isLoaded())
  852.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($leader).'</b> doesn\'t exist.';
  853.         }
  854.         if(empty($guild_errors)) {
  855.             $guild = new Guild();
  856.             $guild->find($guild_name);
  857.             if($guild->isLoaded())
  858.                 $guild_errors[] = 'Guild <b>'.htmlspecialchars($guild_name).'</b> already exist. Select other name.';
  859.         }
  860.         if(empty($guild_errors)) {
  861.             $bad_char = TRUE;
  862.             foreach($array_of_player_nig as $nick_from_list)
  863.                 if($nick_from_list == $player->getName())
  864.                     $bad_char = FALSE;
  865.             if($bad_char)
  866.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($leader).'</b> isn\'t on your account or is already in guild.';
  867.         }
  868.         if(empty($guild_errors)) {
  869.             if($player->getLevel() < $config['site']['guild_need_level'])
  870.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($leader).'</b> has too low level. To create guild you need character with level <b>'.$config['site']['guild_need_level'].'</b>.';
  871.             if($config['site']['guild_need_pacc'] && !$account_logged->isPremium())
  872.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($leader).'</b> is on FREE account. To create guild you need PREMIUM account.';
  873.         }
  874.         if(empty($guild_errors)) {
  875.             if (!$account_logged->isValidPassword($guild_password))
  876.                 $guild_errors[] = 'Wrong password, please check it and try again.';
  877.         }
  878.     }
  879.    
  880.     if(!empty($guild_errors)) {
  881.         $main_content .= '
  882.             <div class="TableContainer" >
  883.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  884.                     <div class="CaptionContainer" >
  885.                         <div class="CaptionInnerContainer" >
  886.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  887.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  888.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  889.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  890.                             <div class="Text" >Error</div>
  891.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  892.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  893.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  894.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  895.                         </div>
  896.                     </div>
  897.                     <tr>
  898.                         <td>
  899.                             <div class="InnerTableContainer" >
  900.                                 <table style="width:100%;" >
  901.                                     <tr>
  902.                                         <td>';
  903.                                     foreach($guild_errors as $guild_error)
  904.                                         $main_content .= '<p>'.$guild_error.'</p>';
  905.                                     $main_content .= '
  906.                                         </td>
  907.                                     </tr>
  908.                                 </table>
  909.                             </div>
  910.                         </td>
  911.                     </tr>
  912.                 </table>
  913.             </div><BR>
  914.             <TABLE BORDER=0 WIDTH=100%>
  915.                 <TR>
  916.                     <TD ALIGN=center>
  917.                         <table border="0" cellspacing="0" cellpadding="0" >
  918.                             <form action="?subtopic=guilds" method="post" >
  919.                                 <tr>
  920.                                     <td style="border:0px;" >';
  921.                                     if ($logged)
  922.                                         if(count($array_of_player_nig) > 0)
  923.                                             $main_content .= '
  924.                                                 <input type="hidden" name=action value=create >';
  925.                                     $main_content .= '
  926.                                         <input type="hidden" name=name value="'.$guild_name.'" >
  927.                                         <input type="hidden" name=leader value="'.$leader.'" >
  928.                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  929.                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  930.                                                 <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  931.                                             </div>
  932.                                         </div>
  933.                                     </td>
  934.                                 </tr>
  935.                             </form>
  936.                         </table>
  937.                     </TD>
  938.                 </TR>
  939.             </TABLE>';
  940.     } else {
  941.         if($todo == "save")
  942.         {
  943.             $new_guild = new Guild();
  944.             $new_guild->setCreationData(time());
  945.             $new_guild->setName($guild_name);
  946.             $new_guild->setOwner($player);
  947.             $new_guild->setDescription('New guild. Leader must edit this text :)');
  948.             $new_guild->setGuildLogo('image/gif', Website::getFileContents('./images/guildlogos/default_logo.gif'));
  949.            
  950.             $new_guild->save();
  951.             $ranks = $new_guild->getGuildRanksList(true);
  952.             foreach($ranks as $rank)
  953.                 if($rank->getLevel() == 3)
  954.                 {
  955.                     $player->setRank($rank);
  956.                     $player->save();
  957.                 }
  958.             $main_content .= '
  959.                 <div class="TableContainer" >
  960.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  961.                         <div class="CaptionContainer" >
  962.                             <div class="CaptionInnerContainer" >
  963.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  964.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  965.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  966.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  967.                                 <div class="Text" >Guild Founded!</div>
  968.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  969.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  970.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  971.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  972.                             </div>
  973.                         </div>
  974.                         <tr>
  975.                             <td>
  976.                                 <div class="InnerTableContainer" >
  977.                                     <table style="width:100%;" >
  978.                                         <tr>
  979.                                             <td>You have founded the '.htmlspecialchars($guild_name).'. Now go ahead and invite the first members.</td>
  980.                                         </tr>
  981.                                     </table>
  982.                                 </div>
  983.                             </td>
  984.                         </tr>
  985.                     </table>
  986.                 </div><br>
  987.                 <TABLE BORDER=0 WIDTH=100%>
  988.                     <TR>
  989.                         <TD ALIGN=center>
  990.                             <table border="0" cellspacing="0" cellpadding="0" >
  991.                                 <form action="?subtopic=guilds" method="post" >
  992.                                     <tr>
  993.                                         <td style="border:0px;" >
  994.                                             <input type="hidden" name=action value=view >
  995.                                             <input type="hidden" name=GuildName value="'.$guild_name.'" >
  996.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  997.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  998.                                                     <input class="ButtonText" type="image" name="Continue" alt="Continue" src="'.$layout_name.'/images/global/buttons/_sbutton_continue.gif" >
  999.                                                 </div>
  1000.                                             </div>
  1001.                                         </td>
  1002.                                     </tr>
  1003.                                 </form>
  1004.                             </table>
  1005.                         </TD>
  1006.                     </TR>
  1007.                 </TABLE>';
  1008.         } else {
  1009.             #form to create
  1010.             $main_content .= 'Do you want to found a new guild? none of your characters may hold one of the two highest ranks in any other guild.<BR><BR>Now enter the name of the new guild, specify the name of your character that should become the first leader and confirm with your account password. Then click on "Submit". Note that the first two data cannot be changed later.<BR><BR>';
  1011.             $main_content .= '
  1012.                 <FORM ACTION="?subtopic=guilds" METHOD="post">
  1013.                 <div class="TableContainer" >
  1014.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1015.                         <div class="CaptionContainer" >
  1016.                             <div class="CaptionInnerContainer" >
  1017.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1018.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1019.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1020.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  1021.                                 <div class="Text" >Found Guild</div>
  1022.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1023.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1024.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1025.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1026.                             </div>
  1027.                         </div>
  1028.                         <tr>
  1029.                             <td>
  1030.                                 <div class="InnerTableContainer" >
  1031.                                     <table style="width:100%;" >
  1032.                                         <TR>
  1033.                                             <TD BGCOLOR=#D4C0A1>
  1034.                                                 <TABLE BORDER=0 CELLPADDING=1>
  1035.                                                     <TR>
  1036.                                                         <TD>Guild Name:</TD>
  1037.                                                         <TD><INPUT NAME="name" VALUE="'.$_REQUEST['name'].'" SIZE=30 MAXLENGTH=29></TD>
  1038.                                                     </TR>
  1039.                                                     <TR>
  1040.                                                         <TD>Leader:</TD>
  1041.                                                         <TD>
  1042.                                                             <SELECT NAME="leader">';
  1043.                                                                 if(count($array_of_player_nig) > 0) {
  1044.                                                                     sort($array_of_player_nig);
  1045.                                                                     foreach($array_of_player_nig as $nick)
  1046.                                                                         $main_content .= '<OPTION>'.htmlspecialchars($nick).'</OPTION>';
  1047.                                                                 }
  1048.                                                         $main_content .= '
  1049.                                                             </SELECT>
  1050.                                                         </TD>
  1051.                                                     </TR>
  1052.                                                     <TR>
  1053.                                                         <TD>Password:</TD>
  1054.                                                         <TD><INPUT TYPE=password NAME="password" SIZE=30 MAXLENGTH=29></TD>
  1055.                                                     </TR>
  1056.                                                 </TABLE>
  1057.                                             </TD>
  1058.                                         </TR>
  1059.                                     </table>
  1060.                                 </div>
  1061.                             </td>
  1062.                         </tr>
  1063.                     </table>
  1064.                 </div><BR>
  1065.                 <TABLE BORDER=0 WIDTH=100%>
  1066.                     <TR>
  1067.                         <TD ALIGN=center><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR></TD>
  1068.                         <TD ALIGN=center>
  1069.                             <table border="0" cellspacing="0" cellpadding="0" >
  1070.                             <form action="?subtopic=guilds" method="post" >
  1071.                                 <tr>
  1072.                                     <td style="border:0px;" >
  1073.                                         <input type="hidden" name="todo" value="save" >
  1074.                                         <input type="hidden" name="action" value="create" >
  1075.                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1076.                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1077.                                                 <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  1078.                                             </div>
  1079.                                         </div>
  1080.                                     </td>
  1081.                                 <tr>
  1082.                             </form>
  1083.                             </table>
  1084.                         </TD>
  1085.                         <TD ALIGN=center>
  1086.                             <table border="0" cellspacing="0" cellpadding="0" >
  1087.                                 <form action="?subtopic=guilds" method="post" >
  1088.                                     <tr>
  1089.                                         <td style="border:0px;" >
  1090.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1091.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1092.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  1093.                                                 </div>
  1094.                                             </div>
  1095.                                         </td>
  1096.                                     </tr>
  1097.                                 </form>
  1098.                             </table>
  1099.                         </TD>
  1100.                         <TD ALIGN=center><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR></TD>
  1101.                     </TR>
  1102.                 </TABLE>';
  1103.         }
  1104.     }
  1105. }
  1106. if ($action == "invite") {
  1107.     //set rights in guild
  1108.     $guild_name = (string) $_REQUEST['GuildName'];
  1109.     $name = $_REQUEST['character'];
  1110.     if(!$logged)
  1111.         $guild_errors[] = 'You are not logged in. You can\'t invite players.';
  1112.     if(empty($guild_errors))
  1113.     {
  1114.         $guild = new Guild();
  1115.         $guild->loadByName($guild_name);
  1116.         if(!$guild->isLoaded())
  1117.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1118.     }
  1119.     if(empty($guild_errors))
  1120.     {
  1121.         $rank_list = $guild->getGuildRanksList();
  1122.         $guild_leader = FALSE;
  1123.         $guild_vice = FALSE;
  1124.         $account_players = $account_logged->getPlayers();
  1125.         foreach($account_players as $player)
  1126.         {
  1127.             $player_rank = $player->getRank();
  1128.             if(!empty($player_rank))
  1129.                 foreach($rank_list as $rank_in_guild)
  1130.                     if($rank_in_guild->getId() == $player_rank->getId())
  1131.                     {
  1132.                         $players_from_account_in_guild[] = $player->getName();
  1133.                         if($player_rank->getLevel() > 1)
  1134.                         {
  1135.                             $guild_vice = TRUE;
  1136.                             $level_in_guild = $player_rank->getLevel();
  1137.                         }
  1138.                         if($guild->getOwner()->getId() == $player->getId())
  1139.                         {
  1140.                             $guild_vice = TRUE;
  1141.                             $guild_leader = TRUE;
  1142.                         }
  1143.                     }
  1144.         }
  1145.     }
  1146.     if(!$guild_vice)
  1147.         $guild_errors[] = 'You are not a leader or vice leader of guild ID <b>'.$guild_name.'</b>.';
  1148.     if($_REQUEST['invitation'] == 'yes')
  1149.     {
  1150.         if(!check_name($name))
  1151.             $guild_errors[] = 'Invalid name format.';
  1152.         if(empty($guild_errors))
  1153.         {
  1154.             $player = new Player();
  1155.             $player->find($name);
  1156.             if(!$player->isLoaded())
  1157.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  1158.             else
  1159.             {
  1160.                 $rank_of_player = $player->getRank();
  1161.                 if(!empty($rank_of_player))
  1162.                     $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> is already in guild. He must leave guild before you can invite him.';
  1163.             }
  1164.         }
  1165.         if(empty($guild_errors))
  1166.         {
  1167.             $invited_list = $guild->listInvites();
  1168.             if(count($invited_list) > 0)
  1169.                 foreach($invited_list as $invited)
  1170.                     if($invited->getName() == $player->getName())
  1171.                         $guild_errors[] = '<b>'.htmlspecialchars($player->getName()).'</b> is already invited to your guild.';
  1172.         }
  1173.     }
  1174.     if($_REQUEST['invitation'] == 'no') {
  1175.         $player_remove_invite = $_REQUEST['character'];
  1176.         $player_noinvite = new Player();
  1177.         $player_noinvite->find($player_remove_invite);
  1178.         if($player_noinvite->isLoaded())
  1179.             $player_noinvite_id = $player_noinvite->getId();
  1180.        
  1181.     }
  1182.    
  1183.     if(!empty($guild_errors)) {
  1184.         $main_content .= '
  1185.             <div class="TableContainer" >
  1186.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  1187.                     <div class="CaptionContainer" >
  1188.                         <div class="CaptionInnerContainer" >
  1189.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1190.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1191.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1192.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  1193.                             <div class="Text" >Error</div>
  1194.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1195.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1196.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1197.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1198.                         </div>
  1199.                     </div>
  1200.                     <tr>
  1201.                         <td>
  1202.                             <div class="InnerTableContainer" >
  1203.                                 <table style="width:100%;" >
  1204.                                     <tr>
  1205.                                         <td class="red" >';
  1206.                                         foreach($guild_errors as $guild_error)
  1207.                                             $main_content .= '<p>'.$guild_error;
  1208.                                     $main_content .= '
  1209.                                         </td>
  1210.                                     </tr>
  1211.                                 </table>
  1212.                             </div>
  1213.                         </td>
  1214.                     </tr>
  1215.                 </table>
  1216.             </div><BR>';
  1217.     } else {
  1218.         if($_REQUEST['invitation'] == 'yes') {
  1219.             $guild->invite($player);
  1220.             //mensagem do char invitado
  1221.             $main_content .= '
  1222.                 <div class="TableContainer" >
  1223.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1224.                         <div class="CaptionContainer" >
  1225.                             <div class="CaptionInnerContainer" >
  1226.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1227.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1228.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1229.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  1230.                                 <div class="Text" >Character Invited</div>
  1231.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1232.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1233.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1234.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1235.                             </div>
  1236.                         </div>
  1237.                         <tr>
  1238.                             <td><div class="InnerTableContainer" >
  1239.                                     <table style="width:100%;" >
  1240.                                         <tr>
  1241.                                             <td>'.htmlspecialchars($player->getName()).' has been invited.</td>
  1242.                                         </tr>
  1243.                                     </table>
  1244.                                 </div>
  1245.                             </td>
  1246.                         </tr>
  1247.                     </table>
  1248.                 </div>
  1249.                 <BR>';
  1250.         }
  1251.         if($_REQUEST['invitation'] == 'no') {
  1252.             $guild->deleteInvite($player_noinvite);
  1253.             $main_content .= '
  1254.                 <div class="TableContainer" >
  1255.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1256.                         <div class="CaptionContainer" >
  1257.                             <div class="CaptionInnerContainer" >
  1258.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1259.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1260.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1261.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  1262.                                 <div class="Text" >Invitation Cancelled</div>
  1263.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1264.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1265.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1266.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1267.                             </div>
  1268.                         </div>
  1269.                         <tr>
  1270.                             <td>
  1271.                                 <div class="InnerTableContainer" >
  1272.                                     <table style="width:100%;" >
  1273.                                         <tr>
  1274.                                             <td>The invitation of '.$player_remove_invite.' has been cancelled.</td>
  1275.                                         </tr>
  1276.                                     </table>
  1277.                                 </div>
  1278.                             </td>
  1279.                         </tr>
  1280.                     </table>
  1281.                 </div>
  1282.                 <BR>';
  1283.         }
  1284.     }
  1285.         $main_content .= '
  1286.             Enter the name of a character you want to invite to your guild and click on "Submit".<BR><BR>';
  1287.         $main_content .= '
  1288.             <div class="TableContainer" >
  1289.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  1290.                     <div class="CaptionContainer" >
  1291.                         <div class="CaptionInnerContainer" >
  1292.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1293.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1294.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1295.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  1296.                             <div class="Text" >Invite Character</div>
  1297.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1298.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1299.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1300.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1301.                         </div>
  1302.                     </div>
  1303.                     <tr>
  1304.                         <td>
  1305.                             <div class="InnerTableContainer" >
  1306.                                 <table style="width:100%;" >
  1307.                                     <TR>
  1308.                                         <TD BGCOLOR=#D4C0A1>
  1309.                                             <FORM ACTION="?subtopic=guilds" METHOD=post>
  1310.                                                 <TABLE BORDER=0 CELLPADDING=1>
  1311.                                                     <TR>
  1312.                                                         <TD>Name:</TD>
  1313.                                                         <TD><INPUT NAME="character" VALUE="" SIZE=30 MAXLENGTH=30></TD>
  1314.                                                         <TD WIDTH=100% ALIGN=right>
  1315.                                                             <table border="0" cellspacing="0" cellpadding="0" >
  1316.                                                                 <tr>
  1317.                                                                     <td style="border:0px;" >
  1318.                                                                         <input type="hidden" name=action value=invite >
  1319.                                                                         <input type="hidden" name=invitation value=yes >
  1320.                                                                         <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1321.                                                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1322.                                                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1323.                                                                                 <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  1324.                                                                             </div>
  1325.                                                                         </div>
  1326.                                                                     </td>                                                  
  1327.                                                                 </tr>
  1328.                                                             </table>
  1329.                                                         </TD>
  1330.                                                     </TR>
  1331.                                                 </TABLE>
  1332.                                             </form>
  1333.                                         </td>
  1334.                                     </tr>
  1335.                                 </table>
  1336.                             </div>
  1337.                         </td>
  1338.                     </tr>
  1339.                 </table>
  1340.             </div>';
  1341.         $invited_list = $guild->listInvites();
  1342.         if(count($invited_list) > 0) {
  1343.             $main_content .= '
  1344.                 <BR>
  1345.                 If you want to cancel an invitation, select the according character and click on "Submit".<BR><BR>
  1346.                 <div class="TableContainer" >
  1347.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1348.                         <div class="CaptionContainer" >
  1349.                             <div class="CaptionInnerContainer" >
  1350.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1351.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1352.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1353.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  1354.                                 <div class="Text" >Cancel Invitation</div>
  1355.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1356.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1357.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1358.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1359.                             </div>
  1360.                         </div>
  1361.                         <tr>
  1362.                             <td>
  1363.                                 <div class="InnerTableContainer" >
  1364.                                     <table style="width:100%;" >
  1365.                                         <TR>
  1366.                                             <TD BGCOLOR=#D4C0A1>
  1367.                                                 <FORM ACTION="?subtopic=guilds" METHOD=post>
  1368.                                                     <TABLE BORDER=0 CELLPADDING=1>
  1369.                                                         <TR>
  1370.                                                             <TD>Name:</TD>
  1371.                                                             <TD>
  1372.                                                                 <SELECT NAME="character">';
  1373.                                                             foreach($invited_list as $invited)
  1374.                                                                 $main_content .= '
  1375.                                                                     <OPTION VALUE="'.$invited->getName().'">'.$invited->getName().'</OPTION>';
  1376.                                                             $main_content .= '
  1377.                                                                 </SELECT>
  1378.                                                             </TD>
  1379.                                                             <TD WIDTH=100% ALIGN=right>
  1380.                                                                 <table border="0" cellspacing="0" cellpadding="0" >
  1381.                                                                     <tr>
  1382.                                                                         <td style="border:0px;" >
  1383.                                                                             <input type="hidden" name=action value=invite >
  1384.                                                                             <input type="hidden" name=invitation value=no >
  1385.                                                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1386.                                                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1387.                                                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1388.                                                                                     <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  1389.                                                                                 </div>
  1390.                                                                             </div>
  1391.                                                                         </td>                                                      
  1392.                                                                     <tr>
  1393.                                                                 </table>
  1394.                                                             </TD>
  1395.                                                         </TR>
  1396.                                                     </TABLE>
  1397.                                                 </FORM>
  1398.                                             </TD>
  1399.                                         </TR>
  1400.                                     </table>
  1401.                                 </div>
  1402.                             </td>
  1403.                         </tr>
  1404.                     </table>
  1405.                 </div>';
  1406.         }
  1407.        
  1408.         $main_content .= '
  1409.             <BR>
  1410.             <TABLE BORDER=0 WIDTH=100%>
  1411.                 <TR>
  1412.                     <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  1413.                             <form action="?subtopic=guilds&action=view" method="post" >
  1414.                                 <tr>
  1415.                                     <td style="border:0px;" >
  1416.                                         <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1417.                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1418.                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1419.                                                 <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  1420.                                             </div>
  1421.                                         </div>
  1422.                                     </td>
  1423.                                 </tr>
  1424.                             </form>
  1425.                         </table>
  1426.                     </TD>
  1427.                 </TR>
  1428.             </TABLE>';
  1429. }
  1430. if($action == "leave") {
  1431.     //set rights in guild
  1432.     $guild_name = (string) $_REQUEST['GuildName'];
  1433.     $name = $_REQUEST['character'];
  1434.     if(!$logged)
  1435.         $guild_errors[] = 'You are not logged in. You can\'t leave guild.';
  1436.     if(empty($guild_errors))
  1437.     {
  1438.         $guild = new Guild();
  1439.         $guild->loadByName($guild_name);
  1440.         if(!$guild->isLoaded())
  1441.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  1442.     }
  1443.  
  1444.     if(empty($guild_errors))
  1445.     {
  1446.         $guild_owner_id = $guild->getOwner()->getId();
  1447.         if($_REQUEST['leaveguild'] == 'yes')
  1448.         {
  1449.             if(!check_name($name))
  1450.                 $guild_errors[] = 'Invalid name format.';
  1451.             if(empty($guild_errors))
  1452.             {
  1453.                 $player = new Player();
  1454.                 $player->find($name);
  1455.                 if(!$player->isLoaded())
  1456.                     $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  1457.                 else
  1458.                     if($player->getAccount()->getId() != $account_logged->getId())
  1459.                         $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t from your account!';
  1460.             }
  1461.             if(empty($guild_errors))
  1462.             {
  1463.                 $player_loaded_rank = $player->getRank();
  1464.                 if(!empty($player_loaded_rank) && $player_loaded_rank->isLoaded())
  1465.                 {
  1466.                     if($player_loaded_rank->getGuild()->getId() != $guild->getId())
  1467.                         $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t from guild <b>'.htmlspecialchars($guild->getName()).'</b>.';
  1468.                 }
  1469.                 else
  1470.                     $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t in any guild.';
  1471.             }
  1472.             if(empty($guild_errors))
  1473.                 if($guild_owner_id == $player->getId())
  1474.                     $guild_errors[] = 'You can\'t leave guild. You are an owner of guild.';
  1475.         }
  1476.         else
  1477.         {
  1478.             $account_players = $account_logged->getPlayers();
  1479.             foreach($account_players as $player_fac)
  1480.             {
  1481.                 $player_rank = $player_fac->getRank();
  1482.                 if(!empty($player_rank))
  1483.                     if($player_rank->getGuild()->getId() == $guild->getId())
  1484.                         if($guild_owner_id != $player_fac->getId())
  1485.                             $array_of_player_ig[] = $player_fac->getName();
  1486.             }
  1487.         }
  1488.     }
  1489.     if(!empty($guild_errors)) {
  1490.         $main_content .= '
  1491.             <div class="TableContainer" >
  1492.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  1493.                     <div class="CaptionContainer" >
  1494.                         <div class="CaptionInnerContainer" >
  1495.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1496.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1497.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1498.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  1499.                             <div class="Text" >Error</div>
  1500.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1501.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1502.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1503.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1504.                         </div>
  1505.                     </div>
  1506.                     <tr>
  1507.                         <td>
  1508.                             <div class="InnerTableContainer" >
  1509.                                 <table style="width:100%;" >
  1510.                                     <tr>
  1511.                                         <td class="red" >';
  1512.                                         foreach($guild_errors as $guild_error)
  1513.                                             $main_content .= '<p>'.$guild_error;
  1514.                                     $main_content .= '
  1515.                                         </td>
  1516.                                     </tr>
  1517.                                 </table>
  1518.                             </div>
  1519.                         </td>
  1520.                     </tr>
  1521.                 </table>
  1522.             </div><BR>';
  1523.     } else {
  1524.         if($_REQUEST['leaveguild'] == 'yes') {
  1525.             $player->setRank();
  1526.             $player->save();
  1527.             $main_content .= '             
  1528.                 <div class="TableContainer" >
  1529.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1530.                         <div class="CaptionContainer" >
  1531.                             <div class="CaptionInnerContainer" >
  1532.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1533.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1534.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1535.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  1536.                                 <div class="Text" >Guild Left</div>
  1537.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1538.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1539.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1540.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1541.                             </div>
  1542.                         </div>
  1543.                         <tr>
  1544.                             <td><div class="InnerTableContainer" >
  1545.                                     <table style="width:100%;" >
  1546.                                         <tr>
  1547.                                             <td>You have left the guild.</td>
  1548.                                         </tr>
  1549.                                     </table>
  1550.                                 </div>
  1551.                             </td>
  1552.                         </tr>
  1553.                     </table>
  1554.                 </div><BR>
  1555.                 <TABLE BORDER=0 WIDTH=100%>
  1556.                     <TR>
  1557.                         <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  1558.                                 <form action="?subtopic=guilds&page=view" method="post" >
  1559.                                     <tr>
  1560.                                         <td style="border:0px;" >
  1561.                                             <input type="hidden" name=action value=view >
  1562.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1563.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1564.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1565.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  1566.                                                 </div>
  1567.                                             </div>
  1568.                                         </td>
  1569.                                     </tr>
  1570.                                 </form>
  1571.                             </table>
  1572.                         </TD>
  1573.                     </TR>
  1574.                 </TABLE>';
  1575.         } else {
  1576.             $main_content .= '
  1577.                 The following of your characters are members of this guild. If you want to leave, select a character and click on "Submit".<BR><BR>';
  1578.             $main_content .= '
  1579.                 <FORM ACTION="?subtopic=guilds" METHOD=post>
  1580.                     <div class="TableContainer" >
  1581.                         <table class="Table1" cellpadding="0" cellspacing="0" >
  1582.                             <div class="CaptionContainer" >
  1583.                                 <div class="CaptionInnerContainer" >
  1584.                                     <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1585.                                     <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1586.                                     <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1587.                                     <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>               
  1588.                                     <div class="Text" >Guild Members</div>
  1589.                                     <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1590.                                     <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1591.                                     <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1592.                                     <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1593.                                 </div>
  1594.                             </div>
  1595.                             <tr>
  1596.                                 <td><div class="InnerTableContainer" >
  1597.                                         <table style="width:100%;" >
  1598.                                             <TR>';
  1599.                                         if(count($array_of_player_ig) > 0) {
  1600.                                             $main_content .= '
  1601.                                                 <TD BGCOLOR=#D4C0A1>';
  1602.                                                 sort($array_of_player_ig);
  1603.                                                 foreach($array_of_player_ig as $player_to_leave)
  1604.                                                     $main_content .= '                                     
  1605.                                                         <INPUT TYPE=radio NAME="character" VALUE="'.htmlspecialchars($player_to_leave).'" '.((count($array_of_player_ig) == 1) ? 'checked' : '').'>'.htmlspecialchars($player_to_leave).'<BR>';
  1606.                                             $main_content .= '</TD>';
  1607.                                         } else {
  1608.                                             $main_content .= '<TD BGCOLOR=#D4C0A1>Any of your characters can\'t leave guild.</TD>';
  1609.                                         }
  1610.                                         $main_content .= '                                     
  1611.                                             </TR>
  1612.                                         </table>
  1613.                                     </div>
  1614.                                 </td>
  1615.                             </tr>
  1616.                         </table>
  1617.                     </div>
  1618.                     <BR>
  1619.                     <TABLE BORDER=0 WIDTH=100%>
  1620.                         <TR align="center">
  1621.                             <TD ALIGN=center>
  1622.                                 <table border="0" cellspacing="0" cellpadding="0" >
  1623.                                     <tr>
  1624.                                         <td style="border:0px;" >
  1625.                                             <input type="hidden" name=action value=leave >
  1626.                                             <input type="hidden" name="leaveguild" value="yes">
  1627.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1628.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1629.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1630.                                                     <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  1631.                                                 </div>
  1632.                                             </div>
  1633.                                         </td>                  
  1634.                                     <tr>
  1635.                                 </form>
  1636.                             </table>
  1637.                         </TD>
  1638.                         <TD ALIGN=center>
  1639.                             <table border="0" cellspacing="0" cellpadding="0" >
  1640.                                 <form action="?subtopic=guilds&action=view" method="post" >
  1641.                                     <tr>
  1642.                                         <td style="border:0px;" >
  1643.                                             <input type="hidden" name=action value=view >
  1644.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1645.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1646.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1647.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  1648.                                                 </div>
  1649.                                             </div>
  1650.                                         </td>
  1651.                                     </tr>
  1652.                                 </form>
  1653.                             </table>
  1654.                         </TD>
  1655.                     </TR>
  1656.                 </TABLE>';
  1657.         }
  1658.     }
  1659. }
  1660. if($action == "join") {
  1661.     //set rights in guild
  1662.     $guild_name = (string) $_REQUEST['GuildName'];
  1663.     $name = $_REQUEST['character'];
  1664.     if(!$logged)
  1665.         $guild_errors[] = 'You are not logged in. You can\'t accept invitations.';
  1666.     if(empty($guild_errors))
  1667.     {
  1668.         $guild = new Guild();
  1669.         $guild->loadByName($guild_name);
  1670.         if(!$guild->isLoaded())
  1671.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  1672.     }
  1673.  
  1674.     if($_REQUEST['joinguild'] == 'yes')
  1675.     {
  1676.         if(!check_name($name))
  1677.             $guild_errors[] = 'Invalid name format.';
  1678.         if(empty($guild_errors))
  1679.         {
  1680.             $player = new Player();
  1681.             $player->find($name);
  1682.             if(!$player->isLoaded())
  1683.             {
  1684.                 $guild_errors[] = 'Player with name <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  1685.             }
  1686.             else
  1687.             {
  1688.                 $rank_of_player = $player->getRank();
  1689.                 if(!empty($rank_of_player))
  1690.                 {
  1691.                     $guild_errors[] = 'Character with name <b>'.htmlspecialchars($name).'</b> is already in guild. You must leave guild before you join other guild.';
  1692.                 }
  1693.             }
  1694.         }
  1695.     }
  1696.     if($_REQUEST['joinguild'] == 'yes')
  1697.     {
  1698.         if(empty($guild_errors))
  1699.         {
  1700.             $is_invited = FALSE;
  1701.             $invited_list = $guild->listInvites();
  1702.             if(count($invited_list) > 0)
  1703.             {
  1704.                 foreach($invited_list as $invited)
  1705.                 {
  1706.                     if($invited->getName() == $player->getName())
  1707.                     {
  1708.                         $is_invited = TRUE;
  1709.                     }
  1710.                 }
  1711.             }
  1712.             if(!$is_invited)
  1713.             {
  1714.                 $guild_errors[] = 'Character '.htmlspecialchars($player->getName()).' isn\'t invited to guild <b>'.htmlspecialchars($guild->getName()).'</b>.';
  1715.             }
  1716.         }
  1717.     } else
  1718.     {
  1719.         if(empty($guild_errors))
  1720.         {
  1721.             $acc_invited = FALSE;
  1722.             $account_players = $account_logged->getPlayers();
  1723.             $invited_list = $guild->listInvites();
  1724.             if(count($invited_list) > 0)
  1725.             {
  1726.                 foreach($invited_list as $invited)
  1727.                 {
  1728.                     foreach($account_players as $player_from_acc)
  1729.                     {
  1730.                         if($invited->getName() == $player_from_acc->getName())
  1731.                         {
  1732.                             $acc_invited = TRUE;
  1733.                             $list_of_invited_players[] = $player_from_acc->getName();
  1734.                         }
  1735.                     }
  1736.                 }
  1737.             }
  1738.         }
  1739.         if(!$acc_invited)
  1740.         {
  1741.             $guild_errors[] = 'Any character from your account isn\'t invited to <b>'.htmlspecialchars($guild->getName()).'</b>.';
  1742.         }
  1743.     }
  1744.     if(!empty($guild_errors)) {
  1745.         $main_content .= '
  1746.             <div class="TableContainer" >
  1747.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  1748.                     <div class="CaptionContainer" >
  1749.                         <div class="CaptionInnerContainer" >
  1750.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1751.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1752.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1753.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  1754.                             <div class="Text" >Error</div>
  1755.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1756.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1757.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1758.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1759.                         </div>
  1760.                     </div>
  1761.                     <tr>
  1762.                         <td>
  1763.                             <div class="InnerTableContainer" >
  1764.                                 <table style="width:100%;" >
  1765.                                     <tr>
  1766.                                         <td class="red" >';
  1767.                                         foreach($guild_errors as $guild_error)
  1768.                                             $main_content .= '<p>'.$guild_error;
  1769.                                     $main_content .= '
  1770.                                         </td>
  1771.                                     </tr>
  1772.                                 </table>
  1773.                             </div>
  1774.                         </td>
  1775.                     </tr>
  1776.                 </table>
  1777.             </div><BR>';
  1778.     }else
  1779.     {
  1780.         if($_REQUEST['joinguild'] == 'yes') {
  1781.             $guild->acceptInvite($player);
  1782.             $main_content .= '             
  1783.                 <div class="TableContainer" >
  1784.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1785.                         <div class="CaptionContainer" >
  1786.                             <div class="CaptionInnerContainer" >
  1787.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1788.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1789.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1790.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  1791.                                 <div class="Text" >Guild Join</div>
  1792.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1793.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1794.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1795.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1796.                             </div>
  1797.                         </div>
  1798.                         <tr>
  1799.                             <td><div class="InnerTableContainer" >
  1800.                                     <table style="width:100%;" >
  1801.                                         <tr>
  1802.                                             <td>You have joined the guild.</td>
  1803.                                         </tr>
  1804.                                     </table>
  1805.                                 </div>
  1806.                             </td>
  1807.                         </tr>
  1808.                     </table>
  1809.                 </div><BR>
  1810.                 <TABLE BORDER=0 WIDTH=100%>
  1811.                     <TR>
  1812.                         <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  1813.                                 <form action="?subtopic=guilds&action=view" method="post" >
  1814.                                     <tr>
  1815.                                         <td style="border:0px;" >
  1816.                                             <input type="hidden" name=action value=view >
  1817.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1818.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1819.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1820.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  1821.                                                 </div>
  1822.                                             </div>
  1823.                                         </td>
  1824.                                     </tr>
  1825.                                 </form>
  1826.                             </table>
  1827.                         </TD>
  1828.                     </TR>
  1829.                 </TABLE>';
  1830.         } else {
  1831.             $main_content .= '
  1832.                 The following of your characters are invited for this guild. If you want to join, select a character and click on "Submit".<BR><BR>';
  1833.             $main_content .= '
  1834.                 <FORM ACTION="?subtopic=guilds" METHOD=post>
  1835.                     <div class="TableContainer" >
  1836.                         <table class="Table1" cellpadding="0" cellspacing="0" >
  1837.                             <div class="CaptionContainer" >
  1838.                                 <div class="CaptionInnerContainer" >
  1839.                                     <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1840.                                     <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1841.                                     <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1842.                                     <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>               
  1843.                                     <div class="Text" >Join Guild</div>
  1844.                                     <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1845.                                     <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1846.                                     <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1847.                                     <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1848.                                 </div>
  1849.                             </div>
  1850.                             <tr>
  1851.                                 <td><div class="InnerTableContainer" >
  1852.                                         <table style="width:100%;" >
  1853.                                             <TR>';
  1854.                                         if(count($list_of_invited_players) > 0) {
  1855.                                             $main_content .= '
  1856.                                                 <TD BGCOLOR=#D4C0A1>';
  1857.                                                 sort($list_of_invited_players);
  1858.                                                 foreach($list_of_invited_players as $invited_player_from_list)
  1859.                                                     $main_content .= '                                     
  1860.                                                         <INPUT TYPE=radio NAME="character" VALUE="'.htmlspecialchars($invited_player_from_list).'" '.((count($list_of_invited_players) == 1) ? 'checked' : '').'>'.htmlspecialchars($invited_player_from_list).'<BR>';
  1861.                                             $main_content .= '</TD>';
  1862.                                         } else {
  1863.                                             $main_content .= '<TD BGCOLOR=#D4C0A1>Any of your characters can\'t join guild.</TD>';
  1864.                                         }
  1865.                                         $main_content .= '                                     
  1866.                                             </TR>
  1867.                                         </table>
  1868.                                     </div>
  1869.                                 </td>
  1870.                             </tr>
  1871.                         </table>
  1872.                     </div>
  1873.                     <BR>
  1874.                     <TABLE BORDER=0 WIDTH=100%>
  1875.                         <TR align="center">
  1876.                             <TD ALIGN=center>
  1877.                                 <table border="0" cellspacing="0" cellpadding="0" >
  1878.                                     <tr>
  1879.                                         <td style="border:0px;" >
  1880.                                             <input type="hidden" name=action value=join >
  1881.                                             <input type="hidden" name="joinguild" value="yes">
  1882.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1883.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1884.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1885.                                                     <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  1886.                                                 </div>
  1887.                                             </div>
  1888.                                         </td>                  
  1889.                                     <tr>
  1890.                                 </form>
  1891.                             </table>
  1892.                         </TD>
  1893.                         <TD ALIGN=center>
  1894.                             <table border="0" cellspacing="0" cellpadding="0" >
  1895.                                 <form action="?subtopic=guilds&action=view" method="post" >
  1896.                                     <tr>
  1897.                                         <td style="border:0px;" >
  1898.                                             <input type="hidden" name=action value=view >
  1899.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  1900.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  1901.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  1902.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  1903.                                                 </div>
  1904.                                             </div>
  1905.                                         </td>
  1906.                                     </tr>
  1907.                                 </form>
  1908.                             </table>
  1909.                         </TD>
  1910.                     </TR>
  1911.                 </TABLE>';
  1912.         }
  1913.     }
  1914. }
  1915. if($action == "ranks") {
  1916.     //set rights in guild
  1917.     $guild_name = (string) $_REQUEST['GuildName'];
  1918.     $ranktorename = (int) $_REQUEST['ranktorename'];
  1919.     $new_rankname = (string) trim($_REQUEST['newrankname']);
  1920.     $rank_name = $_REQUEST['rank_name'];
  1921.     if(!$logged)
  1922.         $guild_errors[] = 'You are not logged in. You can\'t accept invitations.';
  1923.     if(empty($guild_errors)) {
  1924.         $guild = new Guild();
  1925.         $guild->loadByName($guild_name);
  1926.         if(!$guild->isLoaded())
  1927.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  1928.     }
  1929.     if(empty($guild_errors)) {
  1930.         $guild_leader_char = $guild->getOwner();
  1931.         $rank_list = $guild->getGuildRanksList();
  1932.         $guild_leader = FALSE;
  1933.         $account_players = $account_logged->getPlayers();
  1934.         foreach($account_players as $player)
  1935.             if($guild_leader_char->getId() == $player->getId())
  1936.             {
  1937.                 $guild_leader = TRUE;
  1938.                 $level_in_guild = 3;
  1939.             }
  1940.         if(!$guild_leader)
  1941.             $guild_errors[] = 'You are not leader of the Guild.';
  1942.     }
  1943.     if($_REQUEST['changerankname'] == "yes") {
  1944.         $rank_rename = new GuildRank();
  1945.         $rank_rename->load($ranktorename);
  1946.         if(!$rank_rename->isLoaded())
  1947.             $guild_errors[] = 'This rank doesn\'t exist.';
  1948.         if(!check_rank_name($new_rankname))
  1949.             $guild_errors[] = 'Invalid rank name. Please use only a-Z, 0-9 and spaces.';
  1950.     }
  1951.    
  1952.     if($_REQUEST['add_rank'] == "yes")
  1953.         if(!check_rank_name($rank_name))
  1954.             $guild_errors[] = 'Invalid rank name format.';
  1955.            
  1956.     if(!empty($guild_errors)) {
  1957.         //errors
  1958.         $main_content .= '
  1959.             <div class="TableContainer" >
  1960.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  1961.                     <div class="CaptionContainer" >
  1962.                         <div class="CaptionInnerContainer" >
  1963.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1964.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1965.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1966.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  1967.                             <div class="Text" >Guild Rank Errors</div>
  1968.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  1969.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  1970.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1971.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  1972.                         </div>
  1973.                     </div>
  1974.                     <tr>
  1975.                         <td>
  1976.                             <div class="InnerTableContainer" >
  1977.                                 <table style="width:100%;" >
  1978.                                     <tr>
  1979.                                         <td class="red" >';
  1980.                                         foreach($guild_errors as $guild_error)
  1981.                                             $main_content .= '<p>'.$guild_error;
  1982.                                     $main_content .= '
  1983.                                         </td>
  1984.                                     </tr>
  1985.                                 </table>
  1986.                             </div>
  1987.                         </td>
  1988.                     </tr>
  1989.                 </table>
  1990.             </div><BR>';
  1991.     } else {
  1992.         if($_REQUEST['changerankname'] == "yes") {
  1993.             //renamed
  1994.             $rank_rename->setName($new_rankname);
  1995.             $rank_rename->save();
  1996.             $main_content .= '             
  1997.                 <div class="TableContainer" >
  1998.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  1999.                         <div class="CaptionContainer" >
  2000.                             <div class="CaptionInnerContainer" >
  2001.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2002.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2003.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2004.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2005.                                 <div class="Text" >Guild Rank</div>
  2006.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2007.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2008.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2009.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2010.                             </div>
  2011.                         </div>
  2012.                         <tr>
  2013.                             <td><div class="InnerTableContainer" >
  2014.                                     <table style="width:100%;" >
  2015.                                         <tr>
  2016.                                             <td>The name of the rank was changed successfully.</td>
  2017.                                         </tr>
  2018.                                     </table>
  2019.                                 </div>
  2020.                             </td>
  2021.                         </tr>
  2022.                     </table>
  2023.                 </div><BR>
  2024.                 <TABLE BORDER=0 WIDTH=100%>
  2025.                     <TR>
  2026.                         <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  2027.                                 <form action="?subtopic=guilds&action=view" method="post" >
  2028.                                     <tr>
  2029.                                         <td style="border:0px;" >
  2030.                                             <input type="hidden" name=action value=view >
  2031.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2032.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2033.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2034.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2035.                                                 </div>
  2036.                                             </div>
  2037.                                         </td>
  2038.                                     </tr>
  2039.                                 </form>
  2040.                             </table>
  2041.                         </TD>
  2042.                     </TR>
  2043.                 </TABLE>';
  2044.             } elseif($_REQUEST['add_rank'] == "yes") {
  2045.             $new_rank = new GuildRank();
  2046.             $new_rank->setGuild($guild);
  2047.             $new_rank->setLevel(1);
  2048.             $new_rank->setName($rank_name);
  2049.             $new_rank->save();
  2050.            
  2051.             $main_content .= '             
  2052.                 <div class="TableContainer" >
  2053.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  2054.                         <div class="CaptionContainer" >
  2055.                             <div class="CaptionInnerContainer" >
  2056.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2057.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2058.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2059.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2060.                                 <div class="Text" >Guild Rank</div>
  2061.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2062.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2063.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2064.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2065.                             </div>
  2066.                         </div>
  2067.                         <tr>
  2068.                             <td><div class="InnerTableContainer" >
  2069.                                     <table style="width:100%;" >
  2070.                                         <tr>
  2071.                                             <td>The rank was added to Guild.</td>
  2072.                                         </tr>
  2073.                                     </table>
  2074.                                 </div>
  2075.                             </td>
  2076.                         </tr>
  2077.                     </table>
  2078.                 </div><BR>
  2079.                 <TABLE BORDER=0 WIDTH=100%>
  2080.                     <TR>
  2081.                         <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  2082.                                 <form action="?subtopic=guilds&action=view" method="post" >
  2083.                                     <tr>
  2084.                                         <td style="border:0px;" >
  2085.                                             <input type="hidden" name=action value=view >
  2086.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2087.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2088.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2089.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2090.                                                 </div>
  2091.                                             </div>
  2092.                                         </td>
  2093.                                     </tr>
  2094.                                 </form>
  2095.                             </table>
  2096.                         </TD>
  2097.                     </TR>
  2098.                 </TABLE>';
  2099.         } else {
  2100.             $main_content .= '
  2101.                 To change the name of a rank, simply edit name in the corresponding field and confirm the change by clicking on "Submit".<BR>
  2102.                 <BR>
  2103.                 <div class="TableContainer" >
  2104.                     <table class="Table5" cellpadding="0" cellspacing="0" >
  2105.                         <div class="CaptionContainer" >
  2106.                             <div class="CaptionInnerContainer" >
  2107.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2108.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2109.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2110.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  2111.                                 <div class="Text" >Edit Guild Ranks</div>
  2112.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2113.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2114.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2115.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2116.                             </div>
  2117.                         </div>
  2118.                         <tr>
  2119.                             <td>
  2120.                                 <div class="InnerTableContainer" >
  2121.                                     <table style="width:100%;" >
  2122.                                         <tr>
  2123.                                             <td>
  2124.                                                 <div class="TableShadowContainerRightTop" >
  2125.                                                     <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);" ></div>
  2126.                                                 </div>
  2127.                                                 <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);" >
  2128.                                                     <div class="TableContentContainer" >
  2129.                                                         <table class="TableContent" width="100%" >
  2130.                                                             <TR>
  2131.                                                                 <TD BGCOLOR=#D4C0A1>
  2132.                                                                     <TABLE BORDER=0 CELLPADDING=2>
  2133.                                                                         <FORM ACTION="?subtopic=guilds" METHOD=post>
  2134.                                                                             <TR>
  2135.                                                                                 <TD>Set&nbsp;rank&nbsp;name</TD>
  2136.                                                                                 <TD>
  2137.                                                                                     <SELECT NAME="ranktorename">';
  2138.                                                                                 $rank_number = 0;
  2139.                                                                                 foreach($rank_list as $rank) {
  2140.                                                                                     $rank_number++;
  2141.                                                                                     $main_content .= '
  2142.                                                                                         <OPTION VALUE="'.$rank->getID().'">'.$rank_number.': '.$rank->getName().'</OPTION>';
  2143.                                                                                 }
  2144.                                                                                 $main_content .= '
  2145.                                                                                     </SELECT>
  2146.                                                                                 </TD>
  2147.                                                                                 <TD>to:</TD>
  2148.                                                                                 <TD><INPUT NAME="newrankname" VALUE="'.$_REQUEST['newrankname'].'" SIZE=30 MAXLENGTH=29></TD>
  2149.                                                                                 <TD WIDTH=100% ALIGN=right>
  2150.                                                                                     <table border="0" cellspacing="0" cellpadding="0" >
  2151.                                                                                         <tr>
  2152.                                                                                             <td style="border:0px;" >
  2153.                                                                                                 <input type="hidden" name=action value=ranks >
  2154.                                                                                                 <input type="hidden" name="changerankname" value="yes">
  2155.                                                                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2156.                                                                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2157.                                                                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" >
  2158.                                                                                                         <div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2159.                                                                                                         <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  2160.                                                                                                     </div>
  2161.                                                                                                 </div>
  2162.                                                                                             </td>                                                                  
  2163.                                                                                         <tr>
  2164.                                                                                     </table>
  2165.                                                                                 </TD>
  2166.                                                                             </TR>
  2167.                                                                         </FORM>
  2168.                                                                     </TABLE>
  2169.                                                                 </TD>
  2170.                                                             </TR>
  2171.                                                         </table>
  2172.                                                     </div>
  2173.                                                 </div>
  2174.                                                 <div class="TableShadowContainer" >
  2175.                                                     <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bm.gif);" >
  2176.                                                         <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bl.gif);" ></div>
  2177.                                                         <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-br.gif);" ></div>
  2178.                                                     </div>
  2179.                                                 </div>
  2180.                                             </td>
  2181.                                         </tr>
  2182.                                     </table>
  2183.                                 </div>
  2184.                             </td>
  2185.                         </tr>
  2186.                     </table>
  2187.                 </div>
  2188.                 <BR>
  2189.                 <div class="TableContainer" >
  2190.                     <table class="Table5" cellpadding="0" cellspacing="0" >
  2191.                         <div class="CaptionContainer" >
  2192.                             <div class="CaptionInnerContainer" >
  2193.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2194.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2195.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2196.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2197.                                 <div class="Text" >Add new rank</div>
  2198.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2199.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2200.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2201.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2202.                             </div>
  2203.                         </div>
  2204.                         <tr>
  2205.                             <td>
  2206.                                 <div class="InnerTableContainer" >
  2207.                                     <table style="width:100%;" >
  2208.                                         <tr>
  2209.                                             <td>
  2210.                                                 <div class="TableShadowContainerRightTop" >
  2211.                                                     <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);" ></div>
  2212.                                                 </div>
  2213.                                                 <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);" >
  2214.                                                     <div class="TableContentContainer" >
  2215.                                                         <table class="TableContent" width="100%">
  2216.                                                             <TR>
  2217.                                                                 <TD BGCOLOR=#D4C0A1>
  2218.                                                                 <FORM ACTION="?subtopic=guilds" METHOD=post>
  2219.                                                                     <TABLE BORDER=0 CELLPADDING=3>
  2220.                                                                         <tr>
  2221.                                                                             <td valign="middle">New rank name:</td>
  2222.                                                                             <td valign="middle">                                                                               
  2223.                                                                                 <input type="text" name="rank_name" size="50" value="'.$_REQUEST['rank_name'].'">                                                                              
  2224.                                                                             </td>
  2225.                                                                             <td valign="middle">
  2226.                                                                                     <input type="hidden" name=action value=ranks >
  2227.                                                                                     <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2228.                                                                                     <input type="hidden" name="add_rank" value="yes">
  2229.                                                                                     <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2230.                                                                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" >
  2231.                                                                                             <div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2232.                                                                                             <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  2233.                                                                                         </div>
  2234.                                                                                     </div>
  2235.                                                                                 </FORM>
  2236.                                                                             </td>
  2237.                                                                         </tr>
  2238.                                                                     </TABLE>
  2239.                                                                 </TD>
  2240.                                                             </TR>
  2241.                                                         </table>
  2242.                                                     </div>
  2243.                                                 </div>
  2244.                                                 <div class="TableShadowContainer" >
  2245.                                                     <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bm.gif);" >
  2246.                                                         <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-bl.gif);" ></div>
  2247.                                                         <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-br.gif);" ></div>
  2248.                                                     </div>
  2249.                                                 </div>
  2250.                                             </td>
  2251.                                         </tr>
  2252.                                     </table>
  2253.                                 </div>
  2254.                             </table>
  2255.                         </div>
  2256.                     </td>
  2257.                 </tr>
  2258.                 <br>
  2259.                 <TABLE BORDER=0 WIDTH=100%>
  2260.                     <TR>
  2261.                         <TD ALIGN=center>
  2262.                             <table border="0" cellspacing="0" cellpadding="0" >
  2263.                                 <form action="?subtopic=guilds&action=view" method="post" >
  2264.                                     <tr>
  2265.                                         <td style="border:0px;" >
  2266.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2267.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2268.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2269.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2270.                                                 </div>
  2271.                                             </div>
  2272.                                         </td>
  2273.                                     </tr>
  2274.                                 </form>
  2275.                             </table>
  2276.                         </TD>
  2277.                     </TR>
  2278.                 </TABLE>';
  2279.         }
  2280.     }
  2281. }
  2282.  
  2283. #organize ranks
  2284.  
  2285. if($action == "members") {
  2286.    
  2287.     #infos
  2288.     $guild_name = (string) $_REQUEST['GuildName'];
  2289.     $player_name = $_REQUEST['character'];
  2290.     $new_rank = (int) $_REQUEST['newrank'];
  2291.     $newtitle = trim($_REQUEST['newtitle']);
  2292.    
  2293.     if(!$logged)
  2294.         $guild_errors[] = 'You are not logged in. You can\'t change rank.';
  2295.        
  2296.     if(empty($guild_errors)) {
  2297.         $guild = new Guild();
  2298.         $guild->loadByName($guild_name);
  2299.         if(!$guild->isLoaded())
  2300.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  2301.     }
  2302.    
  2303.     if(empty($guild_errors)) {
  2304.         if($_REQUEST['promote'] == "yes")
  2305.             if(!isset($_REQUEST['function']) || $_REQUEST['function'] == "")
  2306.                 $guild_errors[] = 'Select an action.';
  2307.     }
  2308.    
  2309.     if(empty($guild_errors)) {
  2310.         $rank_list = $guild->getGuildRanksList();
  2311.         $guild_leader = FALSE;
  2312.         $guild_vice = FALSE;
  2313.         $account_players = $account_logged->getPlayers();
  2314.         foreach($account_players as $player)
  2315.         {
  2316.             $player_rank = $player->getRank();
  2317.             if(!empty($player_rank))
  2318.                 foreach($rank_list as $rank_in_guild)
  2319.                     if($rank_in_guild->getId() == $player_rank->getId())
  2320.                     {
  2321.                         $players_from_account_in_guild[] = $player->getName();
  2322.                         if($player_rank->getLevel() > 1) {
  2323.                             $guild_vice = TRUE;
  2324.                             $level_in_guild = $player_rank->getLevel();
  2325.                         }
  2326.                         if($guild->getOwner()->getId() == $player->getId()) {
  2327.                             $guild_vice = TRUE;
  2328.                             $guild_leader = TRUE;
  2329.                         }
  2330.                     }
  2331.         }
  2332.        
  2333.         //if(!$guild_vice)
  2334.             //$guild_errors[] = 'You are not leader or vice leader in the Guild.';
  2335.     }
  2336.    
  2337.     if(empty($guild_errors)) {
  2338.         foreach($rank_list as $rank)
  2339.         {
  2340.             if($guild_leader || $rank->getLevel() < $level_in_guild)
  2341.             {
  2342.                 $ranks[$rid]['0'] = $rank->getId();
  2343.                 $ranks[$rid]['1'] = $rank->getName();
  2344.                 $rid++;
  2345.                 $players_with_rank = $rank->getPlayersList();
  2346.                 if(count($players_with_rank) > 0)
  2347.                 {
  2348.                     foreach($players_with_rank as $player)
  2349.                     {
  2350.                         if($guild->getOwner()->getId() != $player->getId() || $guild_leader)
  2351.                         {
  2352.                             $players_with_lower_rank[$sid]['0'] = htmlspecialchars($player->getName());
  2353.                             $players_with_lower_rank[$sid]['1'] = htmlspecialchars($player->getName()).' ('.htmlspecialchars($rank->getName()).')';
  2354.                             $sid++;
  2355.                         }
  2356.                     }
  2357.                 }
  2358.             }
  2359.         }
  2360.        
  2361.         if($_REQUEST['promote'] == 'yes') {
  2362.             $player_to_change = new Player();
  2363.             $player_to_change->find($player_name);
  2364.             if(!$player_to_change->isLoaded())
  2365.                 $guild_errors[] = 'Player with name '.htmlspecialchars($player_name).'</b> doesn\'t exist.';
  2366.         }
  2367.     }
  2368.    
  2369.     if(empty($guild_errors))
  2370.         if($_REQUEST['promote'] == 'yes') {
  2371.             if($_REQUEST['function'] == "setrank") {
  2372.                 $rank = new GuildRank();
  2373.                 $rank->load($new_rank);
  2374.                 if(!$rank->isLoaded())
  2375.                     $guild_errors[] = 'Rank with this ID doesn\'t exist.';
  2376.             }
  2377.             if($_REQUEST['function'] == "settile") {
  2378.                 if(strlen($newtitle) >= 30)
  2379.                     $guild_errors[] = 'Too long guild nick. Max. 30 chars, your: '.strlen($newtitle);
  2380.             }
  2381.             if($_REQUEST['function'] == "exclude") {
  2382.                 if($guild->getOwner()->getName() == $player_to_change->getName())
  2383.                     $guild_errors[] = 'It\'s not exclude guild owner!';
  2384.                
  2385.             }
  2386.         }
  2387.    
  2388.     if(!empty($guild_errors)) {
  2389.         //errors
  2390.         $main_content .= '
  2391.             <div class="TableContainer" >
  2392.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  2393.                     <div class="CaptionContainer" >
  2394.                         <div class="CaptionInnerContainer" >
  2395.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2396.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2397.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2398.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  2399.                             <div class="Text" >Members Errors</div>
  2400.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2401.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2402.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2403.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2404.                         </div>
  2405.                     </div>
  2406.                     <tr>
  2407.                         <td>
  2408.                             <div class="InnerTableContainer" >
  2409.                                 <table style="width:100%;" >
  2410.                                     <tr>
  2411.                                         <td>';
  2412.                                         foreach($guild_errors as $guild_error)
  2413.                                             $main_content .= '<p>'.$guild_error;
  2414.                                     $main_content .= '
  2415.                                         </td>
  2416.                                     </tr>
  2417.                                 </table>
  2418.                             </div>
  2419.                         </td>
  2420.                     </tr>
  2421.                 </table>
  2422.             </div><BR>
  2423.             <TABLE BORDER=0 WIDTH=100%>
  2424.                     <TR>
  2425.                         <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  2426.                                 <form action="?subtopic=guilds&action=view" method="post" >
  2427.                                     <tr>
  2428.                                         <td style="border:0px;" >
  2429.                                             <input type="hidden" name=action value=members >
  2430.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2431.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2432.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2433.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2434.                                                 </div>
  2435.                                             </div>
  2436.                                         </td>
  2437.                                     </tr>
  2438.                                 </form>
  2439.                             </table>
  2440.                         </TD>
  2441.                     </TR>
  2442.                 </TABLE>';
  2443.     } else {
  2444.         if($_REQUEST['promote'] == "yes") {
  2445.             if($_REQUEST['function'] == "setrank") {
  2446.                 $player_to_change->setRank($rank);
  2447.                 $player_to_change->save();
  2448.                 $main_content .= '             
  2449.                     <div class="TableContainer" >
  2450.                         <table class="Table1" cellpadding="0" cellspacing="0" >
  2451.                             <div class="CaptionContainer" >
  2452.                                 <div class="CaptionInnerContainer" >
  2453.                                     <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2454.                                     <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2455.                                     <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2456.                                     <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2457.                                     <div class="Text" >Members</div>
  2458.                                     <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2459.                                     <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2460.                                     <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2461.                                     <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2462.                                 </div>
  2463.                             </div>
  2464.                             <tr>
  2465.                                 <td><div class="InnerTableContainer" >
  2466.                                         <table style="width:100%;" >
  2467.                                             <tr>
  2468.                                                 <td>Rank of player '.htmlspecialchars($player_to_change->getName()).' has been changed to '.htmlspecialchars($rank->getName()).'.</td>
  2469.                                             </tr>
  2470.                                         </table>
  2471.                                     </div>
  2472.                                 </td>
  2473.                             </tr>
  2474.                         </table>
  2475.                     </div><BR>
  2476.                     <TABLE BORDER=0 WIDTH=100%>
  2477.                         <TR>
  2478.                             <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  2479.                                     <form action="?subtopic=guilds&action=view" method="post" >
  2480.                                         <tr>
  2481.                                             <td style="border:0px;" >
  2482.                                                 <input type="hidden" name=action value=view >
  2483.                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2484.                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2485.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2486.                                                         <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2487.                                                     </div>
  2488.                                                 </div>
  2489.                                             </td>
  2490.                                         </tr>
  2491.                                     </form>
  2492.                                 </table>
  2493.                             </TD>
  2494.                         </TR>
  2495.                     </TABLE>';
  2496.                 unset($players_with_lower_rank);
  2497.                 unset($ranks);
  2498.                 $rid = 0;
  2499.                 $sid= 0;
  2500.                 foreach($rank_list as $rank)
  2501.                 {
  2502.                     if($guild_leader || $rank->getLevel() < $level_in_guild)
  2503.                     {
  2504.                         $ranks[$rid]['0'] = $rank->getId();
  2505.                         $ranks[$rid]['1'] = $rank->getName();
  2506.                         $rid++;
  2507.                         $players_with_rank = $rank->getPlayersList();
  2508.                         if(count($players_with_rank) > 0)
  2509.                         {
  2510.                             foreach($players_with_rank as $player)
  2511.                             {
  2512.                                 if($guild->getOwner()->getId() != $player->getId() || $guild_leader)
  2513.                                 {
  2514.                                     $players_with_lower_rank[$sid]['0'] = htmlspecialchars($player->getName());
  2515.                                     $players_with_lower_rank[$sid]['1'] = htmlspecialchars($player->getName()).' ('.htmlspecialchars($rank->getName()).')';
  2516.                                     $sid++;
  2517.                                 }
  2518.                             }
  2519.                         }
  2520.                     }
  2521.                 }
  2522.             }
  2523.             if($_REQUEST['function'] == "settitle") {
  2524.                 $player_to_change->setGuildNick($newtitle);
  2525.                 $player_to_change->save();
  2526.                 $main_content .= '             
  2527.                     <div class="TableContainer" >
  2528.                         <table class="Table1" cellpadding="0" cellspacing="0" >
  2529.                             <div class="CaptionContainer" >
  2530.                                 <div class="CaptionInnerContainer" >
  2531.                                     <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2532.                                     <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2533.                                     <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2534.                                     <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2535.                                     <div class="Text" >Members</div>
  2536.                                     <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2537.                                     <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2538.                                     <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2539.                                     <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2540.                                 </div>
  2541.                             </div>
  2542.                             <tr>
  2543.                                 <td><div class="InnerTableContainer" >
  2544.                                         <table style="width:100%;" >
  2545.                                             <tr>
  2546.                                                 <td>Title of player '.htmlspecialchars($player_to_change->getName()).' has been changed.</td>
  2547.                                             </tr>
  2548.                                         </table>
  2549.                                     </div>
  2550.                                 </td>
  2551.                             </tr>
  2552.                         </table>
  2553.                     </div><BR>
  2554.                     <TABLE BORDER=0 WIDTH=100%>
  2555.                         <TR>
  2556.                             <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  2557.                                     <form action="?subtopic=guilds&action=view" method="post" >
  2558.                                         <tr>
  2559.                                             <td style="border:0px;" >
  2560.                                                 <input type="hidden" name=action value=view >
  2561.                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2562.                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2563.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2564.                                                         <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2565.                                                     </div>
  2566.                                                 </div>
  2567.                                             </td>
  2568.                                         </tr>
  2569.                                     </form>
  2570.                                 </table>
  2571.                             </TD>
  2572.                         </TR>
  2573.                     </TABLE>';
  2574.             }
  2575.             if($_REQUEST['function'] == "exclude") {
  2576.                 $player_to_change->setRank();
  2577.                 $player_to_change->save();
  2578.                 $main_content .= '             
  2579.                     <div class="TableContainer" >
  2580.                         <table class="Table1" cellpadding="0" cellspacing="0" >
  2581.                             <div class="CaptionContainer" >
  2582.                                 <div class="CaptionInnerContainer" >
  2583.                                     <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2584.                                     <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2585.                                     <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2586.                                     <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2587.                                     <div class="Text" >Members</div>
  2588.                                     <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2589.                                     <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2590.                                     <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2591.                                     <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2592.                                 </div>
  2593.                             </div>
  2594.                             <tr>
  2595.                                 <td><div class="InnerTableContainer" >
  2596.                                         <table style="width:100%;" >
  2597.                                             <tr>
  2598.                                                 <td>Player with name '.htmlspecialchars($player->getName()).' has been excluded from your guild.</td>
  2599.                                             </tr>
  2600.                                         </table>
  2601.                                     </div>
  2602.                                 </td>
  2603.                             </tr>
  2604.                         </table>
  2605.                     </div><BR>
  2606.                     <TABLE BORDER=0 WIDTH=100%>
  2607.                         <TR>
  2608.                             <TD ALIGN=center>
  2609.                                 <table border="0" cellspacing="0" cellpadding="0" >
  2610.                                     <form action="?subtopic=guilds&action=view" method="post" >
  2611.                                         <tr>
  2612.                                             <td style="border:0px;" >
  2613.                                                 <input type="hidden" name=action value=view >
  2614.                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2615.                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2616.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2617.                                                         <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2618.                                                     </div>
  2619.                                                 </div>
  2620.                                             </td>
  2621.                                         </tr>
  2622.                                     </form>
  2623.                                 </table>
  2624.                             </TD>
  2625.                         </TR>
  2626.                     </TABLE>';
  2627.             }
  2628.         } else {
  2629.             $main_content .= '
  2630.             Select a member and the action you want to perform, then click on "Submit".<BR><BR>
  2631.             <FORM ACTION="?subtopic=guilds" METHOD=post>
  2632.                 <div class="TableContainer" >
  2633.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  2634.                         <div class="CaptionContainer" >
  2635.                             <div class="CaptionInnerContainer" >
  2636.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2637.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2638.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2639.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  2640.                                 <div class="Text" >Edit Members</div>
  2641.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2642.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2643.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2644.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2645.                             </div>
  2646.                         </div>
  2647.                         <tr>
  2648.                             <td>
  2649.                                 <div class="InnerTableContainer" >
  2650.                                     <table style="width:100%;" >
  2651.                                         <TR>
  2652.                                             <TD BGCOLOR=#D4C0A1>
  2653.                                                 <TABLE BORDER=0 CELLPADDING=1>
  2654.                                                     <TR>
  2655.                                                         <TD VALIGN=top>
  2656.                                                             <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>
  2657.                                                                 <TR>
  2658.                                                                     <TD>Name:</TD>
  2659.                                                                     <TD>
  2660.                                                                         <SELECT NAME="character">';
  2661.                                                                     foreach($players_with_lower_rank as $player_to_list)
  2662.                                                                         $main_content .= '
  2663.                                                                             <option value="'.$player_to_list['0'].'">'.$player_to_list['1'].'</option>';
  2664.                                                                     $main_content .= '
  2665.                                                                         </SELECT>
  2666.                                                                     </TD>
  2667.                                                                 </TR>
  2668.                                                             </TABLE>
  2669.                                                         </TD>
  2670.                                                         <TD>&#160;&#160;&#160;</TD>
  2671.                                                         <TD VALIGN=top>
  2672.                                                             <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>
  2673.                                                                 <TR>
  2674.                                                                     <TD>Action:</TD>
  2675.                                                                     <TD><INPUT TYPE=radio NAME="function" VALUE="setrank" '.(($_REQUEST['function'] == "setrank") ? 'checked' : '').'>
  2676.                                                                         Set rank to
  2677.                                                                         <SELECT NAME="newrank">';
  2678.                                                                     foreach($ranks as $rank)
  2679.                                                                         $main_content .= '
  2680.                                                                             <option value="'.htmlspecialchars($rank['0']).'" '.(($_REQUEST['newrank'] == $rank['0'])).'>'.htmlspecialchars($rank['1']).'</option>';
  2681.                                                                     $main_content .= '
  2682.                                                                         </SELECT>
  2683.                                                                     </TD>
  2684.                                                                 </TR>';
  2685.                                                         if($guild_leader) {
  2686.                                                             $main_content .= '
  2687.                                                                 <TR>
  2688.                                                                     <TD></TD>
  2689.                                                                     <TD><INPUT TYPE=radio NAME="function" VALUE="settitle" '.(($_REQUEST['function'] == "settitle") ? 'checked' : '').'>
  2690.                                                                         Set title to
  2691.                                                                         <INPUT NAME="newtitle" SIZE=30 MAXLENGTH=29></TD>
  2692.                                                                 </TR>';
  2693.                                                             $main_content .= '
  2694.                                                                 <TR>
  2695.                                                                     <TD></TD>
  2696.                                                                     <TD><INPUT TYPE=radio NAME="function" VALUE="exclude" '.(($_REQUEST['function'] == "exclude") ? 'checked' : '').'>
  2697.                                                                         Exclude from guild </TD>
  2698.                                                                 </TR>';
  2699.                                                         }
  2700.                                                         $main_content .= '
  2701.                                                             </TABLE>
  2702.                                                         </TD>
  2703.                                                     </TR>
  2704.                                                 </TABLE>
  2705.                                             </TD>
  2706.                                         </TR>
  2707.                                     </table>
  2708.                                 </div>
  2709.                             </td>
  2710.                         </tr>
  2711.                     </table>
  2712.                 </div>
  2713.             <BR>
  2714.             <TABLE BORDER=0 WIDTH=100%>
  2715.                 <TR align="center">
  2716.                     <TD ALIGN=center>
  2717.                         <table border="0" cellspacing="0" cellpadding="0" >
  2718.                             <tr>
  2719.                                 <td style="border:0px;" >
  2720.                                     <input type="hidden" name=action value=members >
  2721.                                     <input type="hidden" name="promote" value="yes">
  2722.                                     <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2723.                                     <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2724.                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2725.                                             <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  2726.                                         </div>
  2727.                                     </div>
  2728.                                 </td>          
  2729.                             <tr>
  2730.                         </table>
  2731.                     </TD>
  2732.                     </FORM>
  2733.                     <TD ALIGN=center>
  2734.                         <table border="0" cellspacing="0" cellpadding="0" >
  2735.                             <form action="?subtopic=guilds&action=view" method="post" >
  2736.                                 <tr>
  2737.                                     <td style="border:0px;" >
  2738.                                         <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2739.                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2740.                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2741.                                                 <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2742.                                             </div>
  2743.                                         </div>
  2744.                                     </td>
  2745.                                 </tr>
  2746.                             </form>
  2747.                         </table>
  2748.                     </TD>
  2749.                 </TR>
  2750.             </TABLE>';
  2751.         }
  2752.     }
  2753.    
  2754.    
  2755.    
  2756. } #members condition
  2757.  
  2758. if($action == "disband") {
  2759.     $guild_name = (string) $_REQUEST['GuildName'];
  2760.     $password = (string) trim($_REQUEST['password']);
  2761.     if(!$logged)
  2762.         $guild_errors[] = 'You are not logged in. You can\'t disband this Guild.';
  2763.     if(empty($guild_errors)) {
  2764.         $guild = new Guild();
  2765.         $guild->loadByName($guild_name);
  2766.         if(!$guild->isLoaded())
  2767.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  2768.     }
  2769.     if(empty($guild_errors)) {
  2770.         $guild_leader_char = $guild->getOwner();
  2771.             $rank_list = $guild->getGuildRanksList();
  2772.             $guild_leader = FALSE;
  2773.             $account_players = $account_logged->getPlayers();
  2774.             foreach($account_players as $player)
  2775.                 if($guild->getOwner()->getId() == $player->getId())
  2776.                 {
  2777.                     $guild_vice = TRUE;
  2778.                     $guild_leader = TRUE;
  2779.                     $level_in_guild = 3;
  2780.                 }
  2781.                 if(!$guild_leader)
  2782.                     $guild_errors[] = 'You are not leader of Guild.';
  2783.     }
  2784.     if(empty($guild_errors)) {
  2785.         if($_REQUEST['disband'] == "yes")
  2786.             if(!$account_logged->isValidPassword($password))
  2787.                 $guild_errors[] = 'Wrong password.';
  2788.     }
  2789.     if(!empty($guild_errors)) {
  2790.         //errors
  2791.         $main_content .= '
  2792.             <div class="TableContainer" >
  2793.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  2794.                     <div class="CaptionContainer" >
  2795.                         <div class="CaptionInnerContainer" >
  2796.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2797.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2798.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2799.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  2800.                             <div class="Text" >Error</div>
  2801.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2802.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2803.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2804.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2805.                         </div>
  2806.                     </div>
  2807.                     <tr>
  2808.                         <td>
  2809.                             <div class="InnerTableContainer" >
  2810.                                 <table style="width:100%;" >
  2811.                                     <tr>
  2812.                                         <td>';
  2813.                                         foreach($guild_errors as $guild_error)
  2814.                                             $main_content .= '<p>'.$guild_error;
  2815.                                     $main_content .= '
  2816.                                         </td>
  2817.                                     </tr>
  2818.                                 </table>
  2819.                             </div>
  2820.                         </td>
  2821.                     </tr>
  2822.                 </table>
  2823.             </div><BR>
  2824.             <TABLE BORDER=0 WIDTH=100%>
  2825.                         <TR>
  2826.                             <TD ALIGN=center>
  2827.                                 <table border="0" cellspacing="0" cellpadding="0" >
  2828.                                     <form action="?subtopic=guilds" method="post" >
  2829.                                         <input type="hidden" name="action" value="disband">
  2830.                                         <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  2831.                                         <tr>
  2832.                                             <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2833.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2834.                                                         <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2835.                                                     </div>
  2836.                                                 </div>
  2837.                                             </td>
  2838.                                         </tr>
  2839.                                     </form>
  2840.                                 </table>
  2841.                             </TD>
  2842.                         </TR>
  2843.                     </TABLE>';
  2844.     } else {
  2845.             if($_REQUEST['disband'] == "yes") {
  2846.                 $guild->delete();
  2847.                 $main_content .= '
  2848.                     <div class="TableContainer" >
  2849.                         <table class="Table1" cellpadding="0" cellspacing="0" >
  2850.                             <div class="CaptionContainer" >
  2851.                                 <div class="CaptionInnerContainer" >
  2852.                                     <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2853.                                     <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2854.                                     <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2855.                                     <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  2856.                                     <div class="Text" >Guild Disbanded</div>
  2857.                                     <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2858.                                     <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2859.                                     <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2860.                                     <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2861.                                 </div>
  2862.                             </div>
  2863.                             <tr>
  2864.                                 <td>
  2865.                                     <div class="InnerTableContainer" >
  2866.                                         <table style="width:100%;" >
  2867.                                             <tr>
  2868.                                                 <td>You have disbanded the '.$_REQUEST['GuildName'].'.</td>
  2869.                                             </tr>
  2870.                                         </table>
  2871.                                     </div>
  2872.                                 </td>
  2873.                             </tr>
  2874.                         </table>
  2875.                     </div><BR>
  2876.                     <TABLE BORDER=0 WIDTH=100%>
  2877.                         <TR>
  2878.                             <TD ALIGN=center>
  2879.                                 <table border="0" cellspacing="0" cellpadding="0" >
  2880.                                     <form action="?subtopic=guilds" method="post" >
  2881.                                         <tr>
  2882.                                             <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2883.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2884.                                                         <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2885.                                                     </div>
  2886.                                                 </div>
  2887.                                             </td>
  2888.                                         </tr>
  2889.                                     </form>
  2890.                                 </table>
  2891.                             </TD>
  2892.                         </TR>
  2893.                     </TABLE>';
  2894.             } else {
  2895.                 $main_content .= '
  2896.                     Do you really want to disband your guild? Confirm this decision with your password and click on "Submit".<BR>
  2897.                     <BR>
  2898.                     <FORM ACTION="?subtopic=guilds" METHOD=post>
  2899.                         <div class="TableContainer" >
  2900.                             <table class="Table1" cellpadding="0" cellspacing="0" >
  2901.                                 <div class="CaptionContainer" >
  2902.                                     <div class="CaptionInnerContainer" >
  2903.                                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2904.                                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2905.                                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2906.                                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  2907.                                         <div class="Text" >Disband Guild</div>
  2908.                                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  2909.                                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  2910.                                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2911.                                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  2912.                                     </div>
  2913.                                 </div>
  2914.                                 <tr>
  2915.                                     <td>
  2916.                                         <div class="InnerTableContainer" >
  2917.                                             <table style="width:100%;" >
  2918.                                                 <TR>
  2919.                                                     <TD BGCOLOR=#D4C0A1><TABLE BORDER=0 CELLPADDING=1>
  2920.                                                             <TR>
  2921.                                                                 <TD>Password:</TD>
  2922.                                                                 <TD><INPUT TYPE=password NAME="password" SIZE=30 MAXLENGTH=29></TD>
  2923.                                                             </TR>
  2924.                                                         </TABLE>
  2925.                                                     </TD>
  2926.                                                 </TR>
  2927.                                             </table>
  2928.                                         </div>
  2929.                                     </td>
  2930.                                 </tr>
  2931.                             </table>
  2932.                         </div>
  2933.                         <BR>
  2934.                         <TABLE BORDER=0 WIDTH=100%>
  2935.                             <TR>
  2936.                                 <TD ALIGN=center><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR></TD>
  2937.                                 <TD ALIGN=center><table border="0" cellspacing="0" cellpadding="0" >
  2938.                                     <tr>
  2939.                                         <td style="border:0px;" >
  2940.                                             <input type="hidden" name=action value=disband>
  2941.                                             <input type="hidden" name="disband" value="yes">
  2942.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2943.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2944.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2945.                                                     <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  2946.                                                 </div>
  2947.                                             </div>
  2948.                                         </td>                  
  2949.                                     <tr>
  2950.                                 </form>
  2951.                             </table>
  2952.                         </TD>
  2953.                         <TD ALIGN=center>
  2954.                             <table border="0" cellspacing="0" cellpadding="0" >
  2955.                                 <form action="?subtopic=guilds&action=view" method="post" >
  2956.                                     <tr>
  2957.                                         <td style="border:0px;" >
  2958.                                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  2959.                                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  2960.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" >
  2961.                                                     <div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  2962.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  2963.                                                 </div>
  2964.                                             </div>
  2965.                                         </td>
  2966.                                     </tr>
  2967.                                 </form>
  2968.                             </table>
  2969.                         </TD>
  2970.                         <TD ALIGN=center><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR></TD>
  2971.                     </TR>
  2972.                 </TABLE>';
  2973.             }
  2974.     }
  2975. }
  2976. if($action == "description") {
  2977.     $guild_name = (string) $_REQUEST['GuildName'];
  2978.     if(empty($guild_errors))
  2979.     {
  2980.         $guild = new Guild();
  2981.         $guild->loadByName($guild_name);
  2982.         if(!$guild->isLoaded())
  2983.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  2984.     }
  2985.     if(empty($guild_errors)) {
  2986.         $guild_leader_char = $guild->getOwner();
  2987.         $rank_list = $guild->getGuildRanksList();
  2988.         $guild_leader = FALSE;
  2989.         $account_players = $account_logged->getPlayers();
  2990.         foreach($account_players as $player)
  2991.             if($guild->getOwner()->getId() == $player->getId()) {
  2992.                 $guild_vice = TRUE;
  2993.                 $guild_leader = TRUE;
  2994.                 $level_in_guild = 3;
  2995.             }
  2996.         if(!$guild_leader)
  2997.             $guild_errors[] = 'You are not the Guild Leader.';
  2998.     }
  2999.     if(empty($guild_errors)) {
  3000.         $max_image_size_b = $config['site']['guild_image_size_kb'] * 1024;
  3001.         if($_REQUEST['guildlogo'] == "yes") {          
  3002.             $file = $_FILES['newlogo'];
  3003.         if(is_uploaded_file($file['tmp_name']))
  3004.             switch($file['error']) {
  3005.                 case UPLOAD_ERR_OK:
  3006.                     break; // all ok
  3007.                 case UPLOAD_ERR_INI_SIZE:
  3008.                 case UPLOAD_ERR_FORM_SIZE:
  3009.                     $guild_errors[] = 'Image is too large';
  3010.                     break;
  3011.                 case UPLOAD_ERR_PARTIAL:
  3012.                     $guild_errors[] = 'Image was only partially uploaded';
  3013.                     break;
  3014.                 case UPLOAD_ERR_NO_TMP_DIR:
  3015.                     $guild_errors[] = 'Upload folder not found';
  3016.                     break;
  3017.                 case UPLOAD_ERR_CANT_WRITE:
  3018.                     $guild_errors[] = 'Unable to write uploaded file';
  3019.                     break;
  3020.                 case UPLOAD_ERR_EXTENSION:
  3021.                     $guild_errors[] =  'Upload failed due to extension';
  3022.                     break;
  3023.                 default:
  3024.                     $guild_errors[] =  'Unknown error';
  3025.             }
  3026.             if(is_uploaded_file($file['tmp_name'])) {
  3027.                 if($file['size'] > $max_image_size_b)
  3028.                     $guild_errors[] = 'Uploaded image is too big. Size: <b>'.$file['size'].' bytes</b>, Max. size: <b>'.$max_image_size_b.' bytes</b>.';
  3029.                 $info = getimagesize($file['tmp_name']);
  3030.                 if(!$info)
  3031.                     $guild_errors[] = 'Uploaded file is not an image!';
  3032.             }
  3033.         }
  3034.     }
  3035.     if(!empty($guild_errors)) {
  3036.         if($_REQUEST['changedescription'] == "yes") {
  3037.             //errors
  3038.             $main_content .= '
  3039.                 <div class="TableContainer" >
  3040.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  3041.                         <div class="CaptionContainer" >
  3042.                             <div class="CaptionInnerContainer" >
  3043.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3044.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3045.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3046.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  3047.                                 <div class="Text" >Guild Description Error</div>
  3048.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3049.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3050.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3051.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3052.                             </div>
  3053.                         </div>
  3054.                         <tr>
  3055.                             <td>
  3056.                                 <div class="InnerTableContainer" >
  3057.                                     <table style="width:100%;" >
  3058.                                         <tr>
  3059.                                             <td>';
  3060.                                             foreach($guild_errors as $guild_error)
  3061.                                                 $main_content .= '<p>'.$guild_error;
  3062.                                         $main_content .= '
  3063.                                             </td>
  3064.                                         </tr>
  3065.                                     </table>
  3066.                                 </div>
  3067.                             </td>
  3068.                         </tr>
  3069.                     </table>
  3070.                 </div><BR>
  3071.                 <TABLE BORDER=0 WIDTH=100%>
  3072.                     <TR>
  3073.                         <TD ALIGN=center>
  3074.                             <table border="0" cellspacing="0" cellpadding="0" >
  3075.                                 <form action="?subtopic=guilds" method="post" >
  3076.                                     <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  3077.                                     <tr>
  3078.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3079.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3080.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3081.                                                 </div>
  3082.                                             </div>
  3083.                                         </td>
  3084.                                     </tr>
  3085.                                 </form>
  3086.                             </table>
  3087.                         </TD>
  3088.                     </TR>
  3089.                 </TABLE>';
  3090.         }
  3091.         if($_REQUEST['guildlogo'] == "yes") {
  3092.             //errors
  3093.             $main_content .= '
  3094.                 <div class="TableContainer" >
  3095.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  3096.                         <div class="CaptionContainer" >
  3097.                             <div class="CaptionInnerContainer" >
  3098.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3099.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3100.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3101.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  3102.                                 <div class="Text" >Guild Logo Error</div>
  3103.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3104.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3105.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3106.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3107.                             </div>
  3108.                         </div>
  3109.                         <tr>
  3110.                             <td>
  3111.                                 <div class="InnerTableContainer" >
  3112.                                     <table style="width:100%;" >
  3113.                                         <tr>
  3114.                                             <td>';
  3115.                                             foreach($guild_errors as $guild_error)
  3116.                                                 $main_content .= '<p>'.$guild_error;
  3117.                                         $main_content .= '
  3118.                                             </td>
  3119.                                         </tr>
  3120.                                     </table>
  3121.                                 </div>
  3122.                             </td>
  3123.                         </tr>
  3124.                     </table>
  3125.                 </div><BR>
  3126.                 <TABLE BORDER=0 WIDTH=100%>
  3127.                     <TR>
  3128.                         <TD ALIGN=center>
  3129.                             <table border="0" cellspacing="0" cellpadding="0" >
  3130.                                 <form action="?subtopic=guilds" method="post" >
  3131.                                     <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  3132.                                     <tr>
  3133.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3134.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3135.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3136.                                                 </div>
  3137.                                             </div>
  3138.                                         </td>
  3139.                                     </tr>
  3140.                                 </form>
  3141.                             </table>
  3142.                         </TD>
  3143.                     </TR>
  3144.                 </TABLE>';
  3145.         }
  3146.     } else {
  3147.         if($_REQUEST['changedescription'] == "yes") {
  3148.             $description = htmlspecialchars(substr(trim($_REQUEST['description']),0,$config['site']['guild_description_chars_limit']));
  3149.             $guild->set('description', $description);
  3150.             $guild->save();
  3151.             $main_content .= '
  3152.                 <div class="TableContainer" >
  3153.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  3154.                         <div class="CaptionContainer" >
  3155.                             <div class="CaptionInnerContainer" >
  3156.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3157.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3158.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3159.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  3160.                                 <div class="Text" >Guild Description Changed</div>
  3161.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3162.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3163.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3164.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3165.                             </div>
  3166.                         </div>
  3167.                         <tr>
  3168.                             <td>
  3169.                                 <div class="InnerTableContainer" >
  3170.                                     <table style="width:100%;" >
  3171.                                         <tr>
  3172.                                             <td>Your Guild Description was changed succefully.</td>
  3173.                                         </tr>
  3174.                                     </table>
  3175.                                 </div>
  3176.                             </td>
  3177.                         </tr>
  3178.                     </table>
  3179.                 </div><BR>
  3180.                 <TABLE BORDER=0 WIDTH=100%>
  3181.                     <TR>
  3182.                         <TD ALIGN=center>
  3183.                             <table border="0" cellspacing="0" cellpadding="0" >
  3184.                                 <form action="?subtopic=guilds" method="post" >
  3185.                                     <input type="hidden" name="action" value="view">
  3186.                                     <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  3187.                                     <tr>
  3188.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3189.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3190.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3191.                                                 </div>
  3192.                                             </div>
  3193.                                         </td>
  3194.                                     </tr>
  3195.                                 </form>
  3196.                             </table>
  3197.                         </TD>
  3198.                     </TR>
  3199.                 </TABLE>';
  3200.         }
  3201.         elseif($_REQUEST['guildlogo'] == "yes") {
  3202.             if(!is_uploaded_file($file['tmp_name'])) {
  3203.                 $guild->setGuildLogo('image/gif', Website::getFileContents('./images/default_guild_logo.gif'));
  3204.                 $guild->save();
  3205.             } else {
  3206.                 $guild->setGuildLogo($info['mime'], file_get_contents($file['tmp_name']));
  3207.                 $guild->save();
  3208.             }
  3209.             $main_content .= '
  3210.                 <div class="TableContainer" >
  3211.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  3212.                         <div class="CaptionContainer" >
  3213.                             <div class="CaptionInnerContainer" >
  3214.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3215.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3216.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3217.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  3218.                                 <div class="Text" >Guild Logo Changed</div>
  3219.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3220.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3221.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3222.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3223.                             </div>
  3224.                         </div>
  3225.                         <tr>
  3226.                             <td>
  3227.                                 <div class="InnerTableContainer" >
  3228.                                     <table style="width:100%;" >
  3229.                                         <tr>
  3230.                                             <td>Your Guild Logo was changed succefully.</td>
  3231.                                         </tr>
  3232.                                     </table>
  3233.                                 </div>
  3234.                             </td>
  3235.                         </tr>
  3236.                     </table>
  3237.                 </div><BR>
  3238.                 <TABLE BORDER=0 WIDTH=100%>
  3239.                     <TR>
  3240.                         <TD ALIGN=center>
  3241.                             <table border="0" cellspacing="0" cellpadding="0" >
  3242.                                 <form action="?subtopic=guilds" method="post" >
  3243.                                     <input type="hidden" name="action" value="view">
  3244.                                     <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  3245.                                     <tr>
  3246.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3247.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3248.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3249.                                                 </div>
  3250.                                             </div>
  3251.                                         </td>
  3252.                                     </tr>
  3253.                                 </form>
  3254.                             </table>
  3255.                         </TD>
  3256.                     </TR>
  3257.                 </TABLE>';
  3258.         }
  3259.         else {
  3260.                 $main_content .= 'If you want to change the description or the URL of the official homepage of your guild, edit the corresponding field and click on the "Submit" button.<BR><BR>';
  3261.     //formulario com as ações
  3262.     $main_content .= '
  3263.         <FORM ACTION="?subtopic=guilds" METHOD=post>
  3264.             <div class="TableContainer" >
  3265.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  3266.                     <div class="CaptionContainer" >
  3267.                         <div class="CaptionInnerContainer" >
  3268.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3269.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3270.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3271.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  3272.                             <div class="Text" >Change Description</div>
  3273.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3274.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3275.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3276.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3277.                         </div>
  3278.                     </div>
  3279.                     <tr>
  3280.                         <td>
  3281.                             <div class="InnerTableContainer" >
  3282.                                 <table style="width:100%;" >
  3283.                                     <tr>
  3284.                                         <td valign="top">Description:</td>
  3285.                                         <td><textarea name="description" cols="60" rows="15">'.$guild->getDescription().'</textarea></td>
  3286.                                         <td align="right" valign="bottom">
  3287.                                             <table border="0" cellspacing="0" cellpadding="0" >
  3288.                                                 <tr>
  3289.                                                     <td style="border:0px;" >
  3290.                                                         <input type="hidden" name="changedescription" value="yes">
  3291.                                                         <input type="hidden" name="action" value="description">
  3292.                                                         <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3293.                                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3294.                                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3295.                                                                 <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  3296.                                                             </div>
  3297.                                                         </div>
  3298.                                                     </td>
  3299.                                                 </tr>
  3300.                                                 </form>
  3301.                                             </table>
  3302.                                         </td>
  3303.                                     </tr>
  3304.                                 </table>
  3305.                             </div>
  3306.                         </td>
  3307.                     </tr>
  3308.                 </table>
  3309.             </div><BR>
  3310.             If you want to change the logo of your guild, enter the path to a 64*64 pixels GIF icon and click on the "Submit" button.<BR>Leave the path empty if you want to use the default logo.<BR><BR>
  3311.             <FORM ACTION="?subtopic=guilds" METHOD=post enctype="multipart/form-data">
  3312.             <div class="TableContainer" >
  3313.                 <table class="Table1" cellpadding="0" cellspacing="0" >
  3314.                     <div class="CaptionContainer" >
  3315.                         <div class="CaptionInnerContainer" >
  3316.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3317.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3318.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3319.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  3320.                             <div class="Text" >Guild Logo</div>
  3321.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3322.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3323.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3324.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3325.                         </div>
  3326.                     </div>
  3327.                     <tr>
  3328.                         <td>
  3329.                             <div class="InnerTableContainer" >
  3330.                                 <table style="width:100%;" >
  3331.                                     <tr>
  3332.                                         <td valign="top">Current logo:</td>
  3333.                                         <td><IMG SRC="'. $guild->getGuildLogoLink() .'" WIDTH=64 HEIGHT=64></td>
  3334.                                         <td></td>
  3335.                                     </tr>
  3336.                                     <tr>
  3337.                                         <td valign="top">New logo:</td>
  3338.                                         <td><input type="file" name="newlogo"></td>
  3339.                                         <td align="right">
  3340.                                             <table border="0" cellspacing="0" cellpadding="0" >
  3341.                                                 <tr>
  3342.                                                     <td style="border:0px;" >
  3343.                                                         <input type="hidden" name="guildlogo" value="yes">
  3344.                                                         <input type="hidden" name="action" value="description">
  3345.                                                         <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3346.                                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3347.                                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3348.                                                                 <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  3349.                                                             </div>
  3350.                                                         </div>
  3351.                                                     </td>
  3352.                                                 </tr>
  3353.                                                 </form>
  3354.                                             </table>
  3355.                                         </td>
  3356.                                     </tr>
  3357.                                 </table>
  3358.                             </div>
  3359.                         </td>
  3360.                     </tr>
  3361.                 </table>
  3362.             </div><BR>
  3363.             <TABLE BORDER=0 WIDTH=100%>
  3364.                 <TR align="center">
  3365.                     <TD ALIGN=center>
  3366.                         <table border="0" cellspacing="0" cellpadding="0" >
  3367.                             <form action="?subtopic=guilds&action=view" method="post" >
  3368.                                 <tr>
  3369.                                     <td style="border:0px;" >
  3370.                                         <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3371.                                         <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3372.                                             <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3373.                                                 <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3374.                                             </div>
  3375.                                         </div>
  3376.                                     </td>
  3377.                                 </tr>
  3378.                             </form>
  3379.                         </table>
  3380.                     </TD>
  3381.                 </TR>
  3382.             </TABLE>';
  3383.         }
  3384.     }
  3385. }
  3386. if($action == "resignleadership") {
  3387.     $guild_name = (string) $_REQUEST['GuildName'];
  3388.     $pass_to = (string) $_REQUEST['character'];
  3389.     $password = trim($_REQUEST['password']);
  3390.     if(empty($guild_errors))
  3391.     {
  3392.         $guild = new Guild();
  3393.         $guild->loadByName($guild_name);
  3394.         if(!$guild->isLoaded())
  3395.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  3396.     }
  3397.     if(empty($guild_errors))
  3398.     {
  3399.         if($_POST['resign'] == 'yes')
  3400.         {
  3401.             if(!$account_logged->isValidPassword($password))
  3402.                 $guild_errors[] = 'Password is wrong.';
  3403.             if(!check_name($pass_to))
  3404.                 $guild_errors[] = 'Invalid player name format.';
  3405.             if(empty($guild_errors))
  3406.             {
  3407.                 $to_player = new Player();
  3408.                 $to_player->find($pass_to);
  3409.                 if(!$to_player->isLoaded())
  3410.                     $guild_errors[] = 'Player with name <b>'.htmlspecialchars($pass_to).'</b> doesn\'t exist.';
  3411.                 if(empty($guild_errors))
  3412.                 {
  3413.                     $to_player_rank = $to_player->getRank();
  3414.                     if(!empty($to_player_rank))
  3415.                     {
  3416.                         $to_player_guild = $to_player_rank->getGuild();
  3417.                         if($to_player_guild->getId() != $guild->getId())
  3418.                             $guild_errors[] = 'Player with name <b>'.htmlspecialchars($to_player->getName()).'</b> isn\'t from your guild.';
  3419.                     }
  3420.                     else
  3421.                         $guild_errors[] = 'Player with name <b>'.htmlspecialchars($to_player->getName()).'</b> isn\'t from your guild.';
  3422.                 }
  3423.             }
  3424.         }
  3425.     }
  3426.     if(empty($guild_errors)) {
  3427.         if($logged) {
  3428.             $guild_leader_char = $guild->getOwner();
  3429.             $guild_leader = FALSE;
  3430.             $account_players = $account_logged->getPlayers();
  3431.             foreach($account_players as $player)
  3432.                 if($guild_leader_char->getId() == $player->getId()) {
  3433.                     $guild_vice = TRUE;
  3434.                     $guild_leader = TRUE;
  3435.                     $level_in_guild = 3;
  3436.                 }
  3437.             if($guild_leader) {
  3438.                 if($_POST['resign'] == 'yes') {
  3439.                     $newleaderID = $to_player->getID();
  3440.                     $oldleaderID = $guild_leader_char->getId();
  3441.                     $newrank = $guild_leader_char->getRank()->getID();
  3442.                     $oldrank = $to_player_rank->getID();
  3443.                     $up = filter_var($up, FILTER_SANITIZE_STRING);
  3444.                     $up = $SQL->query("UPDATE `guild_membership` SET `rank_id` = '$newrank' WHERE `player_id` = '$newleaderID'");
  3445.                     if($up)
  3446.                         $up2 = filter_var($up2, FILTER_SANITIZE_STRING);
  3447.                         $up2 = $SQL->query("UPDATE `guild_membership` SET `rank_id` = '$oldrank' WHERE `player_id` = '$oldleaderID'");
  3448.                     if($up2) {
  3449.                         $guild->setOwner($to_player);
  3450.                         $guild->save();
  3451.                     }
  3452.                     $saved = TRUE;
  3453.                    
  3454.                     $main_content .= '
  3455.                         <div class="TableContainer" >
  3456.                             <table class="Table1" cellpadding="0" cellspacing="0" >
  3457.                                 <div class="CaptionContainer" >
  3458.                                     <div class="CaptionInnerContainer" >
  3459.                                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3460.                                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3461.                                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3462.                                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  3463.                                         <div class="Text" >New Guild Leadership</div>
  3464.                                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3465.                                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3466.                                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3467.                                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3468.                                     </div>
  3469.                                 </div>
  3470.                                 <tr>
  3471.                                     <td>
  3472.                                         <div class="InnerTableContainer" >
  3473.                                             <table style="width:100%;" >
  3474.                                                 <tr>
  3475.                                                     <td>The new leader is '.$to_player->getName().'.</td>
  3476.                                                 </tr>
  3477.                                             </table>
  3478.                                         </div>
  3479.                                     </td>
  3480.                                 </tr>
  3481.                             </table>
  3482.                         </div><BR>
  3483.                         <TABLE BORDER=0 WIDTH=100%>
  3484.                             <TR>
  3485.                                 <TD ALIGN=center>
  3486.                                     <table border="0" cellspacing="0" cellpadding="0" >
  3487.                                         <form action="?subtopic=guilds" method="post" >
  3488.                                             <input type="hidden" name="action" value="view">
  3489.                                             <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  3490.                                             <tr>
  3491.                                                 <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3492.                                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3493.                                                             <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3494.                                                         </div>
  3495.                                                     </div>
  3496.                                                 </td>
  3497.                                             </tr>
  3498.                                         </form>
  3499.                                     </table>
  3500.                                 </TD>
  3501.                             </TR>
  3502.                         </TABLE>';
  3503.                 } else {
  3504.                     //formulario com as ações
  3505.                     $main_content .= '
  3506.                         Select a member to your new Guild Leader and click "Submit" button.<BR><BR>
  3507.                         <FORM ACTION="?subtopic=guilds" METHOD=post>
  3508.                             <div class="TableContainer" >
  3509.                                 <table class="Table1" cellpadding="0" cellspacing="0" >
  3510.                                     <div class="CaptionContainer" >
  3511.                                         <div class="CaptionInnerContainer" >
  3512.                                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3513.                                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3514.                                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3515.                                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                               
  3516.                                             <div class="Text" >Resign Leadership</div>
  3517.                                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3518.                                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3519.                                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3520.                                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3521.                                         </div>
  3522.                                     </div>
  3523.                                     <tr>
  3524.                                         <td>
  3525.                                             <div class="InnerTableContainer" >
  3526.                                                 <table style="width:100%;" >
  3527.                                                     <TR>
  3528.                                                         <TD BGCOLOR=#D4C0A1>
  3529.                                                             <TABLE BORDER=0 CELLPADDING=1>
  3530.                                                                 <TR>
  3531.                                                                     <TD>
  3532.                                                                         <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>
  3533.                                                                             <TR>
  3534.                                                                                 <TD>Resign Leadership to:</TD>
  3535.                                                                             </TR>
  3536.                                                                         </TABLE>
  3537.                                                                     </TD>
  3538.                                                                     <TD>&#160;&#160;&#160;</TD>
  3539.                                                                     <TD>
  3540.                                                                         <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>
  3541.                                                                             <TR>
  3542.                                                                                 <TD align="right" valign="top">
  3543.                                                                                     <SELECT NAME="character">';
  3544.                                                                                 $rank_list = $guild->getGuildRanksList();
  3545.                                                                                 foreach($rank_list as $rank) {
  3546.                                                                                     $players_with_rank = $rank->getPlayersList();
  3547.                                                                                     foreach($players_with_rank as $player) {
  3548.                                                                                         if($guild_leader_char->getName() != $player->getName()) {
  3549.                                                                                             $main_content .= '<OPTION>' . $player->getName() . '</OPTION>';
  3550.                                                                                         }
  3551.                                                                                     }
  3552.                                                                                 }
  3553.                                                                                 $main_content .='                                                                                  
  3554.                                                                                     </SELECT>
  3555.                                                                                 </TD>
  3556.                                                                             </TR>
  3557.                                                                         </TABLE>
  3558.                                                                     </TD>
  3559.                                                                 </TR>
  3560.                                                             </TABLE>
  3561.                                                         </TD>
  3562.                                                     </TR>
  3563.                                                     <TR>
  3564.                                                         <TD>
  3565.                                                             <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>
  3566.                                                                 <TR>
  3567.                                                                     <TD>Password:</TD>
  3568.                                                                     <TD><input type="password" name="password"></TD>
  3569.                                                                 </TR>
  3570.                                                             </TABLE>                                                   
  3571.                                                         </TD>
  3572.                                                     </TR>
  3573.                                                 </table>
  3574.                                             </div>
  3575.                                         </td>
  3576.                                     </tr>
  3577.                                 </table>
  3578.                             </div>
  3579.                         <BR>
  3580.                         <TABLE BORDER=0 WIDTH=100%>
  3581.                             <TR align="center">
  3582.                                 <TD ALIGN=center>
  3583.                                     <table border="0" cellspacing="0" cellpadding="0" >
  3584.                                         <tr>
  3585.                                             <td style="border:0px;" >
  3586.                                                 <input type="hidden" name=action value=resignleadership >
  3587.                                                 <input type="hidden" name="resign" value="yes">
  3588.                                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3589.                                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3590.                                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3591.                                                         <input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/global/buttons/_sbutton_submit.gif" >
  3592.                                                     </div>
  3593.                                                 </div>
  3594.                                             </td>          
  3595.                                         <tr>
  3596.                                     </table>
  3597.                                 </TD>
  3598.                                 </FORM>
  3599.                                 <TD ALIGN=center>
  3600.                                     <table border="0" cellspacing="0" cellpadding="0" >
  3601.                                         <form action="?subtopic=guilds&action=view" method="post" >
  3602.                                             <tr>
  3603.                                                 <td style="border:0px;" >
  3604.                                                     <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3605.                                                     <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3606.                                                         <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3607.                                                             <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3608.                                                         </div>
  3609.                                                     </div>
  3610.                                                 </td>
  3611.                                             </tr>
  3612.                                         </form>
  3613.                                     </table>
  3614.                                 </TD>
  3615.                             </TR>
  3616.                         </TABLE>';
  3617.                 }
  3618.             }
  3619.             else
  3620.                 $guild_errors[] = 'You are not a leader of guild!';
  3621.         }
  3622.         else
  3623.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  3624.     }
  3625.     if(!empty($guild_errors)) {
  3626.         //errors
  3627.             $main_content .= '
  3628.                 <div class="TableContainer" >
  3629.                     <table class="Table1" cellpadding="0" cellspacing="0" >
  3630.                         <div class="CaptionContainer" >
  3631.                             <div class="CaptionInnerContainer" >
  3632.                                 <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3633.                                 <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3634.                                 <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3635.                                 <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                           
  3636.                                 <div class="Text" >Guild Leadership Error</div>
  3637.                                 <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3638.                                 <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3639.                                 <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3640.                                 <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3641.                             </div>
  3642.                         </div>
  3643.                         <tr>
  3644.                             <td>
  3645.                                 <div class="InnerTableContainer" >
  3646.                                     <table style="width:100%;" >
  3647.                                         <tr>
  3648.                                             <td>';
  3649.                                             foreach($guild_errors as $guild_error)
  3650.                                                 $main_content .= '<p>'.$guild_error;
  3651.                                         $main_content .= '
  3652.                                             </td>
  3653.                                         </tr>
  3654.                                     </table>
  3655.                                 </div>
  3656.                             </td>
  3657.                         </tr>
  3658.                     </table>
  3659.                 </div><BR>
  3660.                 <TABLE BORDER=0 WIDTH=100%>
  3661.                     <TR>
  3662.                         <TD ALIGN=center>
  3663.                             <table border="0" cellspacing="0" cellpadding="0" >
  3664.                                 <form action="?subtopic=guilds" method="post" >
  3665.                                     <input type="hidden" name="action" value="view">
  3666.                                     <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  3667.                                     <tr>
  3668.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3669.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3670.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3671.                                                 </div>
  3672.                                             </div>
  3673.                                         </td>
  3674.                                     </tr>
  3675.                                 </form>
  3676.                             </table>
  3677.                         </TD>
  3678.                     </TR>
  3679.                 </TABLE>';
  3680.     }
  3681. }
  3682. if($action == "guildwars") {
  3683.    
  3684.     # Guild wars status
  3685.     # 1 - War Started
  3686.     # 2 - War Rejected
  3687.     # 3 - War Canceled
  3688.    
  3689.    
  3690.     $guild_name = (string) $_REQUEST['GuildName'];
  3691.     $guild = new Guild();
  3692.     $guild->loadByName($guild_name);
  3693.     if(!$guild->isLoaded())
  3694.         $guild_errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
  3695.    
  3696.     $guild_id = $guild->getID();
  3697.     if(empty($guild_errors)) {
  3698.         //check is it vice or/and leader account (leader has vice + leader rights)
  3699.         $guild_leader_char = $guild->getOwner();
  3700.         $rank_list = $guild->getGuildRanksList();
  3701.         $guild_leader = FALSE;
  3702.         $guild_vice = FALSE;
  3703.         if($logged)
  3704.         {
  3705.             $account_players = $account_logged->getPlayers();
  3706.             foreach($account_players as $player)
  3707.             {
  3708.                 $players_from_account_ids[] = $player->getId();
  3709.                 $player_rank = $player->getRank();
  3710.                 if(!empty($player_rank))
  3711.                     foreach($rank_list as $rank_in_guild)
  3712.                         if($rank_in_guild->getId() == $player_rank->getId())
  3713.                         {
  3714.                             $players_from_account_in_guild[] = $player->getName();
  3715.                             if($player_rank->getLevel() > 1)
  3716.                             {
  3717.                                 $guild_vice = TRUE;
  3718.                                 $level_in_guild = $player_rank->getLevel();
  3719.                             }
  3720.                             if($guild->getOwner()->getId() == $player->getId())
  3721.                             {
  3722.                                 $guild_vice = TRUE;
  3723.                                 $guild_leader = TRUE;
  3724.                             }
  3725.                         }
  3726.             }
  3727.         }
  3728.     }
  3729.     if($guild_leader)
  3730.         $main_content .= '
  3731.             <center>
  3732.                 <table border="0" cellspacing="0" cellpadding="0" >
  3733.                     <form action="?subtopic=guilds" method="post" >
  3734.                         <tr>
  3735.                             <td style="border:0px;" >
  3736.                                 <input type="hidden" name=action value=declarewar >
  3737.                                 <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3738.                                 <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3739.                                     <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3740.                                         <input class="ButtonText" type="image" name="Declare War" alt="Declare War" src="'.$layout_name.'/images/global/buttons/_sbutton_declarewar.gif" >
  3741.                                     </div>
  3742.                                 </div>
  3743.                             </td>
  3744.                         </tr>
  3745.                     </form>
  3746.                 </table>
  3747.             </center>
  3748.             <br/>';
  3749.             /*
  3750.         $main_content .= '
  3751.             <div class="TableContainer" >
  3752.                 <table class="Table5" cellpadding="0" cellspacing="0" >
  3753.                     <div class="CaptionContainer" >
  3754.                         <div class="CaptionInnerContainer" >
  3755.                             <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3756.                             <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3757.                             <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3758.                             <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  3759.                             <div class="Text" >Declarations of War</div>
  3760.                             <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3761.                             <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3762.                             <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3763.                             <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3764.                         </div>
  3765.                     </div>
  3766.                     <tr>
  3767.                         <td><div class="InnerTableContainer" >
  3768.                                 <table style="width:100%;" >
  3769.                                     <tr>
  3770.                                         <td>The guild Lino Lucky has currently no open war declarations.</td>
  3771.                                     </tr>
  3772.                                 </table>
  3773.                             </div>
  3774.                         </td>
  3775.                     </tr>
  3776.                 </table>
  3777.             </div>
  3778.             <br/>';
  3779.             */
  3780.             $main_content .= "<script type=\"text/javascript\"><!--
  3781.         function show_hide(flip)
  3782.         {
  3783.                 var tmp = document.getElementById(flip);
  3784.                 if(tmp)
  3785.                         tmp.style.display = tmp.style.display == 'none' ? '' : 'none';
  3786.         }
  3787.         --></script>";
  3788.     $main_content .= '
  3789.         <div class="TableContainer" >
  3790.             <table class="Table5" cellpadding="0" cellspacing="0" >
  3791.                 <div class="CaptionContainer" >
  3792.                     <div class="CaptionInnerContainer" >
  3793.                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3794.                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3795.                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3796.                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  3797.                         <div class="Text" >Guild Wars</div>
  3798.                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3799.                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3800.                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3801.                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3802.                     </div>
  3803.                 </div>
  3804.                 <tr>
  3805.                     <td>
  3806.                         <div class="InnerTableContainer" >
  3807.                             <table style="width:100%;" >';
  3808.                             $main_content .= '
  3809.                                 <tr>
  3810.                                     <td>
  3811.                                         <div class="TableShadowContainerRightTop" >
  3812.                                                 <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);" ></div>
  3813.                                             </div>
  3814.                                             <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);" >
  3815.                                                 <div class="TableContentContainer" >
  3816.                                                     <table class="TableContent" width="100%" >
  3817.                                                         <tr class="LabelV">
  3818.                                                             <td>Aggressor</td>
  3819.                                                             <td>Information</td>
  3820.                                                             <td>Enemy</td>
  3821.                                                         </tr>';
  3822.                                                         $warFrags = array();
  3823.                                                         foreach($SQL->query('SELECT * FROM `guildwar_kills` WHERE `killerguild` = ' . $guild_id . ' OR `targetguild` = ' . $guild_id . ' ORDER BY `time` DESC')->fetchAll() as $frag)
  3824.                                                         {
  3825.                                                             $warFrags[$frag['warid']][] = $frag;
  3826.                                                         }
  3827.                                                
  3828.                                                         $count = 0;
  3829.                                                         foreach($SQL->query('SELECT `guild_wars`.`id`, `guild_wars`.`guild1`, `guild_wars`.`guild2`, `guild_wars`.`name1`, `guild_wars`.`name2`, `guild_wars`.`status`, `guild_wars`.`started`, `guild_wars`.`ended`, (SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild1`) guild1_kills, (SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild2`) guild2_kills FROM `guild_wars` WHERE `guild1` = ' . $guild_id . ' OR `guild2` = ' . $guild_id . ' ORDER BY CASE `status` WHEN 0 THEN 2 WHEN 1 THEN 1 WHEN 4 THEN 3 WHEN 3 THEN 4 WHEN 2 THEN 5 END, `started` DESC') as $war)
  3830.                                                         {
  3831.                                                             $count++;
  3832.                                                             $main_content .= "<tr style=\"background: " . (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']) . ";\">
  3833.                                                         <td align=\"center\"><a href=\"?subtopic=guilds&action=view&GuildName=".$war['name1']."\"><img src=\"guild_image.php?id=" . $war['guild1'] . "\" width=\"64\" height=\"64\" border=\"0\"/><br />".htmlspecialchars($war['name1'])."</a></td>
  3834.                                                         <td align=\"center\">";
  3835.                                                             switch($war['status'])
  3836.                                                             {
  3837.                                                                 case 0:
  3838.                                                                 {
  3839.                                                                     $main_content .= "<b>Pending acceptation</b><br />Invited on " . date("M d Y, H:i:s", $war['started']) . " for " . (($war['ended'] - $war['started']) / 3600) . " hours war.<br />";
  3840.                                                                     if($guild_leader && $war['guild2'] == $guild->getID())
  3841.                                                                     {
  3842.                                                                         $main_content .= '<br /><a href="?subtopic=guilds&action=guildwar_accept&GuildName=' . $guild_name . '&war=' . $war['id'] . '" onclick="return confirm(\'Are you sure that you want ACCEPT that invitation for 2 hours war?\');" style="cursor: pointer;">accept invitation to war</a>';
  3843.                                                                         $main_content .= '<br /><br /><a href="?subtopic=guilds&action=guildwar_reject&GuildName=' . $guild_name . '&war=' . $war['id'] . '" onclick="return confirm(\'Are you sure that you want REJECT that invitation for 2 hours war?\');" style="cursor: pointer;">reject invitation to war</a>';
  3844.                                                                     }
  3845.                                                                     if($guild_leader && $war['guild1'] == $guild->getID())
  3846.                                                                     {
  3847.                                                                         $main_content .= '<br /><br /><a href="?subtopic=guilds&action=guildwar_cancel&GuildName=' . $guild_name . '&war=' . $war['id'] . '" onclick="return confirm(\'Are you sure that you want CANCEL that invitation for 2 hours war?\');" style="cursor: pointer;">cancel invitation to war</a>';
  3848.                                                                     }
  3849.                                                                     $main_content .= '</font>';
  3850.                                                                     break;
  3851.                                                                 }
  3852.                                                                 case 1:
  3853.                                                                 {
  3854.                                                                     $main_content .= "<font size=\"12\"><span style=\"color: red;\">" . $war['guild1_kills'] . "</span><font color=black> : </font><span style=\"color: lime;\">" . $war['guild2_kills'] . "</span></font><br /><br /><span style=\"color: darkred; font-weight: bold;\">On a brutal war</span><br /><font color=black>Began on " . date("M d Y, H:i:s", $war['started']) . ", will end up after server restart after " . date("M d Y, H:i:s", $war['started'] + (2*3600)) . ".<br /></font>";
  3855.                                                                     $main_content .= "<br /><br />";
  3856.                                                                     if(in_array($war['status'], array(1,4)))
  3857.                                                                     {
  3858.                                                                         $main_content .= "<a onclick=\"show_hide('war-details:" . $war['id'] . "'); return false;\" style=\"cursor: pointer;\">War Details</a>";
  3859.                                                                     }
  3860.                                                                     break;
  3861.                                                                 }
  3862.                                                                 case 2:
  3863.                                                                 {
  3864.                                                                     $main_content .= "<b>Rejected invitation</b><br />Invited on " . date("M d Y, H:i:s", $war['started']) . ", rejected on " . date("M d Y, H:i:s", $war['ended']) . ".</font>";
  3865.                                                                     break;
  3866.                                                                 }
  3867.                                                                 case 3:
  3868.                                                                 {
  3869.                                                                     $main_content .= "<b>Canceled invitation</b><br />Sent invite on " . date("M d Y, H:i:s", $war['started']) . ", canceled on " . date("M d Y, H:i:s", $war['ended']) . ".</font>";
  3870.                                                                     break;
  3871.                                                                 }
  3872.                                                                 case 4:
  3873.                                                                 {
  3874.                                                                     $main_content .= "<b><i>Ended</i></b><br />Began on " . date("M d Y, H:i:s", $war['started']) . ", ended on " . date("M d Y, H:i:s", $war['ended']) . ". Frag statistics: <span style=\"color: red;\">" . $war['guild1_kills'] . "</span> to <span style=\"color: lime;\">" . $war['guild2_kills'] . "</span>.";
  3875.                                                                     $main_content .= "<br /><br />";
  3876.                                                                     if(in_array($war['status'], array(1,4)))
  3877.                                                                     {
  3878.                                                                         $main_content .= "<a onclick=\"show_hide('war-details:" . $war['id'] . "'); return false;\" style=\"cursor: pointer;\">&raquo; Details &laquo;</a>";
  3879.                                                                     }
  3880.                                                                     $main_content .= "</font>";
  3881.                                                                     break;
  3882.                                                                 }
  3883.                                                                 default:
  3884.                                                                 {
  3885.                                                                     $main_content .= "Unknown, please contact with gamemaster.";
  3886.                                                                     break;
  3887.                                                                 }
  3888.                                                             }
  3889.                                                             $main_content .= "</td>
  3890.                                                         <td align=\"center\"><a href=\"?subtopic=guilds&action=view&GuildName=".$war['name2']."\"><img src=\"guild_image.php?id=" . $war['guild2'] . "\" width=\"64\" height=\"64\" border=\"0\"/><br />".htmlspecialchars($war['name2'])."</a></td>
  3891.                                                         </tr>
  3892.                                                         <tr id=\"war-details:" . $war['id'] . "\" style=\"display: none; background: " . (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']) . ";\">
  3893.                                                         <td colspan=\"3\">";
  3894.                                                             if(in_array($war['status'], array(1,4)))
  3895.                                                             {
  3896.                                                                 if(isset($warFrags[$war['id']]))
  3897.                                                                 {
  3898.                                                                     foreach($warFrags[$war['id']] as $frag)
  3899.                                                                     {
  3900.                                                                         $main_content .= date("j M Y, H:i", $frag['time']) . " <span style=\"font-weight: bold; color: " . ($frag['killerguild'] == $war['guild1'] ? "red" :"lime") . ";\">+</span><a href=\"?subtopic=characters&name=" . urlencode($frag['killer']) . "\"><b>".htmlspecialchars($frag['killer'])."</b></a> killed <a href=\"?subtopic=characters&name=".urlencode($frag['target'])."\"> " . htmlspecialchars($frag['target']) . "</a>";
  3901.                                                                     }
  3902.                                                                 }
  3903.                                                                 else
  3904.                                                                     $main_content .= "<center>There were no frags on this war so far.</center>";
  3905.                                                             }
  3906.                                                             else
  3907.                                                                 $main_content .= "</td></tr>";
  3908.                                                         }
  3909.                                                 $main_content .= '
  3910.                                                     </table>
  3911.                                                 </div>
  3912.                                             </div>
  3913.                                         </div>
  3914.                                     </td>
  3915.                                 </tr>';
  3916.                         if($count == 0)
  3917.                             $main_content .= "
  3918.                                 <tr>
  3919.                                     <td>The guild ".$guild_name." is currently not involved in a guild war.</td>
  3920.                                 </tr>";
  3921.                         $main_content .= '
  3922.                             </table>
  3923.                         </div>
  3924.                     </td>
  3925.                 </tr>
  3926.             </table>
  3927.         </div>
  3928.         <br/>';
  3929.         /*
  3930.     $main_content .= '
  3931.         <div class="TableContainer" >
  3932.             <table class="Table5" cellpadding="0" cellspacing="0" >
  3933.                 <div class="CaptionContainer" >
  3934.                     <div class="CaptionInnerContainer" >
  3935.                         <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3936.                         <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3937.                         <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3938.                         <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>                       
  3939.                         <div class="Text" >Guild War History</div>
  3940.                         <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>
  3941.                         <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>
  3942.                         <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3943.                         <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>
  3944.                     </div>
  3945.                 </div>
  3946.                 <tr>
  3947.                     <td>
  3948.                         <div class="InnerTableContainer">
  3949.                             <table style="width:100%;">
  3950.                                 <tr>
  3951.                                     <td>The guild Lino Lucky has never participated in a guild war.</td>
  3952.                                 </tr>
  3953.                             </table>
  3954.                         </div>
  3955.                     </td>
  3956.                 </tr>
  3957.             </table>
  3958.         </div>
  3959.         <br/>';
  3960.         */
  3961.     $main_content .= '
  3962.         <center>
  3963.             <table border="0" cellspacing="0" cellpadding="0" >
  3964.                 <form action="?subtopic=guilds&action=view" method="post" >
  3965.                     <tr>
  3966.                         <td style="border:0px;" >
  3967.                             <input type="hidden" name=GuildName value="'.$_REQUEST['GuildName'].'" >
  3968.                             <div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  3969.                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  3970.                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  3971.                                 </div>
  3972.                             </div>
  3973.                         </td>
  3974.                     </tr>
  3975.                 </form>
  3976.             </table>
  3977.         </center>
  3978.         ';
  3979. }
  3980. if($action == 'declarewar')
  3981. {
  3982.     $guild_name = (string) $_REQUEST['GuildName'];
  3983.     if(!$logged)
  3984.         $guild_errors[] = 'You are not logged.';
  3985.     if(empty($guild_errors))
  3986.     {
  3987.         $guild = new Guild();
  3988.         $guild->loadByName($guild_name);
  3989.         if(!$guild->isLoaded())
  3990.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  3991.         if(empty($guild_errors))
  3992.         {
  3993.             $guild_leader_char = $guild->getOwner();
  3994.             $guild_leader = FALSE;
  3995.             $account_players = $account_logged->getPlayers();
  3996.             foreach($account_players as $player)
  3997.             {
  3998.                 if($guild_leader_char->getId() == $player->getId())
  3999.                 {
  4000.                     $guild_leader = TRUE;
  4001.                 }
  4002.             }
  4003.             if($guild_leader)
  4004.             {
  4005.                 $currentWars = array();
  4006.                 $wars = new DatabaseList('GuildWar');
  4007.                 foreach($wars as $war)
  4008.                 {
  4009.                     if($war->getStatus() == GuildWar::STATE_INVITED || $war->getStatus() == GuildWar::STATE_ON_WAR)
  4010.                     {
  4011.                         if($war->getGuild1ID() == $guild->getID())
  4012.                             $currentWars[$war->getGuild2ID()] = $war->getStatus();
  4013.                         elseif($war->getGuild2ID() == $guild->getID())
  4014.                             $currentWars[$war->getGuild1ID()] = $war->getStatus();
  4015.                     }
  4016.                 }
  4017.  
  4018.                 $main_content .= '<center><h1>' . htmlspecialchars($guild->getName()) . ' vs. ???</h2></center><br /><h3>Choose your enemy!</h3><br /><table width="100%" border="0" cellspacing="1" cellpadding="4">';
  4019.  
  4020.                 $guildsList = new DatabaseList('Guild');
  4021.                 $guildsList->addOrder(new SQL_Order(new SQL_Field('name'), SQL_Order::ASC));
  4022.                 $shown_guilds = 0;
  4023.                 foreach($guildsList as $enemyGuild)
  4024.                 {
  4025.                     if(is_int($shown_guilds / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $shown_guilds++;
  4026.                     $main_content .= '<tr BGCOLOR="'.$bgcolor.'"><td width="70px"><IMG SRC="guild_image.php?id='. $enemyGuild->getID() .'" WIDTH="64" HEIGHT="64"></td><td valign="top"><B>'.htmlspecialchars($enemyGuild->getName()).'</B></td><td>';
  4027.                     if($enemyGuild->getID() != $guild->getID())
  4028.                     {
  4029.                         if(isset($currentWars[$enemyGuild->getID()]))
  4030.                         {
  4031.                             // in war or invited
  4032.                             if($currentWars[$enemyGuild->getID()] == GuildWar::STATE_INVITED)
  4033.                             {
  4034.                                 // guild already invited you or you invited that guild
  4035.                                 $main_content .= 'There is already invitation between your and this guild.';
  4036.                             }
  4037.                             else
  4038.                             {
  4039.                                 // you are on war with this guild
  4040.                                 $main_content .= 'There is already war between your and this guild.';
  4041.                             }
  4042.                         }
  4043.                         else
  4044.                         {
  4045.                             // can invite
  4046.                             $main_content .= '<a href="?subtopic=guilds&action=guildwar_invite&GuildName=' . urlencode($guild->getName()) . '&enemy=' . $enemyGuild->getID() . '" onclick="return confirm(\'Are you sure that you want invite that guild?\')">INVITE FOR WAR</a>';
  4047.                         }
  4048.                     }
  4049.                     else
  4050.                     {
  4051.                         // your own guild
  4052.                         $main_content .= 'YOUR GUILD';
  4053.                     }
  4054.                     $main_content .= '</td></tr>';
  4055.                 }
  4056.                 $main_content .= '</table>';
  4057.             }
  4058.             else
  4059.                 $guild_errors[] = 'You are not a leader of guild!';
  4060.         }
  4061.     }
  4062.     if(!empty($guild_errors))
  4063.     {
  4064.         $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/global/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/global/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
  4065.         foreach($guild_errors as $guild_error)
  4066.             $main_content .= '<li>'.$guild_error.'</li>';
  4067.         $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/global/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>  </div></div><br>';
  4068.         $main_content .= '<br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4069.     }
  4070. }
  4071. if($action == 'guildwar_invite')
  4072. {
  4073.     $guild_name = (string) $_REQUEST['GuildName'];
  4074.     $enemy_id = (int) $_REQUEST['enemy'];
  4075.     if(!$logged)
  4076.         $guild_errors[] = 'You are not logged.';
  4077.     if(empty($guild_errors))
  4078.     {
  4079.         $guild = new Guild();
  4080.         $guild->loadByName($guild_name);
  4081.         $enemyGuild = new Guild($enemy_id);
  4082.         if(!$guild->isLoaded() || !$enemyGuild->isLoaded())
  4083.             $guild_errors[] = 'Guild <b>'.$guild_id.'</b> or <b>'.$enemy_id.'</b> doesn\'t exist.';
  4084.         if(empty($guild_errors))
  4085.         {
  4086.             $guild_leader_char = $guild->getOwner();
  4087.             $guild_leader = FALSE;
  4088.             $account_players = $account_logged->getPlayers();
  4089.             foreach($account_players as $player)
  4090.             {
  4091.                 if($guild_leader_char->getId() == $player->getId())
  4092.                 {
  4093.                     $guild_leader = TRUE;
  4094.                 }
  4095.             }
  4096.             if($guild_leader)
  4097.             {
  4098.                 if($enemyGuild->getID() != $guild->getID())
  4099.                 {
  4100.                     $currentWars = array();
  4101.                     $wars = new DatabaseList('GuildWar');
  4102.                     foreach($wars as $war)
  4103.                     {
  4104.                         if($war->getStatus() == GuildWar::STATE_INVITED || $war->getStatus() == GuildWar::STATE_ON_WAR)
  4105.                         {
  4106.                             if($war->getGuild1ID() == $guild->getID())
  4107.                                 $currentWars[$war->getGuild2ID()] = $war->getStatus();
  4108.                             elseif($war->getGuild2ID() == $guild->getID())
  4109.                                 $currentWars[$war->getGuild1ID()] = $war->getStatus();
  4110.                         }
  4111.                     }
  4112.                     if(isset($currentWars[$enemyGuild->getID()]))
  4113.                     {
  4114.                         // in war or invited
  4115.                         if($currentWars[$enemyGuild->getID()] == GuildWar::STATE_INVITED)
  4116.                         {
  4117.                             // guild already invited you or you invited that guild
  4118.                             $guild_errors[] = 'There is already invitation between your and this guild.';
  4119.                         }
  4120.                         else
  4121.                         {
  4122.                             // you are on war with this guild
  4123.                             $guild_errors[] = 'There is already war between your and this guild.';
  4124.                         }
  4125.                     }
  4126.                     else
  4127.                     {
  4128.                         // can invite
  4129.                         $war = new GuildWar();
  4130.                         $war->setGuild1ID($guild->getID());
  4131.                         $war->setGuild2ID($enemyGuild->getID());
  4132.                         $war->setGuild1Name($guild->getName());
  4133.                         $war->setGuild2Name($enemyGuild->getName());
  4134.                         $war->setStatus(GuildWar::STATE_INVITED);
  4135.                         $war->setStarted(time());
  4136.                         $war->setEnded(0);
  4137.                         $war->save();
  4138.                         header("Location: ?subtopic=guilds&action=view&GuildName=".urlencode($guild_name)."");
  4139.                         $main_content .= 'War invitation sent. Redirecting...';
  4140.                     }
  4141.                 }
  4142.                 else
  4143.                 {
  4144.                     $guild_errors[] = 'You cannot invite same guild!';
  4145.                 }
  4146.             }
  4147.             else
  4148.                 $guild_errors[] = 'You are not a leader of guild!';
  4149.         }
  4150.     }
  4151.     if(!empty($guild_errors))
  4152.     {
  4153.         $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
  4154.         foreach($guild_errors as $guild_error)
  4155.             $main_content .= '<li>'.$guild_error.'</li>';
  4156.         $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br>';
  4157.         $main_content .= '<br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4158.     }
  4159. }
  4160. if($action == 'guildwar_cancel')
  4161. {
  4162.     $guild_name = (string) $_REQUEST['GuildName'];
  4163.     $war_id = (int) $_REQUEST['war'];
  4164.     if(!$logged)
  4165.         $guild_errors[] = 'You are not logged.';
  4166.     if(empty($guild_errors))
  4167.     {
  4168.         $guild = new Guild();
  4169.         $guild->loadByName($guild_name);
  4170.         if(!$guild->isLoaded())
  4171.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  4172.         if(empty($guild_errors))
  4173.         {
  4174.             $guild_leader_char = $guild->getOwner();
  4175.             $guild_leader = FALSE;
  4176.             $account_players = $account_logged->getPlayers();
  4177.             foreach($account_players as $player)
  4178.             {
  4179.                 if($guild_leader_char->getId() == $player->getId())
  4180.                 {
  4181.                     $guild_leader = TRUE;
  4182.                 }
  4183.             }
  4184.             if($guild_leader)
  4185.             {
  4186.                 $war = new GuildWar($war_id);
  4187.                 if(!$war->isLoaded())
  4188.                     $guild_errors[] = 'War with ID <b>'.$war_id.'</b> doesn\'t exist.';
  4189.  
  4190.                 if(empty($guild_errors))
  4191.                 {
  4192.                     if($war->getGuild1ID() != $guild->getID() || $war->getStatus() != GuildWar::STATE_INVITED)
  4193.                     {
  4194.                         $guild_errors[] = 'Your guild did not invite to that war.';
  4195.                     }
  4196.  
  4197.                     if(empty($guild_errors))
  4198.                     {
  4199.                         $war->setStatus(GuildWar::STATE_CANCELED);
  4200.                         $war->setEnded(time());
  4201.                         $war->save();
  4202.                         header("Location: ?subtopic=guilds&action=view&GuildName=".$guild_name."");
  4203.                         $main_content .= 'War invitation rejected. Redirecting...';
  4204.                     }
  4205.                 }
  4206.             }
  4207.             else
  4208.                 $guild_errors[] = 'You are not a leader of guild!';
  4209.         }
  4210.     }
  4211.     if(!empty($guild_errors))
  4212.     {
  4213.         $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
  4214.         foreach($guild_errors as $guild_error)
  4215.             $main_content .= '<li>'.$guild_error.'</li>';
  4216.         $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br>';
  4217.         $main_content .= '<br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4218.     }
  4219. }
  4220. if($action == 'guildwar_reject')
  4221. {
  4222.     $guild_name = (string) $_REQUEST['GuildName'];
  4223.     $war_id = (int) $_REQUEST['war'];
  4224.     if(!$logged)
  4225.         $guild_errors[] = 'You are not logged.';
  4226.     if(empty($guild_errors))
  4227.     {
  4228.         $guild = new Guild();
  4229.         $guild->loadByName($guild_name);
  4230.         if(!$guild->isLoaded())
  4231.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  4232.         if(empty($guild_errors))
  4233.         {
  4234.             $guild_leader_char = $guild->getOwner();
  4235.             $guild_leader = FALSE;
  4236.             $account_players = $account_logged->getPlayers();
  4237.             foreach($account_players as $player)
  4238.             {
  4239.                 if($guild_leader_char->getId() == $player->getId())
  4240.                 {
  4241.                     $guild_leader = TRUE;
  4242.                 }
  4243.             }
  4244.             if($guild_leader)
  4245.             {
  4246.                 $war = new GuildWar($war_id);
  4247.                 if(!$war->isLoaded())
  4248.                     $guild_errors[] = 'War with ID <b>'.$war_id.'</b> doesn\'t exist.';
  4249.  
  4250.                 if(empty($guild_errors))
  4251.                 {
  4252.                     if($war->getGuild2ID() != $guild->getID() || $war->getStatus() != GuildWar::STATE_INVITED)
  4253.                     {
  4254.                         $guild_errors[] = 'Your guild is not invited to that war.';
  4255.                     }
  4256.  
  4257.                     if(empty($guild_errors))
  4258.                     {
  4259.                         $war->setStatus(GuildWar::STATE_REJECTED);
  4260.                         $war->setEnded(time());
  4261.                         $war->save();
  4262.                         header("Location: ?subtopic=guilds&action=view&GuildName=".urlencode($guild_name)."");
  4263.                         $main_content .= 'War invitation rejected. Redirecting...';
  4264.                     }
  4265.                 }
  4266.             }
  4267.             else
  4268.                 $guild_errors[] = 'You are not a leader of guild!';
  4269.         }
  4270.     }
  4271.     if(!empty($guild_errors))
  4272.     {
  4273.         $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
  4274.         foreach($guild_errors as $guild_error)
  4275.             $main_content .= '<li>'.$guild_error.'</li>';
  4276.         $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br>';
  4277.         $main_content .= '<br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4278.     }
  4279. }
  4280. if($action == 'guildwar_accept')
  4281. {
  4282.     $guild_name = (string) $_REQUEST['GuildName'];
  4283.     $war_id = (int) $_REQUEST['war'];
  4284.     if(!$logged)
  4285.         $guild_errors[] = 'You are not logged.';
  4286.     if(empty($guild_errors))
  4287.     {
  4288.         $guild = new Guild();
  4289.         $guild->loadByName($guild_name);
  4290.         if(!$guild->isLoaded())
  4291.             $guild_errors[] = 'Guild <b>'.$guild_name.'</b> doesn\'t exist.';
  4292.         if(empty($guild_errors))
  4293.         {
  4294.             $guild_leader_char = $guild->getOwner();
  4295.             $guild_leader = FALSE;
  4296.             $account_players = $account_logged->getPlayers();
  4297.             foreach($account_players as $player)
  4298.             {
  4299.                 if($guild_leader_char->getId() == $player->getId())
  4300.                 {
  4301.                     $guild_leader = TRUE;
  4302.                 }
  4303.             }
  4304.             if($guild_leader)
  4305.             {
  4306.                 $war = new GuildWar($war_id);
  4307.                 if(!$war->isLoaded())
  4308.                     $guild_errors[] = 'War with ID <b>'.$war_id.'</b> doesn\'t exist.';
  4309.  
  4310.                 if(empty($guild_errors))
  4311.                 {
  4312.                     if($war->getGuild2ID() != $guild->getID() || $war->getStatus() != GuildWar::STATE_INVITED)
  4313.                     {
  4314.                         $guild_errors[] = 'Your guild is not invited to that war.';
  4315.                     }
  4316.  
  4317.                     if(empty($guild_errors))
  4318.                     {
  4319.                         $war->setStatus(GuildWar::STATE_ON_WAR);
  4320.                         $war->setStarted(time());
  4321.                         $war->setEnded(0);
  4322.                         $war->save();
  4323.                         header("Location: ?subtopic=guilds&action=view&GuildName=".urlencode($guild_name)."");
  4324.                         $main_content .= 'War invitation accepted. Redirecting...';
  4325.                     }
  4326.                 }
  4327.             }
  4328.             else
  4329.                 $guild_errors[] = 'You are not a leader of guild!';
  4330.         }
  4331.     }
  4332.     if(!empty($guild_errors))
  4333.     {
  4334.         $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
  4335.         foreach($guild_errors as $guild_error)
  4336.             $main_content .= '<li>'.$guild_error.'</li>';
  4337.         $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br>';
  4338.         $main_content .= '<br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4339.     }
  4340. }
  4341. if($action == "guildevents") {
  4342.     $main_content .= '
  4343.         Page under construction
  4344.         <BR><BR>
  4345.                 <TABLE BORDER=0 WIDTH=100%>
  4346.                     <TR>
  4347.                         <TD ALIGN=center>
  4348.                             <table border="0" cellspacing="0" cellpadding="0" >
  4349.                                 <form action="?subtopic=guilds" method="post" >
  4350.                                     <input type="hidden" name="action" value="view">
  4351.                                     <input type="hidden" name="GuildName" value="'.$_REQUEST['GuildName'].'">
  4352.                                     <tr>
  4353.                                         <td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" >
  4354.                                                 <div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div>
  4355.                                                     <input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" >
  4356.                                                 </div>
  4357.                                             </div>
  4358.                                         </td>
  4359.                                     </tr>
  4360.                                 </form>
  4361.                             </table>
  4362.                         </TD>
  4363.                     </TR>
  4364.                 </TABLE>';
  4365. }
  4366. if($action == 'deletebyadmin')
  4367. {
  4368.     $guild_id = (int) $_REQUEST['guild'];
  4369.     if(empty($guild_errors))
  4370.     {
  4371.         $guild = new Guild();
  4372.         $guild->load($guild_id);
  4373.         if(!$guild->isLoaded())
  4374.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  4375.     }
  4376.     if(empty($guild_errors))
  4377.     {
  4378.         if($logged)
  4379.         {
  4380.             if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  4381.             {
  4382.                 if($_POST['todo'] == 'save')
  4383.                 {
  4384.                     $guild->delete();
  4385.                     $main_content .= '<div class="TableContainer" >  <table class="Table1" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>Guild with ID <b>'.$guild_id.'</b> has been deleted.</td></tr>          </table>        </div>  </table></div></td></tr><br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4386.                 }
  4387.                 else
  4388.                     $main_content .= '<div class="TableContainer" >  <table class="Table1" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>Are you sure you want delete guild <b>'.htmlspecialchars($guild->getName()).'</b>?<br>
  4389.                     <form action="?subtopic=guilds&guild='.$guild_id.'&action=deletebyadmin" METHOD=post><input type="hidden" name="todo" value="save"><input type="submit" value="Yes, delete"></form>
  4390.                     </td></tr>          </table>        </div>  </table></div></td></tr><br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4391.             }
  4392.             else
  4393.                 $guild_errors[] = 'You are not an admin!';
  4394.         }
  4395.         else
  4396.             $guild_errors[] = 'You are not logged. You can\'t delete guild.';
  4397.     }
  4398.     if(!empty($guild_errors))
  4399.     {
  4400.         $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/global/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/global/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
  4401.         foreach($guild_errors as $guild_error)
  4402.             $main_content .= '<li>'.$guild_error.'</li>';
  4403.         $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/global/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);" /></div>  </div></div><br>';
  4404.         $main_content .= '<br/><center><form action="?subtopic=guilds" METHOD=post><div class="BigButton" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/global/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/global/buttons/_sbutton_back.gif" ></div></div></form></center>';
  4405.     }
  4406. }
Add Comment
Please, Sign In to add comment