mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-30 07:07:14 +00:00
fix diplomacy
This commit is contained in:
@@ -1333,23 +1333,17 @@ class MYSQL_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAllianceDipProfile($aid, $type){
|
function getAllianceDipProfile($aid, $type){
|
||||||
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1'";
|
$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);
|
$array = $this->query_return($q);
|
||||||
if(mysql_num_rows($result) == 0){
|
foreach($array as $row){
|
||||||
$q2 = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli2 = '$aid' AND type = '$type' AND accepted = '1'";
|
if($row['alli1'] == $aid){
|
||||||
$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)){
|
|
||||||
$alliance = $this->getAlliance($row['alli2']);
|
$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> ";
|
$text .= "<a href=allianz.php?aid=".$alliance['id'].">".$alliance['tag']."</a><br> ";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(strlen($text) == 0){
|
if(strlen($text) == 0){
|
||||||
$text = "-<br>";
|
$text = "-<br>";
|
||||||
}
|
}
|
||||||
@@ -1357,23 +1351,17 @@ class MYSQL_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAllianceWar($aid){
|
function getAllianceWar($aid){
|
||||||
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3'";
|
$q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'";
|
||||||
$result = mysql_query($q, $this->connection);
|
$array = $this->query_return($q);
|
||||||
if(mysql_num_rows($result) == 0){
|
foreach($array as $row){
|
||||||
$q2 = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli2 = '$aid' AND type = '3' AND accepted = '1'";
|
if($row['alli1'] == $aid){
|
||||||
$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)){
|
|
||||||
$alliance = $this->getAlliance($row['alli2']);
|
$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> ";
|
$text .= "<a href=allianz.php?aid=".$alliance['id'].">".$alliance['tag']."</a><br> ";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(strlen($text) == 0){
|
if(strlen($text) == 0){
|
||||||
$text = "-<br>";
|
$text = "-<br>";
|
||||||
}
|
}
|
||||||
@@ -1391,6 +1379,7 @@ class MYSQL_DB {
|
|||||||
$result = mysql_query($q, $this->connection);
|
$result = mysql_query($q, $this->connection);
|
||||||
return $this->mysql_fetch_all($result);
|
return $this->mysql_fetch_all($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function diplomacyExistingRelationships($session_alliance) {
|
function diplomacyExistingRelationships($session_alliance) {
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1";
|
$q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 1";
|
||||||
$result = mysql_query($q, $this->connection);
|
$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";
|
$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);
|
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) {
|
function setAlliForumLink($aid, $link) {
|
||||||
$q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid";
|
$q = "UPDATE " . TB_PREFIX . "alidata SET `forumlink` = '$link' WHERE id = $aid";
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
} else if($row['type'] == 3){
|
} else if($row['type'] == 3){
|
||||||
$type = "War";
|
$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 {
|
} else {
|
||||||
echo '<tr><td colspan="3" class="none">none</td></tr>';
|
echo '<tr><td colspan="3" class="none">none</td></tr>';
|
||||||
|
|||||||
@@ -280,7 +280,9 @@ $invite_permission = $database->getAlliancePermission($session->uid, "opt4", 0);
|
|||||||
include ("Templates/Alliance/chgdiplo.tpl");
|
include ("Templates/Alliance/chgdiplo.tpl");
|
||||||
break;
|
break;
|
||||||
case 103:
|
case 103:
|
||||||
|
if($database->checkDiplomacyInviteAccept($session->alliance, $_POST['type'])){
|
||||||
$database->diplomacyInviteAccept($_POST['id'], $_POST['alli2']);
|
$database->diplomacyInviteAccept($_POST['id'], $_POST['alli2']);
|
||||||
|
}
|
||||||
include ("Templates/Alliance/chgdiplo.tpl");
|
include ("Templates/Alliance/chgdiplo.tpl");
|
||||||
break;
|
break;
|
||||||
case 104:
|
case 104:
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%diplomacy` (
|
|||||||
`alli1` int(11) unsigned NOT NULL,
|
`alli1` int(11) unsigned NOT NULL,
|
||||||
`alli2` int(11) unsigned NOT NULL,
|
`alli2` int(11) unsigned NOT NULL,
|
||||||
`type` tinyint(1) unsigned NOT NULL,
|
`type` tinyint(1) unsigned NOT NULL,
|
||||||
`accepted` int(1) NOT NULL,
|
`accepted` tinyint(1) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user