Guest User

bug at guilds.php znote with war system when invite another

a guest
Apr 18th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.23 KB | None | 0 0
  1. <?php require_once 'engine/init.php';
  2. if ($config['require_login']['guilds']) protect_page();
  3. include 'layout/overall/header.php';
  4.  
  5. if (user_logged_in() === true) {
  6.    
  7.     // fetch data
  8.     $char_count = user_character_list_count($session_user_id);
  9.     $char_array = user_character_list($user_data['id']);
  10.    
  11.     $characters = array();
  12.     if ($char_array !== false) {
  13.         foreach ($char_array as $value) {
  14.             $characters[] = $value['name'];
  15.         }
  16.     }
  17. }
  18.  
  19. if (empty($_GET['name'])) {
  20. // Display the guild list
  21. ?>
  22.  
  23. <h1>Guild List:</h1>
  24. <?php
  25. $guilds = get_guilds_list();
  26. if ($guilds !== false) {
  27. ?>
  28. <table id="guildsTable" class="table table-striped table-hover">
  29.     <tr class="yellow">
  30.         <th>Guild name:</th>
  31.         <th>Members:</th>
  32.         <th>Founded:</th>
  33.     </tr>
  34.         <?php
  35.        
  36.  
  37.        
  38.         foreach ($guilds as $guild) {
  39.             $gcount = count_guild_members($guild['id']);
  40.             if ($gcount >= 1) {
  41.                 $url = url("guilds.php?name=". $guild['name']);
  42.                 echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">';
  43.                 echo '<td>'. $guild['name'] .'</td>';
  44.                 echo '<td>'. count_guild_members($guild['id']) .'</td>';
  45.                 echo '<td>'. getClock($guild['creationdata'], true) .'</td>';
  46.                 echo '</tr>';
  47.             }
  48.         }
  49.         ?>
  50. </table>
  51. <?php } else echo '<p>Guild list is empty.</p>';?>
  52. <!-- user stuff -->
  53. <?php
  54. if (user_logged_in() === true) {   
  55.     // post verifications
  56.     // CREATE GUILD
  57.     if (!empty($_POST['selected_char']) && !empty($_POST['guild_name'])) {
  58.         if (user_character_account_id($_POST['selected_char']) === $session_user_id) {
  59.             //code here
  60.             $name = sanitize($_POST['selected_char']);
  61.             $user_id = user_character_id($name);
  62.             if ($config['TFSVersion'] !== 'TFS_10') $char_data = user_character_data($user_id, 'level', 'online');
  63.             else {
  64.                 $char_data = user_character_data($user_id, 'level');
  65.                 $char_data['online'] = (user_is_online_10($user_id)) ? 1 : 0;
  66.             }
  67.            
  68.             // If character level is high enough
  69.             if ($char_data['level'] >= $config['create_guild_level']) {
  70.            
  71.                 // If character is offline
  72.                 if ($char_data['online'] == 0) {
  73.                     $acc_data = user_data($user_data['id'], 'premdays');
  74.                    
  75.                     // If character is premium
  76.                     if ($config['guild_require_premium'] == false || $acc_data['premdays'] > 0) {
  77.                    
  78.                         if (get_character_guild_rank($user_id) < 1) {
  79.                        
  80.                             if (preg_match("/^[a-zA-Z_ ]+$/", $_POST['guild_name'])) {
  81.                             // Only allow normal symbols as guild name
  82.                                
  83.                                 $guildname = sanitize($_POST['guild_name']);
  84.                                
  85.                                 $gid = get_guild_id($guildname);
  86.                                 if ($gid === false) {
  87.                                     create_guild($user_id, $guildname);
  88.                                     header('Location: success.php');
  89.                                     exit();
  90.                                 } else echo 'A guild with that name already exist.';
  91.                             } else echo 'Guild name may only contain a-z, A-Z and spaces.';
  92.                         } else echo 'You are already in a guild.';
  93.                     } else echo 'You need a premium account to create a guild.';
  94.                 } else echo 'Your character must be offline to create a guild.';
  95.             } else echo $name .' is level '. $char_data['level'] .'. But you need level '. $config['create_guild_level'] .'+ to create your own guild!';
  96.         }
  97.     }
  98.     // end 
  99.     ?>
  100.    
  101.    
  102.     <!-- FORMS TO CREATE GUILD-->
  103.     <form action="" method="post">
  104.         <ul>
  105.             <li>
  106.                 Create Guild:<br>
  107.                 <select name="selected_char">
  108.                 <?php
  109.                 for ($i = 0; $i < $char_count; $i++) {
  110.                     echo '<option value="'. $characters[$i] .'">'. $characters[$i] .'</option>';    
  111.                 }
  112.                 ?>
  113.                 </select>
  114.                 <input type="text" name="guild_name">
  115.                
  116.                 <input type="submit" value="Create Guild">
  117.             </li>
  118.         </ul>
  119.     </form>
  120.    
  121.     <?php
  122. } else echo 'You need to be logged in to create guilds.';
  123. ?>
  124. <!-- end user-->
  125.  
  126. <?php
  127. } else { // GUILD OVERVIEW
  128.     $gid = get_guild_id($_GET['name']);
  129.     if ($gid === false) {
  130.         header('Location: guilds.php');
  131.         exit();
  132.     }
  133.     $gcount = count_guild_members($gid);
  134.     if ($gcount < 1) {
  135.         header('Location: guilds.php');
  136.         exit();
  137.     }
  138.     $inv_data = guild_invite_list($gid);
  139.     $players = get_guild_players($gid);
  140.     $inv_count = 0;
  141.    
  142.     // Calculate invite count
  143.     if ($inv_data !== false) {
  144.         foreach ($inv_data as $inv) {
  145.             ++$inv_count;
  146.         }
  147.     }
  148.    
  149.     // calculate visitor access
  150.     if (user_logged_in() === true) {
  151.         // Get visitor access in this guild
  152.         $highest_access = 0;
  153.  
  154.         foreach ($players as $player) {
  155.             $rid = $player['rank_id'];
  156.            
  157.             for ($i = 0; $i < $char_count; $i++) {
  158.                 if ($config['TFSVersion'] !== 'TFS_10') $data = user_character_data(user_character_id($characters[$i]), 'rank_id');
  159.                 else $data = mysql_select_single("SELECT `rank_id` FROM `guild_membership` WHERE `player_id`='". user_character_id($characters[$i]) ."' LIMIT 1;");
  160.                 if ($data['rank_id'] == $rid) {
  161.                     $access = get_guild_position($data['rank_id']);
  162.                     if ($access == 2 || $access == 3) { //If player got access level vice leader or leader
  163.                         if ($access > $highest_access) $highest_access = $access;
  164.                     }
  165.                 }
  166.             }
  167.         }
  168.     }
  169.     // Display the specific guild page
  170. ?>
  171.  
  172. <h1>Guild: <?php echo sanitize($_GET['name']);
  173. ?> </h1>
  174. <table id="guildViewTable" class="table table-striped">
  175.     <tr class="yellow">
  176.         <th>Rank:</th>
  177.         <th>Name:</th>
  178.         <th>Level:</th>
  179.         <th>Vocation:</th>
  180.         <th>Status:</th>
  181.     </tr>
  182.         <?php
  183.         foreach ($players as $player) {
  184.             if ($config['TFSVersion'] !== 'TFS_10') $chardata = user_character_data(user_character_id($player['name']), 'online');
  185.             else $chardata['online'] = (user_is_online_10(user_character_id($player['name']))) ? 1 : 0;
  186.             echo '<tr>';
  187.             echo '<td>'. get_player_guild_rank($player['rank_id']) .'</td>';
  188.             echo '<td><a href="characterprofile.php?name='. $player['name'] .'">'. $player['name'] .'</a></td>';
  189.             echo '<td>'. $player['level'] .'</td>';
  190.             echo '<td>'. $config['vocations'][$player['vocation']] .'</td>';
  191.             if ($chardata['online'] == 1) echo '<td> <b><font color="green"> Online </font></b></td>';
  192.             else echo '<td> Offline </td>';
  193.             echo '</tr>';
  194.         }
  195.         ?>
  196. </table>
  197.  
  198. <?php if ($inv_count > 0) { ?>
  199. <h3>Invited characters</h3>
  200. <table>
  201.     <tr class="yellow">
  202.         <td>Name:</td>
  203.         <?php
  204.         if ($highest_access == 2 || $highest_access == 3) {
  205.             echo '<td>Remove:</td>';
  206.         }
  207.         // Shuffle through visitor characters
  208.         for ($i = 0; $i < $char_count; $i++) {
  209.             $exist = false;
  210.             // Shuffle through invited character, see if they match your character.
  211.             if ($inv_data !== false) foreach ($inv_data as $inv) {
  212.                 if (user_character_id($characters[$i]) == $inv['player_id']) {
  213.                     $exist = true;
  214.                 }
  215.             }
  216.             if ($exist) echo '<td>Join Guild:</td><td>Reject Invitation:</td>';
  217.         }
  218.         ?>
  219.     </tr>
  220.         <?php
  221.         $bool = false;
  222.         if ($inv_data !== false) foreach ($inv_data as $inv) {
  223.             $uninv = user_character_data($inv['player_id'], 'name');
  224.             echo '<tr>';
  225.             echo '<td>'. $uninv['name'] .'</td>';
  226.             // Remove invitation
  227.             if ($highest_access == 2 || $highest_access == 3) {
  228.             ?> <form action="" method="post"> <?php
  229.                 echo '<td>';
  230.                 echo '<input type="hidden" name="uninvite" value="' . $inv['player_id'] . '" />';
  231.                 echo '<input type="submit" value="Remove Invitation">';
  232.                 echo '</td>';
  233.             ?> </form> <?php
  234.             }
  235.             // Join Guild
  236.             ?> <form action="" method="post"> <?php
  237.                 for ($i = 0; $i < $char_count; $i++) {
  238.                     if (user_character_id($characters[$i]) == $inv['player_id']) {
  239.                         echo '<td>';
  240.                         echo '<input type="hidden" name="joinguild" value="' . $inv['player_id'] . '" />';
  241.                         echo '<input type="submit" value="Join Guild">';
  242.                         echo '</td>';
  243.                         $bool = true;
  244.                     }
  245.                 }
  246.                 if (isset($bool, $exist) && !$bool && $exist) {
  247.                     echo '<td></td>';
  248.                     $bool = false;
  249.                 }
  250.             ?> </form> <?php
  251.             // Reject invitation
  252.             ?> <form action="" method="post"> <?php
  253.                 for ($i = 0; $i < $char_count; $i++) {
  254.                     if (user_character_id($characters[$i]) == $inv['player_id']) {
  255.                         echo '<td>';
  256.                         echo '<input type="hidden" name="uninvite" value="' . $inv['player_id'] . '" />';
  257.                         echo '<input type="submit" value="Reject Invitation">';
  258.                         echo '</td>';
  259.                         $bool = true;
  260.                     }
  261.                 }
  262.                 if (isset($bool, $exist) && !$bool && $exist) {
  263.                     echo '<td></td>';
  264.                     $bool = false;
  265.                 }
  266.             ?> </form> <?php
  267.             echo '</tr>';
  268.         }
  269.         ?>
  270. </table>
  271. <?php } ?>
  272. <!-- Leader stuff -->
  273. <?php
  274. // Only guild leaders
  275. if (user_logged_in() === true) {
  276.    
  277.     // Uninvite and joinguild is also used for visitors who reject their invitation.
  278.     if (!empty($_POST['uninvite'])) {
  279.         //
  280.         guild_remove_invitation($_POST['uninvite'], $gid);
  281.         header('Location: guilds.php?name='. $_GET['name']);
  282.         exit();
  283.     }
  284.     if (!empty($_POST['joinguild'])) {
  285.         //
  286.         foreach ($inv_data as $inv) {
  287.             if ($inv['player_id'] == $_POST['joinguild']) {
  288.                 if ($config['TFSVersion'] !== 'TFS_10') $chardata = user_character_data($_POST['joinguild'], 'online');
  289.                 else $chardata['online'] = (user_is_online_10($_POST['joinguild'])) ? 1 : 0;
  290.                 if ($chardata['online'] == 0) {
  291.                     if (guild_player_join($_POST['joinguild'], $gid)) {
  292.                         header('Location: guilds.php?name='. $_GET['name']);
  293.                         exit();
  294.                     } else echo '<font color="red" size="4">Failed to find guild position representing member.</font>';
  295.                 } else echo '<font color="red" size="4">Character must be offline before joining guild.</font>';
  296.             }
  297.         }
  298.     }
  299.    
  300.     if (!empty($_POST['leave_guild'])) {
  301.         $name = sanitize($_POST['leave_guild']);
  302.         $cidd = user_character_id($name);
  303.         // If character is offline
  304.         if ($config['TFSVersion'] !== 'TFS_10') $chardata = user_character_data($cidd, 'online');
  305.         else $chardata['online'] = (user_is_online_10($cidd)) ? 1 : 0;
  306.         if ($chardata['online'] == 0) {
  307.             if ($config['TFSVersion'] !== 'TFS_10') guild_player_leave($cidd);
  308.             else guild_player_leave_10($cidd);
  309.             header('Location: guilds.php?name='. $_GET['name']);
  310.             exit();
  311.         } else echo '<font color="red" size="4">Character must be offline first!</font>';
  312.     }
  313.    
  314. if ($highest_access >= 2) {
  315.     // Guild leader stuff
  316.    
  317.     // Promote character to guild position
  318.     if (!empty($_POST['promote_character']) && !empty($_POST['promote_position'])) {
  319.         // Verify that promoted character is from this guild.
  320.         $p_rid = $_POST['promote_position'];
  321.         $p_cid = user_character_id($_POST['promote_character']);
  322.         $p_guild = get_player_guild_data($p_cid);
  323.        
  324.         if ($p_guild['guild_id'] == $gid) {
  325.             // Do the magic.
  326.             if ($config['TFSVersion'] !== 'TFS_10') $chardata = user_character_data($p_cid, 'online');
  327.             else $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0;
  328.             if ($chardata['online'] == 0) {
  329.                 if ($config['TFSVersion'] !== 'TFS_10') update_player_guild_position($p_cid, $p_rid);
  330.                 else update_player_guild_position_10($p_cid, $p_rid);
  331.                 header('Location: guilds.php?name='. $_GET['name']);
  332.                 exit();
  333.             } else echo '<font color="red" size="4">Character not offline.</font>';
  334.            
  335.         }
  336.     }
  337.     if (!empty($_POST['invite'])) {
  338.         if (user_character_exist($_POST['invite'])) {
  339.             //
  340.             $status = false;
  341.             if ($inv_data !== false) {
  342.                 foreach ($inv_data as $inv) {
  343.                     if ($inv['player_id'] == user_character_id($_POST['invite'])) $status = true;
  344.                 }
  345.             }
  346.             foreach ($players as $player) {
  347.                 if ($player['name'] == $_POST['invite']) $status = true;
  348.             }
  349.            
  350.             if ($status == false) {
  351.                 guild_invite_player(user_character_id($_POST['invite']), $gid);
  352.                 header('Location: guilds.php?name='. $_GET['name']);
  353.                 exit();
  354.             } else echo '<font color="red" size="4">That character is already invited(or a member) on this guild.</font>';
  355.         } else echo '<font color="red" size="4">That character name does not exist.</font>';
  356.     }
  357.    
  358.    
  359.     if (!empty($_POST['war_invite'])) {
  360.         $n = get_guild_id($_POST['war_invite']);
  361.         if (user_guild_exist($n)) {
  362.             $wars = mysql_select_multi("SELECT `id`, `guild1`, `guild2`, `status` FROM `guild_wars` WHERE (`guild1` = ".$gid." OR `guild1` = ".$n.") AND (`guild2` = ".get_guild_id($_GET['name'])." OR `guild2` = ".$n.") AND (`status` = 0 OR `status` = 1);");      
  363.             $status = false; $t = guild_war_invite_check($_GET['name']); $v = get_guild_name($gid);
  364.             if ($t !== false) {
  365.                 foreach ($t as $x) {
  366.                     if ($x['id'] == $n) $status = true;
  367.                 }
  368.             }
  369.            
  370.             foreach ($v as $k) {
  371.                 if ($k['name'] == $_POST['war_invite']) $status = true;
  372.             }
  373.                        
  374.             if ($wars == false && $status == false) {
  375.                 mysql_insert("INSERT INTO `guild_wars` (`guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended`) VALUES ('".$gid."', '".$n."', '".$_GET['name']."', '".$_POST['war_invite']."', '0', '".time()."', '0');");
  376.                 echo 'You have invited <a href="guilds.php?name='.$_POST['war_invite'].'">' .$_POST['war_invite'].'</a> to war.';
  377.             } else echo '<font color="red" size="4">This guild has already been invited to war(or you\'re trying to invite your own guild).</FONT>';
  378.         } else echo '<font color="red" size="4">That guild name does not exist.</font>';
  379.     }
  380.    
  381.     if (!empty($_POST['war_rdeclaration'])) {
  382.         guild_war_rdeclaration($_POST['war_rdeclaration'], $gid);
  383.         header('Location: guilds.php?name='. $_GET['name']);
  384.         exit();
  385.     }
  386.    
  387.     if (!empty($_POST['war_reject'])) {
  388.         guild_war_reject($_POST['war_reject'], $gid);
  389.         header('Location: guilds.php?name='. $_GET['name']);
  390.         exit();
  391.     }
  392.    
  393.     if (!empty($_POST['war_accept'])) {
  394.         guild_war_accept($_POST['war_accept'], $gid);
  395.         header('Location: guilds.php?name='. $_GET['name']);
  396.         exit();
  397.     }
  398.    
  399.     if (!empty($_POST['war_cancel'])) {
  400.         guild_war_cancel($_POST['war_cancel'], $gid);
  401.         header('Location: guilds.php?name='. $_GET['name']);
  402.         exit();
  403.     }
  404.        
  405.     if (!empty($_POST['disband'])) {
  406.         //
  407.         $gidd = (int)$_POST['disband'];
  408.         $members = get_guild_players($gidd);
  409.         $online = false;
  410.        
  411.         // First figure out if anyone are online.
  412.         foreach ($members as $member) {
  413.             if ($config['TFSVersion'] !== 'TFS_10') $chardata = user_character_data(user_character_id($member['name']), 'online');
  414.             else $chardata['online'] = (user_is_online_10(user_character_id($member['name']))) ? 1 : 0;
  415.             if ($chardata['online'] == 1) {
  416.                 $online = true;
  417.             }
  418.         }
  419.        
  420.         if (!$online) {
  421.             // Then remove guild rank from every player.
  422.             if ($config['TFSVersion'] !== 'TFS_10') foreach ($members as $member) guild_player_leave(user_character_id($member['name']));
  423.             else foreach ($members as $member) guild_player_leave_10(user_character_id($member['name']));
  424.            
  425.             // Remove all guild invitations to this guild
  426.             if ($inv_count > 0) guild_remove_invites($gidd);
  427.            
  428.             // Then remove the guild itself.
  429.             guild_delete($gidd);
  430.             header('Location: success.php');
  431.             exit();
  432.         } else echo '<font color="red" size="4">All members must be offline to disband the guild.</font>';
  433.     }
  434.    
  435.     if (!empty($_POST['new_leader'])) {
  436.         $new_leader = (int)$_POST['new_leader'];
  437.         $old_leader = guild_leader($gid);
  438.        
  439.         $online = false;
  440.         if ($config['TFSVersion'] !== 'TFS_10') {
  441.             $newData = user_character_data($new_leader, 'online');
  442.             $oldData = user_character_data($old_leader, 'online');
  443.         } else {
  444.             $newData['online'] = (user_is_online_10($new_leader)) ? 1 : 0;
  445.             $oldData['online'] = (user_is_online_10($old_leader)) ? 1 : 0;
  446.         }
  447.         if ($newData['online'] == 1 || $oldData['online'] == 1) $online = true;
  448.        
  449.         if ($online == false) {
  450.             if (guild_change_leader($new_leader, $old_leader)) {
  451.                 header('Location: guilds.php?name='. $_GET['name']);
  452.                 exit();
  453.             } else echo '<font color="red" size="4">Something went wrong when attempting to change leadership.</font>';
  454.         } else echo '<font color="red" size="4">The new and old leader must be offline to change leadership.</font>';
  455.     }
  456.    
  457.     if (!empty($_POST['change_ranks'])) {
  458.         $c_gid = (int)$_POST['change_ranks'];
  459.         $c_ranks = get_guild_rank_data($c_gid);
  460.         $rank_data = array();
  461.         $rank_ids = array();
  462.        
  463.         // Feed new rank data
  464.         foreach ($c_ranks as $rank) {
  465.             $tmp = 'rank_name!'. $rank['level'];
  466.             if (!empty($_POST[$tmp])) {
  467.                 $rank_data[$rank['level']] = sanitize($_POST[$tmp]);
  468.                 $rank_ids[$rank['level']] = $rank['id'];
  469.             }
  470.         }
  471.        
  472.         foreach ($rank_data as $level => $name) {
  473.             guild_change_rank($rank_ids[$level], $name);
  474.         }
  475.        
  476.         header('Location: guilds.php?name='. $_GET['name']);
  477.         exit();
  478.     }
  479.    
  480.     if (!empty($_POST['remove_member'])) {
  481.         $name = sanitize($_POST['remove_member']);
  482.         $cid = user_character_id($name);
  483.        
  484.         if ($config['TFSVersion'] !== 'TFS_10') guild_remove_member($cid);
  485.         else guild_remove_member_10($cid);
  486.         header('Location: guilds.php?name='. $_GET['name']);
  487.         exit();
  488.     }
  489.  
  490.     if (!empty($_POST['forumGuildId'])) {
  491.         if ($config['forum']['guildboard'] === true) {
  492.             $forumExist = mysql_select_single("SELECT `id` FROM `znote_forum` WHERE `guild_id`='$gid' LIMIT 1;");
  493.                 if ($forumExist === false) {
  494.                     // Insert data
  495.                     mysql_insert("INSERT INTO `znote_forum` (`name`, `access`, `closed`, `hidden`, `guild_id`)
  496.                         VALUES ('Guild',
  497.                             '1',
  498.                             '0',
  499.                             '0',
  500.                             '$gid');");
  501.                     echo '<h1>Guild board has been created.</h1>';
  502.                 } else echo '<h1>Guild board already exist.</h1>';
  503.            
  504.         } else {
  505.             echo '<h1>Error: Guild board system is disabled.</h1>';
  506.         }
  507.     }
  508.    
  509.     $members = count_guild_members($gid);
  510.     $ranks = get_guild_rank_data($gid);
  511.     ?>
  512.         <!-- Form to create guild -->
  513.         <?php
  514.             if ($config['forum']['guildboard'] === true && $config['forum']['enabled'] === true) {
  515.                 $forumExist = mysql_select_single("SELECT `id` FROM `znote_forum` WHERE `guild_id`='$gid' LIMIT 1;");
  516.                 if ($forumExist === false) {
  517.                     ?>
  518.                     <form action="" method="post">
  519.                         <ul>
  520.                             <li>Create forum guild board:<br>
  521.                             <input type="hidden" name="forumGuildId" value="<?php echo $gid; ?>">
  522.                             <input type="submit" value="Create Guild Board">
  523.                         </ul>
  524.                     </form>
  525.                     <?php
  526.                 }
  527.             }
  528.         ?>
  529.        
  530.         <!-- forms to invite character -->
  531.         <form action="" method="post">
  532.             <ul>
  533.                 <li>Invite Character to guild:<br>
  534.                     <input type="text" name="invite" placeholder="Character name">
  535.                     <input type="submit" value="Invite Character">
  536.                 </li>
  537.             </ul>
  538.         </form>
  539.         <?php if ($members > 1) { ?>
  540.         <!-- FORMS TO PROMOTE CHARACTER-->
  541.         <form action="" method="post">
  542.             <ul>
  543.                 <li>
  544.                     Promote Character:<br>
  545.                     <select name="promote_character">
  546.                     <?php
  547.                     //$gid = get_guild_id($_GET['name']);
  548.                     //$players = get_guild_players($gid);
  549.                     foreach ($players as $player) {
  550.                         $pl_data = get_player_guild_data(user_character_id($player['name']));
  551.                         if ($pl_data['rank_level'] != 3) {
  552.                             echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
  553.                         }  
  554.                     }
  555.                     ?>
  556.                     </select>
  557.                     <select name="promote_position">
  558.                         <?php
  559.                         foreach ($ranks as $rank) {
  560.                             if ($rank['level'] != 3) {
  561.                                 if ($rank['level'] != 2) {
  562.                                     echo '<option value="'. $rank['id'] .'">'. $rank['name'] .'</option>';
  563.                                 } else {
  564.                                     if ($highest_access == 3) {
  565.                                         echo '<option value="'. $rank['id'] .'">'. $rank['name'] .'</option>';
  566.                                     }
  567.                                 }
  568.                             }
  569.                         }
  570.                         ?>
  571.                     </select>
  572.                     <input type="submit" value="Promote Member">
  573.                 </li>
  574.             </ul>
  575.         </form>
  576.         <!-- Remove member from guild -->
  577.         <form action="" method="post">
  578.             <ul>
  579.                 <li>
  580.                     Kick member from guild:<br>
  581.                     <select name="remove_member">
  582.                     <?php
  583.                     //$gid = get_guild_id($_GET['name']);
  584.                     //$players = get_guild_players($gid);
  585.                     foreach ($players as $player) {
  586.                         $pl_data = get_player_guild_data(user_character_id($player['name']));
  587.                         if ($pl_data['rank_level'] != 3) {
  588.                             if ($pl_data['rank_level'] != 2) {
  589.                                 echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
  590.                             } else if ($highest_access == 3) echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
  591.                         }
  592.                     }
  593.                     ?>
  594.                     </select>
  595.                     <input type="submit" value="Remove member">
  596.                 </li>
  597.             </ul>
  598.         </form>
  599.         <?php } ?>
  600.         <br><br>
  601.         <?php if ($highest_access == 3) { ?>
  602.         <!-- forms to change rank titles -->
  603.         <form action="" method="post">
  604.             <ul>
  605.                 <li><b>Change rank titles:</b><br>
  606.                     <?php
  607.                         $rank_count = 1;
  608.                         foreach ($ranks as $rank) {
  609.                             echo '<input type="text" name="rank_name!'. $rank['level'] .'" value="'. $rank['name'] .'">';
  610.                         }
  611.                         echo '<input type="hidden" name="change_ranks" value="' . $gid . '" />';
  612.                     ?>
  613.                     <input type="submit" value="Update Ranks">
  614.                 </li>
  615.             </ul>
  616.         </form>
  617.         <!-- forms to disband guild -->
  618.         <form action="" method="post">
  619.             <ul>
  620.                 <li><b>DELETE GUILD (All members must be offline):</b><br>
  621.                     <?php echo '<input type="hidden" name="disband" value="' . $gid . '" />'; ?>
  622.                     <input type="submit" value="Disband Guild">
  623.                 </li>
  624.             </ul>
  625.         </form>
  626.         <!-- forms to change leadership-->
  627.         <?php if ($members > 1) { ?>
  628.         <form action="" method="post">
  629.             <ul>
  630.                 <li><b>Change Leadership with:</b><br>
  631.                     <select name="new_leader">
  632.                     <?php
  633.                     //$gid = get_guild_id($_GET['name']);
  634.                     //$players = get_guild_players($gid);
  635.                     foreach ($players as $player) {
  636.                         $pl_data = get_player_guild_data(user_character_id($player['name']));
  637.                         if ($pl_data['rank_level'] != 3) {
  638.                             echo '<option value="'. user_character_id($player['name']) .'">'. $player['name'] .'</option>';
  639.                         }
  640.                     }
  641.                     ?>
  642.                     </select>
  643.                     <input type="submit" value="Change Leadership">
  644.                 </li>
  645.             </ul>
  646.         </form>
  647.         <?php } ?>
  648. <?php if ($config['guildwar_enabled'] === true) { ?>
  649.             <h2>Guild War Management:</h2>
  650.         <!-- Invite guild to war -->
  651.         <form action="" method="post">
  652.             <ul>
  653.                 <li>Invite guild to war:<br>
  654.                     <input type="text" name="war_invite" placeholder="Guild name">
  655.                     <input type="submit" value="Invite Guild" class="btn btn-primary">
  656.                 </li>
  657.             </ul>
  658.         </form>
  659.        
  660. <!-- cancel war declaration -->
  661. <?php
  662. $t = mysql_select_multi("SELECT `id`, `guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended` FROM `guild_wars` WHERE `guild1` = '".$gid."' AND `status` = 0 ORDER BY `started` DESC");
  663. if (!empty($t)) {
  664.     echo '<h3>War declarations</h3><table id="guildsTable" class="table table-striped table-hover"><tr class="yellow"><th>#</th><th>Guild Name:</th><th>Remove Invitation</th></tr>';
  665.     $i = 0;
  666.         foreach($t as $v) {
  667.     $i++;
  668.         echo '<tr><td>'.$i.'</td><td><a href="guilds.php?name='.$v['name2'].'">'.$v['name2'].'</a></td><td><form action="" method="post" onsubmit="return confirm(\'Are you sure you want to cancel your invitation?\')";><input type="hidden" name="war_rdeclaration" value="'.$v['guild2'].'" /><input type="submit" value="Remove Invitation" class="btn btn-danger needconfirmation"></form></td></tr>';
  669.     }
  670. ?>
  671. </table>
  672. <?php } ?>
  673.  
  674. <!-- accept/reject invitation -->
  675.         <?php
  676. $t = mysql_select_multi("SELECT `id`, `guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended` FROM `guild_wars` WHERE `guild2` = '".$gid."' AND `status` = 0 ORDER BY `started` DESC");
  677. if (!empty($t)) {
  678.     echo '<h3>Pending invitations</h3><table id="guildsTable" class="table table-striped table-hover"><tr class="yellow"><th>#</th><th>Guild Name:</th><th>Accept Invitation</th><th>Reject Invitation</th></tr>';
  679.     $i = 0;
  680.         foreach($t as $v) {
  681.     $i++;
  682.         echo '<tr><td>'.$i.'</td><td><a href="guilds.php?name='.$v['name1'].'">'.$v['name1'].'</a></td><td><form action="" method="post"><input type="hidden" name="war_accept" value="'.$v['guild1'].'" /><input type="submit" value="Accept Invitation" class="btn btn-primary"></form></td><td><form action="" method="post" onsubmit="return confirm(\'Are you sure you want to reject this invitation?\')";><input type="hidden" name="war_reject" value="'.$v['guild1'].'" /><input type="submit" value="Reject Invitation" class="btn"></form></td></tr>';
  683.     }
  684. ?>
  685. </table>
  686. <?php } ?>
  687.  
  688. <!-- end war -->
  689. <?php
  690. $t = mysql_select_multi("SELECT `id`, `guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended` FROM `guild_wars` WHERE (`guild1` = ".$gid." OR `guild2` = ".$gid.") AND `status` = 1 ORDER BY `started` DESC");
  691. if (!empty($t)) {
  692.     echo '<h3>Active Guild Wars</h3><table id="guildsTable" class="table table-striped table-hover"><tr class="yellow"><th>#</th><th>Guild Name:</th><th>Cancel War</th></tr>';
  693.     $i = 0;
  694.         foreach($t as $v) {
  695.     $i++;
  696.     if ($v['guild1'] == $gid) {
  697.         echo '<tr><td>'.$i.'</td><td><a href="guilds.php?name='.$v['name2'].'">'.$v['name2'].'</a></td><td><form action="" method="post" onsubmit="return confirm(\'Are you sure you want to cancel this war?\')";><input type="hidden" name="war_cancel" value="'.$v['guild2'].'" /><input type="submit" value="Cancel War" class="btn btn-danger needconfirmation"></form></td></tr>';
  698.     } else echo '<tr><td>'.$i.'</td><td><a href="guilds.php?name='.$v['name1'].'">'.$v['name1'].'</a></td><td><form action="" method="post" onsubmit="return confirm(\'Are you sure you want to cancel this war?\')";><input type="hidden" name="war_cancel" value="'.$v['guild1'].'" /><input type="submit" value="Cancel War" class="btn btn-danger needconfirmation"></form></td></tr>';
  699.  
  700.  
  701. }
  702.  
  703. ?>
  704. </table>
  705. <?php } ?>
  706. <?php } } } ?>
  707. <!-- end leader-->
  708. <?php } ?>
  709. <?php
  710. if ($config['TFSVersion'] == 'TFS_02' || $config['TFSVersion'] == 'TFS_10') $wardata = get_guild_wars();
  711. else if ($config['TFSVersion'] == 'TFS_03') $wardata = get_guild_wars03();
  712. else die("Can't recognize TFS version. It has to be either TFS_02 or TFS_03. Correct this in config.php");
  713. $war_exist = false;
  714. if ($wardata !== false) {
  715.     foreach ($wardata as $wars) {
  716.         if ($wars['guild1'] == $gid || $wars['guild2'] == $gid) $war_exist = true;
  717.     }
  718. }
  719. if ($war_exist && $config['guildwar_enabled'] === true) {
  720. ?>
  721. <h2>War overview:</h2>
  722. <table>
  723.     <tr class="yellow">
  724.         <td>Attacker:</td>
  725.         <td>Defender:</td>
  726.         <td>status:</td>
  727.         <td>started:</td>
  728.     </tr>
  729.         <?php
  730.         foreach ($wardata as $wars) {
  731.             if ($wars['guild1'] == $gid || $wars['guild2'] == $gid) {
  732.                 $url = url("guildwar.php?warid=". $wars['id']);
  733.                 echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">';
  734.                 echo '<td>'. $wars['name1'] .'</td>';
  735.                 echo '<td>'. $wars['name2'] .'</td>';
  736.                 echo '<td>'. $config['war_status'][$wars['status']] .'</td>';
  737.                 echo '<td>'. getClock($wars['started'], true) .'</td>';
  738.                 echo '</tr>';
  739.             }
  740.         }
  741.         ?>
  742. </table>
  743. <?php } ?>
  744. <!-- leave guild with character -->
  745. <?php
  746. $bool = false;
  747. if (user_logged_in() === true) {
  748.     for ($i = 0; $i < $char_count; $i++) {
  749.         foreach ($players as $player) {
  750.             if ($player['name'] == $characters[$i]) $bool = true;
  751.         }
  752.     }
  753.     if ($bool) {
  754. $forumExist = mysql_select_single("SELECT `id` FROM `znote_forum` WHERE `guild_id`='$gid' LIMIT 1;");
  755. if ($forumExist !== false) {
  756.     ?> - <font size="4"><a href="forum.php?cat=<?php echo $forumExist['id']; ?>">Visit Guild Board</a></font><br><br><br><?php
  757. }
  758. ?>
  759.  
  760. <form action="" method="post">
  761.     <ul>
  762.         <li>
  763.             Leave Guild:<br>
  764.             <select name="leave_guild">
  765.                 <option disabled>With...</option>
  766.             <?php
  767.             for ($i = 0; $i < $char_count; $i++) {
  768.                 foreach ($players as $player) {
  769.                     if ($player['name'] == $characters[$i]) {
  770.                         $data = get_player_guild_data(user_character_id($player['name']));
  771.                         if ($data['rank_level'] != 3) echo '<option value="'. $characters[$i] .'">'. $characters[$i] .'</option>';
  772.                         else echo '<option disabled>'. $characters[$i] .' [disabled:Leader]</option>';
  773.                     }
  774.                 }
  775.             }
  776.             ?>
  777.             </select>
  778.             <input type="submit" value="Leave Guild">
  779.         </li>
  780.     </ul>
  781. </form>
  782. <?php
  783. } // display form if user has a character in guild
  784. } // user logged in
  785. } // if warname as $_GET
  786. include 'layout/overall/footer.php'; ?>
Add Comment
Please, Sign In to add comment