php case edit if core dbs- querySingle SELECT COUNT user FROM users WH

  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
<?php
case 'edit':
if (core::$dbs->querySingle("SELECT COUNT(user) FROM users WHERE id=?",array($id)) == 0)
{
fnc::message('Нет такого юзера','error');
break;
}
$data_user = core::$dbs->queryFetch("SELECT * FROM users WHERE id=? LIMIT 1", array($id));
]
if (!isset($_POST['submit'])) {
if(isset($_GET['saved'])) echo fnc::message('Профайл изменен!','success');
if(isset($_GET['error'])) echo fnc::message('Ошибка при записи!','error');
$data = array();
$data = unserialize($data_user['moder']);
echo "<form action='?do=user&amp;act=edit&amp;id={$data_user['id']}' method='post'>\n";
echo '<div class="ank"><b><u>ID: ' . $data_user['id'] . '</u></b><br/>';
//echo '<b><u>Смотреть анкету:</u></b> <a href="/id'.$data_user['id'] . '?from='.base64_encode('/apanel/?do=user&amp;act=edit&amp;id='.$data_user['id']).'">' . $data_user['user'] . '</a><br /><br />';
echo '<b><u>Смотреть анкету:</u></b> <a href="/id'.$data_user['id'] . '">' . $data_user['user'] . '</a><br /><br />';
echo 'Ник:<br/>';
echo "<input name='upnick' value='{$data_user['user']}' title='nick'/><br/>\n";
echo 'Постов форума:<br/>';
echo "<input name='postsf' value='{$data_user['postsf']}' title='posts'/><br/>\n";
echo 'Статус:<br/>';
echo "<input name='status' value='{$data_user['status']}' title='status'/><br/>\n";
echo 'Секретный E-mail:<br/>';
echo "<input name='mail_secret' value='{$data_user['mail_secret']}' title='mail_secret'/><br/>\n";
if ($level>=8) {
echo 'Балланс (руб.)<br/>';
echo "<input name='rur' value='{$data_user['rur']}' title='rur'/><br/>\n";
echo 'wmid<br/>';
echo "<input name='wmid' value='{$data_user['wmid']}' title='rur'/><br/>\n";
echo 'кошелек<br/>';
echo "<input name='wmr' value='{$data_user['wmr']}' title='rur'/><br/>\n";
echo 'QIWI кошелёк<br/>';
echo "<input name='qiwi' value='{$data_user['qiwi']}' title='qiwi'/><br/>\n";
}
echo 'Активность<br/>
<input name="activity" value="'.round($data_user['activity'],2,2).'"/><br/>';
if ($data_user['level']<=$level){
echo "<b>Уровень</b>:<br/>\n";
echo '<select name="right">';
echo '<option value="'.$data_user['level'].'">'.$data_user['level'].'-'.fnc::lev($data_user['level']).'</option>';
for($i = 0;$i <= ($level-1);$i++){
echo '<option value="'.$i.'">'.$i.'-'.fnc::lev($i).'</option>';
}
echo '</select><br/>';
}
$checked = ($data_user['kurator_zc'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="kurator_zc" type="checkbox" value="1"'.$checked.' /> ';
echo 'Куратор ЗЦ</label><br/>';
$checked = ($data_user['jur'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="jur" type="checkbox" value="1"'.$checked.' /> ';
echo 'Журналист</label><br/>';
$checked = ($data_user['qiwi_check'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="qiwi_check" type="checkbox" value="1"'.$checked.' /> ';
echo 'Подтвердить QIWI</label><br/>';
$checked = ($data_user['exk'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="exk" type="checkbox" value="1"'.$checked.' /> ';
echo 'Запретить доступ к эксклюзиву</label><br/>';
$checked = ($data_user['ex_elit'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="ex_elit" type="checkbox" value="1"'.$checked.' /> ';
echo 'Запретить доступ к элитным файлам</label><br/>';
$checked = ($data_user['wm_check'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="wm_check" type="checkbox" value="1"'.$checked.' /> ';
echo 'Подтвердить WMID</label><br/>';
/*$checked = ($data['forum'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="forum" type="checkbox" value="1"'.$checked.' /> ';
echo 'Модератор форума</label><br/>';
$checked = ($data['blog'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="blog" type="checkbox" value="1"'.$checked.' /> ';
echo 'Модератор блогов</label><br/>';
$checked = ($data['share'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="share" type="checkbox" value="1"'.$checked.' /> ';
echo 'Модератор обменника</label><br/>';
$checked = ($data['table'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="table" type="checkbox" value="1"'.$checked.' /> ';
echo 'Модератор стол заказов</label><br/>';
$checked = ($data['total'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="total" type="checkbox" value="1"'.$checked.' /> ';
echo 'Модератор тотализатора</label><br/>';
$checked = ($data_user['wpy'] == 1) ? ' checked="checked"' : '';
echo '<label><input name="wpy" type="checkbox" value="1"'.$checked.' /> ';
echo 'Шпион</label><br/>';
*/
echo "<input type='submit' name='submit' value='Сохранить'/></form></div>\n";
echo '<div class="main"><a href="?do=user&amp;act=password&amp;id=' . $data_user['id'] . '">Сменить пароль</a></div>';
} else{
$qiwi = isset($_POST['qiwi']) ? fnc::check($_POST['qiwi']) : null;
$qiwi_check = (int)$_POST['qiwi_check'];
$wm_check = (int)$_POST['wm_check'];
$upnick = fnc::check($_POST['upnick']);
$mail_secret = fnc::check($_POST['mail_secret']);
$status = fnc::check($_POST['status']);
$rur = fnc::check($_POST['rur']);
$wmid = intval($_POST['wmid']);
$wmr = intval($_POST['wmr']);
$postsf = intval($_POST['postsf']);
$gposts = intval($_POST['gposts']);
$exk = intval($_POST['exk']);
$ex_elit = intval($_POST['ex_elit']);
$activity = fnc::check($_POST['activity']);
$right = abs(intval($_POST['right']));
$wpy = intval($_POST['wpy']);
$jur = intval($_POST['jur']);
$kurator_zc = intval($_POST['kurator_zc']);
$data['share'] = isset($_POST['share']) ? abs((int)$_POST['share']) : 0;
$data['forum'] = isset($_POST['forum']) ? abs((int)$_POST['forum']) : 0;
$data['blog'] = isset($_POST['blog']) ? abs((int)$_POST['blog']) : 0;
$data['table'] = isset($_POST['table']) ? abs((int)$_POST['table']) : 0;
$data['total'] = isset($_POST['total']) ? abs((int)$_POST['total']) : 0;
$data = serialize($data);
$latuser = mb_strtolower(fnc::rus_to_k($_POST['upnick']));
$upnick = str_replace(' ','',$upnick);
if ($upnick == '') {
fnc::message('Ошибка обновления!','error');
break;
}
$b = core::$dbs->queryFetch("SELECT user,level FROM users WHERE id =? LIMIT 1;",array($id));
$prl = $b['level'];
$nnick = $b['user'];
if (core::$dbs->querySingle("SELECT COUNT(id) FROM users WHERE latuser=? AND user!=?",array($latuser,$upnick)) !=0){
fnc::message('Такой ник уже занят!','error');
break;
}
if($right >= $user_data['right'])
{
fnc::message('Иди нахуй, не пашет!','error');
break;
}
if (($id == 11 and $level < 8) || ($id == 1 and $level < 8)) {
fnc::message('Не надо снимать Супер-Админа!','error');
break;
}
if ($nick != $upnick)
fnc::f('nick',$nick,'',$ip,$user_agent,($sex==1?'сменил':'сменила').' Ник юзеру с ID: '.$id.'('.$nnick.'=>'.$upnick);
$_SESSION['login'] = $b['user'];
if(core::$dbs->query("UPDATE users SET
user = ?,
postsf = ?,
status = ?,
activity = ?,
level = ?,
latuser = ?,
wpy = ?,
moder = ?,
kurator_zc = ?,
jur = ?,
mail_secret = ?,
rur = ?,
wmid = ?,
wmr = ?,
qiwi = ?,
qiwi_check = ?,
exk = ?,
ex_elit = ?,
wm_check = ?
WHERE
id = ? LIMIT 1",array($upnick,$postsf,$status,$activity,$right,$latuser,$wpy,$data,$kurator_zc,$jur,$mail_secret,$rur,$wmid,$wmr,$qiwi,$qiwi_check,$exk,$ex_elit,$wm_check,$id)))
{
if ($b['user'] != $upnick) {
$text = ''.$nick.' сменил Ваш ник на '.$upnick.'';
fnc::lenta($id,$text,'prochee');
core::$dbs->query("INSERT INTO nicks SET user_id = ?, nick_1 = ?, nick_2 = ?, who = ?, time = ?",array($id,$_SESSION['login'],$upnick,$user_id,time()));
}
if ($prl != $level)
{
$ur = fnc::lev($right);
$text = 'Вам был присвоен уровень '.$ur.'';
fnc::lenta($id,$text,'prochee');
$mmes = fnc::lev($level)." ".$nick." присваивает ".$upnick." уровень ".$ur."!";
fnc::f('upd',$nick,'',$ip,$user_agent,$mmes);
}
msg('Данные сохранены!');
header('location: '.$_SERVER['HTTP_REFERER']);
} else header('Location:?do=user&act=edit&id=' . $id . '&error');
}
break;