diff --git a/README.md b/README.md index a11e191..55e39c5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ ZnoteAAC ======== [![CodeFactor](https://www.codefactor.io/repository/github/znote/znoteaac/badge)](https://www.codefactor.io/repository/github/znote/znoteaac) +### Branch: v2 +The purpose of this branch is to server as code cleanup, and strip distro compatibility for anything below TFS 1.4. +I want to refactor some code, try to get Znote AAC a bit more lightweight. Remove single-use functions from globally included function files etc. + +New features and bugfixes might arrive here first, and then backported to 1.5/6 (master branch). + +--- + ### What is Znote AAC? Znote AAC is a full-fledged website used together with an Open Tibia(OT) server. diff --git a/engine/function/general.php b/engine/function/general.php index 76f090f..e89f322 100644 --- a/engine/function/general.php +++ b/engine/function/general.php @@ -422,10 +422,8 @@ function output_errors($errors) { return ''; } -// Resize images - +// Resize images and create image function resize_imagex($file, $width, $height) { - list($w, $h) = getimagesize($file['tmp']); $ratio = max($width/$w, $height/$h); @@ -443,7 +441,8 @@ function resize_imagex($file, $width, $height) { 0, 0, $x, 0, $width, $height, - $w, $h); + $w, $h + ); imagegif($tmp, $path); imagedestroy($image); @@ -452,71 +451,43 @@ function resize_imagex($file, $width, $height) { return true; } -// Guild logo upload security +// Validate guild logo function check_image($image) { + $image_data = array( + 'new_name' => $_GET['name'].'.gif', + 'name' => $image['name'], + 'tmp' => $image['tmp_name'], + 'error' => $image['error'], + 'size' => $image['size'], + 'type' => $image['type'] + ); - $image_data = array('new_name' => $_GET['name'].'.gif', 'name' => $image['name'], 'tmp' => $image['tmp_name'], 'error' => $image['error'], 'size' => $image['size'], 'type' => $image['type']); - - // First security check, quite useless but still do its job - if ($image_data['type'] === 'image/gif') { - - // Second security check, lets go - $check = getimagesize($image_data['tmp']); - - if ($check) { - - // Third - if ($check['mime'] === 'image/gif') { - - $path_info = pathinfo($image_data['name']); - - // Last one - if ($path_info['extension'] === 'gif') { - - // Resize image - $img = resize_imagex($image_data, 100, 100); - - if ($img) { - - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } - - } else { - - header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$path_info['extension'].'].&name='. $_GET['name']); - exit(); - } - - } else { - - header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$check['mime'].'].&name='. $_GET['name']); - exit(); - } - - } else { - - header('Location: guilds.php?error=Uploaded image is invalid.&name='. $_GET['name']); - exit(); - } - - } else { - + if ($image_data['type'] !== 'image/gif') { header('Location: guilds.php?error=Only gif images are accepted, you uploaded:['.$image_data['type'].'].&name='. $_GET['name']); exit(); } -} -// Check guild logo -function logo_exists($guild) { - $guild = sanitize($guild); - if (file_exists('engine/guildimg/'.$guild.'.gif')) { + $check = getimagesize($image_data['tmp']); + if (!$check) { + header('Location: guilds.php?error=Uploaded image is invalid.&name='. $_GET['name']); + exit(); + } - echo'engine/guildimg/'.$guild.'.gif'; - - } else { - - echo'engine/guildimg/default@logo.gif'; + if ($check['mime'] !== 'image/gif') { + header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$check['mime'].'].&name='. $_GET['name']); + exit(); + } + + $path_info = pathinfo($image_data['name']); + if ($path_info['extension'] !== 'gif') { + header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$path_info['extension'].'].&name='. $_GET['name']); + exit(); + } + + // Resize image + if (resize_imagex($image_data, 100, 100)) { + header('Location: guilds.php?name='. $_GET['name']); + exit(); } } diff --git a/engine/function/users.php b/engine/function/users.php index 39e62ed..6fe57c6 100644 --- a/engine/function/users.php +++ b/engine/function/users.php @@ -250,62 +250,6 @@ function guild_remove_member_10($cid) { mysql_update("DELETE FROM `guild_membership` WHERE `player_id`='$cid' LIMIT 1;"); } -// Change guild rank name. -function guild_change_rank($rid, $name) { - $rid = (int)$rid; - $name = sanitize($name); - - mysql_update("UPDATE `guild_ranks` SET `name`='$name' WHERE `id`=$rid"); -} - -// Change guild leader (parameters: cid, new and old leader). -function guild_change_leader($nCid, $oCid) { - $nCid = (int)$nCid; - $oCid = (int)$oCid; - $gid = guild_leader_gid($oCid); - $ranks = get_guild_rank_data($gid); - $leader_rid = 0; - $vice_rid = 0; - - - // Get rank id for leader and vice leader. - foreach ($ranks as $rank) { - if ($rank['level'] == 3) $leader_rid = $rank['id']; - if ($rank['level'] == 2) $vice_rid = $rank['id']; - } - - $status = false; - if ($leader_rid > 0 && $vice_rid > 0) $status = true; - - // Verify that we found the rank ids for vice leader and leader. - if ($status) { - - // Update players and set their new rank id - if (config('ServerEngine') !== 'TFS_10') { - mysql_update("UPDATE `players` SET `rank_id`='$leader_rid' WHERE `id`=$nCid LIMIT 1;"); - mysql_update("UPDATE `players` SET `rank_id`='$vice_rid' WHERE `id`=$oCid LIMIT 1;"); - } else { - mysql_update("UPDATE `guild_membership` SET `rank_id`='$leader_rid' WHERE `player_id`=$nCid LIMIT 1;"); - mysql_update("UPDATE `guild_membership` SET `rank_id`='$vice_rid' WHERE `player_id`=$oCid LIMIT 1;"); - } - - // Update guilds set new ownerid - guild_new_leader($nCid, $gid); - } - - return $status; -} - -// Changes leadership of aguild to player_id -function guild_new_leader($new_leader, $gid) { - $new_leader = (int)$new_leader; - $gid = (int)$gid; - if (config('ServerEngine') !== 'OTHIRE') - mysql_update("UPDATE `guilds` SET `ownerid`='$new_leader' WHERE `id`=$gid"); - else - mysql_update("UPDATE `guilds` SET `owner_id`='$new_leader' WHERE `id`=$gid"); -} - // Returns $gid of a guild leader($cid). function guild_leader_gid($leader) { $leader = (int)$leader; @@ -326,158 +270,12 @@ function guild_leader($gid) { return ($data !== false) ? $data['ownerid'] : false; } -// Disband guild -function guild_remove_invites($gid) { - $gid = (int)$gid; - mysql_delete("DELETE FROM `guild_invites` WHERE `guild_id`='$gid';"); -} - -// Remove guild invites -function guild_delete($gid) { - $gid = (int)$gid; - mysql_delete("DELETE FROM `guilds` WHERE `id`='$gid';"); -} - -// Player leave guild -function guild_player_leave($cid) { - $cid = (int)$cid; - mysql_update("UPDATE `players` SET `rank_id`='0', `guildnick`= NULL WHERE `id`=$cid LIMIT 1;"); -} -function guild_player_leave_10($cid) { - $cid = (int)$cid; - mysql_delete("DELETE FROM `guild_membership` WHERE `player_id`='$cid' LIMIT 1;"); -} - -// Player join guild -function guild_player_join($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - // Create a status we can return depending on results. - $status = false; - - if (config('ServerEngine') !== 'TFS_10') { - // Get rank data - $ranks = get_guild_rank_data($gid); - // Locate rank id for regular member position in this guild - $rid = false; - foreach ($ranks as $rank) { - if ($rank['level'] == 1) $rid = $rank['id']; - } - // Add to guild if rank id was found: - if ($rid != false) { - // Remove the invite: - //guild_remove_invitation($cid, $gid); - guild_remove_all_invitations($cid); - // Add to guild: - mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`=$cid"); - $status = true; - } - - } else { - // Find rank id for regular member in this guild - $guildrank = mysql_select_single("SELECT `id` FROM `guild_ranks` WHERE `guild_id`='$gid' AND `level`='1' LIMIT 1;"); - if ($guildrank !== false) { - $rid = $guildrank['id']; - // Remove invite - //guild_remove_invitation($cid, $gid); - guild_remove_all_invitations($cid); - // Add to guild - mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('$cid', '$gid', '$rid', '');"); - // Return success - return true; - } return false; - } - return $status; -} - -// Remove cid invitation from guild (gid) -function guild_remove_invitation($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid' AND `guild_id`='$gid';"); -} - -// Remove ALL invitations -function guild_remove_all_invitations($cid) { - $cid = (int)$cid; - mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid';"); -} - -// Invite character to guild -function guild_invite_player($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - mysql_insert("INSERT INTO `guild_invites` (`player_id`, `guild_id`) VALUES ('$cid', '$gid')"); -} - // Gets a list of invited players to a particular guild. function guild_invite_list($gid) { $gid = (int)$gid; return mysql_select_multi("SELECT `gi`.`player_id`, `gi`.`guild_id`, `p`.`name` FROM `guild_invites` AS `gi` INNER JOIN `players` AS `p` ON `gi`.`player_id`=`p`.`id` WHERE `gi`.`guild_id`='$gid';"); } -// Update player's guild position -function update_player_guild_position($cid, $rid) { - $cid = (int)$cid; - $rid = (int)$rid; - mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`=$cid"); -} -function update_player_guild_position_10($cid, $rid) { - $cid = (int)$cid; - $rid = (int)$rid; - mysql_update("UPDATE `guild_membership` SET `rank_id`='$rid' WHERE `player_id`=$cid"); -} - -// Update player's guild nick -function update_player_guildnick($cid, $nick) { - $cid = (int)$cid; - $nick = sanitize($nick); - if (!empty($nick)) { - mysql_update("UPDATE `players` SET `guildnick`='$nick' WHERE `id`=$cid"); - } else { - mysql_update("UPDATE `players` SET `guildnick`='' WHERE `id`=$cid"); - } -} -function update_player_guildnick_10($cid, $nick) { - $cid = (int)$cid; - $nick = sanitize($nick); - if (!empty($nick)) { - mysql_update("UPDATE `guild_membership` SET `nick`='$nick' WHERE `player_id`=$cid"); - } else { - mysql_update("UPDATE `guild_membership` SET `nick`='' WHERE `player_id`=$cid"); - } -} - -// Get guild data, using guild id. -function get_guild_rank_data($gid) { - $gid = (int)$gid; - return mysql_select_multi("SELECT `id`, `guild_id`, `name`, `level` FROM `guild_ranks` WHERE `guild_id`='$gid' ORDER BY `id` DESC LIMIT 0, 30"); -} - -// Creates a guild, where cid is the owner of the guild, and name is the name of guild. -function create_guild($cid, $name) { - $cid = (int)$cid; - $name = sanitize($name); - $time = time(); - - // Create the guild - if (config('ServerEngine') !== 'OTHIRE') - mysql_insert("INSERT INTO `guilds` (`name`, `ownerid`, `creationdata`, `motd`) VALUES ('$name', '$cid', '$time', '');"); - else - mysql_insert("INSERT INTO `guilds` (`name`, `owner_id`, `creationdate`) VALUES ('$name', '$cid', '$time');"); - - // Get guild id - $gid = get_guild_id($name); - - // Get rank id for guild leader - $data = mysql_select_single("SELECT `id` FROM `guild_ranks` WHERE `guild_id`='$gid' AND `level`='3' LIMIT 1;"); - $rid = ($data !== false) ? $data['id'] : false; - - // Give player rank id for leader of his guild - if (config('ServerEngine') !== 'TFS_10') mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`='$cid' LIMIT 1;"); - else mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('$cid', '$gid', '$rid', '');"); -} - // Search player table on cid for his rank_id, returns rank_id function get_character_guild_rank($cid) { $cid = (int)$cid; @@ -497,13 +295,6 @@ function get_player_guild_rank($rank_id) { return ($data !== false) ? $data['name'] : false; } -// Get a player guild position ID, using his rank_id -function get_guild_position($rid) { - $rid = (int)$rid; - $data = mysql_select_single("SELECT `level` FROM `guild_ranks` WHERE `id`=$rid;"); - return ($data !== false) ? $data['level'] : false; -} - // Get a players rank_id, guild_id, rank_level(ID), rank_name(string), using cid(player id) function get_player_guild_data($cid) { $cid = (int)$cid; @@ -522,7 +313,7 @@ function get_player_guild_data($cid) { // Returns guild name of guild id function get_guild_name($gid) { $gid = (int)$gid; - $guild = mysql_select_single("SELECT `name` FROM `guilds` WHERE `id`=$gid LIMIT 1;"); + $guild = mysql_select_single("SELECT `name` FROM `guilds` WHERE `id`={$gid} LIMIT 1;"); if ($guild !== false) return $guild['name']; else return false; } @@ -530,7 +321,7 @@ function get_guild_name($gid) { // Returns guild id from name function get_guild_id($name) { $name = sanitize($name); - $data = mysql_select_single("SELECT `id` FROM `guilds` WHERE `name`='$name';"); + $data = mysql_select_single("SELECT `id` FROM `guilds` WHERE `name`='{$name}';"); return ($data !== false) ? $data['id'] : false; } @@ -573,18 +364,6 @@ function get_guild_level_data($gid) { } else return false; } -// Returns total members in a guild (integer) -function count_guild_members($gid) { - $gid = (int)$gid; - if (config('ServerEngine') !== 'TFS_10') { - $data = mysql_select_single("SELECT COUNT(p.id) AS total FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id WHERE gr.guild_id =$gid"); - return ($data !== false) ? $data['total'] : false; - } else { - $data = mysql_select_single("SELECT COUNT('guild_id') AS `total` FROM `guild_membership` WHERE `guild_id`='$gid';"); - return ($data !== false) ? $data['total'] : false; - } -} - // // GUILD WAR // @@ -1736,33 +1515,4 @@ function user_logged_in() { return (getSession('user_id') !== false) ? true : false; } -function guild_war_invitation($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - $gname = get_guild_name($cid); - $ename = get_guild_name($gid); - $time = time(); - mysql_insert("INSERT INTO `guild_wars` (`guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended`) VALUES ('$cid', '$gid', '$gname', '$ename', '0', '$time', '0');"); -} - -function accept_war_invitation($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - mysql_update("UPDATE `guild_wars` SET `status` = 1 WHERE `guild1` = '$cid' AND `guild2` = '$gid' AND `status` = 0;"); -} - -function reject_war_invitation($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - $time = time(); - mysql_update("UPDATE `guild_wars` SET `status` = 2, `ended` = '$time' WHERE `guild1` = '$cid' AND `guild2` = '$gid';"); -} - -function cancel_war_invitation($cid, $gid) { - $cid = (int)$cid; - $gid = (int)$gid; - $time = time(); - mysql_update("UPDATE `guild_wars` SET `status` = 3, `ended` = '$time' WHERE `guild2` = '$cid' AND `guild1` = '$gid';"); -} - ?> diff --git a/guilds.php b/guilds.php index db89818..bfaba4b 100644 --- a/guilds.php +++ b/guilds.php @@ -1,17 +1,24 @@ hasExpired()) { - if ($TFSVersion != 'TFS_10') - if ($TFSVersion === 'OTHIRE') - $guilds = mysql_select_multi("SELECT `t`.`id`, `t`.`name`, `t`.`creationdate`, (SELECT count(p.rank_id) FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id WHERE gr.guild_id =`t`.`id`) AS `total` FROM `guilds` as `t` ORDER BY `t`.`name`;"); - else - $guilds = mysql_select_multi("SELECT `t`.`id`, `t`.`name`, `t`.`creationdata`, `motd`, (SELECT count(p.rank_id) FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id WHERE gr.guild_id =`t`.`id`) AS `total` FROM `guilds` as `t` ORDER BY `t`.`name`;"); - else - $guilds = mysql_select_multi("SELECT `id`, `name`, `creationdata`, `motd`, (SELECT COUNT('guild_id') FROM `guild_membership` WHERE `guild_id`=`id`) AS `total` FROM `guilds` ORDER BY `name`;"); + $guilds = mysql_select_multi(" + SELECT + `id`, + `name`, + `creationdata`, + `motd`, + ( SELECT + COUNT('guild_id') + FROM `guild_membership` + WHERE `guild_id`=`id` + ) AS `total` + FROM `guilds` + ORDER BY `name`; + "); // Add level data info to guilds if ($guilds !== false) @@ -26,10 +33,195 @@ function guild_list($TFSVersion) { return $guilds; } +function get_guild_position($rid) { + $rid = (int)$rid; + $data = mysql_select_single("SELECT `level` FROM `guild_ranks` WHERE `id`={$rid};"); + return ($data !== false) ? $data['level'] : false; +} + +// Check guild logo +function logo_exists($guild) { + $guild = sanitize($guild); + echo (file_exists('engine/guildimg/'.$guild.'.gif')) ? 'engine/guildimg/'.$guild.'.gif' : 'engine/guildimg/default@logo.gif'; +} + +// Remove cid invitation from guild (gid) +function guild_remove_invitation($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + mysql_delete(" + DELETE FROM `guild_invites` + WHERE `player_id`='{$cid}' + AND `guild_id`='{$gid}' + ;"); +} + +function update_player_guildnick_10($cid, $nick) { + $cid = (int)$cid; + $nick = sanitize($nick); + mysql_update("UPDATE `guild_membership` SET `nick`='{$nick}' WHERE `player_id`={$cid}"); +} + +function guild_player_join($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + + // Find rank id for regular member in this guild + $guildrank = mysql_select_single(" + SELECT `id` + FROM `guild_ranks` + WHERE `guild_id`='{$gid}' + AND `level`='1' LIMIT 1; + "); + + if ($guildrank !== false) { + $rid = $guildrank['id']; + // Remove invite + mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='{$cid}';"); + // Add to guild + mysql_insert(" + INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) + VALUES ('{$cid}', '{$gid}', '{$rid}', '') + ;"); + // Return success + return true; + } + + return false; +} + +function guild_player_leave_10($cid) { + $cid = (int)$cid; + mysql_delete("DELETE FROM `guild_membership` WHERE `player_id`='{$cid}' LIMIT 1;"); +} + +function update_player_guild_position_10($cid, $rid) { + $cid = (int)$cid; + $rid = (int)$rid; + mysql_update("UPDATE `guild_membership` SET `rank_id`='{$rid}' WHERE `player_id`={$cid}"); +} + +function guild_invite_player($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + mysql_insert("INSERT INTO `guild_invites` (`player_id`, `guild_id`) VALUES ('{$cid}', '{$gid}')"); +} + +function guild_remove_invites($gid) { + $gid = (int)$gid; + mysql_delete("DELETE FROM `guild_invites` WHERE `guild_id`='{$gid}';"); +} + +function guild_delete($gid) { + $gid = (int)$gid; + mysql_delete("DELETE FROM `guilds` WHERE `id`='{$gid}';"); +} + +// Get guild data, using guild id. +function get_guild_rank_data($gid) { + $gid = (int)$gid; + return mysql_select_multi("SELECT `id`, `guild_id`, `name`, `level` FROM `guild_ranks` WHERE `guild_id`='{$gid}' ORDER BY `id` DESC LIMIT 0, 30"); +} + +// Changes leadership of a guild to player_id +function guild_new_leader($new_leader, $gid) { + $new_leader = (int)$new_leader; + $gid = (int)$gid; + mysql_update("UPDATE `guilds` SET `ownerid`='{$new_leader}' WHERE `id`={$gid}"); +} + +// Change guild leader (parameters: cid, new and old leader). +function guild_change_leader($nCid, $oCid) { + $nCid = (int)$nCid; + $oCid = (int)$oCid; + $gid = guild_leader_gid($oCid); + $ranks = get_guild_rank_data($gid); + $leader_rid = 0; + $vice_rid = 0; + + // Get rank id for leader and vice leader. + foreach ($ranks as $rank) { + if ($rank['level'] == 3) $leader_rid = $rank['id']; + if ($rank['level'] == 2) $vice_rid = $rank['id']; + } + + $status = ($leader_rid > 0 && $vice_rid > 0) ? true : false; + + if ($status) { + // Update players and set their new rank id + mysql_update("UPDATE `guild_membership` SET `rank_id`='{$leader_rid}' WHERE `player_id`={$nCid} LIMIT 1;"); + mysql_update("UPDATE `guild_membership` SET `rank_id`='{$vice_rid}' WHERE `player_id`={$oCid} LIMIT 1;"); + + // Update guilds set new ownerid + guild_new_leader($nCid, $gid); + } + + return $status; +} + +// Creates a guild, where cid is the owner of the guild, and name is the name of guild. +function create_guild($cid, $name) { + $cid = (int)$cid; + $name = sanitize($name); + $time = time(); + + // Create the guild + mysql_insert("INSERT INTO `guilds` (`name`, `ownerid`, `creationdata`, `motd`) VALUES ('{$name}', '{$cid}', '{$time}', '');"); + + // Get guild id + $gid = get_guild_id($name); + + // Get rank id for guild leader + $data = mysql_select_single("SELECT `id` FROM `guild_ranks` WHERE `guild_id`='{$gid}' AND `level`='3' LIMIT 1;"); + $rid = ($data !== false) ? $data['id'] : false; + + // Give player rank id for leader of his guild + mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('{$cid}', '{$gid}', '{$rid}', '');"); +} + +// Returns total members in a guild (integer) +function count_guild_members($gid) { + $gid = (int)$gid; + $data = mysql_select_single("SELECT COUNT('guild_id') AS `total` FROM `guild_membership` WHERE `guild_id`='{$gid}';"); + return ($data !== false) ? $data['total'] : false; +} + +// Guildwar functions +function guild_war_invitation($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + $gname = get_guild_name($cid); + $ename = get_guild_name($gid); + $time = time(); + mysql_insert(" + INSERT INTO `guild_wars` (`guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended`) + VALUES ('{$cid}', '{$gid}', '{$gname}', '{$ename}', '0', '{$time}', '0') + ;"); +} + +function accept_war_invitation($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + mysql_update("UPDATE `guild_wars` SET `status` = 1 WHERE `guild1` = '{$cid}' AND `guild2` = '{$gid}' AND `status` = 0;"); +} + +function reject_war_invitation($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + $time = time(); + mysql_update("UPDATE `guild_wars` SET `status` = 2, `ended` = '{$time}' WHERE `guild1` = '{$cid}' AND `guild2` = '{$gid}';"); +} + +function cancel_war_invitation($cid, $gid) { + $cid = (int)$cid; + $gid = (int)$gid; + $time = time(); + mysql_update("UPDATE `guild_wars` SET `status` = 3, `ended` = '{$time}' WHERE `guild2` = '{$cid}' AND `guild1` = '{$gid}';"); +} + include 'layout/overall/header.php'; if (user_logged_in() === true) { - // fetch data $char_count = user_character_list_count($session_user_id); $char_array = user_character_list($user_data['id']); @@ -47,64 +239,69 @@ if (user_logged_in() === true) { $char_count = 0; } -if (empty($_GET['name'])) { // Display the guild list - +if (empty($_GET['name'])) { //data_dump($guild, false, "guild data"); - $guilds = guild_list($config['ServerEngine']); if (isset($guilds) && !empty($guilds) && $guilds !== false) { //data_dump($guilds, false, "Guilds"); -?> - - - - - - - - = 1) { - $url = url("guilds.php?name=". $guild['name']); - ?> - - - - - - '. getClock($guild['creationdata'], true) .''; - } + ?> + +
LogoDescriptionGuild data
- - - - 0) echo '
'.$guild['motd']; ?> -
- -
-
-
+ + + + + + = 1) { + $url = url("guilds.php?name=". $guild['name']); + ?> + + + + + + '. getClock($guild['creationdata'], true) .''; + } + } + ?> +
LogoDescriptionGuild data
+ + + + 0) echo '
'.$guild['motd']; ?> +
+ +
+
+
+ Guild list is empty.

