Guest User

Untitled

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