fix diplomacy

This commit is contained in:
unknown
2012-07-05 01:50:55 +03:00
parent a2aeeab6e8
commit e98ff77c31
4 changed files with 35 additions and 30 deletions
+31 -28
View File
@@ -1333,23 +1333,17 @@ class MYSQL_DB {
}
function getAllianceDipProfile($aid, $type){
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1'";
$result = mysql_query($q, $this->connection);
if(mysql_num_rows($result) == 0){
$q2 = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli2 = '$aid' AND type = '$type' AND accepted = '1'";
$result2 = mysql_query($q2, $this->connection);
while($row = mysql_fetch_array($result2)){
$alliance = $this->getAlliance($row['alli1']);
$text = "";
$text .= "<a href=allianz.php?aid=".$alliance['id'].">".$alliance['tag']."</a><br> ";
}
}else{
while($row = mysql_fetch_array($result)){
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'";
$array = $this->query_return($q);
foreach($array as $row){
if($row['alli1'] == $aid){
$alliance = $this->getAlliance($row['alli2']);
$text = "";
}elseif($row['alli2'] == $aid){
$alliance = $this->getAlliance($row['alli1']);
}
$text .= "";
$text .= "<a href=allianz.php?aid=".$alliance['id'].">".$alliance['tag']."</a><br> ";
}
}
if(strlen($text) == 0){
$text = "-<br>";
}
@@ -1357,23 +1351,17 @@ class MYSQL_DB {
}
function getAllianceWar($aid){
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3'";
$result = mysql_query($q, $this->connection);
if(mysql_num_rows($result) == 0){
$q2 = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli2 = '$aid' AND type = '3' AND accepted = '1'";
$result2 = mysql_query($q2, $this->connection);
while($row = mysql_fetch_array($result2)){
$alliance = $this->getAlliance($row['alli1']);
$text = "";
$text .= "<a href=allianz.php?aid=".$alliance['id'].">".$alliance['tag']."</a><br> ";
}
}else{
while($row = mysql_fetch_array($result)){
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'";
$array = $this->query_return($q);
foreach($array as $row){
if($row['alli1'] == $aid){
$alliance = $this->getAlliance($row['alli2']);
$text = "";
}elseif($row['alli2'] == $aid){
$alliance = $this->getAlliance($row['alli1']);
}
$text .= "";
$text .= "<a href=allianz.php?aid=".$alliance['id'].">".$alliance['tag']."</a><br> ";
}
}
if(strlen($text) == 0){
$text = "-<br>";
}
@@ -1391,6 +1379,7 @@ class MYSQL_DB {
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
function diplomacyExistingRelationships($session_alliance) {
$q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1";
$result = mysql_query($q, $this->connection);
@@ -1407,6 +1396,20 @@ class MYSQL_DB {
$q = "DELETE FROM " . TB_PREFIX . "diplomacy WHERE id = $id AND alli2 = $session_alliance OR id = $id AND alli1 = $session_alliance";
return mysql_query($q, $this->connection);
}
function checkDiplomacyInviteAccept($aid, $type) {
$q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $aid AND type = $type AND accepted = 1 OR alli2 = $aid AND type = $type AND accepted = 1";
$result = mysql_query($q, $this->connection);
if($type == 3){
return true;
}else{
if(mysql_num_rows($result) < 4) {
return true;
} else {
return false;
}
}
}
function setAlliForumLink($aid, $link) {
$q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid";
+1 -1
View File
@@ -149,7 +149,7 @@
} else if($row['type'] == 3){
$type = "War";
}
echo '<tr><td width="18"><form method="post" action="allianz.php"><input type="hidden" name="o" value="102"><input type="hidden" name="id" value="'.$row['id'].'"><input type="hidden" name="alli1" value="'.$row['alli1'].'"><input type="image" class="cancel" src="img/x.gif" title="Cancel" /></td></form><form method="post" action="allianz.php"><td width="18"><input type="hidden" name="o" value="103"><input type="hidden" name="id" value="'.$row['id'].'"><input type="hidden" name="alli2" value="'.$row['alli2'].'"><input type="image" class="accept" src="img/x.gif" title="Accept" /></td></form><td><a href="allianz.php?aid='.$row['alli1'].'"><center>'.$database->getAllianceName($row['alli1']).'</a></center></td><td width="80"><center>'.$type.'</center></td></tr>';
echo '<tr><td width="18"><form method="post" action="allianz.php"><input type="hidden" name="o" value="102"><input type="hidden" name="id" value="'.$row['id'].'"><input type="hidden" name="alli1" value="'.$row['alli1'].'"><input type="image" class="cancel" src="img/x.gif" title="Cancel" /></td></form><form method="post" action="allianz.php"><td width="18"><input type="hidden" name="o" value="103"><input type="hidden" name="id" value="'.$row['id'].'"><input type="hidden" name="alli2" value="'.$row['alli2'].'"><input type="hidden" name="type" value="'.$row['type'].'"><input type="image" class="accept" src="img/x.gif" title="Accept" /></td></form><td><a href="allianz.php?aid='.$row['alli1'].'"><center>'.$database->getAllianceName($row['alli1']).'</a></center></td><td width="80"><center>'.$type.'</center></td></tr>';
}
} else {
echo '<tr><td colspan="3" class="none">none</td></tr>';
+2
View File
@@ -280,7 +280,9 @@ $invite_permission = $database->getAlliancePermission($session->uid, "opt4", 0);
include ("Templates/Alliance/chgdiplo.tpl");
break;
case 103:
if($database->checkDiplomacyInviteAccept($session->alliance, $_POST['type'])){
$database->diplomacyInviteAccept($_POST['id'], $_POST['alli2']);
}
include ("Templates/Alliance/chgdiplo.tpl");
break;
case 104:
+1 -1
View File
@@ -467,7 +467,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%diplomacy` (
`alli1` int(11) unsigned NOT NULL,
`alli2` int(11) unsigned NOT NULL,
`type` tinyint(1) unsigned NOT NULL,
`accepted` int(1) NOT NULL,
`accepted` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--