Guest User

Untitled

a guest
Nov 12th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 155.37 KB | None | 0 0
  1. <?php
  2. if(!defined('INITIALIZED'))
  3.     exit;
  4.  
  5. if($action == 'login')
  6. {
  7.     if(check_guild_name($_REQUEST['guild']))
  8.         $guild = $_REQUEST['guild'];
  9.     if($_REQUEST['redirect'] == 'guild' || $_REQUEST['redirect'] == 'guilds')
  10.         $redirect = $_REQUEST['redirect'];
  11.     if(!$logged)
  12.     {
  13.         $main_content .= 'Please enter your account number and your password.<br/><a href="?subtopic=createaccount" >Create an account</a> if you do not have one yet.<br/><br/><form action="?subtopic=guilds&action=login&guild='.urlencode($guild).'&redirect='.$redirect.'" method="post" ><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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Account Login</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td class="LabelV" ><span >Account Number:</span></td><td style="width:100%;" ><input type="password" name="account_login" SIZE="10" maxlength="10" ></td></tr><tr><td class="LabelV" ><span >Password:</span></td><td><input type="password" name="password_login" size="30" maxlength="29" ></td></tr>          </table>        </div>  </table></div></td></tr><br/><table width="100%" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><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="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=lostaccount" method="post" ><tr><td style="border:0px;" ><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="Account lost?" alt="Account lost?" src="'.$layout_name.'/images/buttons/_sbutton_accountlost.gif" ></div></div></td></tr></form></table></td></tr></table>';
  14.     }
  15.     else
  16.     {
  17.         $main_content .= '<center><h3>Now you are logged. Redirecting...</h3></center>';
  18.         if($redirect == 'guilds')
  19.             header("Location: ?subtopic=guilds");
  20.         elseif($redirect == 'guild')
  21.             header("Location: ?subtopic=guilds&action=show&guild=".urlencode($guild));
  22.         else
  23.             $main_content .= 'Wrong address to redirect!';
  24.     }
  25. }
  26. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  27. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  28. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  29. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  30. //show list of guilds
  31. if($action == '')
  32. {
  33.     if(count($config['site']['worlds']) > 1)
  34.     {
  35.         foreach($config['site']['worlds'] as $idd => $world_n)
  36.         {
  37.             if($idd == (int) $_REQUEST['world'])
  38.             {
  39.                 $world_id = $idd;
  40.                 $world_name = $world_n;
  41.             }
  42.         }
  43.     }
  44.     if(!isset($world_id))
  45.     {
  46.         $world_id = 0;
  47.         $world_name = $config['server']['serverName'];
  48.     }
  49.     if(count($config['site']['worlds']) > 1)
  50.     {
  51.         $main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD></TD><TD>
  52.         <FORM ACTION="" METHOD=get><INPUT TYPE="hidden" NAME="subtopic" VALUE="guilds"><TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>World Selection</B></TD></TR><TR><TD BGCOLOR="'.$config['site']['darkborder'].'">
  53.         <TABLE BORDER=0 CELLPADDING=1><TR><TD>Guilds on world:</TD><TD><SELECT SIZE="1" NAME="world">';
  54.         foreach($config['site']['worlds'] as $id => $world_n)
  55.         {
  56.             if($id == $world_id)
  57.                 $main_content .= '<OPTION VALUE="'.$id.'" selected="selected">'.htmlspecialchars($world_n).'</OPTION>';
  58.             else
  59.                 $main_content .= '<OPTION VALUE="'.$id.'">'.htmlspecialchars($world_n).'</OPTION>';
  60.         }
  61.         $main_content .= '</SELECT> </TD><TD><INPUT TYPE="image" NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif">
  62.             </TD></TR></TABLE></TABLE></FORM></TABLE>';
  63.     }
  64.    
  65.     $guilds_list = new DatabaseList('Guild');
  66.     $filterWorld = new SQL_Filter(new SQL_Field('world_id', 'guilds'), SQL_Filter::EQUAL, $world_id);
  67.     $guilds_list->setFilter($filterWorld);
  68.     $guilds_list->addOrder(new SQL_Order(new SQL_Field('name'), SQL_Order::ASC));
  69.    
  70.     $main_content .= '<h2><center>Guilds on '.htmlspecialchars($world_name).'</center></h2><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
  71.     <TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=3 CLASS=white><B>Guilds on '.htmlspecialchars($world_name).'</B></TD></TR>
  72.     <TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=64><B>Logo</B></TD>
  73.     <TD WIDTH=100%><B>Description</B></TD>
  74.     <TD WIDTH=56><B>&#160;</B></TD></TR>';
  75.     $showed_guilds = 1;
  76.     if(count($guilds_list) > 0)
  77.     {
  78.         foreach($guilds_list as $guild)
  79.         {
  80.             if(is_int($showed_guilds / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_guilds++;
  81.             $description = $guild->getDescription();
  82.             $newlines   = array("\r\n", "\n", "\r");
  83.             $description_with_lines = str_replace($newlines, '<br />', $description, $count);
  84.             if($count < $config['site']['guild_description_lines_limit'])
  85.                 $description = $description_with_lines;
  86.             $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><TD><IMG SRC="'. $guild->getGuildLogoLink() .'" WIDTH=64 HEIGHT=64></TD>
  87.             <TD valign="top"><B>'.htmlspecialchars($guild->getName()).'</B><BR/>'.$description.'';
  88.             if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  89.                 $main_content .= '<br /><a href="?subtopic=guilds&action=deletebyadmin&guild='.$guild->getId().'">Delete this guild (for ADMIN only!)</a>';
  90.             $main_content .= '</TD><TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild->getId().'" METHOD=post><TR><TD>
  91.             <INPUT TYPE=image NAME="View" ALT="View" SRC="'.$layout_name.'/images/buttons/sbutton_view.gif" BORDER=0 WIDTH=120 HEIGHT=18>
  92.             </TD></TR></FORM></TABLE>
  93.             </TD></TR>';
  94.         }
  95.     }
  96.     else
  97.         $main_content .= '<TR BGCOLOR='.$config['site']['lightborder'].'><TD><IMG SRC="images/default_guild_logo.gif" WIDTH=64 HEIGHT=64></TD>
  98.         <TD valign="top"><B>Create guild</B><BR/>Currently there is no guild on server. Create first! Press button "Create Guild".</TD>
  99.         <TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=createguild" METHOD=post><TR><TD>
  100.         <INPUT TYPE=image NAME="Create Guild" ALT="Create Guild" SRC="'.$layout_name.'/images/buttons/sbutton_createguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
  101.         </TD></TR></FORM></TABLE></TD></TR>';
  102.     $main_content .= '</TABLE><br><br>';
  103.     if($logged)
  104.         $main_content .= '<TABLE BORDER=0 WIDTH=100%><TR><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD><TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=createguild" METHOD=post><TR><TD>
  105.         <INPUT TYPE=image NAME="Create Guild" ALT="Create Guild" SRC="'.$layout_name.'/images/buttons/sbutton_createguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
  106.         </TD></TR></FORM></TABLE></TD><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD></TR></TABLE>
  107.         <BR />If you have any problem with guilds try:
  108.         <BR /><a href="?subtopic=guilds&action=cleanup_players">Cleanup players</a> - can\'t join guild/be invited? Can\'t create guild? Try cleanup players.';
  109.     else
  110.         $main_content .= 'Before you can create guild you must login.<br><TABLE BORDER=0 WIDTH=100%><TR><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD><TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=login&redirect=guilds" METHOD=post><TR><TD>
  111.         <INPUT TYPE=image NAME="Login" ALT="Login" SRC="'.$layout_name.'/images/buttons/sbutton_login.gif" BORDER=0 WIDTH=120 HEIGHT=18>
  112.         </TD></TR></FORM></TABLE></TD><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD></TR></TABLE>';
  113. }
  114. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  115. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  116. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  117. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. //show guild page
  134. //show guild page
  135. if($action == 'show')
  136. {
  137.     $guild_id = (int) $_REQUEST['guild'];
  138.     $guild = new Guild();
  139.     $guild->load($guild_id);
  140.     if(!$guild->isLoaded())
  141.         $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  142.     if(!empty($guild_errors))
  143.     {
  144.         //show errors
  145.         $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/>';
  146.         foreach($guild_errors as $guild_error)
  147.             $main_content .= '<li>'.$guild_error;
  148.         //errors and back button
  149.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  150.     }
  151.     else
  152.     {
  153.         //check is it vice or/and leader account (leader has vice + leader rights)
  154.         $guild_leader_char = $guild->getOwner();
  155.         $rank_list = $guild->getGuildRanksList();
  156.         $guild_leader = FALSE;
  157.         $guild_vice = FALSE;
  158.         if($logged)
  159.         {
  160.             $account_players = $account_logged->getPlayers();
  161.             foreach($account_players as $player)
  162.             {
  163.                 $players_from_account_ids[] = $player->getId();
  164.                 $player_rank = $player->getRank();
  165.                 if(!empty($player_rank))
  166.                     foreach($rank_list as $rank_in_guild)
  167.                         if($rank_in_guild->getId() == $player_rank->getId())
  168.                         {
  169.                             $players_from_account_in_guild[] = $player->getName();
  170.                             if($player_rank->getLevel() > 1)
  171.                             {
  172.                                 $guild_vice = TRUE;
  173.                                 $level_in_guild = $player_rank->getLevel();
  174.                             }
  175.                             if($guild->getOwner()->getId() == $player->getId())
  176.                             {
  177.                                 $guild_vice = TRUE;
  178.                                 $guild_leader = TRUE;
  179.                             }
  180.                         }
  181.             }
  182.         }
  183.         //show guild page
  184.         $guild_logo = "default_logo.gif";
  185.         if(empty($guild_logo) || !file_exists("guilds/".$guild_logo))
  186.             $guild_logo = "default_logo.gif";
  187.         $description = $guild->getCustomField('description');
  188.         $newlines   = array("\r\n", "\n", "\r");
  189.         $description_with_lines = str_replace($newlines, '<br />', $description, $count);
  190.         if($count < $config['site']['guild_description_lines_limit'])
  191.             $description = $description_with_lines;
  192.         $guild_owner = $guild->getOwner();
  193.         if($guild_owner->isLoaded())
  194.             $guild_owner = $guild_owner->getName();
  195.         $main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR>
  196.        <TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD>
  197.        <TABLE BORDER=0 WIDTH=100%>
  198.        <TR><TD WIDTH=64><IMG SRC="guilds/'.$guild_logo.'" WIDTH=64 HEIGHT=64></TD>
  199.        <TD ALIGN=center WIDTH=100%><H1>'.$guild->getName().'</H1></TD>
  200.        <TD WIDTH=64><IMG SRC="guilds/'.$guild_logo.'" WIDTH=64 HEIGHT=64></TD></TR>
  201.        </TABLE><BR>'.$description.'<BR><BR><a href="?subtopic=characters&name='.urlencode($guild_owner).'"><b>'.$guild_owner.'</b></a> is guild leader of <b>'.$guild->getName().'</b>.<BR>The guild was founded on '.$config['server']['serverName'].' on '.date("j F Y", $guild->getCreationData()).'.';
  202.         if($guild_leader)
  203.             $main_content .= '&nbsp;&nbsp;&nbsp;<a href="?subtopic=guilds&action=manager&guild='.$guild_name.'"><IMG SRC="'.$layout_name.'/images/buttons/sbutton_manageguild.png" BORDER=0 WIDTH=120 HEIGHT=18 alt="Manage Guild"></a>';
  204.         $main_content .= '<BR><BR>
  205.        <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
  206.        <TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=5 CLASS=white><B>Guild Members</B></TD></TR>
  207.        <TR BGCOLOR='.$config['site']['darkborder'].'>
  208.         <TD ><B>Rank</B></TD>
  209.        <TD ><B>Name and Title</B></TD>
  210.         <TD ><B>Vocation</B></TD>
  211.         <TD ><B>Level</B></TD>
  212.         <TD ><B>Status</B></TD>
  213.         </TR>';
  214.             $showed_players = 1;
  215.         foreach($rank_list as $rank)
  216.         {
  217.             $players_with_rank = $rank->getPlayersList();
  218.    
  219.             $players_with_rank_number = count($players_with_rank);
  220.  
  221.             if($players_with_rank_number > 0)
  222.             {
  223.                 if(is_int($showed_players / 2)) { $bgcolor = $config['site']['darkborder']; } else
  224.                 { $bgcolor = $config['site']['lightborder']; } $showed_players++;
  225.                 $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><TD valign="top">'.$rank->getName().'</TD>
  226.                <TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>';
  227.                 foreach($players_with_rank as $player)
  228.                 {
  229. $main_content .= '';
  230.                     $main_content .= '<TR><TD>
  231.                     <FORM ACTION="?subtopic=guilds&action=change_nick&name='.urlencode($player->getName()).'" METHOD=post>
  232.                     <A HREF="?subtopic=characters&name='.urlencode($player->getName()).'">'.($player->isOnline() ?
  233.                     "<font color=\"green\">".$player->getName()."</font>" : "<font color=\"red\">".$player->getName()."</font>").'</A>
  234.                 ';
  235.  /*   <br><small>Level: '.$player->getLevel().' '.$vocation_name[$player->getPromotion()][$player->getVocation()].'</small> */                
  236.  
  237.  $guild_nick = $player->getGuildNick();
  238.                     if($logged)
  239.                         if(in_array($player->getId(), $players_from_account_ids))
  240.                             $main_content .= '(<input type="text" name="nick" value="'.htmlentities($player->getGuildNick()).'"><input type="submit" value="Change">)';
  241.                         else
  242.                         if(!empty($guild_nick))
  243.                             $main_content .= ' ('.htmlentities($player->getGuildNick()).')';
  244.                     else
  245.                         if(!empty($guild_nick))
  246.                             $main_content .= ' ('.htmlentities($player->getGuildNick()).')';
  247.                     if($level_in_guild > $rank->getLevel() || $guild_leader)
  248.                         if($guild_leader_char->getName() != $player->getName())
  249.                             $main_content .= '&nbsp;<font size=1>{<a href="?subtopic=guilds&action=kickplayer&guild='.$guild->getId().'&name='.urlencode($player->getName()).'">KICK</a>}</font>';
  250.                     $main_content .= '</TR></FORM>';
  251.  
  252.                 }
  253.                 $main_content .= '</TABLE></TD><TD>'.$vocation_name[$player->getPromotion()][$player->getVocation()].'<TD>'.$player->getLevel().'</TR>';
  254.                
  255.                
  256.                
  257.             }
  258.         }
  259.         $main_content .= '</TABLE><br><br>';
  260.         $guild_id = (int)$_GET['guild'];$guildMembers = $SQL->query( 'SELECT COUNT(`gr`.`id`) AS `total` FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` = '.$guild_id )->fetch( );$allM = $SQL->query ('SELECT COUNT(1) as `people` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') AND online = 1')->fetch(); $allM1 = $SQL->query ('SELECT SUM(`level`) as `level` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ')->fetch(); $allM2 = $SQL->query ('SELECT AVG(`level`) as `level` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ')->fetch(); $allM3 = $SQL->query ('SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ORDER BY `level` ASC LIMIT 1')->fetch(); $allM4 = $SQL->query ('SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ORDER BY `level` DESC LIMIT 1')->fetch(); $invite = $SQL->query( 'SELECT COUNT(*) FROM `guild_invites` WHERE `guild_id` = '.$guild_id.'')->fetch( );                        $main_content .= '<table width="100%" cellspacing="1" cellpadding="4" border="0">        <tbody><tr bgcolor="#505050"><td class="white" colspan="3"><b>Guild Statistic</b></td></tr>        <tr bgcolor="#d4c0a1"><td width="30%"><b>Type</b></td>        <td width="50%"><b>Value</b></td></tr><tr bgcolor="#f1e0c6">                <td valign="top">Number of Members in Guild</td>        <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$guildMembers['total'].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#d4c0a1"><td valign="top">Number of Members Online in Guild</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM[0].'</td></tr></tbody></table>        </td></tr>                <td valign="top">Total Level in guild</td>        <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM1[0].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#d4c0a1"><td valign="top">Avg Level in guild</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.round($allM2[0]).'</td></tr></tbody></table>        </td></tr>                <td valign="top">Lowest Level in guild</td>        <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM3[0].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#d4c0a1"><td valign="top">Highest Level in guild</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM4[0].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#f1e0c6"><td valign="top">Number of Invited Members</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$invite[0].'</td></tr></tbody></table>        </td></tr>        </table>';  
  261. $invited_list = $guild->listInvites();
  262.         if(count($invited_list) == 0)
  263.             $main_content .= '<BR><BR><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Invited Characters</B></TD></TR><TR BGCOLOR='.$config['site']['lightborder'].'><TD>No invited characters found.</TD></TR></TABLE>';
  264.         else
  265.         {
  266.             $main_content .= '<BR><BR><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Invited Characters</B></TD></TR>';
  267.             $show_accept_invite = 0;
  268.             $showed_invited = 1;
  269.             foreach($invited_list as $invited_player)
  270.             {
  271.                 if(count($account_players) > 0)
  272.                     foreach($account_players as $player_from_acc)
  273.                         if($player_from_acc->getName() == $invited_player->getName())
  274.                             $show_accept_invite++;
  275.                 if(is_int($showed_invited / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_invited++;
  276.                 $main_content .= '<TR bgcolor="'.$bgcolor.'"><TD><a href="?subtopic=characters&name='.urlencode($invited_player->getName()).'">'.$invited_player->getName().'</a>';
  277.                 if($guild_vice)
  278.                     $main_content .= '  (<a href="?subtopic=guilds&action=deleteinvite&guild='.$guild_name.'&name='.$invited_player->getName().'">Cancel Invitation</a>)';
  279.                 $main_content .= '</TD></TR>';
  280.             }
  281.             $main_content .= '</TABLE>';
  282.         }
  283.         $main_content .= '<BR><BR>
  284.        <TABLE BORDER=0 WIDTH=100%><TR><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD>';
  285.         if(!$logged)
  286.             $main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=login&guild='.$guild_name.'&redirect=guild" METHOD=post><TR><TD>
  287.            <INPUT TYPE=image NAME="Login" ALT="Login" SRC="'.$layout_name.'/images/buttons/sbutton_login.gif" BORDER=0 WIDTH=120 HEIGHT=18>
  288.            </TD></TR></FORM></TABLE></TD>';
  289.         else
  290.         {
  291.             if($show_accept_invite > 0)
  292.                 $main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=acceptinvite&guild='.$guild_name.'" METHOD=post><TR><TD>
  293.                <INPUT TYPE=image NAME="Accept Invite" ALT="Accept Invite" SRC="'.$layout_name.'/images/buttons/sbutton_acceptinvite.png" BORDER=0 WIDTH=120 HEIGHT=18>
  294.                </TD></TR></FORM></TABLE></TD>';
  295.             if($guild_vice)
  296.             {
  297.                 $main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=invite&guild='.$guild_name.'" METHOD=post><TR><TD>
  298.                <INPUT TYPE=image NAME="Invite Player" ALT="Invite Player" SRC="'.$layout_name.'/images/buttons/sbutton_inviteplayer.png" BORDER=0 WIDTH=120 HEIGHT=18>
  299.                </TD></TR></FORM></TABLE></TD>';
  300.                 $main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=changerank&guild='.$guild_name.'" METHOD=post><TR><TD>
  301.                <INPUT TYPE=image NAME="Change Rank" ALT="Change Rank" SRC="'.$layout_name.'/images/buttons/sbutton_changerank.png" BORDER=0 WIDTH=120 HEIGHT=18>
  302.                </TD></TR></FORM></TABLE></TD>';
  303.             }
  304.             if($players_from_account_in_guild > 0)
  305.                 $main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=leaveguild&guild='.$guild_name.'" METHOD=post><TR><TD>
  306.                <INPUT TYPE=image NAME="Leave Guild" ALT="Leave Guild" SRC="'.$layout_name.'/images/buttons/sbutton_leaveguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
  307.                </TD></TR></FORM></TABLE></TD>';
  308.         }
  309.         $main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&world='.$guild->getWorld().'" METHOD=post><TR><TD>
  310.        <INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18>
  311.        </TD></TR></FORM></TABLE>
  312.        </TD><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD></TR></TABLE>
  313.        </TD><TD><IMG src="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  314.        </TR></TABLE></TABLE>';
  315.     }
  316. }
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. //--------------------------------------------------------------------------------------------------------------------
  350. //--------------------------------------------------------------------------------------------------------------------
  351. //--------------------------------------------------------------------------------------------------------------------
  352. //--------------------------------------------------------------------------------------------------------------------
  353. //change rank of player in guild
  354. if($action == 'changerank')
  355. {
  356.     $guild_id = (int) $_REQUEST['guild'];
  357.     if(!$logged)
  358.         $guild_errors[] = 'You are not logged in. You can\'t change rank.';
  359.     if(empty($guild_errors))
  360.     {
  361.         $guild = new Guild();
  362.         $guild->load($guild_id);
  363.         if(!$guild->isLoaded())
  364.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  365.     }
  366.     if(!empty($guild_errors))
  367.     {
  368.         //show errors
  369.         $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/>';
  370.         foreach($guild_errors as $guild_error)
  371.             $main_content .= '<li>'.$guild_error;
  372.         //errors and back button
  373.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  374.     }
  375.     else
  376.     {
  377.     //check is it vice or/and leader account (leader has vice + leader rights)
  378.     $rank_list = $guild->getGuildRanksList();
  379.     $guild_leader = FALSE;
  380.     $guild_vice = FALSE;
  381.     $account_players = $account_logged->getPlayers();
  382.     foreach($account_players as $player)
  383.     {
  384.         $player_rank = $player->getRank();
  385.         if(!empty($player_rank))
  386.             foreach($rank_list as $rank_in_guild)
  387.                 if($rank_in_guild->getId() == $player_rank->getId())
  388.                 {
  389.                     $players_from_account_in_guild[] = $player->getName();
  390.                     if($player_rank->getLevel() > 1) {
  391.                         $guild_vice = TRUE;
  392.                         $level_in_guild = $player_rank->getLevel();
  393.                     }
  394.                     if($guild->getOwner()->getId() == $player->getId()) {
  395.                         $guild_vice = TRUE;
  396.                         $guild_leader = TRUE;
  397.                     }
  398.                 }
  399.     }
  400.     if($guild_vice)
  401.     {
  402.         foreach($rank_list as $rank)
  403.         {
  404.             if($guild_leader || $rank->getLevel() < $level_in_guild)
  405.             {
  406.                 $ranks[$rid]['0'] = $rank->getId();
  407.                 $ranks[$rid]['1'] = $rank->getName();
  408.                 $rid++;
  409.                 $players_with_rank = $rank->getPlayersList();
  410.                 if(count($players_with_rank) > 0)
  411.                 {
  412.                     foreach($players_with_rank as $player)
  413.                     {
  414.                         if($guild->getOwner()->getId() != $player->getId() || $guild_leader)
  415.                         {
  416.                             $players_with_lower_rank[$sid]['0'] = htmlspecialchars($player->getName());
  417.                             $players_with_lower_rank[$sid]['1'] = htmlspecialchars($player->getName()).' ('.htmlspecialchars($rank->getName()).')';
  418.                             $sid++;
  419.                         }
  420.                     }
  421.                 }
  422.             }
  423.         }
  424.         if($_REQUEST['todo'] == 'save')
  425.         {
  426.             $player_name = $_REQUEST['name'];
  427.             $new_rank = (int) $_REQUEST['rankid'];
  428.             if(!check_name($player_name))
  429.                 $change_errors[] = 'Invalid player name format.';
  430.             $rank = new GuildRank();
  431.             $rank->load($new_rank);
  432.             if(!$rank->isLoaded())
  433.                 $change_errors[] = 'Rank with this ID doesn\'t exist.';
  434.             if($level_in_guild <= $rank->getLevel() && !$guild_leader)
  435.                 $change_errors[] = 'You can\'t set ranks with equal or higher level than your.';
  436.             if(empty($change_errors))
  437.             {
  438.                 $player_to_change = new Player();
  439.                 $player_to_change->find($player_name);
  440.                 if(!$player_to_change->isLoaded())
  441.                     $change_errors[] = 'Player with name '.htmlspecialchars($player_name).'</b> doesn\'t exist.';
  442.                 else
  443.                 {
  444.                     $player_in_guild = FALSE;
  445.                     if($guild->getName() == $player_to_change->getRank()->getGuild()->getName() || $guild_leader)
  446.                     {
  447.                         $player_in_guild = TRUE;
  448.                         $player_has_lower_rank = FALSE;
  449.                         if($player_to_change->getRank()->getLevel() < $level_in_guild || $guild_leader)
  450.                             $player_has_lower_rank = TRUE;
  451.                     }
  452.                 }
  453.                 $rank_in_guild = FALSE;
  454.                 foreach($rank_list as $rank_from_guild)
  455.                     if($rank_from_guild->getId() == $rank->getId())
  456.                         $rank_in_guild = TRUE;
  457.                 if(!$player_in_guild)
  458.                 $change_errors[] = 'This player isn\'t in your guild.';
  459.                 if(!$rank_in_guild)
  460.                     $change_errors[] = 'This rank isn\'t in your guild.';
  461.                 if(!$player_has_lower_rank)
  462.                     $change_errors[] = 'This player has higher rank in guild than you. You can\'t change his/her rank.';
  463.             }
  464.             if(empty($change_errors))
  465.             {
  466.                 $player_to_change->setRank($rank);
  467.                 $player_to_change->save();
  468.                 $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>Rank of player <b>'.htmlspecialchars($player_to_change->getName()).'</b> has been changed to <b>'.htmlspecialchars($rank->getName()).'</b>.</td></tr>          </table>        </div>  </table></div></td></tr><br>';
  469.                 unset($players_with_lower_rank);
  470.                 unset($ranks);
  471.                 $rid = 0;
  472.                 $sid= 0;
  473.                 foreach($rank_list as $rank)
  474.                 {
  475.                     if($guild_leader || $rank->getLevel() < $level_in_guild)
  476.                     {
  477.                         $ranks[$rid]['0'] = $rank->getId();
  478.                         $ranks[$rid]['1'] = $rank->getName();
  479.                         $rid++;
  480.                         $players_with_rank = $rank->getPlayersList();
  481.                         if(count($players_with_rank) > 0)
  482.                         {
  483.                             foreach($players_with_rank as $player)
  484.                             {
  485.                                 if($guild->getOwner()->getId() != $player->getId() || $guild_leader)
  486.                                 {
  487.                                     $players_with_lower_rank[$sid]['0'] = htmlspecialchars($player->getName());
  488.                                     $players_with_lower_rank[$sid]['1'] = htmlspecialchars($player->getName()).' ('.htmlspecialchars($rank->getName()).')';
  489.                                     $sid++;
  490.                                 }
  491.                             }
  492.                         }
  493.                     }
  494.                 }
  495.             }
  496.             else
  497.             {
  498.                 $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/>';
  499.                 foreach($change_errors as $change_error)
  500.                     $main_content .= '<li>'.$change_error;
  501.                 $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/>';
  502.             }
  503.         }
  504.         $main_content .= '<FORM ACTION="?subtopic=guilds&action=changerank&guild='.$guild_id.'&todo=save" METHOD=post>
  505.         <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
  506.         <TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Change Rank</B></TD></TR>
  507.         <TR BGCOLOR='.$config['site']['darkborder'].'><TD>Name: <SELECT NAME="name">';
  508.         foreach($players_with_lower_rank as $player_to_list)
  509.             $main_content .= '<OPTION value="'.$player_to_list['0'].'">'.$player_to_list['1'];
  510.         $main_content .= '</SELECT>&nbsp;Rank:&nbsp;<SELECT NAME="rankid">';
  511.         foreach($ranks as $rank)
  512.             $main_content .= '<OPTION value="'.htmlspecialchars($rank['0']).'">'.htmlspecialchars($rank['1']);
  513.         $main_content .= '</SELECT>&nbsp;&nbsp;&nbsp;<INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD><TR>
  514.         </TABLE></FORM><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  515.     }
  516.     else
  517.         $main_content .= 'Error. You are not a leader or vice leader in guild '.htmlspecialchars($guild->getName()).'.<FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></FORM>';
  518.     }
  519. }
  520.  
  521. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  522. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  523. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  524. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  525. //show guild page
  526. if($action == 'deleteinvite')
  527. {
  528.     //set rights in guild
  529.     $guild_id = (int) $_REQUEST['guild'];
  530.     $name = $_REQUEST['name'];
  531.     if(!$logged)
  532.         $guild_errors[] = 'You are not logged in. You can\'t delete invitations.';
  533.     if(!check_name($name))
  534.         $guild_errors[] = 'Invalid name format.';
  535.     if(empty($guild_errors))
  536.     {
  537.         $guild = new Guild();
  538.         $guild->load($guild_id);
  539.         if(!$guild->isLoaded())
  540.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  541.     }
  542.     if(empty($guild_errors))
  543.     {
  544.         $rank_list = $guild->getGuildRanksList();
  545.         $guild_leader = FALSE;
  546.         $guild_vice = FALSE;
  547.         $account_players = $account_logged->getPlayers();
  548.         foreach($account_players as $player)
  549.         {
  550.             $player_rank = $player->getRank();
  551.             if(!empty($player_rank))
  552.             {
  553.                 foreach($rank_list as $rank_in_guild)
  554.                 {
  555.                     if($rank_in_guild->getId() == $player_rank->getId())
  556.                     {
  557.                         $players_from_account_in_guild[] = $player->getName();
  558.                         if($player_rank->getLevel() > 1)
  559.                         {
  560.                             $guild_vice = TRUE;
  561.                             $level_in_guild = $player_rank->getLevel();
  562.                         }
  563.                         if($guild->getOwner()->getId() == $player->getId())
  564.                         {
  565.                             $guild_vice = TRUE;
  566.                             $guild_leader = TRUE;
  567.                         }
  568.                     }
  569.                 }
  570.             }
  571.         }
  572.     }
  573.     if(empty($guild_errors))
  574.     {
  575.         $player = new Player();
  576.         $player->find($name);
  577.         if(!$player->isLoaded())
  578.             $guild_errors[] = 'Player with name <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  579.     }
  580.     if(!$guild_vice)
  581.         $guild_errors[] = 'You are not a leader or vice leader of guild <b>'.htmlspecialchars($guild->getName()).'</b>.';
  582.     if(empty($guild_errors))
  583.     {
  584.         $invited_list = $guild->listInvites();
  585.         if(count($invited_list) > 0)
  586.         {
  587.             $is_invited = FALSE;
  588.             foreach($invited_list as $invited)
  589.                 if($invited->getName() == $player->getName())
  590.                     $is_invited = TRUE;
  591.             if(!$is_invited)
  592.                 $guild_errors[] = '<b>'.htmlspecialchars($player->getName()).'</b> isn\'t invited to your guild.';
  593.         }
  594.         else
  595.             $guild_errors[] = 'No one is invited to your guild.';
  596.     }
  597.     if(!empty($guild_errors))
  598.     {
  599.         $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/>';
  600.         foreach($guild_errors as $guild_error)
  601.             $main_content .= '<li>'.$guild_error;
  602.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  603.     }
  604.     else
  605.     {
  606.         if($_REQUEST['todo'] == 'save')
  607.         {
  608.             $guild->deleteInvite($player);
  609.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Delete player invitation</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Player with name <b>'.htmlspecialchars($player->getName()).'</b> has been deleted from "invites list".</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  610.         }
  611.         else
  612.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Delete player invitation</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Are you sure you want to delete player with name <b>'.htmlspecialchars($player->getName()).'</b> from "invites list"?</TD></TR></TABLE><br/><center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><FORM ACTION="?subtopic=guilds&action=deleteinvite&guild='.$guild_id.'&name='.urlencode($player->getName()).'&todo=save" METHOD=post><TD align="right" width="50%"><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>&nbsp;&nbsp;</TD></FORM><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TD>&nbsp;&nbsp;<INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD></TR></FORM></TABLE></center>';
  613.     }
  614. }
  615.  
  616. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  617. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  618. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  619. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  620. //show guild page
  621. if($action == 'invite')
  622. {
  623.     //set rights in guild
  624.     $guild_id = (int) $_REQUEST['guild'];
  625.     $name = $_REQUEST['name'];
  626.     if(!$logged)
  627.         $guild_errors[] = 'You are not logged in. You can\'t invite players.';
  628.     if(empty($guild_errors))
  629.     {
  630.         $guild = new Guild();
  631.         $guild->load($guild_id);
  632.         if(!$guild->isLoaded())
  633.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  634.     }
  635.     if(empty($guild_errors))
  636.     {
  637.         $rank_list = $guild->getGuildRanksList();
  638.         $guild_leader = FALSE;
  639.         $guild_vice = FALSE;
  640.         $account_players = $account_logged->getPlayers();
  641.         foreach($account_players as $player)
  642.         {
  643.             $player_rank = $player->getRank();
  644.             if(!empty($player_rank))
  645.                 foreach($rank_list as $rank_in_guild)
  646.                     if($rank_in_guild->getId() == $player_rank->getId())
  647.                     {
  648.                         $players_from_account_in_guild[] = $player->getName();
  649.                         if($player_rank->getLevel() > 1)
  650.                         {
  651.                             $guild_vice = TRUE;
  652.                             $level_in_guild = $player_rank->getLevel();
  653.                         }
  654.                         if($guild->getOwner()->getId() == $player->getId())
  655.                         {
  656.                             $guild_vice = TRUE;
  657.                             $guild_leader = TRUE;
  658.                         }
  659.                     }
  660.         }
  661.     }
  662.     if(!$guild_vice)
  663.         $guild_errors[] = 'You are not a leader or vice leader of guild ID <b>'.$guild_id.'</b>.';
  664.     if($_REQUEST['todo'] == 'save')
  665.     {
  666.         if(!check_name($name))
  667.             $guild_errors[] = 'Invalid name format.';
  668.         if(empty($guild_errors))
  669.         {
  670.             $player = new Player();
  671.             $player->find($name);
  672.             if(!$player->isLoaded())
  673.                 $guild_errors[] = 'Player with name <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  674.             else
  675.             {
  676.                 $rank_of_player = $player->getRank();
  677.                 if(!empty($rank_of_player))
  678.                     $guild_errors[] = 'Player with name <b>'.htmlspecialchars($name).'</b> is already in guild. He must leave guild before you can invite him.';
  679.             }
  680.         }
  681.         if(empty($guild_errors) && $guild->getWorld() != $player->getWorld())
  682.             $guild_errors[] = '<b>'.htmlspecialchars($player->getName()).'</b> is from other world then your guild.';
  683.         if(empty($guild_errors))
  684.         {
  685.             $invited_list = $guild->listInvites();
  686.             if(count($invited_list) > 0)
  687.                 foreach($invited_list as $invited)
  688.                     if($invited->getName() == $player->getName())
  689.                         $guild_errors[] = '<b>'.htmlspecialchars($player->getName()).'</b> is already invited to your guild.';
  690.         }
  691.     }
  692.     if(!empty($guild_errors))
  693.     {
  694.         $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/>';
  695.         foreach($guild_errors as $guild_error)
  696.             $main_content .= '<li>'.$guild_error;
  697.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  698.     }
  699.     else
  700.         if($_REQUEST['todo'] == 'save')
  701.         {
  702.             $guild->invite($player);
  703.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Invite player</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Player with name <b>'.htmlspecialchars($player->getName()).'</b> has been invited to your guild.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  704.         }
  705.         else
  706.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Invite player</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%><FORM ACTION="?subtopic=guilds&action=invite&guild='.$guild_id.'&todo=save" METHOD=post>Invite player with name:&nbsp;&nbsp;<INPUT TYPE="text" NAME="name">&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></FORM></TD></TD></TR></TR></TABLE><br/><center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TD><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD></TR></FORM></TABLE></center>';
  707. }
  708.  
  709.  
  710. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  711. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  712. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  713. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  714. //show guild page
  715. if($action == 'acceptinvite')
  716. {
  717.     //set rights in guild
  718.     $guild_id = (int) $_REQUEST['guild'];
  719.     $name = $_REQUEST['name'];
  720.     if(!$logged)
  721.         $guild_errors[] = 'You are not logged in. You can\'t accept invitations.';
  722.     if(empty($guild_errors))
  723.     {
  724.         $guild = new Guild();
  725.         $guild->load($guild_id);
  726.         if(!$guild->isLoaded())
  727.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  728.     }
  729.  
  730.     if($_REQUEST['todo'] == 'save')
  731.     {
  732.         if(!check_name($name))
  733.             $guild_errors[] = 'Invalid name format.';
  734.         if(empty($guild_errors))
  735.         {
  736.             $player = new Player();
  737.             $player->find($name);
  738.             if(!$player->isLoaded())
  739.             {
  740.                 $guild_errors[] = 'Player with name <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  741.             }
  742.             else
  743.             {
  744.                 $rank_of_player = $player->getRank();
  745.                 if(!empty($rank_of_player))
  746.                 {
  747.                     $guild_errors[] = 'Character with name <b>'.htmlspecialchars($name).'</b> is already in guild. You must leave guild before you join other guild.';
  748.                 }
  749.             }
  750.         }
  751.     }
  752.     if($_REQUEST['todo'] == 'save')
  753.     {
  754.         if(empty($guild_errors))
  755.         {
  756.             $is_invited = FALSE;
  757.             $invited_list = $guild->listInvites();
  758.             if(count($invited_list) > 0)
  759.             {
  760.                 foreach($invited_list as $invited)
  761.                 {
  762.                     if($invited->getName() == $player->getName())
  763.                     {
  764.                         $is_invited = TRUE;
  765.                     }
  766.                 }
  767.             }
  768.             if(!$is_invited)
  769.             {
  770.                 $guild_errors[] = 'Character '.htmlspecialchars($player->getName()).' isn\'t invited to guild <b>'.htmlspecialchars($guild->getName()).'</b>.';
  771.             }
  772.         }
  773.     }
  774.     else
  775.     {
  776.         if(empty($guild_errors))
  777.         {
  778.             $acc_invited = FALSE;
  779.             $account_players = $account_logged->getPlayers();
  780.             $invited_list = $guild->listInvites();
  781.             if(count($invited_list) > 0)
  782.             {
  783.                 foreach($invited_list as $invited)
  784.                 {
  785.                     foreach($account_players as $player_from_acc)
  786.                     {
  787.                         if($invited->getName() == $player_from_acc->getName())
  788.                         {
  789.                             $acc_invited = TRUE;
  790.                             $list_of_invited_players[] = $player_from_acc->getName();
  791.                         }
  792.                     }
  793.                 }
  794.             }
  795.         }
  796.         if(!$acc_invited)
  797.         {
  798.             $guild_errors[] = 'Any character from your account isn\'t invited to <b>'.htmlspecialchars($guild->getName()).'</b>.';
  799.         }
  800.     }
  801.     if(!empty($guild_errors))
  802.     {
  803.         $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/>';
  804.         foreach($guild_errors as $guild_error)
  805.         {
  806.             $main_content .= '<li>'.$guild_error;
  807.         }
  808.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  809.     }
  810.     else
  811.     {
  812.         if($_REQUEST['todo'] == 'save')
  813.         {
  814.             $guild->acceptInvite($player);
  815.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Accept invitation</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Player with name <b>'.htmlspecialchars($player->getName()).'</b> has been added to guild <b>'.htmlspecialchars($guild->getName()).'</b>.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  816.         }
  817.         else
  818.         {
  819.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Accept invitation</B></TD></TR>';
  820.             $main_content .= '<TR BGCOLOR='.$config['site']['lightborder'].'><TD WIDTH=100%>Select character to join guild:</TD></TR>';
  821.             $main_content .= '<TR BGCOLOR='.$config['site']['darkborder'].'><TD>
  822.             <form action="?subtopic=guilds&action=acceptinvite&guild='.$guild_id.'&todo=save" METHOD="post">';
  823.             sort($list_of_invited_players);
  824.             foreach($list_of_invited_players as $invited_player_from_list)
  825.             {
  826.                 $main_content .= '<input type="radio" name="name" value="'.htmlspecialchars($invited_player_from_list).'" />'.htmlspecialchars($invited_player_from_list).'<br>';
  827.             }
  828.             $main_content .= '<br><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></form></TD></TR></TABLE><br/><center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TD><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD></TR></FORM></TABLE></center>';
  829.         }
  830.     }
  831. }
  832.  
  833.  
  834. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  835. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  836. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  837. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  838. //show guild page
  839. if($action == 'kickplayer')
  840. {
  841.     //set rights in guild
  842.     $guild_id = (int) $_REQUEST['guild'];
  843.     $name = $_REQUEST['name'];
  844.     if(!$logged)
  845.         $guild_errors[] = 'You are not logged in. You can\'t kick characters.';
  846.     if(!check_name($name))
  847.         $guild_errors[] = 'Invalid name format.';
  848.     if(empty($guild_errors))
  849.     {
  850.         $guild = new Guild();
  851.         $guild->load($guild_id);
  852.         if(!$guild->isLoaded())
  853.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  854.     }
  855.     if(empty($guild_errors))
  856.     {
  857.         $rank_list = $guild->getGuildRanksList();
  858.         $guild_leader = FALSE;
  859.         $guild_vice = FALSE;
  860.         $account_players = $account_logged->getPlayers();
  861.         foreach($account_players as $player)
  862.         {
  863.             $player_rank = $player->getRank();
  864.             if(!empty($player_rank))
  865.             {
  866.                 foreach($rank_list as $rank_in_guild)
  867.                 {
  868.                     if($rank_in_guild->getId() == $player_rank->getId())
  869.                     {
  870.                         $players_from_account_in_guild[] = $player->getName();
  871.                         if($player_rank->getLevel() > 1)
  872.                         {
  873.                             $guild_vice = TRUE;
  874.                             $level_in_guild = $player_rank->getLevel();
  875.                         }
  876.                         if($guild->getOwner()->getId() == $player->getId())
  877.                         {
  878.                             $guild_vice = TRUE;
  879.                             $guild_leader = TRUE;
  880.                         }
  881.                     }
  882.                 }
  883.             }
  884.         }
  885.     }
  886.     if(empty($guild_errors))
  887.     {
  888.         if(!$guild_leader && $level_in_guild < 3)
  889.         {
  890.             $guild_errors[] = 'You are not a leader of guild <b>'.htmlspecialchars($guild->getName()).'</b>. You can\'t kick players.';
  891.         }
  892.     }
  893.     if(empty($guild_errors))
  894.     {
  895.         $player = new Player();
  896.         $player->find($name);
  897.         if(!$player->isLoaded())
  898.         {
  899.             $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  900.         }
  901.         else
  902.         {
  903.             if($player->getRank()->getGuild()->getName() != $guild->getName())
  904.             {
  905.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t from your guild.';
  906.             }
  907.         }
  908.     }
  909.     if(empty($guild_errors))
  910.     {
  911.         if($player->getRank()->getLevel() >= $level_in_guild && !$guild_leader)
  912.         {
  913.             $guild_errors[] = 'You can\'t kick character <b>'.htmlspecialchars($name).'</b>. Too high access level.';
  914.         }
  915.     }
  916.     if(empty($guild_errors))
  917.     {
  918.         if($guild->getOwner()->getName() == $player->getName())
  919.         {
  920.             $guild_errors[] = 'It\'s not possible to kick guild owner!';
  921.         }
  922.     }
  923.     if(!empty($guild_errors))
  924.     {
  925.         $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/>';
  926.         foreach($guild_errors as $guild_error)
  927.         {
  928.             $main_content .= '<li>'.$guild_error;
  929.         }
  930.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  931.     }
  932.     else
  933.         if($_REQUEST['todo'] == 'save')
  934.         {
  935.             $player->setRank();
  936.             $player->save();
  937.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Kick player</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Player with name <b>'.htmlspecialchars($player->getName()).'</b> has been kicked from your guild.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  938.         }
  939.         else
  940.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Kick player</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Are you sure you want to kick player with name <b>'.htmlspecialchars($player->getName()).'</b> from your guild?</TD></TR></TABLE><br/><center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><FORM ACTION="?subtopic=guilds&action=kickplayer&guild='.$guild_id.'&name='.urlencode($player->getName()).'&todo=save" METHOD=post><TD align="right" width="50%"><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>&nbsp;&nbsp;</TD></FORM><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TD>&nbsp;&nbsp;<INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD></TR></FORM></TABLE></center>';
  941. }
  942.  
  943. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  944. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  945. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  946. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  947. //show guild page
  948. if($action == 'leaveguild')
  949. {
  950.     //set rights in guild
  951.     $guild_id = (int) $_REQUEST['guild'];
  952.     $name = $_REQUEST['name'];
  953.     if(!$logged)
  954.         $guild_errors[] = 'You are not logged in. You can\'t leave guild.';
  955.     if(empty($guild_errors))
  956.     {
  957.         $guild = new Guild();
  958.         $guild->load($guild_id);
  959.         if(!$guild->isLoaded())
  960.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  961.     }
  962.  
  963.     if(empty($guild_errors))
  964.     {
  965.         $guild_owner_id = $guild->getOwner()->getId();
  966.         if($_REQUEST['todo'] == 'save')
  967.         {
  968.             if(!check_name($name))
  969.                 $guild_errors[] = 'Invalid name format.';
  970.             if(empty($guild_errors))
  971.             {
  972.                 $player = new Player();
  973.                 $player->find($name);
  974.                 if(!$player->isLoaded())
  975.                     $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  976.                 else
  977.                     if($player->getAccount()->getId() != $account_logged->getId())
  978.                         $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t from your account!';
  979.             }
  980.             if(empty($guild_errors))
  981.             {
  982.                 $player_loaded_rank = $player->getRank();
  983.                 if(!empty($player_loaded_rank) && $player_loaded_rank->isLoaded())
  984.                 {
  985.                     if($player_loaded_rank->getGuild()->getId() != $guild->getId())
  986.                         $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t from guild <b>'.htmlspecialchars($guild->getName()).'</b>.';
  987.                 }
  988.                 else
  989.                     $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t in any guild.';
  990.             }
  991.             if(empty($guild_errors))
  992.                 if($guild_owner_id == $player->getId())
  993.                     $guild_errors[] = 'You can\'t leave guild. You are an owner of guild.';
  994.         }
  995.         else
  996.         {
  997.             $account_players = $account_logged->getPlayers();
  998.             foreach($account_players as $player_fac)
  999.             {
  1000.                 $player_rank = $player_fac->getRank();
  1001.                 if(!empty($player_rank))
  1002.                     if($player_rank->getGuild()->getId() == $guild->getId())
  1003.                         if($guild_owner_id != $player_fac->getId())
  1004.                             $array_of_player_ig[] = $player_fac->getName();
  1005.             }
  1006.         }
  1007.     }
  1008.     if(!empty($guild_errors))
  1009.     {
  1010.         $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/>';
  1011.         foreach($guild_errors as $guild_error)
  1012.             $main_content .= '<li>'.$guild_error.'</li>';
  1013.         $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/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  1014.     }
  1015.     else
  1016.     {
  1017.         if($_REQUEST['todo'] == 'save')
  1018.         {
  1019.             $player->setRank();
  1020.             $player->save();
  1021.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Leave guild</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%>Player with name <b>'.htmlspecialchars($player->getName()).'</b> leaved guild <b>'.htmlspecialchars($guild->getName()).'</b>.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  1022.         }
  1023.         else
  1024.         {
  1025.             $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Leave guild</B></TD></TR>';
  1026.             if(count($array_of_player_ig) > 0)
  1027.             {
  1028.                 $main_content .= '<TR BGCOLOR='.$config['site']['lightborder'].'><TD WIDTH=100%>Select character to leave guild:</TD></TR>';
  1029.                 $main_content .= '<TR BGCOLOR='.$config['site']['darkborder'].'><TD>
  1030.                 <form action="?subtopic=guilds&action=leaveguild&guild='.$guild_id.'&todo=save" METHOD="post">';
  1031.                 sort($array_of_player_ig);
  1032.                 foreach($array_of_player_ig as $player_to_leave)
  1033.                     $main_content .= '<input type="radio" name="name" value="'.htmlspecialchars($player_to_leave).'" />'.htmlspecialchars($player_to_leave).'<br>';
  1034.                 $main_content .= '</TD></TR><br></TABLE>';
  1035.             }
  1036.             else
  1037.                 $main_content .= '<TR BGCOLOR='.$config['site']['lightborder'].'><TD WIDTH=100%>Any of your characters can\'t leave guild.</TD></TR>';
  1038.             $main_content .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><tr>';
  1039.             if(count($array_of_player_ig) > 0)
  1040.                 $main_content .= '<td width="130" valign="top"><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></form></td>';
  1041.             $main_content .= '<td><FORM ACTION="?subtopic=guilds&action=show&guild='.$guild_id.'" METHOD=post><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></FORM></td></tr></table>';
  1042.         }
  1043.     }
  1044. }
  1045.  
  1046. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1047. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1048. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1049. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1050. //create guild
  1051. if($action == 'createguild')
  1052. {
  1053.     $new_guild_name = trim($_REQUEST['guild']);
  1054.     $name = $_REQUEST['name'];
  1055.     $todo = $_REQUEST['todo'];
  1056.     if(!$logged)
  1057.         $guild_errors[] = 'You are not logged in. You can\'t create guild.';
  1058.     if(empty($guild_errors))
  1059.     {
  1060.         $account_players = $account_logged->getPlayers();
  1061.         foreach($account_players as $player)
  1062.         {
  1063.             $player_rank = $player->getRank();
  1064.             if(empty($player_rank))
  1065.                 if($player->getLevel() >= $config['site']['guild_need_level'])
  1066.                     if(!$config['site']['guild_need_pacc'] || $account_logged->isPremium())
  1067.                         $array_of_player_nig[] = $player->getName();
  1068.         }
  1069.     }
  1070.  
  1071.     if(count($array_of_player_nig) == 0)
  1072.         $guild_errors[] = 'On your account all characters are in guilds or have too low level to create new guild.';
  1073.     if($todo == 'save')
  1074.     {
  1075.         if(!check_guild_name($new_guild_name))
  1076.         {
  1077.             $guild_errors[] = 'Invalid guild name format.';
  1078.         }
  1079.         if(!check_name($name))
  1080.         {
  1081.             $guild_errors[] = 'Invalid character name format.';
  1082.         }
  1083.         if(empty($guild_errors))
  1084.         {
  1085.             $player = new Player();
  1086.             $player->find($name);
  1087.             if(!$player->isLoaded())
  1088.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> doesn\'t exist.';
  1089.         }
  1090.         if(empty($guild_errors))
  1091.         {
  1092.             $guild = new Guild();
  1093.             $guild->find($new_guild_name);
  1094.             if($guild->isLoaded())
  1095.                 $guild_errors[] = 'Guild <b>'.htmlspecialchars($new_guild_name).'</b> already exist. Select other name.';
  1096.         }
  1097.         if(empty($guild_errors))
  1098.         {
  1099.             $bad_char = TRUE;
  1100.             foreach($array_of_player_nig as $nick_from_list)
  1101.                 if($nick_from_list == $player->getName())
  1102.                     $bad_char = FALSE;
  1103.             if($bad_char)
  1104.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> isn\'t on your account or is already in guild.';
  1105.         }
  1106.         if(empty($guild_errors))
  1107.         {
  1108.             if($player->getLevel() < $config['site']['guild_need_level'])
  1109.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> has too low level. To create guild you need character with level <b>'.$config['site']['guild_need_level'].'</b>.';
  1110.             if($config['site']['guild_need_pacc'] && !$account_logged->isPremium())
  1111.                 $guild_errors[] = 'Character <b>'.htmlspecialchars($name).'</b> is on FREE account. To create guild you need PREMIUM account.';
  1112.         }
  1113.     }
  1114.     if(!empty($guild_errors))
  1115.     {
  1116.         $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/>';
  1117.         foreach($guild_errors as $guild_error)
  1118.             $main_content .= '<li>'.$guild_error.'</li>';
  1119.         $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>';
  1120.         unset($todo);
  1121.     }
  1122.  
  1123.     if($todo == 'save')
  1124.     {
  1125.         $new_guild = new Guild();
  1126.         $new_guild->setCreationData(time());
  1127.         $new_guild->setName($new_guild_name);
  1128.         $new_guild->setOwner($player);
  1129.         $new_guild->setDescription('New guild. Leader must edit this text :)');
  1130.         $new_guild->setWorldID($player->getWorld());
  1131.         $new_guild->setGuildLogo('image/gif', Website::getFileContents('./images/default_guild_logo.gif'));
  1132.        
  1133.         $new_guild->save();
  1134.         $ranks = $new_guild->getGuildRanksList(true);
  1135.         foreach($ranks as $rank)
  1136.             if($rank->getLevel() == 3)
  1137.             {
  1138.                 $player->setRank($rank);
  1139.                 $player->save();
  1140.             }
  1141.         $main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Create guild</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%><b>Congratulations!</b><br/>You have created guild <b>'.htmlspecialchars($new_guild_name).'</b>. <b>'.htmlspecialchars($player->getName()).'</b> is leader of this guild. Now you can invite players, change picture, description and motd of guild. Press submit to open guild manager.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$new_guild->getId().'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
  1142.     }
  1143.     else
  1144.     {
  1145.         $main_content .= 'To play on '.$config['server']['serverName'].' you need an account.
  1146.         All you have to do to create your new account is to enter your email address, password to new account, verification code from picture and to agree to the terms presented below.
  1147.         If you have done so, your account number, password and e-mail address will be shown on the following page and your account and password will be sent
  1148.         to your email address along with further instructions.<BR><BR>
  1149.         <FORM ACTION="?subtopic=guilds&action=createguild&todo=save" METHOD=post>
  1150.         <TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  1151.         <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>Create an '.htmlspecialchars($config['server']['serverName']).' Account</B></TD></TR>
  1152.         <TR><TD BGCOLOR="'.$config['site']['darkborder'].'"><TABLE BORDER=0 CELLSPACING=8 CELLPADDING=0>
  1153.           <TR><TD>
  1154.             <TABLE BORDER=0 CELLSPACING=5 CELLPADDING=0>';
  1155.         $main_content .= '<TR><TD width="150" valign="top"><B>Leader: </B></TD><TD><SELECT name="name">';
  1156.         if(count($array_of_player_nig) > 0)
  1157.         {
  1158.             sort($array_of_player_nig);
  1159.             foreach($array_of_player_nig as $nick)
  1160.                 $main_content .= '<OPTION>'.htmlspecialchars($nick).'</OPTION>';
  1161.         }
  1162.         $main_content .= '</SELECT><BR><font size="1" face="verdana,arial,helvetica">(Name of leader of new guild.)</font></TD></TR>
  1163.             <TR><TD width="150" valign="top"><B>Guild name: </B></TD><TD><INPUT NAME="guild" VALUE="" SIZE=30 MAXLENGTH=50><BR><font size="1" face="verdana,arial,helvetica">(Here write name of your new guild.)</font></TD></TR>
  1164.             </TABLE>
  1165.           </TD></TR>
  1166.         </TABLE></TD></TR>
  1167.         </TABLE>
  1168.         <BR>
  1169.         <TABLE BORDER=0 WIDTH=100%>
  1170.           <TR><TD ALIGN=center>
  1171.             <IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR>
  1172.           </TD><TD ALIGN=center VALIGN=top>
  1173.             <INPUT TYPE=image NAME="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>
  1174.             </FORM>
  1175.           </TD><TD ALIGN=center>
  1176.             <FORM  ACTION="?subtopic=guilds" METHOD=post>
  1177.             <INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18>
  1178.             </FORM>
  1179.           </TD><TD ALIGN=center>
  1180.             <IMG SRC="/images/blank.gif" WIDTH=120 HEIGHT=1 BORDER=0><BR>
  1181.           </TD></TR>
  1182.         </TABLE>
  1183.         </TD>
  1184.         <TD><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  1185.         </TR>
  1186.         </TABLE>';
  1187.     }
  1188. }
  1189. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1190. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1191. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1192. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1193. if($action == 'manager')
  1194. {
  1195.     $guild_id = (int) $_REQUEST['guild'];
  1196.     if(empty($guild_errors))
  1197.     {
  1198.         $guild = new Guild();
  1199.         $guild->load($guild_id);
  1200.         if(!$guild->isLoaded())
  1201.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1202.     }
  1203.     if(empty($guild_errors))
  1204.     {
  1205.         if($logged)
  1206.         {
  1207.             $guild_leader_char = $guild->getOwner();
  1208.             $rank_list = $guild->getGuildRanksList();
  1209.             $guild_leader = FALSE;
  1210.             $account_players = $account_logged->getPlayers();
  1211.             foreach($account_players as $player)
  1212.                 if($guild_leader_char->getId() == $player->getId())
  1213.                 {
  1214.                     $guild_vice = TRUE;
  1215.                     $guild_leader = TRUE;
  1216.                     $level_in_guild = 3;
  1217.                 }
  1218.             if($guild_leader)
  1219.             {
  1220.                 $main_content .= '<center><h2>Welcome to guild manager!</h2></center>Here you can change names of ranks, delete and add ranks, pass leadership to other guild member and delete guild.';
  1221.                 $main_content .= '<br/><br/><table style="clear:both" border=0 cellpadding=0 cellspacing=0 width="100%">
  1222.                 <tr bgcolor='.$config['site']['darkborder'].'><td width="170"><font color="red"><b>Option</b></font></td><td><font color="red"><b>Description</b></font></td></tr>
  1223.                 <tr bgcolor='.$config['site']['lightborder'].'><td width="170"><b><a href="?subtopic=guilds&guild='.$guild_id.'&action=passleadership">Pass Leadership</a></b></td><td><b>Pass leadership of guild to other guild member.</b></td></tr>
  1224.                 <tr bgcolor='.$config['site']['darkborder'].'><td width="170"><b><a href="?subtopic=guilds&guild='.$guild_id.'&action=deleteguild">Delete Guild</a></b></td><td><b>Delete guild, kick all members.</b></td></tr>
  1225.                 <tr bgcolor='.$config['site']['lightborder'].'><td width="170"><b><a href="?subtopic=guilds&guild='.$guild_id.'&action=changedescription">Change Description</a></b></td><td><b>Change description of guild.</b></td></tr>
  1226.                 <tr bgcolor='.$config['site']['darkborder'].'><td width="170"><b><a href="?subtopic=guilds&guild='.$guild_id.'&action=changemotd">Change MOTD</a></b></td><td><b>Change MOTD of guild.</b></td></tr>
  1227.                 <tr bgcolor='.$config['site']['lightborder'].'><td width="170"><b><a href="?subtopic=guilds&guild='.$guild_id.'&action=changelogo">Change guild logo</a></b></td><td><b>Upload new guild logo.</b></td></tr>
  1228.                 </table>';
  1229.                 $main_content .= '<br><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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Add new rank</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td width="120" valign="top">New rank name:</td><td> <form action="?subtopic=guilds&guild='.$guild_id.'&action=addrank" method="POST"><input type="text" name="rank_name" size="20"><input type="submit" value="Add"></form></td></tr>          </table>        </div>  </table></div></td></tr>';
  1230.                 $main_content .= '<center><h3>Change rank names and levels</h3></center><form action="?subtopic=guilds&action=saveranks&guild='.$guild_id.'" method=POST><table style="clear:both" border=0 cellpadding=0 cellspacing=0 width="100%"><tr bgcolor='.$config['site']['vdarkborder'].'><td rowspan="2" width="120" align="center"><font color="white"><b>Delete Rank</b></font></td><td rowspan="2" width="300"><font color="white"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name</b></font></td><td colspan="3" align="center"><font color="white"><b>Level of RANK in guild</b></font></td></tr><tr bgcolor='.$config['site']['vdarkborder'].'><td align="center" bgcolor="red"><font color="white"><b>Leader (3)</b></font></td><td align="center" bgcolor="yellow"><font color="black"><b>Vice (2)</b></font></td><td align="center" bgcolor="green"><font color="white"><b>Member (1)</b></font></td></tr>';
  1231.                 foreach($rank_list as $rank)
  1232.                 {
  1233.                     if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
  1234.                     $main_content .= '<tr bgcolor="'.$bgcolor.'"><td align="center"><a href="?subtopic=guilds&guild='.$guild_id.'&action=deleterank&rankid='.urlencode($rank->getId()).'" border="0"><img src="'.$layout_name.'/images/news/delete.png" border="0" alt="Delete Rank"></a></td><td><input type="text" name="'.htmlspecialchars($rank->getId()).'_name" value="'.htmlspecialchars($rank->getName()).'" size="35"></td><td align="center"><input type="radio" name="'.$rank->getId().'_level" value="3"';
  1235.                     if($rank->getLevel() == 3)
  1236.                         $main_content .= ' checked="checked"';
  1237.                     $main_content .= ' /></td><td align="center"><input type="radio" name="'.$rank->getId().'_level" value="2"';
  1238.                     if($rank->getLevel() == 2)
  1239.                         $main_content .= ' checked="checked"';
  1240.                     $main_content .= ' /></td><td align="center"><input type="radio" name="'.$rank->getId().'_level" value="1"';
  1241.                     if($rank->getLevel() == 1)
  1242.                         $main_content .= ' checked="checked"';
  1243.                     $main_content .= ' /></td></tr>';
  1244.                 }
  1245.                 $main_content .= '<tr bgcolor='.$config['site']['vdarkborder'].'><td>&nbsp;</td><td>&nbsp;</td><td colspan="3" align="center"><input type="submit" value="Save All"></td></tr></table></form>';
  1246.                 $main_content .= '<h3>Ranks info:</h3><b>0. Owner of guild</b> - it\'s highest rank, only one player in guild may has this rank. Player with this rank can:
  1247.                 <li>Invite/Cancel Invitation/Kick Player from guild
  1248.                 <li>Change ranks of all players in guild
  1249.                 <li>Delete guild or pass leadership to other guild member
  1250.                 <li>Change names, levels(leader,vice,member), add and delete ranks
  1251.                 <li>Change MOTD, logo and description of guild<hr>
  1252.                 <b>3. Leader</b> - it\'s second rank in guild. Player with this rank can:
  1253.                 <li>Invite/Cancel Invitation/Kick Player from guild (only with lower rank than his)
  1254.                 <li>Change ranks of players with lower rank level ("vice leader", "member") in guild<hr>
  1255.                 <b>2. Vice Leader</b> - it\'s third rank in guild. Player with this rank can:
  1256.                 <li>Invite/Cancel Invitation
  1257.                 <li>Change ranks of players with lower rank level ("member") in guild<hr>
  1258.                 <b>1. Member</b> - it\'s lowest rank in guild. Player with this rank can:
  1259.                 <li>Be a member of guild';
  1260.                 $main_content .= '<br/><center><form action="?subtopic=guilds&action=show&guild='.$guild_id.'" 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>';
  1261.             }
  1262.             else
  1263.                 $guild_errors[] = 'You are not a leader of guild!';
  1264.         }
  1265.         else
  1266.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1267.     }
  1268.     if(!empty($guild_errors))
  1269.     {
  1270.         $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/>';
  1271.         foreach($guild_errors as $guild_error)
  1272.             $main_content .= '<li>'.$guild_error.'</li>';
  1273.         $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>';
  1274.     }
  1275. }
  1276. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1277. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1278. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1279. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1280. if($action == 'changelogo')
  1281. {
  1282.     $guild_id = (int) $_REQUEST['guild'];
  1283.  
  1284.     $guild = new Guild();
  1285.     $guild->load($guild_id);
  1286.     if(!$guild->isLoaded())
  1287.         $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1288.     if(empty($guild_errors))
  1289.     {
  1290.         if($logged)
  1291.         {
  1292.             $guild_leader_char = $guild->getOwner();
  1293.             $guild_leader = FALSE;
  1294.             $account_players = $account_logged->getPlayers();
  1295.             foreach($account_players as $player)
  1296.                 if($guild_leader_char->getId() == $player->getId())
  1297.                 {
  1298.                     $guild_vice = TRUE;
  1299.                     $guild_leader = TRUE;
  1300.                     $level_in_guild = 3;
  1301.                 }
  1302.             if($guild_leader)
  1303.             {
  1304.                 $max_image_size_b = $config['site']['guild_image_size_kb'] * 1024;
  1305.                 if($_REQUEST['todo'] == 'save')
  1306.                 {
  1307.                     $file = $_FILES['newlogo'];
  1308.                     switch($file['error'])
  1309.                     {
  1310.                         case UPLOAD_ERR_OK:
  1311.                             break; // all ok
  1312.                         case UPLOAD_ERR_INI_SIZE:
  1313.                         case UPLOAD_ERR_FORM_SIZE:
  1314.                             $upload_errors[] = 'Image is too large';
  1315.                             break;
  1316.                         case UPLOAD_ERR_PARTIAL:
  1317.                             $upload_errors[] = 'Image was only partially uploaded';
  1318.                             break;
  1319.                         case UPLOAD_ERR_NO_FILE:
  1320.                             $upload_errors[] = 'No image was uploaded';
  1321.                             break;
  1322.                         case UPLOAD_ERR_NO_TMP_DIR:
  1323.                             $upload_errors[] = 'Upload folder not found';
  1324.                             break;
  1325.                         case UPLOAD_ERR_CANT_WRITE:
  1326.                             $upload_errors[] = 'Unable to write uploaded file';
  1327.                             break;
  1328.                         case UPLOAD_ERR_EXTENSION:
  1329.                             $upload_errors[] =  'Upload failed due to extension';
  1330.                             break;
  1331.                         default:
  1332.                             $upload_errors[] =  'Unknown error';
  1333.                     }
  1334.                     if(is_uploaded_file($file['tmp_name']))
  1335.                     {
  1336.                         if($file['size'] > $max_image_size_b)
  1337.                             $upload_errors[] = 'Uploaded image is too big. Size: <b>'.$file['size'].' bytes</b>, Max. size: <b>'.$max_image_size_b.' bytes</b>.';
  1338.                         $info = getimagesize($file['tmp_name']);
  1339.                         if(!$info)
  1340.                             $upload_errors[] = 'Uploaded file is not an image!';
  1341.                     }
  1342.                     else
  1343.                         $upload_errors[] = 'You didn\'t send file or file is too big. Limit: <b>'.$config['site']['guild_image_size_kb'].' KB</b>.';
  1344.                     //show errors or save file
  1345.                     if(!empty($upload_errors))
  1346.                     {
  1347.                         $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/>';
  1348.                         foreach($upload_errors as $guild_error)
  1349.                             $main_content .= '<li>'.$guild_error;
  1350.                         $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>';
  1351.                     }
  1352.                     else
  1353.                     {
  1354.                         $guild->setGuildLogo($info['mime'], file_get_contents($file['tmp_name']));
  1355.                         $guild->save();
  1356.                     }
  1357.                 }
  1358.                 $main_content .= '<center><h2>Change guild logo</h2></center>Here you can change logo of your guild.<BR>Current logo: <img src="' . $guild->getGuildLogoLink() . '" HEIGHT="64" WIDTH="64"><BR><BR>';
  1359.                 $main_content .= '<form enctype="multipart/form-data" action="?subtopic=guilds&guild='.$guild_id.'&action=changelogo" method="POST">
  1360.                 <input type="hidden" name="todo" value="save" />
  1361.                 <input type="hidden" name="MAX_FILE_SIZE" value="'.$max_image_size_b.'" />
  1362.                     Select new logo: <input name="newlogo" type="file" />
  1363.                     <input type="submit" value="Send new logo" /></form>Only <b>jpg, gif, png, bmp</b> pictures. Max. size: <b>'.$config['site']['guild_image_size_kb'].' KB</b><br>';
  1364.                 $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=manager" 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>';
  1365.             }
  1366.             else
  1367.                 $guild_errors[] = 'You are not a leader of guild!';
  1368.         }
  1369.         else
  1370.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1371.     }
  1372.     if(!empty($guild_errors))
  1373.     {
  1374.         $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/>';
  1375.         foreach($guild_errors as $guild_error)
  1376.             $main_content .= '<li>'.$guild_error.'</li>';
  1377.         $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>';
  1378.         $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>';
  1379.     }
  1380. }
  1381.  
  1382.  
  1383. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1384. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1385. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1386. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1387. if($action == 'deleterank')
  1388. {
  1389.     $guild_id = (int) $_REQUEST['guild'];
  1390.     $rank_to_delete = (int) $_REQUEST['rankid'];
  1391.     if(empty($guild_errors))
  1392.     {
  1393.         $guild = new Guild();
  1394.         $guild->load($guild_id);
  1395.         if(!$guild->isLoaded())
  1396.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1397.     }
  1398.     if(empty($guild_errors))
  1399.     {
  1400.         if($logged)
  1401.         {
  1402.             $guild_leader_char = $guild->getOwner();
  1403.             $rank_list = $guild->getGuildRanksList();
  1404.             $guild_leader = FALSE;
  1405.             $account_players = $account_logged->getPlayers();
  1406.             foreach($account_players as $player)
  1407.                 if($guild->getOwner()->getId() == $player->getId())
  1408.                 {
  1409.                     $guild_leader = TRUE;
  1410.                     $level_in_guild = 3;
  1411.                 }
  1412.             if($guild_leader)
  1413.             {
  1414.                 $rank = new GuildRank();
  1415.                 $rank->load($rank_to_delete);
  1416.                 if(!$rank->isLoaded())
  1417.                     $guild_errors2[] = 'Rank with ID '.$rank_to_delete.' doesn\'t exist.';
  1418.                 else
  1419.                 {
  1420.                     if($rank->getGuild()->getId() != $guild->getId())
  1421.                         $guild_errors2[] = 'Rank with ID '.$rank_to_delete.' isn\'t from your guild.';
  1422.                     else
  1423.                     {
  1424.                         if(count($rank_list) < 2)
  1425.                             $guild_errors2[] = 'You have only 1 rank in your guild. You can\'t delete this rank.';
  1426.                         else
  1427.                         {
  1428.                             $players_with_rank = $rank->getPlayersList();
  1429.                             $players_with_rank_number = count($players_with_rank);
  1430.                             if($players_with_rank_number > 0)
  1431.                             {
  1432.                                 foreach($rank_list as $checkrank)
  1433.                                     if($checkrank->getId() != $rank->getId())
  1434.                                         if($checkrank->getLevel() <= $rank->getLevel())
  1435.                                             $new_rank = $checkrank;
  1436.                                 if(empty($new_rank))
  1437.                                 {
  1438.                                     $new_rank = new GuildRank();
  1439.                                     $new_rank->setGuild($guild);
  1440.                                     $new_rank->setLevel($rank->getLevel());
  1441.                                     $new_rank->setName('New Rank level '.$rank->getLevel());
  1442.                                     $new_rank->save();
  1443.                                 }
  1444.                                 foreach($players_with_rank as $player_in_guild)
  1445.                                 {
  1446.                                     $player_in_guild->setRank($new_rank);
  1447.                                     $player_in_guild->save();
  1448.                                 }
  1449.                             }
  1450.                             $rank->delete();
  1451.                             $saved = TRUE;
  1452.                         }
  1453.                     }
  1454.                 }
  1455.                 if($saved)
  1456.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Rank Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>Rank <b>'.htmlspecialchars($rank->getName()).'</b> has been deleted. Players with this rank has now other rank.</td></tr>          </table>        </div>  </table></div></td></tr>';
  1457.                 else
  1458.                 {
  1459.                     $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/>';
  1460.                     foreach($guild_errors2 as $guild_error)
  1461.                         $main_content .= '<li>'.$guild_error.'</li>';
  1462.                     $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>';
  1463.                 }
  1464.                 //back button
  1465.                 $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=manager" 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>';
  1466.             }
  1467.             else
  1468.                 $guild_errors[] = 'You are not a leader of guild!';
  1469.         }
  1470.         else
  1471.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1472.     }
  1473.     if(!empty($guild_errors))
  1474.     {
  1475.         $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/>';
  1476.         foreach($guild_errors as $guild_error)
  1477.             $main_content .= '<li>'.$guild_error.'</li>';
  1478.         $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>';
  1479.         $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>';
  1480.     }
  1481. }
  1482. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1483. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1484. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1485. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1486. if($action == 'addrank')
  1487. {
  1488.     $guild_id = (int) $_REQUEST['guild'];
  1489.     $ranknew = $_REQUEST['rank_name'];
  1490.     if(empty($guild_errors))
  1491.     {
  1492.         if(!check_rank_name($ranknew))
  1493.             $guild_errors[] = 'Invalid rank name format.';
  1494.         if(!$logged)
  1495.             $guild_errors[] = 'You are not logged.';
  1496.         $guild = new Guild();
  1497.         $guild->load($guild_id);
  1498.         if(!$guild->isLoaded())
  1499.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1500.         if(empty($guild_errors))
  1501.         {
  1502.             $guild_leader_char = $guild->getOwner();
  1503.             $rank_list = $guild->getGuildRanksList();
  1504.             $guild_leader = FALSE;
  1505.             $account_players = $account_logged->getPlayers();
  1506.             foreach($account_players as $player)
  1507.                 if($guild_leader_char->getId() == $player->getId())
  1508.                 {
  1509.                     $guild_vice = TRUE;
  1510.                     $guild_leader = TRUE;
  1511.                     $level_in_guild = 3;
  1512.                 }
  1513.             if($guild_leader)
  1514.             {
  1515.                 $new_rank = new GuildRank();
  1516.                 $new_rank->setGuild($guild);
  1517.                 $new_rank->setLevel(1);
  1518.                 $new_rank->setName($ranknew);
  1519.                 $new_rank->save();
  1520.                 header("Location: ?subtopic=guilds&guild=".$guild_id."&action=manager");
  1521.                 $main_content .= 'New rank added. Redirecting...';
  1522.             }
  1523.             else
  1524.                 $guild_errors[] = 'You are not a leader of guild!';
  1525.         }
  1526.         if(!empty($guild_errors))
  1527.         {
  1528.             $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/>';
  1529.             foreach($guild_errors as $guild_error)
  1530.                 $main_content .= '<li>'.$guild_error;
  1531.             $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>';
  1532.             $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=show" 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>';
  1533.         }
  1534.     }
  1535.     else
  1536.         if(!empty($guild_errors))
  1537.         {
  1538.             $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/>';
  1539.             foreach($guild_errors as $guild_error)
  1540.                 $main_content .= '<li>'.$guild_error;
  1541.             $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>';
  1542.             $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>';
  1543.         }
  1544. }
  1545.  
  1546. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1547. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1548. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1549. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1550. if($action == 'changedescription')
  1551. {
  1552.     $guild_id = (int) $_REQUEST['guild'];
  1553.     if(empty($guild_errors))
  1554.     {
  1555.         $guild = new Guild();
  1556.         $guild->load($guild_id);
  1557.         if(!$guild->isLoaded())
  1558.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1559.     }
  1560.     if(empty($guild_errors))
  1561.     {
  1562.         if($logged)
  1563.         {
  1564.             $guild_leader_char = $guild->getOwner();
  1565.             $rank_list = $guild->getGuildRanksList();
  1566.             $guild_leader = FALSE;
  1567.             $account_players = $account_logged->getPlayers();
  1568.             foreach($account_players as $player)
  1569.                 if($guild->getOwner()->getId() == $player->getId())
  1570.                 {
  1571.                     $guild_vice = TRUE;
  1572.                     $guild_leader = TRUE;
  1573.                     $level_in_guild = 3;
  1574.                 }
  1575.             if($guild_leader)
  1576.             {
  1577.                 if($_REQUEST['todo'] == 'save')
  1578.                 {
  1579.                     $description = htmlspecialchars(substr(trim($_REQUEST['description']),0,$config['site']['guild_description_chars_limit']));
  1580.                     $guild->set('description', $description);
  1581.                     $guild->save();
  1582.                     $saved = TRUE;
  1583.                 }
  1584.                 $main_content .= '<center><h2>Change guild description</h2></center>';
  1585.                 if($saved)
  1586.                     $main_content .= '<center><font color="red" size="3"><b>CHANGES HAS BEEN SAVED!</b></font></center><br>';
  1587.                 $main_content .= 'Here you can change description of your guild.<BR>';
  1588.                 $main_content .= '<form enctype="multipart/form-data" action="?subtopic=guilds&guild='.$guild_id.'&action=changedescription" method="POST">
  1589.                 <input type="hidden" name="todo" value="save" />
  1590.                     <textarea name="description" cols="60" rows="'.($config['site']['guild_description_lines_limit'] - 1).'">'.$guild->getDescription().'</textarea><br>
  1591.                     (max. '.$config['site']['guild_description_lines_limit'].' lines, max. '.$config['site']['guild_description_chars_limit'].' chars) <input type="submit" value="Save description" /></form><br>';
  1592.                 $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=manager" 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>';
  1593.             }
  1594.             else
  1595.                 $guild_errors[] = 'You are not a leader of guild!';
  1596.         }
  1597.         else
  1598.         $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1599.     }
  1600.     if(!empty($guild_errors))
  1601.     {
  1602.         $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/>';
  1603.         foreach($guild_errors as $guild_error)
  1604.             $main_content .= '<li>'.$guild_error.'</li>';
  1605.         $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>';
  1606.         $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>';
  1607.     }
  1608. }
  1609.  
  1610. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1611. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1612. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1613. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1614. if($action == 'passleadership')
  1615. {
  1616.     $guild_id = (int) $_REQUEST['guild'];
  1617.     $pass_to = trim($_REQUEST['player']);
  1618.     if(empty($guild_errors))
  1619.     {
  1620.         $guild = new Guild();
  1621.         $guild->load($guild_id);
  1622.         if(!$guild->isLoaded())
  1623.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1624.     }
  1625.     if(empty($guild_errors))
  1626.     {
  1627.         if($_POST['todo'] == 'save')
  1628.         {
  1629.             if(!check_name($pass_to))
  1630.                 $guild_errors2[] = 'Invalid player name format.';
  1631.             if(empty($guild_errors2))
  1632.             {
  1633.                 $to_player = new Player();
  1634.                 $to_player->find($pass_to);
  1635.                 if(!$to_player->isLoaded())
  1636.                     $guild_errors2[] = 'Player with name <b>'.htmlspecialchars($pass_to).'</b> doesn\'t exist.';
  1637.                 if(empty($guild_errors2))
  1638.                 {
  1639.                     $to_player_rank = $to_player->getRank();
  1640.                     if(!empty($to_player_rank))
  1641.                     {
  1642.                         $to_player_guild = $to_player_rank->getGuild();
  1643.                         if($to_player_guild->getId() != $guild->getId())
  1644.                             $guild_errors2[] = 'Player with name <b>'.htmlspecialchars($to_player->getName()).'</b> isn\'t from your guild.';
  1645.                     }
  1646.                     else
  1647.                         $guild_errors2[] = 'Player with name <b>'.htmlspecialchars($to_player->getName()).'</b> isn\'t from your guild.';
  1648.                 }
  1649.             }
  1650.         }
  1651.     }
  1652.     if(empty($guild_errors) && empty($guild_errors2))
  1653.     {
  1654.         if($logged)
  1655.         {
  1656.             $guild_leader_char = $guild->getOwner();
  1657.             $guild_leader = FALSE;
  1658.             $account_players = $account_logged->getPlayers();
  1659.             foreach($account_players as $player)
  1660.                 if($guild_leader_char->getId() == $player->getId())
  1661.                 {
  1662.                     $guild_vice = TRUE;
  1663.                     $guild_leader = TRUE;
  1664.                     $level_in_guild = 3;
  1665.                 }
  1666.             if($guild_leader)
  1667.             {
  1668.                 if($_POST['todo'] == 'save')
  1669.                 {
  1670.                     $guild->setOwner($to_player);
  1671.                     $guild->save();
  1672.                     $saved = TRUE;
  1673.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td><b>'.htmlspecialchars($to_player->getName()).'</b> is now a Leader of <b>'.htmlspecialchars($guild->getName()).'</b>.</td></tr>          </table>        </div>  </table></div></td></tr><br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=show" 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>';
  1674.                 }
  1675.                 else
  1676.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>Pass leadership to: </b><br>
  1677.                     <form action="?subtopic=guilds&guild='.$guild_id.'&action=passleadership" METHOD=post><input type="hidden" name="todo" value="save"><input type="text" size="40" name="player"><input type="submit" value="Save"></form>
  1678.                     </td></tr>          </table>        </div>  </table></div></td></tr><br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=manager" 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>';
  1679.             }
  1680.             else
  1681.                 $guild_errors[] = 'You are not a leader of guild!';
  1682.         }
  1683.         else
  1684.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1685.     }
  1686.     if(empty($guild_errors) && !empty($guild_errors2))
  1687.     {
  1688.         $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/>';
  1689.         foreach($guild_errors2 as $guild_error2)
  1690.             $main_content .= '<li>'.$guild_error2;
  1691.         $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>';
  1692.         $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=passleadership" 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>';
  1693.     }
  1694.     if(!empty($guild_errors))
  1695.     {
  1696.         $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/>';
  1697.         foreach($guild_errors as $guild_error)
  1698.             $main_content .= '<li>'.$guild_error;
  1699.         if(!empty($guild_errors2))
  1700.             foreach($guild_errors2 as $guild_error2)
  1701.                 $main_content .= '<li>'.$guild_error2;
  1702.         $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><br/><center><form action="?subtopic=guilds&action=show&guild='.$guild_id.'" 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>';
  1703.     }
  1704. }
  1705. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1706. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1707. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1708. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1709. if($action == 'deleteguild')
  1710. {
  1711.     $guild_id = (int) $_REQUEST['guild'];
  1712.     if(empty($guild_errors))
  1713.     {
  1714.         $guild = new Guild();
  1715.         $guild->load($guild_id);
  1716.         if(!$guild->isLoaded())
  1717.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1718.     }
  1719.     if(empty($guild_errors))
  1720.     {
  1721.         if($logged)
  1722.         {
  1723.             $guild_leader_char = $guild->getOwner();
  1724.             $rank_list = $guild->getGuildRanksList();
  1725.             $guild_leader = FALSE;
  1726.             $account_players = $account_logged->getPlayers();
  1727.             foreach($account_players as $player)
  1728.                 if($guild->getOwner()->getId() == $player->getId())
  1729.                 {
  1730.                     $guild_vice = TRUE;
  1731.                     $guild_leader = TRUE;
  1732.                     $level_in_guild = 3;
  1733.                 }
  1734.             if($guild_leader)
  1735.             {
  1736.                 if($_POST['todo'] == 'save')
  1737.                 {
  1738.                     $guild->delete();
  1739.                     $saved = TRUE;
  1740.                 }
  1741.                 if($saved)
  1742.                 {
  1743.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/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>';
  1744.                     $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>';
  1745.                 }
  1746.                 else
  1747.                 {
  1748.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/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 with ID <b>'.$guild_id.'</b>?<br>
  1749.                     <form action="?subtopic=guilds&guild='.$guild_id.'&action=deleteguild" METHOD=post><input type="hidden" name="todo" value="save"><input type="submit" value="Yes, delete"></form>
  1750.                     </td></tr>          </table>        </div>  </table></div></td></tr>';
  1751.                     $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=manager" 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>';
  1752.                 }
  1753.             }
  1754.             else
  1755.                 $guild_errors[] = 'You are not a leader of guild!';
  1756.         }
  1757.         else
  1758.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1759.     }
  1760.     if(!empty($guild_errors))
  1761.     {
  1762.         $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/>';
  1763.         foreach($guild_errors as $guild_error)
  1764.             $main_content .= '<li>'.$guild_error.'</li>';
  1765.         $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>';
  1766.         $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>';
  1767.     }
  1768. }
  1769.  
  1770.  
  1771. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1772. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1773. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1774. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1775. if($action == 'deletebyadmin')
  1776. {
  1777.     $guild_id = (int) $_REQUEST['guild'];
  1778.     if(empty($guild_errors))
  1779.     {
  1780.         $guild = new Guild();
  1781.         $guild->load($guild_id);
  1782.         if(!$guild->isLoaded())
  1783.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1784.     }
  1785.     if(empty($guild_errors))
  1786.     {
  1787.         if($logged)
  1788.         {
  1789.             if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  1790.             {
  1791.                 if($_POST['todo'] == 'save')
  1792.                 {
  1793.                     $guild->delete();
  1794.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/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/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>';
  1795.                 }
  1796.                 else
  1797.                     $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/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Guild Deleted</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/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>
  1798.                     <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>
  1799.                     </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/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>';
  1800.             }
  1801.             else
  1802.                 $guild_errors[] = 'You are not an admin!';
  1803.         }
  1804.         else
  1805.             $guild_errors[] = 'You are not logged. You can\'t delete guild.';
  1806.     }
  1807.     if(!empty($guild_errors))
  1808.     {
  1809.         $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/>';
  1810.         foreach($guild_errors as $guild_error)
  1811.             $main_content .= '<li>'.$guild_error.'</li>';
  1812.         $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>';
  1813.         $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>';
  1814.     }
  1815. }
  1816.  
  1817. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1818. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1819. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1820. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1821. if($action == 'changemotd')
  1822. {
  1823.     $guild_id = (int) $_REQUEST['guild'];
  1824.     if(empty($guild_errors))
  1825.     {
  1826.         $guild = new Guild();
  1827.         $guild->load($guild_id);
  1828.         if(!$guild->isLoaded())
  1829.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1830.     }
  1831.     if(empty($guild_errors))
  1832.     {
  1833.         if($logged)
  1834.         {
  1835.             $guild_leader_char = $guild->getOwner();
  1836.             $rank_list = $guild->getGuildRanksList();
  1837.             $guild_leader = FALSE;
  1838.             $account_players = $account_logged->getPlayers();
  1839.             foreach($account_players as $player)
  1840.                 if($guild->getOwner()->getId() == $player->getId())
  1841.                 {
  1842.                     $guild_vice = TRUE;
  1843.                     $guild_leader = TRUE;
  1844.                     $level_in_guild = 3;
  1845.                 }
  1846.             if($guild_leader)
  1847.             {
  1848.                 if($_REQUEST['todo'] == 'save')
  1849.                 {
  1850.                     $motd = htmlspecialchars(substr(trim($_REQUEST['motd']),0,$config['site']['guild_motd_chars_limit']));
  1851.                     $guild->set('motd', $motd);
  1852.                     $guild->save();
  1853.                     $saved = TRUE;
  1854.                 }
  1855.                 $main_content .= '<center><h2>Change guild MOTD</h2></center>';
  1856.                 if($saved)
  1857.                     $main_content .= '<center><font color="red" size="3"><b>CHANGES HAS BEEN SAVED!</b></font></center><br>';
  1858.                 $main_content .= 'Here you can change MOTD (Message of the Day, showed in game!) of your guild.<BR>';
  1859.                 $main_content .= '<form enctype="multipart/form-data" action="?subtopic=guilds&guild='.$guild_id.'&action=changemotd" method="POST">
  1860.                 <input type="hidden" name="todo" value="save" />
  1861.                     <textarea name="motd" cols="60" rows="3">'.$guild->get('motd').'</textarea><br>
  1862.                     (max. '.$config['site']['guild_motd_chars_limit'].' chars) <input type="submit" value="Save MOTD" /></form><br>';
  1863.                 $main_content .= '<br/><center><form action="?subtopic=guilds&guild='.$guild_id.'&action=manager" 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>';
  1864.             }
  1865.             else
  1866.                 $guild_errors[] = 'You are not a leader of guild!';
  1867.         }
  1868.         else
  1869.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1870.     }
  1871.     if(!empty($guild_errors))
  1872.     {
  1873.         $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/>';
  1874.         foreach($guild_errors as $guild_error)
  1875.             $main_content .= '<li>'.$guild_error;
  1876.         $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>';
  1877.         $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>';
  1878.     }
  1879. }
  1880.  
  1881. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1882. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1883. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1884. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1885. if($action == 'saveranks')
  1886. {
  1887.     $guild_id = (int) $_REQUEST['guild'];
  1888.     if(empty($guild_errors))
  1889.     {
  1890.         $guild = new Guild();
  1891.         $guild->load($guild_id);
  1892.         if(!$guild->isLoaded())
  1893.             $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
  1894.     }
  1895.     if(empty($guild_errors))
  1896.     {
  1897.         if($logged)
  1898.         {
  1899.             $guild_leader_char = $guild->getOwner();
  1900.             $rank_list = $guild->getGuildRanksList();
  1901.             $guild_leader = FALSE;
  1902.             $account_players = $account_logged->getPlayers();
  1903.             foreach($account_players as $player)
  1904.                 if($guild_leader_char->getId() == $player->getId())
  1905.                 {
  1906.                     $guild_vice = TRUE;
  1907.                     $guild_leader = TRUE;
  1908.                     $level_in_guild = 3;
  1909.                 }
  1910.             if($guild_leader)
  1911.             {
  1912.                 foreach($rank_list as $rank)
  1913.                 {
  1914.                     $rank_id = $rank->getId();
  1915.                     $name = $_REQUEST[$rank_id.'_name'];
  1916.                     $level = (int) $_REQUEST[$rank_id.'_level'];
  1917.                     if(check_rank_name($name))
  1918.                         $rank->setName($name);
  1919.                     else
  1920.                         $ranks_errors[] = 'Invalid rank name. Please use only a-Z, 0-9 and spaces. Rank ID <b>'.$rank_id.'</b>.';
  1921.                     if($level > 0 && $level < 4)
  1922.                         $rank->setLevel($level);
  1923.                     else
  1924.                         $ranks_errors[] = 'Invalid rank level. Contact with admin. Rank ID <b>'.$rank_id.'</b>.';
  1925.                     $rank->save();
  1926.                 }
  1927.                 if(!empty($ranks_errors))
  1928.                 {
  1929.                     $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/>';
  1930.                     foreach($ranks_errors as $guild_error)
  1931.                         $main_content .= '<li>'.$guild_error.'</li>';
  1932.                     $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>';
  1933.                 }
  1934.                 else
  1935.                     header("Location: ?subtopic=guilds&action=manager&guild=".$guild_id);
  1936.             }
  1937.             else
  1938.                 $guild_errors[] = 'You are not a leader of guild!';
  1939.         }
  1940.         else
  1941.             $guild_errors[] = 'You are not logged. You can\'t manage guild.';
  1942.     }
  1943.     if(!empty($guild_errors)) {
  1944.     $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/>';
  1945.     foreach($guild_errors as $guild_error) {
  1946.         $main_content .= '<li>'.$guild_error.'</li>';
  1947.     }
  1948.     $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>';
  1949.     }
  1950. }
  1951. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1952. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1953. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1954. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  1955. if($action == 'cleanup_players')
  1956. {
  1957.     if($logged)
  1958.     {
  1959.         if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
  1960.         {
  1961.             $players_list = new DatabaseList('Player');
  1962.         }
  1963.         else
  1964.             $players_list = $account_logged->getPlayersList();
  1965.         if(count($players_list) > 0)
  1966.         {
  1967.             foreach($players_list as $player)
  1968.             {
  1969.                 $player_rank = $player->getRank();
  1970.                 if(!empty($player_rank))
  1971.                 {
  1972.                     if($player_rank->isLoaded())
  1973.                     {
  1974.                         $rank_guild = $player_rank->getGuild();
  1975.                         if(!$rank_guild->isLoaded())
  1976.                         {
  1977.                             $player->setRank();
  1978.                             $player->setGuildNick();
  1979.                             $player->save();
  1980.                             $changed_ranks_of[] = $player->getName();
  1981.                             $deleted_ranks[] = 'ID: '.$player_rank->getId().' - '.$player_rank->getName();
  1982.                             $player_rank->delete();
  1983.                         }
  1984.                     }
  1985.                     else
  1986.                     {
  1987.                         $player->setRank();
  1988.                         $player->setGuildNick('');
  1989.                         $player->save();
  1990.                         $changed_ranks_of[] = $player->getName();
  1991.                     }
  1992.                    
  1993.                 }
  1994.             }
  1995.             $main_content .= "<b>Deleted ranks (this ranks guilds doesn't exist [bug fix]):</b>";
  1996.             if(!empty($deleted_ranks))
  1997.                 foreach($deleted_ranks as $rank)
  1998.                     $main_content .= "<li>".htmlspecialchars($rank);
  1999.             $main_content .= "<BR /><BR /><b>Changed ranks of players (rank or guild of rank doesn't exist [bug fix]):</b>";
  2000.             if(!empty($changed_ranks_of))
  2001.                 foreach($changed_ranks_of as $name)
  2002.                     $main_content .= "<li>".htmlspecialchars($name);
  2003.         }
  2004.         else
  2005.             $main_content .= "0 players found.";
  2006.     }
  2007.     else
  2008.         $main_content .= "You are not logged in.";
  2009.     $main_content .= "<center><h3><a href=\"?subtopic=guilds\">BACK</a></h3></center>";
  2010. }
  2011. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  2012. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  2013. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  2014. //-----------------------------------------------------------------------------//-----------------------------------------------------------------------------
  2015.     if($action == 'change_nick')
  2016.     {
  2017.         if($logged)
  2018.         {
  2019.             $player_n = $_REQUEST['name'];
  2020.             $new_nick = $_REQUEST['nick'];
  2021.             $player = new Player();
  2022.             $player->find($player_n);
  2023.             $player_from_account = FALSE;
  2024.             if(strlen($new_nick) <= 30)
  2025.             {
  2026.                 if($player->isLoaded())
  2027.                 {
  2028.                     $account_players = $account_logged->getPlayersList();
  2029.                     if(count($account_players))
  2030.                     {
  2031.                         foreach($account_players as $acc_player)
  2032.                         {
  2033.                             if($acc_player->getId() == $player->getId())
  2034.                                 $player_from_account = TRUE;
  2035.                         }
  2036.                         if($player_from_account)
  2037.                         {
  2038.                             $player->setGuildNick($new_nick);
  2039.                             $player->save();
  2040.                             $main_content .= 'Guild nick of player <b>'.htmlspecialchars($player->getName()).'</b> changed to <b>'.htmlspecialchars($new_nick).'</b>.';
  2041.                             $addtolink = '&action=show&guild='.$player->getRank()->getGuild()->getId();
  2042.                         }
  2043.                         else
  2044.                             $main_content .= 'This player is not from your account.';
  2045.                     }
  2046.                     else
  2047.                         $main_content .= 'This player is not from your account.';
  2048.                 }
  2049.                 else
  2050.                     $main_content .= 'Unknow error occured.';
  2051.             }
  2052.             else
  2053.                 $main_content .= 'Too long guild nick. Max. 30 chars, your: '.strlen($new_nick);
  2054.         }
  2055.         else
  2056.             $main_content .= 'You are not logged.';
  2057.         $main_content .= '<center><h3><a href="?subtopic=guilds'.$addtolink.'">BACK</a></h3></center>';
  2058.     }
Add Comment
Please, Sign In to add comment