From 015093049d59a1b92f8adf1afb3da3641b5a7511 Mon Sep 17 00:00:00 2001 From: yi12345 Date: Tue, 14 May 2013 19:46:03 +0300 Subject: [PATCH] more fixes --- GameEngine/Database/db_MYSQL.php | 40 ++-- GameEngine/Database/db_MYSQLi.php | 46 ++-- Templates/Alliance/Forum/forum_10.tpl | 8 + Templates/Alliance/Forum/forum_6.tpl | 14 +- Templates/Alliance/Forum/forum_9.tpl | 8 + Templates/Alliance/forum.tpl | 291 ++++++++++++++++++++++++-- install/data/sql.sql | 8 + 7 files changed, 350 insertions(+), 65 deletions(-) diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 3fd6c055..cbd5f73c 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -1039,19 +1039,19 @@ class MYSQL_DB { return mysql_insert_id($this->connection); } - function CreatTopic($title, $post, $cat, $owner, $alli, $ends) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } + function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) { + $date = time(); + $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')"; + mysql_query($q, $this->connection); + return mysql_insert_id($this->connection); + } - function CreatPost($post, $tids, $owner) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date')"; - mysql_query($q, $this->connection); - return mysql_insert_id($this->connection); - } + function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) { + $date = time(); + $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')"; + mysql_query($q, $this->connection); + return mysql_insert_id($this->connection); + } function UpdatePostDate($id) { $date = time(); @@ -1059,15 +1059,15 @@ class MYSQL_DB { return mysql_query($q, $this->connection); } - function EditUpdateTopic($id, $post) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post' where id = $id"; - return mysql_query($q, $this->connection); - } + function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) { + $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; + return mysql_query($q, $this->connection); + } - function EditUpdatePost($id, $post) { - $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post' where id = $id"; - return mysql_query($q, $this->connection); - } + function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) { + $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; + return mysql_query($q, $this->connection); + } function LockTopic($id, $mode) { $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'"; diff --git a/GameEngine/Database/db_MYSQLi.php b/GameEngine/Database/db_MYSQLi.php index 44184829..a8fc8348 100644 --- a/GameEngine/Database/db_MYSQLi.php +++ b/GameEngine/Database/db_MYSQLi.php @@ -28,7 +28,7 @@ class MYSQLi_DB { $timep = (strtotime(START_TIME) + PROTECTION); } $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)"; - if(mysql_query($q, $this->connection)) { + if(mysql_query($this->connection, $q)) { return mysql_insert_id($this->connection); } else { return false; @@ -1042,19 +1042,19 @@ class MYSQLi_DB { return mysqli_insert_id($this->connection); } - function CreatTopic($title, $post, $cat, $owner, $alli, $ends) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','')"; - mysqli_query($this->connection, $q); - return mysqli_insert_id($this->connection); - } + function CreatTopic($title, $post, $cat, $owner, $alli, $ends, $alliance, $player, $coor, $report) { + $date = time(); + $q = "INSERT into " . TB_PREFIX . "forum_topic values (0,'$title','$post','$date','$date','$cat','$owner','$alli','$ends','','','$alliance','$player','$coor','$report')"; + mysqli_query($this->connection, $q); + return mysqli_insert_id($this->connection); + } - function CreatPost($post, $tids, $owner) { - $date = time(); - $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date')"; - mysqli_query($this->connection, $q); - return mysqli_insert_id($this->connection); - } + function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) { + $date = time(); + $q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')"; + mysqli_query($this->connection, $q); + return mysqli_insert_id($this->connection); + } function UpdatePostDate($id) { $date = time(); @@ -1062,15 +1062,15 @@ class MYSQLi_DB { return mysqli_query($this->connection, $q); } - function EditUpdateTopic($id, $post) { - $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post' where id = $id"; - return mysqli_query($this->connection, $q); - } + function EditUpdateTopic($id, $post, $alliance, $player, $coor, $report) { + $q = "UPDATE " . TB_PREFIX . "forum_topic set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; + return mysqli_query($this->connection, $q); + } - function EditUpdatePost($id, $post) { - $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post' where id = $id"; - return mysqli_query($this->connection, $q); - } + function EditUpdatePost($id, $post, $alliance, $player, $coor, $report) { + $q = "UPDATE " . TB_PREFIX . "forum_post set post = '$post', alliance0 = '$alliance', player0 = '$player', coor0 = '$coor', report0 = '$report' where id = $id"; + return mysqli_query($this->connection, $q); + } function LockTopic($id, $mode) { $q = "UPDATE " . TB_PREFIX . "forum_topic set close = '$mode' where id = '$id'"; @@ -1311,13 +1311,13 @@ class MYSQLi_DB { function diplomacyInviteCheck($session_alliance) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli2 = $session_alliance AND accepted = 0"; - $result = mysql_query($q, $this->connection); + $result = mysql_query($this->connection, $q); return $this->mysql_fetch_all($result); } function diplomacyInviteCheck2($ally1, $ally2) { $q = "SELECT * FROM " . TB_PREFIX . "diplomacy WHERE alli1 = $ally1 AND alli2 = $ally2 accepted = 0"; - $result = mysql_query($q, $this->connection); + $result = mysql_query($this->connection, $q); return $this->mysql_fetch_all($result); } diff --git a/Templates/Alliance/Forum/forum_10.tpl b/Templates/Alliance/Forum/forum_10.tpl index 317a7da0..273ad21e 100644 --- a/Templates/Alliance/Forum/forum_10.tpl +++ b/Templates/Alliance/Forum/forum_10.tpl @@ -12,11 +12,19 @@ foreach($posts as $pos) { $poss = stripslashes($pos['post']); $poss = preg_replace('/\[message\]/', '', $poss); $poss = preg_replace('/\[\/message\]/', '', $poss); + $alliance0 = $pos['alliance0']; + $player0 = $pos['player0']; + $coor0 = $pos['coor0']; + $report0 = $pos['report0']; } ?>
+ + + + diff --git a/Templates/Alliance/Forum/forum_6.tpl b/Templates/Alliance/Forum/forum_6.tpl index 6662e841..8313b794 100644 --- a/Templates/Alliance/Forum/forum_6.tpl +++ b/Templates/Alliance/Forum/forum_6.tpl @@ -20,13 +20,21 @@ foreach($varray as $vil) { $countAu = $database->CountTopic($arr['owner']); $displayarray = $database->getUserArray($arr['owner'],1); if($displayarray['tribe'] == 1) { - $trip = "Romans"; + $trip = "Fire"; }else if($displayarray['tribe'] == 2) { - $trip = "Teutons"; + $trip = "Water"; }else if($displayarray['tribe'] == 3) { - $trip = "Gauls"; + $trip = "Earth"; +}else if($displayarray['tribe'] == 4) { + $trip = "Air"; +}else if($displayarray['tribe'] == 5) { + $trip = "Lightning"; } $input = $arr['post']; +$alliance = $arr['alliance0']; +$player = $arr['player0']; +$coor = $arr['coor0']; +$report = $arr['report0']; $bbcoded = $input; include("GameEngine/BBCode.php"); $bbcode_topic = stripslashes(nl2br($bbcoded)); diff --git a/Templates/Alliance/Forum/forum_9.tpl b/Templates/Alliance/Forum/forum_9.tpl index eb2b593f..93094e7a 100644 --- a/Templates/Alliance/Forum/forum_9.tpl +++ b/Templates/Alliance/Forum/forum_9.tpl @@ -8,11 +8,19 @@ foreach($topics as $top) { $ans = stripslashes($top['post']); $ans = preg_replace('/\[message\]/', '', $ans); $ans = preg_replace('/\[\/message\]/', '', $ans); + $alliance0 = $top['alliance0']; + $player0 = $top['player0']; + $coor0 = $top['coor0']; + $report0 = $top['report0']; } ?> + + + +
diff --git a/Templates/Alliance/forum.tpl b/Templates/Alliance/forum.tpl index d9aab9fd..63b77a0d 100644 --- a/Templates/Alliance/forum.tpl +++ b/Templates/Alliance/forum.tpl @@ -42,7 +42,7 @@ if(isset($_POST['editforum'])){ } if(isset($_POST['newtopic'])){ $title = $_POST['thema']; - $post = $_POST['text']; + $text = $_POST['text']; $cat = $_POST['fid']; $owner = $session->uid; $alli = $_POST['pid']; @@ -52,39 +52,292 @@ if(isset($_POST['newtopic'])){ }else{ $ends = ''; } - if(!preg_match('/\[message\]/',$post) && !preg_match('/\[\/message\]/',$post)){ - $post = "[message]".$post."[/message]"; - $database->CreatTopic($title,$post,$cat,$owner,$alli,$ends); + if($text != ""){ + if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){ + $text = "[message]".$text."[/message]"; + $alliance = $player = $coor = $report = 0; + for($i=0;$i<=$alliance;$i++){ + if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){ + $alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text); + if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){ + $j = $i+1; + $alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text); + $alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1); + $alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1); + $text = $alliance2."[/alliance".$i."]".$alliance1; + $alliance += 1; + } + } + } + for($i=0;$i<=$player;$i++){ + if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){ + $player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text); + if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){ + $j = $i+1; + $player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text); + $player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1); + $player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1); + $text = $player2."[/player".$i."]".$player1; + $player += 1; + } + } + } + for($i=0;$i<=$coor;$i++){ + if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){ + $coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text); + if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){ + $j = $i+1; + $coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text); + $coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1); + $coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1); + $text = $coor2."[/coor".$i."]".$coor1; + $coor += 1; + } + } + } + for($i=0;$i<=$report;$i++){ + if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){ + $report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text); + if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){ + $j = $i+1; + $report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text); + $report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1); + $report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1); + $text = $report2."[/report".$i."]".$report1; + $report += 1; + } + } + } + $database->CreatTopic($title,$text,$cat,$owner,$alli,$ends,$alliance,$player,$coor,$report); } } +} if(isset($_POST['newpost'])){ - $post = $_POST['text']; - $post = htmlspecialchars($post); + $text = $_POST['text']; $tids = $_POST['tid']; $owner = $session->uid; - if($post != ""){ - if(!preg_match('/\[message\]/',$post) && !preg_match('/\[\/message\]/',$post)){ - $post = "[message]".$post."[/message]"; - $database->UpdatePostDate($tids); - $database->CreatPost($post,$tids,$owner); + if($text != ""){ + if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){ + $text = "[message]".$text."[/message]"; + $alliance = $player = $coor = $report = 0; + for($i=0;$i<=$alliance;$i++){ + if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){ + $alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text); + if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){ + $j = $i+1; + $alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text); + $alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1); + $alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1); + $text = $alliance2."[/alliance".$i."]".$alliance1; + $alliance += 1; + } + } + } + for($i=0;$i<=$player;$i++){ + if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){ + $player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text); + if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){ + $j = $i+1; + $player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text); + $player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1); + $player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1); + $text = $player2."[/player".$i."]".$player1; + $player += 1; + } + } + } + for($i=0;$i<=$coor;$i++){ + if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){ + $coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text); + if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){ + $j = $i+1; + $coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text); + $coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1); + $coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1); + $text = $coor2."[/coor".$i."]".$coor1; + $coor += 1; + } + } + } + for($i=0;$i<=$report;$i++){ + if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){ + $report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text); + if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){ + $j = $i+1; + $report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text); + $report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1); + $report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1); + $text = $report2."[/report".$i."]".$report1; + $report += 1; + } + } + } + $database->UpdatePostDate($tids); + $database->CreatPost($text,$tids,$owner,$alliance,$player,$coor,$report); } } } if(isset($_POST['editans'])){ - $post = $_POST['text']; + $text = $_POST['text']; + $text = preg_replace('/\[message\]/', '', $text); + $text = preg_replace('/\[\/message\]/', '', $text); + for($i=1;$i<=$_POST['alliance0'];$i++){ + $text = preg_replace('/\[alliance'.$i.'\]/', '[alliance0]', $text); + $text = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance0]', $text); + } + for($i=0;$i<=$_POST['player0'];$i++){ + $text = preg_replace('/\[player'.$i.'\]/', '[player0]', $text); + $text = preg_replace('/\[\/player'.$i.'\]/', '[/player0]', $text); + } + for($i=0;$i<=$_POST['coor0'];$i++){ + $text = preg_replace('/\[coor'.$i.'\]/', '[coor0]', $text); + $text = preg_replace('/\[\/coor'.$i.'\]/', '[/coor0]', $text); + } + for($i=0;$i<=$_POST['report0'];$i++){ + $text = preg_replace('/\[report'.$i.'\]/', '[report0]', $text); + $text = preg_replace('/\[\/report'.$i.'\]/', '[/report0]', $text); + } $topic_id = $_POST['tid']; - if(!preg_match('/\[message\]/',$post) && !preg_match('/\[\/message\]/',$post)){ - $post = "[message]".$post."[/message]"; - $database->EditUpdateTopic($topic_id,$post); + if($text != ""){ + if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){ + $text = "[message]".$text."[/message]"; + $alliance = $player = $coor = $report = 0; + for($i=0;$i<=$alliance;$i++){ + if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){ + $alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text); + if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){ + $j = $i+1; + $alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text); + $alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1); + $alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1); + $text = $alliance2."[/alliance".$i."]".$alliance1; + $alliance += 1; + } + } + } + for($i=0;$i<=$player;$i++){ + if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){ + $player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text); + if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){ + $j = $i+1; + $player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text); + $player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1); + $player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1); + $text = $player2."[/player".$i."]".$player1; + $player += 1; + } + } + } + for($i=0;$i<=$coor;$i++){ + if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){ + $coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text); + if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){ + $j = $i+1; + $coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text); + $coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1); + $coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1); + $text = $coor2."[/coor".$i."]".$coor1; + $coor += 1; + } + } + } + for($i=0;$i<=$report;$i++){ + if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){ + $report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text); + if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){ + $j = $i+1; + $report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text); + $report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1); + $report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1); + $text = $report2."[/report".$i."]".$report1; + $report += 1; + } + } + } + $database->EditUpdateTopic($topic_id,$text,$alliance,$player,$coor,$report); + } } } if(isset($_POST['editpost'])){ - $post = $_POST['text']; + $text = $_POST['text']; + $text = preg_replace('/\[message\]/', '', $text); + $text = preg_replace('/\[\/message\]/', '', $text); + for($i=1;$i<=$_POST['alliance0'];$i++){ + $text = preg_replace('/\[alliance'.$i.'\]/', '[alliance0]', $text); + $text = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance0]', $text); + } + for($i=0;$i<=$_POST['player0'];$i++){ + $text = preg_replace('/\[player'.$i.'\]/', '[player0]', $text); + $text = preg_replace('/\[\/player'.$i.'\]/', '[/player0]', $text); + } + for($i=0;$i<=$_POST['coor0'];$i++){ + $text = preg_replace('/\[coor'.$i.'\]/', '[coor0]', $text); + $text = preg_replace('/\[\/coor'.$i.'\]/', '[/coor0]', $text); + } + for($i=0;$i<=$text['report0'];$i++){ + $text = preg_replace('/\[report'.$i.'\]/', '[report0]', $text); + $text = preg_replace('/\[\/report'.$i.'\]/', '[/report0]', $text); + } $posts_id = $_POST['pod']; - if(!preg_match('/\[message\]/',$post) && !preg_match('/\[\/message\]/',$post)){ - $post = "[message]".$post."[/message]"; - $database->EditUpdatePost($posts_id,$post); + if($text != ""){ + if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){ + $text = "[message]".$text."[/message]"; + $alliance = $player = $coor = $report = 0; + for($i=0;$i<=$alliance;$i++){ + if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){ + $alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text); + if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){ + $j = $i+1; + $alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text); + $alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1); + $alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1); + $text = $alliance2."[/alliance".$i."]".$alliance1; + $alliance += 1; + } + } + } + for($i=0;$i<=$player;$i++){ + if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){ + $player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text); + if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){ + $j = $i+1; + $player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text); + $player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1); + $player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1); + $text = $player2."[/player".$i."]".$player1; + $player += 1; + } + } + } + for($i=0;$i<=$coor;$i++){ + if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){ + $coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text); + if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){ + $j = $i+1; + $coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text); + $coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1); + $coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1); + $text = $coor2."[/coor".$i."]".$coor1; + $coor += 1; + } + } + } + for($i=0;$i<=$report;$i++){ + if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){ + $report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text); + if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){ + $j = $i+1; + $report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text); + $report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1); + $report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1); + $text = $report2."[/report".$i."]".$report1; + $report += 1; + } + } + } + $database->EditUpdatePost($posts_id,$text,$alliance,$player,$coor,$report); + } } } if(!isset($_GET['admin'])) { diff --git a/install/data/sql.sql b/install/data/sql.sql index 80bba466..088f5640 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -717,6 +717,10 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%forum_post` ( `topic` varchar(255) NOT NULL, `owner` varchar(255) NOT NULL, `date` varchar(255) NOT NULL, + `alliance0` int(11) unsigned NOT NULL, + `player0` int(11) unsigned NOT NULL, + `coor0` int(11) unsigned NOT NULL, + `report0` int(11) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -743,6 +747,10 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%forum_topic` ( `ends` varchar(255) NOT NULL, `close` varchar(255) NOT NULL, `stick` varchar(255) NOT NULL, + `alliance0` int(11) unsigned NOT NULL, + `player0` int(11) unsigned NOT NULL, + `coor0` int(11) unsigned NOT NULL, + `report0` int(11) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;