Share Pastebin
Guest
Public paste!

Untitled

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