require_once core system php echo only_reg echo ban header Общий чат r

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?
require_once '../core/system.php';
echo only_reg();
echo ban();
$header = 'Общий чат';
require_once H.'core/head.php';
mysql_query("DELETE FROM `chat` WHERE timer<='".$tm."' ");
if($user['mesto'] != 'Общий чат') mysql_query("UPDATE `user` set `mesto` = 'Общий чат' where `id` = '".$user['id']."' LIMIT 1");
if($user['save'] < 1){
header('Location: /');
}
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
$lelfi = $_SERVER['REQUEST_TIME'] - 60;
$elfilox = mysql_result(mysql_query("SELECT COUNT(id) FROM `chat` WHERE `msg` = '".$msg."' and `id_user` = '".$user['id']."' and `time`>".$lelfi.""),0);
if($elfilox > 0 ) {
$err = 'Сообщение повторяет предыдущее!';
header('Location: ? ');
}
if(mb_strlen($msg) < 1 or mb_strlen($msg) > 400) $err = 'Длина сообщения должна быть от 1 до 400 символов';
if($user['level'] < 10) $err = 'Писать в чате можно только с 10 уровня!';
if(!isset($err)) {
$f = $_SERVER['REQUEST_TIME']+43200;
if(!isset($_GET['edit'])) {
mysql_query("INSERT INTO `chat` SET `id_user` = '".$user['id']."', `msg` = '".$msg."', `timer` = '".$f."', `time` = '".$_SERVER['REQUEST_TIME']."'");
} else {
mysql_query("UPDATE `chat` SET `msg`='".$msg."' WHERE `id`='".intval($_GET['id_msg'])."'");
}
header('Location: ?');
exit();
} else {
header('Location: ?');
$_SESSION['err'] = $err;
exit();
}
} else {
header('Location: ?');
$_SESSION['err'] = 'Введите текст';
exit();
}
break;
default:
if(isset($_GET['del'])){
if($user['prava'] < 2){
$_SESSION['error'] = 'Ошибка!';
header("Location: ?");exit;}
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `chat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?");
}
$k_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `chat` WHERE `hiking`='' and `elit`=''"),0);
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
echo '<div class="foot">
<a href="?"><img src="/images/icon/reload.png"> Обновить
</a>
<span class="float-right">
<a href="/moduls/smiles">
<img src="/images/icon/smiley.png"> Смайлики</a>
</span>
</div>
<div class="line"></div>';
$req = mysql_query("SELECT * from `ban` where `id_us` = '".$user['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$ban = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto == 0){
if(isset($_GET['edit']) && $user['prava'] > 3) {
$uu = mysql_query("SELECT * FROM `chat` WHERE `id`='".intval($_GET['id_msg'])."' LIMIT 1");
$edo = mysql_fetch_array($uu);
echo '<div class="head">
<div class="empty"></div>
<form method="post" action="?act=post&edit&id_msg='.intval($_GET['id_msg']).'">
<input class="chat-area" value="'.$edo['msg'].'" name="msg" />
</textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить">
</span>
</form>
</div>';
} else {
if(isset($_GET['id'])) {
$ank = mysql_fetch_array(mysql_query("SELECT nick FROM `user` WHERE `id` = '".abs(intval($_GET['id']))."' LIMIT 1"));
echo '<div class="head">
<div class="empty"></div>
<form method="post" action="?act=post">
<input class="chat-area" value="'.$ank['nick'].', " name="msg" />
</textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить">
</span>
</form>
</div>';
} else {
echo'<div class="head">
<div class="empty"></div>
<form method="post" action="?act=post">
<textarea rows="3" class="chat-area" name="msg">
</textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить">
</span>
</form>
</div>';
}
}
echo '<div class="line"></div>';
}
$q = mysql_query("SELECT * FROM `chat` WHERE `hiking`='' and `elit`='' ORDER BY `id` DESC LIMIT ".$start.", 10");
while($post = mysql_fetch_array($q)) {
$to = mysql_fetch_array(mysql_query("SELECT * FROM `chat` WHERE `msg` LIKE '%".$user['nick'].",%'"));
$sata = array('"'.$user['nick'].',", '.$to.'');
if($to['']==$user['nick']){
echo'<font color="orange">'.$sata[1].'</font>';
}
echo''.$sata['2'].'';
$ank = mysql_fetch_array(mysql_query("SELECT id,font,prava,nick FROM `user` WHERE `id` = ".$post['id_user']." LIMIT 1"));
$req = mysql_query("SELECT id from `ban` where `id_us` = '".$ank['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$avto = mysql_num_rows($req);
if($avto > 0){
echo'<div class="player">';
echo online($ank['id']);
echo ' <a href="/user/'.$ank['id'].'/"><font color="'.$ank['font'].'">'.$ank['nick'].'</font></a>';
if($ank['nick'] != $user['nick']){
echo '<a href="?id='.$ank['id'].'"> (+)</a>';
}
echo '<span class="mit">'.vremja($post['time']).'</span>';
if ($user['prava'] >= 4){
echo'</br>'.smiles($post['msg']).' <font color="#FE2E2E">[BANED]</font>';
}
if ($user['prava'] >= 2){
echo' <a href="?del&id_msg='.$post['id'].'">[X]</a>';
}
echo'</br>
<font color="'.$color.'"> </font>';
?>
</div>
<div class="line"></div>
</div>
<?
} else {
if($ank['prava']==5){
$status="<font color='ffc22b'>[A]</font>"; $color="#F7990D";}
if($ank['prava']==4){
$status="<font color='ffc22b'>[a]</font>"; $color="EBC621";}
if($ank['prava']==3){
$status="<font color='ffc22b'>[M]</font>";
}
if($ank['prava']==2){
$status="<font color='ffc22b'>[m]</font>";
}
?>
<div class="player">
<?
echo online($ank['id']);
echo ' <a href="/user/'.$ank['id'].'/">
<font color="'.$ank['font'].'">'.$ank['nick'].'</font>
</a>';
if($ank['prava'] > 1){
echo $status;
}
if($ank['nick'] != $user['nick']){
echo' <a href="?id='.$ank['id'].'">(+)</a>';
}
echo '<span class="mit">'.date("H:i:s", $post['time']).' </span>';
if ($user['prava'] >= 2){
echo" <a href='?del&id_msg=".$post['id']."'>[X]</a>";
}
if ($user['prava'] > 3){
echo' <span class="float-right"><a href="?edit&id_msg='.$post['id'].'">[Изм.]</a></span>';
}
if ($ank['prava'] >= 4){
echo'</br>
<font color="'.$color.'">'.smiles(antimat($post['msg'])).'</font>
</font> ';
} else {
echo'</br>'.smiles(antimat($post['msg'])).' ';
}
?>
</div>
<div class="line"></div>
<?
}
}
?>
</div>
</div>
<?
if ($k_page > 1){
str('?',$k_page,$page);
?>
<div class="line"></div>
<?
}
$chat = mysql_result(mysql_query("SELECT COUNT(id) FROM `user` WHERE `mesto`='Общий чат' and `online` > '".($_SERVER['REQUEST_TIME']-10800)."'"),0);
?>
<div class="mli">
<div class="empty2"></div>
<center>
Сейчас в общем чате
<a href="info">
<?=$chat?> игроков
</a>
</center>
<div class="empty2"></div>
</div>
<?
}
require_once H.'core/foot.php';
?>