diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php
index 112d3b57..fcbe1442 100755
--- a/GameEngine/Alliance.php
+++ b/GameEngine/Alliance.php
@@ -76,7 +76,7 @@ class Alliance {
}
}
}
-
+
/**
* Determines if a player can act with the forum (edit/delete/create things, etc.)
*
@@ -87,10 +87,13 @@ class Alliance {
public static function canAct($datas, $mode = 0){
global $database, $session;
- return (/*$database->CheckEditRes($datas['aid']) == 1 && */((($database->isAllianceOwner($session->uid) == $datas['alliance'] ||
- ($datas['forum_perm'] == 1 && $session->alliance == $datas['alliance'])) && $session->alliance > 0 &&
- ($mode || (isset($datas['admin']) && !empty($datas['admin']) && $datas['admin'] == "switch_admin"))) ||
- $datas['owner'] == $session->uid) || ($datas['forum_owner'] == $session->uid && $datas['alliance'] == 0));
+ $hasSwitchedToAdmin = isset($datas['admin']) && !empty($datas['admin']) && $datas['admin'] == "switch_admin";
+
+ return (/*$database->CheckEditRes($datas['aid']) == 1 && */($datas['alliance'] > 0 && (($database->isAllianceOwner($session->uid) == $datas['alliance'] ||
+ ($datas['forum_perm'] == 1 && $session->alliance == $datas['alliance'])) &&
+ ($mode || $hasSwitchedToAdmin)) ||
+ ($datas['owner'] == $session->uid && $session->access != ADMIN)) ||
+ ($session->access == ADMIN && ($mode || $hasSwitchedToAdmin)));
}
/**
diff --git a/GameEngine/BBCode.php b/GameEngine/BBCode.php
index 932442ec..65eb6c62 100755
--- a/GameEngine/BBCode.php
+++ b/GameEngine/BBCode.php
@@ -3,7 +3,7 @@
include_once ("config.php");
include_once ("Lang/".LANG.".php");
-$pattern = array();
+$pattern = [];
$pattern[0] = "/\[b\](.*?)\[\/b\]/is";
$pattern[1] = "/\[i\](.*?)\[\/i\]/is";
$pattern[2] = "/\[u\](.*?)\[\/u\]/is";
@@ -94,7 +94,7 @@ $pattern[86] = "/\*veryangry\*/";
$pattern[87] = "/\*veryhappy\*/";
$pattern[88] = "/\;\)/";
-$replace = array();
+$replace = [];
$replace[0] = "$1";
$replace[1] = "$1";
$replace[2] = "$1";
@@ -195,12 +195,9 @@ $input = preg_replace_callback(
function($matches) {
global $database;
- $aname = $database->getAllianceID($matches[1]);
- if ($aname) {
- return "".$matches[2]."";
- } else {
- return $matches[2];
- }
+ $aname = $database->getAllianceName($matches[2]);
+ if (!empty($aname)) return "".$aname."";
+ else return "Alliance not found!";
},
$input);
@@ -210,12 +207,9 @@ $input = preg_replace_callback(
function($matches) {
global $database;
- $uname = $database->getUserField((int) $matches[1], "id", 0);
- if ($uname) {
- return "".$matches[2]."";
- } else {
- return $matches[2];
- }
+ $uname = $database->getUserField((int) $matches[2], "username", 0);
+ if (!empty($uname) && $uname != "[?]") return "".$uname."";
+ else return "Player not found!";
},
$input);
@@ -224,10 +218,12 @@ $input = preg_replace_callback(
"/\[report(\d{0,20})\]([^\]]*)\[\/report\d{0,20}\]/is",
function($matches) {
global $database;
-
- $report = count($database->getNotice2((int) $matches[1]));
- if (count($report)) return "".$matches[2]."";
- else return $matches[2];
+
+ $reportID = $matches[1] > 0 ? $matches[1] : $matches[2];
+ $report = $database->getNotice2((int) $reportID, null, false);
+
+ if (!empty($report)) return "".$report['topic']."";
+ else return "Report not found!";
},
$input);
@@ -235,15 +231,25 @@ $input = preg_replace_callback(
$input = preg_replace_callback(
"/\[coor(\d{0,20})\]([^\]]*)\[\/coor\d{0,20}\]/is",
function($matches) {
- global $generator;
-
- $cwref = $generator->getMapCheck($matches[1]);
- return "".$matches[2]."";
+ global $generator, $database;
+
+ $name = "";
+ $coordinates = explode("|", $matches[2]);
+ $wRef = $database->getVilWref($coordinates[0], $coordinates[1]);
+ $cwref = $generator->getMapCheck($wRef);
+ $state = $database->getVillageType($wRef);
+ if($state > 0){
+ if($database->getVillageState($wRef)) $name = $database->getVillageField($wRef, 'name');
+ else $name = ABANDVALLEY;
+ }
+ else $name = $database->getOasisInfo($wRef)['name'];
+
+ if(!empty($name)) return "".$name." (".$coordinates[0]."|".$coordinates[1].")"."";
+ return "Village not found!";
},
$input);
$input = preg_replace('/\[message\]/', '', $input);
$input = preg_replace('/\[\/message\]/', '', $input);
$bbcoded = preg_replace($pattern, $replace, $input);
-
?>
diff --git a/GameEngine/Database.php b/GameEngine/Database.php
index f0b68f01..e24e764f 100755
--- a/GameEngine/Database.php
+++ b/GameEngine/Database.php
@@ -2517,10 +2517,10 @@ class MYSQLi_DB implements IDbConnection {
return mysqli_query($this->dblink,$q);
}
- function UpdateEditForum($id, $name, $des, $ally, $alliances, $users) {
- list($id, $name, $des, $ally, $alliances, $users) = $this->escape_input((int) $id, $name, $des, (int) $ally, $alliances, $users);
+ function UpdateEditForum($id, $name, $des, $alliances, $users) {
+ list($id, $name, $des, $alliances, $users) = $this->escape_input((int) $id, $name, $des, $alliances, $users);
- $q = "UPDATE " . TB_PREFIX . "forum_cat SET forum_name = '$name', forum_des = '$des', display_to_alliances = '$alliances', display_to_users = '$users' WHERE id = $id AND alliance = $ally";
+ $q = "UPDATE " . TB_PREFIX . "forum_cat SET forum_name = '$name', forum_des = '$des', display_to_alliances = '$alliances', display_to_users = '$users' WHERE id = $id";
return mysqli_query($this->dblink,$q);
}
@@ -2584,11 +2584,11 @@ class MYSQLi_DB implements IDbConnection {
return mysqli_insert_id($this->dblink);
}
- function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) {
- list($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) = $this->escape_input($title, $post, (int) $cat, (int) $owner, (int) $alli, (int) $ends, (int) $alliance, (int) $player, (int) $coor, (int) $report);
+ function CreatTopic($title, $post, $cat, $owner, $alli, $ends) {
+ list($title, $post, $cat, $owner, $alli, $ends) = $this->escape_input($title, $post, (int) $cat, (int) $owner, (int) $alli, (int) $ends);
$date = time();
- $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post',$date, $date, $cat, $owner, $alli, $ends, 0, 0, $alliance, $player, $coor, $report)";
+ $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post',$date, $date, $cat, $owner, $alli, $ends, 0, 0)";
mysqli_query($this->dblink,$q);
return mysqli_insert_id($this->dblink);
}
@@ -2671,12 +2671,12 @@ class MYSQLi_DB implements IDbConnection {
FORUM SUREY
*************************/
- function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report, $fid2 = 0) {
+ function CreatPost($post, $tids, $owner, $fid2 = 0) {
global $message, $session;
- list($post, $tids, $owner, $alliance, $player, $coor, $report, $fid2) = $this->escape_input($post, (int) $tids, $owner, (int) $alliance, (int) $player, (int) $coor, (int) $report, (int) $fid2);
+ list($post, $tids, $owner, $fid2) = $this->escape_input($post, (int) $tids, $owner, (int) $fid2);
$date = time();
- $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post',$tids,'$owner','$date',$alliance,$player,$coor,$report)";
+ $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post',$tids,'$owner','$date')";
mysqli_query($this->dblink,$q);
$postID = mysqli_insert_id($this->dblink);
@@ -2715,18 +2715,18 @@ class MYSQLi_DB implements IDbConnection {
return mysqli_query($this->dblink,$q);
}
- function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) {
- list($id, $post, $alliance, $player, $coor, $report) = $this->escape_input((int) $id, $post, (int) $alliance, (int) $player, (int) $coor, (int) $report);
+ function EditUpdateTopic($id, $post) {
+ list($id, $post) = $this->escape_input((int) $id, $post);
- $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = $alliance, player0 = $player, coor0 = $coor, report0 = $report where id = $id";
+ $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post' where id = $id";
return mysqli_query($this->dblink, $q);
}
- function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) {
- list($id, $post, $alliance, $player, $coor, $report) = $this->escape_input((int) $id, $post, (int) $alliance, (int) $player, (int) $coor, (int) $report);
+ function EditUpdatePost($id, $post) {
+ list($id, $post) = $this->escape_input((int) $id, $post);
- $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = $alliance, player0 = $player, coor0 = $coor, report0 = $report where id = $id";
+ $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post' where id = $id";
return mysqli_query($this->dblink,$q);
}
diff --git a/Templates/Alliance/Forum/forum_1.tpl b/Templates/Alliance/Forum/forum_1.tpl
index 7bd6b01b..150b08d9 100644
--- a/Templates/Alliance/Forum/forum_1.tpl
+++ b/Templates/Alliance/Forum/forum_1.tpl
@@ -9,6 +9,9 @@ if($session->access == BANNED){
header("Location: banned.php");
exit;
}
+
+if($session->access != ADMIN && ($session->alliance == 0 || ($session->alliance > 0 && !$opt['opt5']))) $alliance->redirect($_GET);
+
?>