';?> + + = $config['create_guild_level']) { @@ -156,7 +353,6 @@ if (user_logged_in() === true) { ?> - @@ -203,6 +399,7 @@ if (user_logged_in() === true) { $playerRank = $charactersRank[$i]; if ($playerRank == $rid) { + // Get a player guild position ID, using his rank_id $access = get_guild_position($playerRank); if ($access == 2 || $access == 3) { //If player got access level vice leader or leader if ($access > $highest_access) $highest_access = $access; @@ -213,432 +410,449 @@ if (user_logged_in() === true) { } } // Display the specific guild page -?> + ?> -
- ".sanitize($_GET['error'])."

" : ""; ?> - -
- + +
+ ".sanitize($_GET['error'])."

"; + + if ($config['use_guild_logos']): ?> +
+ +
+ +
+

Guild:

+

+
- -
-

Guild:

-

-
-
- - - - - - - - - +
Rank:Name:Level:Vocation:Status:
+ + + + + + + + '; - echo ''; - $rankName = $player['rank_name']; - echo ''; - echo ''; - echo ''; - if ($chardata['online'] == 1) echo ''; - else echo ''; - echo ''; - } - ?> -
Rank:Name:Level:Vocation:Status:
' . ($rankName !== $player['rank_name'] ? $player['rank_name'] : '') . ''. $player['name'] .''; - if (!empty($player['guildnick'])) { - echo ' ('. $player['guildnick'] .')'; - } - echo ''. $player['level'] .''. $config['vocations'][$player['vocation']]['name'] .' Online Offline
- - 0) { ?> -

Invited characters

- - - - Remove:'; - } - // Shuffle through visitor characters - for ($i = 0; $i < $char_count; $i++) { - $exist = false; - // Shuffle through invited character, see if they match your character. - if ($inv_data !== false) foreach ($inv_data as $inv) { - if ($charactersId[$i] == $inv['player_id']) { - $exist = true; + //data_dump($players, false, "Data"); + $rankName = ''; + foreach ($players as $player) { + $chardata['online'] = (in_array($player['id'], $onlinelist)) ? 1 : 0; + echo ''; + echo ''; + $rankName = $player['rank_name']; + echo ''; - } - ?> - - '; - echo ''; - // Remove invitation - if ($highest_access == 2 || $highest_access == 3) { - ?> '; - echo ''; - echo ''; echo ''; - ?> '. $player['level'] .''; + echo ''; + if ($chardata['online'] == 1) echo ''; + else echo ''; + echo ''; } - // Join Guild - ?> +
Name:
' . ($rankName !== $player['rank_name'] ? $player['rank_name'] : '') . ''. $player['name'] .''; + if (!empty($player['guildnick'])) { + echo ' ('. $player['guildnick'] .')'; } - } - if ($exist) echo 'Join Guild:Reject Invitation:
'. $inv['name'] .'
'. $config['vocations'][$player['vocation']]['name'] .' Online Offline
+ + 0): ?> +

