update: now you cannot write the values [message] or [/message] in your message + fix addressbook

This commit is contained in:
unknown
2012-06-10 19:37:42 +03:00
parent 72b8ddf9c2
commit 57eaa07638
5 changed files with 99 additions and 89 deletions
+9
View File
@@ -3090,6 +3090,15 @@
}
return $casualties;
}
function addFriend($uid, $column, $friend) {
$q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid";
return mysql_query($q, $this->connection);
}
function deleteFriend($uid, $column) {
$q = "UPDATE " . TB_PREFIX . "users SET $column = 0 WHERE id = $uid";
return mysql_query($q, $this->connection);
}
}
;
+35 -1
View File
@@ -63,6 +63,9 @@
case "m6":
$this->createNote($post);
break;
case "m7":
$this->addFriends($post);
break;
}
}
}
@@ -307,14 +310,16 @@
if($topic == "") {
$topic = "No subject";
}
if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){
$text = "[message]".$text."[/message]";
if($permission[opt7]==1){
if ($userally != 0) {
while ($allmembers = mysql_fetch_array($allmembersQ)) {
$database->sendMessage($allmembers[id],$session->uid,$topic,$text,0);
}
}
}
}
}
}
private function sendMessage($recieve, $topic, $text) {
@@ -327,6 +332,7 @@
if($topic == "") {
$topic = "No subject";
}
if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){
$text = "[message]".$text."[/message]";
//if to multihunter
if($user == "0") {
@@ -335,6 +341,7 @@
} else {
$database->sendMessage($user, $session->uid, $topic, $text, 0);
}
}
}
//7 = village, attacker, att tribe, u1 - u10, lost %, w,c,i,c , cap
@@ -408,5 +415,32 @@
return false;
}
public function addFriends($post) {
global $database;
for($i=0;$i<19;$i++) {
if($post['addfriends'.$i] != ""){
$uid = $database->getUserField($post['addfriends'.$i], "id", 1);
$added = 0;
for($j=0;$j<=$i;$j++) {
if($added == 0){
$user = $database->getUserField($post['myid'], "friend".$j, 0);
$exist = 0;
for($k=0;$k<=19;$k++){
$user1 = $database->getUserField($post['myid'], "friend".$k, 0);
if($user1 == $uid or $user1 == $post['myid']){
$exist = 1;
}
}
if($user == 0 && $exist == 0){
$database->addFriend($post['myid'],"friend".$j,$uid);
$added = 1;
}
}
}
}
}
header("Location: nachrichten.php?t=1");
}
}
;
+31 -88
View File
@@ -2,6 +2,7 @@
<h1>Messages</h1>
<?php
include("menu.tpl");
$user = $database->getUserArray($session->uid, 1);
?>
<script language="JavaScript" type="text/javascript">
function setReceiver(name) {
@@ -97,101 +98,43 @@ Reply:
</p>
</form>
<div id="adressbook" class="hide"><h2>Addressbook</h2>
<form method="post" name="abform" action="nachrichten.php" accept-charset="UTF-8">
<input type="hidden" name="a" value="3e9" />
<input type="hidden" name="t" value="1" />
<input type="hidden" id="copy_receiver" name="copy_receiver" value="" />
<input type="hidden" id="copy_subject" name="copy_subject" value="" />
<input type="hidden" id="copy_igm" name="copy_igm" value="" />
<input type="hidden" name="sbmtype" value="default" />
<input type="hidden" name="sbmvalue" value="" />
<table cellpadding="1" cellspacing="1" id="friendlist"><tr><td class="end"></td>
<form method="post" action="nachrichten.php">
<input type="hidden" name="ft" value="m7" />
<input type="hidden" name="myid" value="<?php echo $session->uid; ?>" />
<table cellpadding="1" cellspacing="1" id="friendlist">
<?php for($i=0;$i<20;$i++) {
if($user['friend'.$i] == 0){
if(is_int($i/2)){ echo "<tr>"; } ?><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[0]" value="" maxlength="15" />
<input class="text" type="text" name="addfriends<?php echo $i; ?>" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="on"></td><?php if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";}}else{
if(is_int($i/2)){ echo "<tr>"; } ?><td class="end"><a href="nachrichten.php?delfriend=<?php echo $i; ?>"><img class="del" src="img/x.gif" alt="delete" title="delete"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[1]" value="" maxlength="15" />
<?php echo "<a href=\"spieler.php?uid=".$user['friend'.$i]."\">".$database->getUserField($user['friend'.$i],"username",0)."</a>"; ?>
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[2]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[3]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[4]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[5]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[6]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[7]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[8]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[9]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[10]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[11]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[12]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[13]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[14]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[15]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[16]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[17]" value="" maxlength="15" />
</td>
<td class="on"></td></tr><tr><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[18]" value="" maxlength="15" />
</td>
<td class="on"></td><td></td><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends[19]" value="" maxlength="15" />
</td>
<td class="on"></td></tr></table>
<?php
$friend = $database->getUserArray($user['friend'.$i], 1);
if ((time()-600) < $friend['timestamp']){ // 0 Min - 10 Min
echo " <td class=on><img class=online1 src=img/x.gif title='Now online' alt='Now online' /></td>";
}elseif ((time()-86400) < $friend['timestamp'] && (time()-600) > $friend['timestamp']){ // 10 Min - 1 Days
echo " <td class=on><img class=online2 src=img/x.gif title='Offline' alt='Offline' /></td>";
}elseif ((time()-259200) < $friend['timestamp'] && (time()-86400) > $friend['timestamp']){ // 1-3 Days
echo " <td class=on><img class=online3 src=img/x.gif title='Last 3 days' alt='Last 3 days' /></td>";
}elseif ((time()-604800) < $friend['timestamp'] && (time()-259200) > $friend['timestamp']){
echo " <td class=on><img class=online4 src=img/x.gif title='Last 7 days' alt='Last 7 days' /></td>";
}else{
echo " <td class=on><img class=online5 src=img/x.gif title=now online alt=now online /></td>";
}
if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";}
}} ?>
</tr></table>
<p class="btn">
<input type="image" value="" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save" />
</p>
</form><a href="#" onclick="closeFriendsList(); return false;"><img src="img/x.gif" id="close" alt="close adressbook" title="close adressbook"/></a></div></div>
<div id="write_foot" class="msg_foot">
</div>
<br />
</div>
<br />
<span style="color: #DD0000"><b>Warning:</b> you can't use the values <b>[message]</b> or <b>[/message]</b> in your message because it can cause problem with bbcode system.</span>
</div>
+20
View File
@@ -1354,6 +1354,26 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%users` (
`oldrank` bigint(255) unsigned NOT NULL DEFAULT '0',
`regtime` int(10) unsigned NOT NULL DEFAULT '0',
`invited` int(10) unsigned NOT NULL DEFAULT '0',
`friend0` int(10) unsigned NOT NULL,
`friend1` int(10) unsigned NOT NULL,
`friend2` int(10) unsigned NOT NULL,
`friend3` int(10) unsigned NOT NULL,
`friend4` int(10) unsigned NOT NULL,
`friend5` int(10) unsigned NOT NULL,
`friend6` int(10) unsigned NOT NULL,
`friend7` int(10) unsigned NOT NULL,
`friend8` int(10) unsigned NOT NULL,
`friend9` int(10) unsigned NOT NULL,
`friend10` int(10) unsigned NOT NULL,
`friend11` int(10) unsigned NOT NULL,
`friend12` int(10) unsigned NOT NULL,
`friend13` int(10) unsigned NOT NULL,
`friend14` int(10) unsigned NOT NULL,
`friend15` int(10) unsigned NOT NULL,
`friend16` int(10) unsigned NOT NULL,
`friend17` int(10) unsigned NOT NULL,
`friend18` int(10) unsigned NOT NULL,
`friend19` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
+4
View File
@@ -27,6 +27,10 @@ if(isset($_GET['t'])) {
header("Location: ".$_SERVER['PHP_SELF']);
}
}
if(isset($_GET['delfriend']) && is_numeric($_GET['delfriend'])){
$database->deleteFriend($session->uid,"friend".$_GET['delfriend']);
header("Location: ".$_SERVER['PHP_SELF']."?t=1");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>