mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-15 03:31:10 +03:00
user admin edit
This commit is contained in:
parent
2fcdd47091
commit
8e10948f82
3 changed files with 58 additions and 19 deletions
|
@ -98,7 +98,7 @@ class Register
|
|||
)
|
||||
);
|
||||
|
||||
DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password, :photourl, 5, 0, :online, :content)', array(':username' => ltrim($username), ':password' => password_hash(ltrim($password), PASSWORD_BCRYPT), ':photourl'=>'/static/img/avatar.png', ':email' => $email, ':content' => $content, ':online'=>time()));
|
||||
DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password, :photourl, 5, 0, :online, 0, :content)', array(':username' => ltrim($username), ':password' => password_hash(ltrim($password), PASSWORD_BCRYPT), ':photourl'=>'/static/img/avatar.png', ':email' => $email, ':content' => $content, ':online'=>time()));
|
||||
$cstrong = True;
|
||||
$token = GenerateRandomStr::gen_uuid();
|
||||
$user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id'];
|
||||
|
|
|
@ -41,7 +41,7 @@ class Routes
|
|||
Router::get('/api/photo/vote', 'ApiController@photovote');
|
||||
Router::get('/api/photo/comment/rate', 'ApiController@photocommentvote');
|
||||
|
||||
Router::get('/admin', 'AdminController@index');
|
||||
Router::any('/admin', 'AdminController@index');
|
||||
|
||||
Router::get('/logout', 'MainController@logout');
|
||||
Router::get('/404', 'ExceptionRegister@notfound');
|
||||
|
|
|
@ -1,13 +1,52 @@
|
|||
<?php
|
||||
use \App\Services\Date;
|
||||
use \App\Services\{Date, DB};
|
||||
$user = new \App\Models\User($_GET['user_id']);
|
||||
|
||||
if ($user->i('id') === null) {
|
||||
die('Пользователь не найден');
|
||||
}
|
||||
|
||||
// Функция для обновления JSON и возврата обновленных данных
|
||||
function updateJson($data, $key, $value) {
|
||||
$data[$key] = $value;
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (isset($_POST['subbtn'])) {
|
||||
// Получение данных из формы
|
||||
$premoderation = $_POST['premoderation'];
|
||||
$accountstatus = $_POST['accountstatus'];
|
||||
$admin = $_POST['admin'];
|
||||
|
||||
// Предполагаем, что у вас есть user_id, полученный из сессии или другого источника
|
||||
$userId = $_GET['user_id'];
|
||||
|
||||
// Получение текущего JSON из базы данных
|
||||
$currentJson = $user->i('content');
|
||||
|
||||
if (!empty($currentJson)) {
|
||||
$currentJson = json_decode($currentJson, true);
|
||||
|
||||
// Обновление JSON данных
|
||||
$updatedJson = updateJson($currentJson, 'premoderation', $premoderation);
|
||||
$updatedJsonString = json_encode($updatedJson, JSON_PRETTY_PRINT);
|
||||
|
||||
// Обновление базы данных
|
||||
DB::query("UPDATE users SET status = ?, admin = ?, content = ? WHERE id = ?", [
|
||||
$accountstatus,
|
||||
$admin,
|
||||
$updatedJsonString,
|
||||
$userId
|
||||
]);
|
||||
|
||||
echo "Данные успешно обновлены.";
|
||||
} else {
|
||||
echo "Ошибка: JSON данные не найдены.";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<form method="post" name="form" id="form" enctype="multipart/form-data" style="display:inline-block; min-width:500px;">
|
||||
<form action="/admin?type=UserEdit&user_id=<?=$_GET['user_id']?>" method="post" name="form" id="form" enctype="multipart/form-data" style="display:inline-block; min-width:500px;">
|
||||
|
||||
<p><img src="<?=$user->i('photourl')?>" width="50"> <?=$user->i('username')?></p>
|
||||
<p>Был в сети: <b><?= Date::zmdate($user->i('online')) ?> <?php if (time() - 300 <= $user->i('online')) { ?><i>(online)</i><?php } ?></b></p>
|
||||
|
@ -19,19 +58,19 @@ if ($user->i('id') === null) {
|
|||
|
||||
|
||||
<div style="margin-bottom:3px; margin-top:5px">Прямая загрузка</div>
|
||||
<select name="aboutrid" style="width:100%">
|
||||
<option value="0">Да</option>
|
||||
<option value="24">Нет</option>
|
||||
<select name="premoderation" style="width:100%">
|
||||
<option value="true" <?php if ($user->content('premoderation') === 'true') { echo 'selected'; } ?>>Да</option>
|
||||
<option value="false" <?php if ($user->content('premoderation') === 'false' || $user->content('premoderation') === null) { echo 'selected'; } ?>>Нет</option>
|
||||
</select>
|
||||
<div style="margin-bottom:3px; margin-top:5px">Статус аккаунта</div>
|
||||
<select name="aboutrid" style="width:100%">
|
||||
<option value="0">Без ограничений</option>
|
||||
<option value="24">Заблокирован</option>
|
||||
<select name="accountstatus" style="width:100%">
|
||||
<option value="0" <?php if ($user->i('status') === 0) { echo 'selected'; } ?>>Без ограничений</option>
|
||||
<option value="1" <?php if ($user->i('status') === 1) { echo 'selected'; } ?>>Заблокирован</option>
|
||||
</select>
|
||||
<div style="margin-bottom:3px; margin-top:5px">Фотомодератор</div>
|
||||
<select name="aboutrid" style="width:100%">
|
||||
<option value="0">Да</option>
|
||||
<option value="24">Нет</option>
|
||||
<select name="admin" style="width:100%">
|
||||
<option value="2" <?php if ($user->i('admin') === 2) { echo 'selected'; } ?>>Да</option>
|
||||
<option value="0" <?php if ($user->i('admin') === 0) { echo 'selected'; } ?>>Нет</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
@ -44,6 +83,6 @@ if ($user->i('id') === null) {
|
|||
|
||||
</div>
|
||||
|
||||
<div class="cmt-submit"><input type="submit" value="Применить"></div>
|
||||
<div class="cmt-submit"><input name="subbtn" type="submit" value="Применить"></div>
|
||||
|
||||
</form>
|
Loading…
Reference in a new issue