Invited characters

+ + + + Remove:'; + } + // Shuffle through visitor characters for ($i = 0; $i < $char_count; $i++) { - if ($charactersId[$i] == $inv['player_id']) { - echo ''; - $bool = true; + $exist = false; + // Shuffle through invited character, see if they match your character. + if ($inv_data !== false) foreach ($inv_data as $inv) { + if ($charactersId[$i] == $inv['player_id']) { + $exist = true; + } } + if ($exist) echo ''; } - if (isset($bool, $exist) && !$bool && $exist) { - echo ''; - $bool = false; - } - ?> + + '; + echo ''; + // Remove invitation + if ($highest_access == 2 || $highest_access == 3) { + ?> '; echo ''; - echo ''; + echo ''; echo ''; - $bool = true; + ?> '; + echo ''; + echo ''; + echo ''; + $bool = true; + } + } + if (isset($bool, $exist) && !$bool && $exist) { + echo ''; + $bool = false; + } + ?> '; + echo ''; + echo ''; + echo ''; + $bool = true; + } + } + if (isset($bool, $exist) && !$bool && $exist) { + echo ''; + $bool = false; + } + ?> '; } - if (isset($bool, $exist) && !$bool && $exist) { - echo ''; - $bool = false; - } - ?> '; - } - ?> -
Name:'; - echo ''; - echo ''; - echo 'Join Guild:Reject Invitation:
'. $inv['name'] .'
- - - + + - // Uninvite and joinguild is also used for visitors who reject their invitation. - if (!empty($_POST['uninvite'])) { - // - guild_remove_invitation($_POST['uninvite'], $gid); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } - if (!empty($_POST['joinguild'])) { - $joining_player_id = (int)$_POST['joinguild']; - // Join a guild - if ($inv_data !== false) foreach ($inv_data as $inv) { - if ((int)$inv['player_id'] == $joining_player_id) { - if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($joining_player_id, 'online'); - else $chardata['online'] = (user_is_online_10($joining_player_id)) ? 1 : 0; - if ($chardata['online'] == 0) { - // Ensure player is not already a member of another guild - if (get_character_guild_rank($joining_player_id) === false) { - if (guild_player_join($joining_player_id, (int)$gid)) { - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } else echo 'Failed to find guild position representing member.'; - } else { - $already_guild = get_player_guild_data($joining_player_id); - $already_guild_name = get_guild_name($already_guild['guild_id']); - echo "You are already {$already_guild['rank_name']} of another guild: {$already_guild_name}.
You need to leave that guild first before you can join another one.
"; - } - } else echo 'Character must be offline before joining guild.'; - } - } - } + + Character must be offline first!'; - } + } -if ($highest_access >= 2) { - // Guild leader stuff - - // Change Guild Nick - if (!empty($_POST['player_guildnick'])) { - if ($config['guild_allow_nicknames']) { - $p_cid = user_character_id($_POST['player_guildnick']); - $p_guild = get_player_guild_data($p_cid); - if (preg_match("/^[a-zA-Z_ ]+$/", $_POST['guildnick']) || empty($_POST['guildnick'])) { - // Only allow normal symbols as guild nick - $p_nick = sanitize($_POST['guildnick']); - if ($p_guild['guild_id'] == $gid) { - if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($p_cid, 'online'); - else $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0; + // Join guild + if (!empty($_POST['joinguild'])) { + $joining_player_id = (int)$_POST['joinguild']; + // Join a guild + if ($inv_data !== false) foreach ($inv_data as $inv) { + if ((int)$inv['player_id'] == $joining_player_id) { + $chardata['online'] = (user_is_online_10($joining_player_id)) ? 1 : 0; if ($chardata['online'] == 0) { - if ($config['ServerEngine'] !== 'TFS_10') update_player_guildnick($p_cid, $p_nick); - else update_player_guildnick_10($p_cid, $p_nick); + + // Ensure player is not already a member of another guild + if (get_character_guild_rank($joining_player_id) === false) { + if (guild_player_join($joining_player_id, (int)$gid)) { + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } else echo 'Failed to find guild position representing member.'; + + } else { + $already_guild = get_player_guild_data($joining_player_id); + $already_guild_name = get_guild_name($already_guild['guild_id']); + + echo "You are already {$already_guild['rank_name']} of another guild: {$already_guild_name}.
You need to leave that guild first before you can join another one.
"; + } + + } else echo 'Character must be offline before joining guild.'; + } + } + } + + // leave guild + if (!empty($_POST['leave_guild'])) { + $name = sanitize($_POST['leave_guild']); + $cidd = user_character_id($name); + // If character is offline + $chardata['online'] = (user_is_online_10($cidd)) ? 1 : 0; + if ($chardata['online'] == 0) { + guild_player_leave_10($cidd); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } else echo 'Character must be offline first!'; + } + + // vice leader (and guild leader) actions + if ($highest_access >= 2) { + // Vice-leaders and leaders + // Change Guild Nick + if (!empty($_POST['player_guildnick'])) { + if ($config['guild_allow_nicknames']) { + $p_cid = user_character_id($_POST['player_guildnick']); + $p_guild = get_player_guild_data($p_cid); + + if (preg_match("/^[a-zA-Z_ ]+$/", $_POST['guildnick']) || empty($_POST['guildnick'])) { + // Only allow normal symbols as guild nick + $p_nick = sanitize($_POST['guildnick']); + + if ($p_guild['guild_id'] == $gid) { + $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0; + + if ($chardata['online'] == 0) { + update_player_guildnick_10($p_cid, $p_nick); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } else echo 'Character not offline.'; + } + + } else echo 'Character guild nick may only contain a-z, A-Z and spaces.'; + } else echo 'Change guild nickname feature has been disabled.'; + } + + // Promote character to guild position + if (!empty($_POST['promote_character']) && !empty($_POST['promote_position'])) { + // Verify that promoted character is from this guild. + $p_rid = $_POST['promote_position']; + $p_cid = user_character_id($_POST['promote_character']); + $p_guild = get_player_guild_data($p_cid); + + if ($p_guild['guild_id'] == $gid) { + $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0; + if ($chardata['online'] == 0) { + update_player_guild_position_10($p_cid, $p_rid); header('Location: guilds.php?name='. $_GET['name']); exit(); } else echo 'Character not offline.'; } - } else echo 'Character guild nick may only contain a-z, A-Z and spaces.'; - } else echo 'Change guild nickname feature has been disabled.'; - } + } - // Promote character to guild position - if (!empty($_POST['promote_character']) && !empty($_POST['promote_position'])) { - // Verify that promoted character is from this guild. - $p_rid = $_POST['promote_position']; - $p_cid = user_character_id($_POST['promote_character']); - $p_guild = get_player_guild_data($p_cid); + // Invite character to guild + if (!empty($_POST['invite'])) { + if (user_character_exist($_POST['invite'])) { + // Make sure they are not in another guild + $charid = user_character_id($_POST['invite']); + $membership = mysql_select_single("SELECT `rank_id` FROM `guild_membership` WHERE `player_id`='{$charid}' LIMIT 1;"); + if (!$membership) { + $status = false; + if ($inv_data !== false) { + foreach ($inv_data as $inv) { + if ($inv['player_id'] == user_character_id($_POST['invite'])) $status = true; + } + } + foreach ($players as $player) { + if ($player['name'] == $_POST['invite']) $status = true; + } - if ($p_guild['guild_id'] == $gid) { - // Do the magic. - if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($p_cid, 'online'); - else $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0; - if ($chardata['online'] == 0) { - if ($config['ServerEngine'] !== 'TFS_10') update_player_guild_position($p_cid, $p_rid); - else update_player_guild_position_10($p_cid, $p_rid); + if ($status == false) { + guild_invite_player($charid, $gid); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } else echo 'That character is already invited(or a member) on this guild.'; + } else echo 'That character is already in a guild.'; + + } else echo 'That character name does not exist.'; + } + + // Guild Message (motd) + if (!empty($_POST['motd'])) { + $motd = sanitize($_POST['motd']); + mysql_update("UPDATE `guilds` SET `motd`='{$motd}' WHERE `id`='{$gid}' LIMIT 1;"); header('Location: guilds.php?name='. $_GET['name']); exit(); - } else echo 'Character not offline.'; - - } - } - if (!empty($_POST['invite'])) { - if (user_character_exist($_POST['invite'])) { - // Make sure they are not in another guild - - if ($config['ServerEngine'] != 'TFS_10') { - $charname = sanitize($_POST['invite']); - $playerdata = mysql_select_single("SELECT `id`, `rank_id` FROM `players` WHERE `name`='$charname' LIMIT 1;"); - $charid = $playerdata['id']; - $membership = ($playerdata['rank_id'] > 0) ? true : false; - } else { - $charid = user_character_id($_POST['invite']); - $membership = mysql_select_single("SELECT `rank_id` FROM `guild_membership` WHERE `player_id`='$charid' LIMIT 1;"); } - if (!$membership) { - // - $status = false; - if ($inv_data !== false) { - foreach ($inv_data as $inv) { - if ($inv['player_id'] == user_character_id($_POST['invite'])) $status = true; - } - } - foreach ($players as $player) { - if ($player['name'] == $_POST['invite']) $status = true; - } - if ($status == false) { - guild_invite_player($charid, $gid); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } else echo 'That character is already invited(or a member) on this guild.'; - } else echo 'That character is already in a guild.'; + // Disband guild + if (!empty($_POST['disband'])) { + $gidd = (int)$_POST['disband']; + $members = get_guild_players($gidd); + $online = false; - } else echo 'That character name does not exist.'; - } - // Guild Message (motd) - if (!empty($_POST['motd'])) { - $motd = sanitize($_POST['motd']); - mysql_update("UPDATE `guilds` SET `motd`='$motd' WHERE `id`='$gid' LIMIT 1;"); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } - - if (!empty($_POST['disband'])) { - // - $gidd = (int)$_POST['disband']; - $members = get_guild_players($gidd); - $online = false; - - // First figure out if anyone are online. - foreach ($members as $member) { - if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data(user_character_id($member['name']), 'online'); - else $chardata['online'] = (user_is_online_10(user_character_id($member['name']))) ? 1 : 0; - if ($chardata['online'] == 1) { - $online = true; - } - } - - if (!$online) { - // Then remove guild rank from every player. - if ($config['ServerEngine'] !== 'TFS_10') foreach ($members as $member) guild_player_leave(user_character_id($member['name'])); - else foreach ($members as $member) guild_player_leave_10(user_character_id($member['name'])); - - // Remove all guild invitations to this guild - if ($inv_count > 0) guild_remove_invites($gidd); - - // Then remove the guild itself. - guild_delete($gidd); - header('Location: success.php'); - exit(); - } else echo 'All members must be offline to disband the guild.'; - } - - if (!empty($_POST['new_leader'])) { - $new_leader = (int)$_POST['new_leader']; - $old_leader = guild_leader($gid); - - $online = false; - if ($config['ServerEngine'] !== 'TFS_10') { - $newData = user_character_data($new_leader, 'online'); - $oldData = user_character_data($old_leader, 'online'); - } else { - $newData['online'] = (user_is_online_10($new_leader)) ? 1 : 0; - $oldData['online'] = (user_is_online_10($old_leader)) ? 1 : 0; - } - if ($newData['online'] == 1 || $oldData['online'] == 1) $online = true; - - if ($online == false) { - if (guild_change_leader($new_leader, $old_leader)) { - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } else echo 'Something went wrong when attempting to change leadership.'; - } else echo 'The new and old leader must be offline to change leadership.'; - } - - if (!empty($_POST['change_ranks'])) { - $c_gid = (int)$_POST['change_ranks']; - $c_ranks = get_guild_rank_data($c_gid); - $rank_data = array(); - $rank_ids = array(); - - // Feed new rank data - foreach ($c_ranks as $rank) { - $tmp = 'rank_name!'. $rank['level']; - if (!empty($_POST[$tmp])) { - $rank_data[$rank['level']] = sanitize($_POST[$tmp]); - $rank_ids[$rank['level']] = $rank['id']; - } - } - - foreach ($rank_data as $level => $name) { - guild_change_rank($rank_ids[$level], $name); - } - - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } - - if (!empty($_POST['remove_member'])) { - $name = sanitize($_POST['remove_member']); - $cid = user_character_id($name); - - if ($config['ServerEngine'] !== 'TFS_10') guild_remove_member($cid); - else guild_remove_member_10($cid); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } - - if (!empty($_POST['forumGuildId'])) { - if ($config['forum']['guildboard'] === true) { - $forumExist = mysql_select_single("SELECT `id` FROM `znote_forum` WHERE `guild_id`='$gid' LIMIT 1;"); - if ($forumExist === false) { - // Insert data - mysql_insert("INSERT INTO `znote_forum` (`name`, `access`, `closed`, `hidden`, `guild_id`) - VALUES ('Guild', - '1', - '0', - '0', - '$gid');"); - echo '

