mirror of
https://github.com/WerySkok/nativegallery.git
synced 2024-12-22 16:41:17 +03:00
update profiles
This commit is contained in:
parent
c0637969fc
commit
8a896c9cfb
8 changed files with 183 additions and 4 deletions
|
@ -56,7 +56,7 @@ class Register
|
|||
)
|
||||
);
|
||||
|
||||
DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password, :photourl, 5, :content)', array(':username' => ltrim($username), ':password' => password_hash(ltrim($password), PASSWORD_BCRYPT), ':photourl'=>'/static/img/avatar.png', ':email' => $email, ':content' => $content));
|
||||
DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password, :photourl, 5, :online, :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'];
|
||||
|
|
22
app/Controllers/ProfileController.php
Normal file
22
app/Controllers/ProfileController.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use \App\Services\{Router, Auth, DB, Json};
|
||||
use \App\Controllers\ExceptionRegister;
|
||||
use \App\Core\Page;
|
||||
|
||||
class ProfileController
|
||||
{
|
||||
|
||||
|
||||
public static function lk()
|
||||
{
|
||||
Page::set('Profile/LK');
|
||||
}
|
||||
public static function i()
|
||||
{
|
||||
Page::set('Profile/Index');
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,15 +15,16 @@ class Routes
|
|||
Router::get('/login', 'LoginController@i');
|
||||
Router::get('/register', 'RegisterController@i');
|
||||
Router::get('/photo/$id', 'PhotoController@i');
|
||||
Router::get('/author/$id', 'ProfileController@i');
|
||||
Router::post('/api/login', 'ApiController@login');
|
||||
Router::post('/api/register', 'ApiController@register');
|
||||
|
||||
|
||||
|
||||
if (Auth::userid() > 0) {
|
||||
|
||||
Router::get('/lk', 'ProfileController@lk');
|
||||
} else {
|
||||
//Router::redirect('/login?return='.$_SERVER['HTTP_REFERER']);
|
||||
Router::redirect('/login?return='.$_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,5 +11,9 @@ class User {
|
|||
public function i($table) {
|
||||
return DB::query("SELECT * FROM users WHERE id=:id", array(':id'=>$this->userid))[0][$table];
|
||||
}
|
||||
public function content($table) {
|
||||
$content = json_decode(self::i('content'), true);
|
||||
return $content[$table];
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ class Auth
|
|||
if ($userInfo && count($userInfo) > 0) {
|
||||
$userid = $userInfo[0]['user_id'];
|
||||
|
||||
//DB::query('UPDATE users SET online=:timed WHERE id=:id', array(':id'=>$userid, ':timed'=>time()));
|
||||
DB::query('UPDATE users SET online=:timed WHERE id=:id', array(':id'=>$userid, ':timed'=>time()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
static/img/avatar.png
Normal file
BIN
static/img/avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
use \App\Services\{Auth, DB, Date};
|
||||
use \App\Models\User;
|
||||
|
||||
$user = new User(explode('/', $_SERVER['REQUEST_URI'])[2]);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="backgr"></div>
|
||||
<table class="tmain">
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
|
||||
<tr>
|
||||
<td class="main">
|
||||
<h1><?= $user->i('username') ?></h1>
|
||||
<?php
|
||||
if ($user->i('id') === Auth::userid()) { ?>
|
||||
<p><b><a href="/lk/profile">Редактировать мой профиль</a></b></p>
|
||||
<?php } ?>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" width="100%">
|
||||
<div class="p20" style="padding-right:12px">
|
||||
<table>
|
||||
<col width="170px">
|
||||
<?php
|
||||
if ($user->content('location') !== null) { ?>
|
||||
<tr>
|
||||
<td class="sm" style="padding:3px 10px 3px 0">Откуда:</td>
|
||||
<td><?= $user->content('location') ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td class="sm" style="padding:3px 10px 3px 0">Дата регистрации:</td>
|
||||
<td><span class="sm"><?= Date::zmdate($user->content('regdate')) ?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm" style="padding:3px 10px 3px 0">Рейтинг:</td>
|
||||
<td><span class="sm">фото <b>0</b>, комментарии <b>+1</b></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm" style="padding:3px 10px 3px 0">Время у пользователя:</td>
|
||||
<td><span class="sm"><b>06:22</b></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm" style="padding:3px 10px 3px 0">Был на сайте:</td>
|
||||
<td><span class="sm"><?= Date::zmdate($user->i('online')) ?> <?php if (time() - 300 <= $user->i('online')) { ?>(<b>online</b>)<?php } ?></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><br />
|
||||
<div class="sm" style="float:right"><a href="/lk/ticket.php?action=add&aid=140"></a></div>
|
||||
<div>Пользователей, подписанных на мои фотографии: <b>2</b></div><br>
|
||||
<div><b><a href="/comments.php?w-aid=140">Комментарии, написанные этим пользователем</a><br />
|
||||
<a href="/favorites/?aid=140&type=1">Избранное пользователя</a></b></div>
|
||||
<p><b><a href="/lk/pm.php?action=new&to=140">Отправить личное сообщение пользователю</a></b></p>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<script>
|
||||
function getBodyScrollTop() {
|
||||
return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
|
||||
}
|
||||
|
||||
function showUserPhoto() {
|
||||
_getID('userphoto_big_img').src = '<?= $user->i('photourl') ?>';
|
||||
_getID('userphoto_big_div').style.top = '' + (getBodyScrollTop() + 10) + 'px';
|
||||
_getID('userphoto_big_div').style.display = 'block';
|
||||
}
|
||||
|
||||
function hideUserPhoto() {
|
||||
_getID('userphoto_big_div').style.display = 'none';
|
||||
}
|
||||
|
||||
document.onclick = function(e) {
|
||||
e = e || window.event;
|
||||
E = e.target || e.srcElement;
|
||||
if (E.id != 'userphoto_big_div' && E.id != 'userphoto_img') {
|
||||
_getID('userphoto_big_div').style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="userphoto_big_div" style="position:absolute; display:none; border:1px solid gray; padding:10px; background-color:white; margin:auto; text-align:center; right:100px; z-index:3000" class="p5 shadow"><a href="#" onclick="hideUserPhoto(); return false"><img src="" id="userphoto_big_img" border="0" style="vertical-align:middle"></a>
|
||||
<div style="margin-top:8px"><a class="dot" href="#" onclick="hideUserPhoto(); return false">закрыть</a></div>
|
||||
</div>
|
||||
|
||||
<a href="<?= $user->i('photourl') ?>" onclick="showUserPhoto(); return false;"><img src="<?= $user->i('photourl') ?>" alt="" id="userphoto_img" class="f" style="width:auto; max-width:100px"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
45
views/pages/Profile/LK.php
Normal file
45
views/pages/Profile/LK.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
use \App\Services\{Auth, DB};
|
||||
use \App\Models\User;
|
||||
$user = new User(Auth::userid());
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="backgr"></div>
|
||||
<table class="tmain">
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
|
||||
<tr>
|
||||
<td class="main">
|
||||
<h1>Общая информация</h1>
|
||||
<h4>Здравствуйте, <a href="/author/<?=Auth::userid()?>/"><?=$user->i('username')?></a>!</h4>
|
||||
<p>
|
||||
Количество ваших фотографий на сайте: <b><?=DB::query('SELECT COUNT(*) FROM photos WHERE user_id=:uid', array(':uid'=>Auth::userid()))[0]['COUNT(*)']?></b></p>
|
||||
<p>Всего фотографий в очереди на публикацию: <b>2175</b></p><br />
|
||||
<h4>Индекс загрузки</h4>
|
||||
<p>Текущее значение <a href="/page/111" class="und">индекса загрузки</a>: <b><?=$user->i('uploadindex')?></b></p>
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue