Alliance forum fixes part 4

+Public forums can now be created by MH only
+Public forums can only be edited by MH only (every MH)
+Fixed BBCode in forum posts
+Removed 8 unused columns from the database
+Removed about 150 lines of unused code in forum.tpl
+Minor improvements and bug fixing
This commit is contained in:
iopietro
2018-05-20 16:50:26 +02:00
parent cbcc9b5262
commit 34c8000e44
14 changed files with 128 additions and 380 deletions
+8 -5
View File
@@ -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)));
}
/**
+29 -23
View File
@@ -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] = "<b>$1</b>";
$replace[1] = "<i>$1</i>";
$replace[2] = "<u>$1</u>";
@@ -195,12 +195,9 @@ $input = preg_replace_callback(
function($matches) {
global $database;
$aname = $database->getAllianceID($matches[1]);
if ($aname) {
return "<a href=allianz.php?aid=$aname>".$matches[2]."</a>";
} else {
return $matches[2];
}
$aname = $database->getAllianceName($matches[2]);
if (!empty($aname)) return "<a href=allianz.php?aid=$matches[2]>".$aname."</a>";
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 "<a href=spieler.php?uid=$uname>".$matches[2]."</a>";
} else {
return $matches[2];
}
$uname = $database->getUserField((int) $matches[2], "username", 0);
if (!empty($uname) && $uname != "[?]") return "<a href=spieler.php?uid=$matches[2]>".$uname."</a>";
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 "<a href=berichte.php?id=".$matches[1].">".$matches[2]."</a>";
else return $matches[2];
$reportID = $matches[1] > 0 ? $matches[1] : $matches[2];
$report = $database->getNotice2((int) $reportID, null, false);
if (!empty($report)) return "<a href=berichte.php?id=".$reportID.">".$report['topic']."</a>";
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 "<a href=karte.php?d=".$matches[1]."&amp;c=".$cwref.">".$matches[2]."</a>";
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 "<a href=karte.php?d=".$wRef."&amp;c=".$cwref.">".$name." (".$coordinates[0]."|".$coordinates[1].")"."</a>";
return "Village not found!";
},
$input);
$input = preg_replace('/\[message\]/', '', $input);
$input = preg_replace('/\[\/message\]/', '', $input);
$bbcoded = preg_replace($pattern, $replace, $input);
?>
+15 -15
View File
@@ -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);
}