Guild board has been created.

'; - } else echo '

Guild board already exist.

'; - - } else { - echo '

Error: Guild board system is disabled.

'; - } - } - - if ($config['ServerEngine'] == 'TFS_02' || $config['ServerEngine'] == 'OTHIRE' || $config['ServerEngine'] == 'TFS_10' && $config['guildwar_enabled'] === true) { - if (!empty($_POST['warinvite'])) { - $targetGuild = get_guild_id($_POST['warinvite']); - if ($targetGuild) { - $status = false; - $war_invite = mysql_select_single("SELECT `id` FROM `guilds` WHERE `id` = '$gid';"); - if ($war_invite !== false) { - foreach ($war_invite as $inv) { - if ($inv['id'] == $targetGuild) $status = true; + // First figure out if anyone are online. + foreach ($members as $member) { + $chardata['online'] = (user_is_online_10(user_character_id($member['name']))) ? 1 : 0; + if ($chardata['online'] == 1) { + $online = true; } } - $check_guild = get_guild_name($gid); - foreach ($check_guild as $guild) { - if ($guild['name'] == $_POST['warinvite']) $status = true; + if (!$online) { + // Then remove guild rank from every player. + foreach ($members as $member) + guild_player_leave_10(user_character_id($member['name'])); + + // Remove all guild invitations to this guild + if ($inv_count > 0) + guild_remove_invites($gidd); + + // Then remove the guild itself. + guild_delete($gidd); + header('Location: success.php'); + exit(); + } else echo 'All members must be offline to disband the guild.'; + } + + // Change guild leader + if (!empty($_POST['new_leader'])) { + $new_leader = (int)$_POST['new_leader']; + $old_leader = guild_leader($gid); + + $online = false; + $newData['online'] = (user_is_online_10($new_leader)) ? 1 : 0; + $oldData['online'] = (user_is_online_10($old_leader)) ? 1 : 0; + + if ($newData['online'] == 1 || $oldData['online'] == 1) $online = true; + + if ($online == false) { + if (guild_change_leader($new_leader, $old_leader)) { + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } else echo 'Something went wrong when attempting to change leadership.'; + } else echo 'The new and old leader must be offline to change leadership.'; + } + + // Change guild ranks + if (!empty($_POST['change_ranks'])) { + $c_gid = (int)$_POST['change_ranks']; + $c_ranks = get_guild_rank_data($c_gid); + $rank_data = array(); + $rank_ids = array(); + + // Feed new rank data + foreach ($c_ranks as $rank) { + $tmp = 'rank_name!'. $rank['level']; + if (!empty($_POST[$tmp])) { + $rank_data[$rank['level']] = sanitize($_POST[$tmp]); + $rank_ids[$rank['level']] = $rank['id']; + } } - if ((int)$gid === (int)$targetGuild) $status = true; + // Change guild rank name. + foreach ($rank_data as $level => $name) { + $rid = (int)$rank_ids[$level]; + $name = sanitize($name); + mysql_update("UPDATE `guild_ranks` SET `name`='{$name}' WHERE `id`={$rid}"); + } - $wars = mysql_select_multi("SELECT `id`, `guild1`, `guild2`, `status` FROM `guild_wars` WHERE (`guild1` = '$gid' OR `guild1` = '$targetGuild') AND (`guild2` = '$gid' OR `guild2` = '$targetGuild') AND `status` IN (0, 1);"); - if ($status == false && $wars == false) { - guild_war_invitation($gid, $targetGuild); - $limit = (empty($_POST['limit'])) ? 100 : (int)$_POST['limit']; - mysql_insert("INSERT INTO `znote_guild_wars` (`limit`) VALUES ('$limit');"); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } + + // Remove guild member + if (!empty($_POST['remove_member'])) { + $name = sanitize($_POST['remove_member']); + $cid = user_character_id($name); + guild_remove_member_10($cid); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } + + // Create forum guild board + if (!empty($_POST['forumGuildId'])) { + + if ($config['forum']['guildboard'] === true) { + $forumExist = mysql_select_single("SELECT `id` FROM `znote_forum` WHERE `guild_id`='{$gid}' LIMIT 1;"); + + if ($forumExist === false) { + // Insert data + mysql_insert(" + INSERT INTO `znote_forum` + (`name`, `access`, `closed`, `hidden`, `guild_id`) + VALUES ('Guild','1','0','0','{$gid}') + ;"); + echo '

Guild board has been created.

'; + } else echo '

Guild board already exist.

'; + + } else { + echo '

Error: Guild board system is disabled.

'; + } + } + + // Guildwar actions + if ($config['guildwar_enabled'] === true) { + + // Invite another guild to war + if (!empty($_POST['warinvite'])) { + $targetGuild = get_guild_id($_POST['warinvite']); + if ($targetGuild) { + $status = false; + + $war_invite = mysql_select_single("SELECT `id` FROM `guilds` WHERE `id` = '$gid';"); + if ($war_invite !== false) { + foreach ($war_invite as $inv) { + if ($inv['id'] == $targetGuild) $status = true; + } + } + + $check_guild = get_guild_name($gid); + foreach ($check_guild as $guild) { + if ($guild['name'] == $_POST['warinvite']) $status = true; + } + + if ((int)$gid === (int)$targetGuild) $status = true; + + $wars = mysql_select_multi(" + SELECT + `id`, `guild1`, `guild2`, `status` + FROM `guild_wars` + WHERE (`guild1` = '$gid' OR `guild1` = '$targetGuild') + AND (`guild2` = '$gid' OR `guild2` = '$targetGuild') + AND `status` IN (0, 1) + ;"); + + if ($status == false && $wars == false) { + guild_war_invitation($gid, $targetGuild); + $limit = (empty($_POST['limit'])) ? 100 : (int)$_POST['limit']; + mysql_insert("INSERT INTO `znote_guild_wars` (`limit`) VALUES ('$limit');"); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } else echo 'This guild has already been invited to war(or you\'re trying to invite your own).'; + + } else echo 'That guild name does not exist.'; + } + + if (!empty($_POST['cancel_war_invite'])) { + cancel_war_invitation($_POST['cancel_war_invite'], $gid); header('Location: guilds.php?name='. $_GET['name']); exit(); - } else echo 'This guild has already been invited to war(or you\'re trying to invite your own).'; - } else echo 'That guild name does not exist.'; - } + } - if (!empty($_POST['cancel_war_invite'])) { - cancel_war_invitation($_POST['cancel_war_invite'], $gid); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } + if (!empty($_POST['reject_war_invite'])) { + reject_war_invitation($_POST['reject_war_invite'], $gid); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } - if (!empty($_POST['reject_war_invite'])) { - reject_war_invitation($_POST['reject_war_invite'], $gid); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } + if (!empty($_POST['accept_war_invite'])) { + accept_war_invitation($_POST['accept_war_invite'], $gid); + header('Location: guilds.php?name='. $_GET['name']); + exit(); + } + } - if (!empty($_POST['accept_war_invite'])) { - accept_war_invitation($_POST['accept_war_invite'], $gid); - header('Location: guilds.php?name='. $_GET['name']); - exit(); - } - } - - $members = count_guild_members($gid); - $ranks = get_guild_rank_data($gid); - ?> - - = 2) { } } - if ($config['use_guild_logos']) { - - ?> - - -
- -
- -
'; + // Form to upload guild logo + if ($config['use_guild_logos']) { + ?> +
+ +
+
'; + } } + ?> - } ?> - -
- -
- -
- -
- - +
- - - 1) { ?> - -
- +
+ + + +
+ -
- -
- -
- -

- - -
- +
+ + + 1): ?> + +
+ +
+ + +
+ +
+ +

