Guest User

guild.php

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