+ + + + +
+ -
- -
- -
- - 1) { ?> -
- +
+ + +
+ +
+ + + 1): ?> +
+ +
+ + + + +

Guild War Management:

+
+ +
+ + + + + + + + + '. $player['name'] .''; - } + $i = 0; + $wars = mysql_select_multi(" + SELECT + `guild1`, `guild2`, `name1`, `name2`, `started`, + ( SELECT `limit` + FROM `znote_guild_wars` + WHERE `znote_guild_wars`.`id` = `guild_wars`.`id` + ) AS `limit` + FROM `guild_wars` + WHERE (`guild1` = '$gid' OR `guild2` = '$gid') + AND `status` = 0 + ORDER BY `started` DESC + "); + if (!empty($wars) || $wars !== false) { + foreach($wars as $war): + $i++; + $row = ""; + $row .= ""; + + $row .= ''; + $row .= ""; + $row .= ''; + echo $row; + endforeach; } + + if ($i == 0) echo ''; ?> - - - - - - - -

Guild War Management:

- - - - -
AggressorInformationEnemy
{$war['name1']}
'; + + $row .= 'Pending invitation'; + $row .= '
Invited on '. getClock($war['started'], true) .'.'; + $row .= "
The frag limit is set to {$war['limit']} frags.
"; + + if ($war['guild1'] == $gid) { + $row .= '
'; + $row .= ""; + $row .= ''; + $row .= '
'; + } else if ($war['guild2'] == $gid) { + $row .= '
'; + $row .= ""; + $row .= ''; + $row .= '
'; + + $row .= '
'; + $row .= ""; + $row .= ''; + $row .= '
'; + } + $row .= '
{$war['name2']}
Currently there are no pending invitations.
- '; +
AggressorInformationEnemy
'.$war['name1'].''; - echo '
Pending invitation
Invited on ' . getClock($war['started'], true) . '.
The frag limit is set to ' . $war['limit'] . ' frags.
'; - if ($war['guild1'] == $gid) { - echo '
'; - } else if ($war['guild2'] == $gid) { - echo '
'; - echo '
'; - } - echo '
'.$war['name2'].'
+ + + +
Currently there are no pending invitations.
'; - echo ''; - } } ?> - - - -

War overview:

- - - - - - - + if ($war_exist) { + ?> +

War overview:

+
Attacker:Defender:status:started:
+ + + + + + '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - } + ?> + + + + + + + -
Attacker:Defender:status:started:
'. $wars['name1'] .''. $wars['name2'] .''. $config['war_status'][$wars['status']] .''. getClock($wars['started'], true) .'
- - - + - Visit Guild Board


+ ?> -
- -
- +
+ +
+ \ No newline at end of file