mirror of
https://github.com/WerySkok/nativegallery.git
synced 2024-12-23 00:50:58 +03:00
Login created!
This commit is contained in:
parent
3649e03d8f
commit
c0637969fc
6 changed files with 142 additions and 81 deletions
|
@ -43,21 +43,15 @@ class Login
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
$loc = $data['country'].', '.$data['city'];
|
$loc = $data['country'].', '.$data['city'];
|
||||||
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id, :platform, :browser, :browserversion, 0, :ip, :servicekey, :loc)', array(
|
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id)', array(
|
||||||
':token' => $token,
|
':token' => $token,
|
||||||
':user_id' => $user_id,
|
':user_id' => $user_id,
|
||||||
':platform' => $ua->platform(),
|
|
||||||
':browser' => $ua->browser(),
|
|
||||||
':browserversion' => $ua->browserVersion(),
|
|
||||||
':ip' => $ip,
|
|
||||||
':servicekey' => $servicekey,
|
|
||||||
':loc' => $loc
|
|
||||||
));
|
));
|
||||||
|
|
||||||
setcookie("BIRUXSESS", $token, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
setcookie("NGALLERYSESS", $token, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
||||||
setcookie("BIRUXSERVICE", $servicekey, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
setcookie("NGALLERYSERVICE", $servicekey, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
||||||
setcookie("BIRUXSESS_", '1', time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
setcookie("NGALLERYSESS_", '1', time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
||||||
setcookie("BIRUXID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
setcookie("NGALLERYID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE);
|
||||||
|
|
||||||
echo Json::return (
|
echo Json::return (
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -56,7 +56,7 @@ class Register
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
DB::query('INSERT INTO users VALUES (\'0\', :username, :email, :password 5, :content)', array(':username' => ltrim($username), ':password' => password_hash(ltrim($password), PASSWORD_BCRYPT), ':email' => $email, ':content' => $content));
|
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));
|
||||||
$cstrong = True;
|
$cstrong = True;
|
||||||
$token = GenerateRandomStr::gen_uuid();
|
$token = GenerateRandomStr::gen_uuid();
|
||||||
$user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id'];
|
$user_id = DB::query('SELECT id FROM users WHERE username=:username', array(':username' => $username))[0]['id'];
|
||||||
|
@ -81,15 +81,10 @@ class Register
|
||||||
|
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
$loc = $data['country'].', '.$data['city'];
|
$loc = $data['country'].', '.$data['city'];
|
||||||
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id, :platform, :browser, :browserversion, 0, :ip, :servicekey, :loc)', array(
|
DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id)', array(
|
||||||
':token' => $token,
|
':token' => $token,
|
||||||
':user_id' => $user_id,
|
':user_id' => $user_id,
|
||||||
':platform' => $ua->platform(),
|
|
||||||
':browser' => $ua->browser(),
|
|
||||||
':browserversion' => $ua->browserVersion(),
|
|
||||||
':ip' => $ip,
|
|
||||||
':servicekey' => $servicekey,
|
|
||||||
':loc' => $loc
|
|
||||||
));
|
));
|
||||||
|
|
||||||
setcookie("NGALLERYSESS", $token, time() + 120 * 180 * 240 * 720, '/', NULL, NULL, TRUE);
|
setcookie("NGALLERYSESS", $token, time() + 120 * 180 * 240 * 720, '/', NULL, NULL, TRUE);
|
||||||
|
|
15
app/Models/User.php
Normal file
15
app/Models/User.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
use \App\Services\DB;
|
||||||
|
|
||||||
|
class User {
|
||||||
|
|
||||||
|
public $userid;
|
||||||
|
function __construct(int $user_id) {
|
||||||
|
$this->userid = $user_id;
|
||||||
|
}
|
||||||
|
public function i($table) {
|
||||||
|
return DB::query("SELECT * FROM users WHERE id=:id", array(':id'=>$this->userid))[0][$table];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,18 +9,17 @@ class Auth
|
||||||
{
|
{
|
||||||
$userid = 0;
|
$userid = 0;
|
||||||
|
|
||||||
if (!empty($_COOKIE['NGALLERYSESS']) && !empty( $_COOKIE['NGALLERYSESS_']) || $_COOKIE['KANDLESERVICETOKEN__779hfh908BNol8FHn7d9MNFOL8fjND8D9MNfdo'] ==='BIRUXSERVICE__TOKENYY') {
|
if (!empty($_COOKIE['NGALLERYSESS']) && !empty($_COOKIE['NGALLERYSESS_'])) {
|
||||||
$userInfo = DB::query('SELECT user_id FROM login_tokens WHERE token=:token', array(':token' => $_COOKIE['NGALLERYSESS']));
|
$userInfo = DB::query('SELECT user_id FROM login_tokens WHERE token=:token', array(':token' => $_COOKIE['NGALLERYSESS']));
|
||||||
if ($userInfo && count($userInfo) > 0) {
|
if ($userInfo && count($userInfo) > 0) {
|
||||||
$userid = $userInfo[0]['user_id'];
|
$userid = $userInfo[0]['user_id'];
|
||||||
DB::query('UPDATE users SET online=:timed WHERE id=:id', array(':id'=>$userid, ':timed'=>time()));
|
|
||||||
} else if ($_COOKIE['KANDLESERVICETOKEN__779hfh908BNol8FHn7d9MNFOL8fjND8D9MNfdo'] ==='BIRUXSERVICE__TOKENYY') {
|
//DB::query('UPDATE users SET online=:timed WHERE id=:id', array(':id'=>$userid, ':timed'=>time()));
|
||||||
return 1000000013;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $userid;
|
return (int)$userid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
ngallery:
|
||||||
|
root:
|
||||||
|
maintenance: false
|
||||||
|
debug: true
|
||||||
|
botkey: '89D5D5DDS9SD'
|
||||||
|
db:
|
||||||
|
name: 'kndle'
|
||||||
|
host: '127.127.126.50'
|
||||||
|
login: 'root'
|
||||||
|
password: ''
|
||||||
|
websockets:
|
||||||
|
messages: "wss://birux.ru/wss"
|
||||||
|
storage:
|
||||||
|
type: 's3'
|
||||||
|
s3:
|
||||||
|
domains:
|
||||||
|
public: 'cdn.biruxpages.eu.org'
|
||||||
|
gateway: 'https://ebe2250f09e5d59d02abd3b5eb483b4b.eu.r2.cloudflarestorage.com'
|
||||||
|
credentials:
|
||||||
|
key: 'e5eb99cd33ef7b25a1cf2090cd1dc592'
|
||||||
|
secret: '4d7c5ed69cad0e28c545ea825fb51997c92127655f344b60efcfec64d0e4c2ff'
|
||||||
|
region: 'auto'
|
||||||
|
version: 'latest'
|
||||||
|
bucket: 'birux'
|
||||||
|
img:
|
||||||
|
proxy: true
|
||||||
|
percent: 50
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use \App\Services\Auth;
|
||||||
|
use \App\Models\User;
|
||||||
|
|
||||||
|
$user = new \App\Models\User(Auth::userid());
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="mm-bar">
|
<td class="mm-bar">
|
||||||
<ul class="mm mm-level-1">
|
<ul class="mm mm-level-1">
|
||||||
|
@ -47,8 +54,30 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<?php
|
||||||
|
if (Auth::userid() < 0) { ?>
|
||||||
<li class="mm-pad-right"><a href="/login" class="mm-item"><span class="mm-icon"><i class="fas fa-xs fa-address-card"></i></span><span class="mm-label">Войти</span></a></li>
|
<li class="mm-pad-right"><a href="/login" class="mm-item"><span class="mm-icon"><i class="fas fa-xs fa-address-card"></i></span><span class="mm-label">Войти</span></a></li>
|
||||||
<li><a href="/register" class="mm-item"><span class="mm-icon"><i class="fas fa-xs fa-user"></i></span><span class="mm-label">Регистрация</span></a></li>
|
<li><a href="/register" class="mm-item"><span class="mm-icon"><i class="fas fa-xs fa-user"></i></span><span class="mm-label">Регистрация</span></a></li>
|
||||||
|
<?php } else { ?>
|
||||||
|
<li class="mm-pad-right mm-wide"><a href="/author/32944/" class="mm-item"><span class="mm-icon"><i class="fas fa-xs fa-user"></i></span><span class="mm-label"><?=$user->i('username')?></span></a>
|
||||||
|
<div>
|
||||||
|
<ul class="mm-level-2">
|
||||||
|
<li><a href="/lk/" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-info-circle"></i></span><span class="mm-label">Общая информация</span></a></li>
|
||||||
|
<li><a href="/lk/upload.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-plus-square"></i></span><span class="mm-label"><b>Предложить фото</b></span></a></li>
|
||||||
|
<li><a href="/lk/history.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-images"></i></span><span class="mm-label">Журнал</span></a></li>
|
||||||
|
<li><a href="/lk/konkurs.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-compass"></i></span><span class="mm-label">Конкурс</span></a></li>
|
||||||
|
<li><a href="/lk/vehicles.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-folder-plus"></i></span><span class="mm-label"><b>Правка БД</b></span></a></li>
|
||||||
|
<li><a href="/lk/video.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-film"></i></span><span class="mm-label">Мои видео</span></a></li>
|
||||||
|
<li><a href="/lk/ticket.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-question-circle"></i></span><span class="mm-label">Мои заявки</span></a></li>
|
||||||
|
<li><a href="/lk/profile.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-cog"></i></span><span class="mm-label">Настройки профиля</span></a></li>
|
||||||
|
<li><a href="/lk/pm.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-comments"></i></span><span class="mm-label">Личные сообщения</span></a></li>
|
||||||
|
<li><a href="/search.php?aid=32944" class="mm-item"><span class="mm-icon"><i class="far fa-sm fa-fw fa-images"></i></span><span class="mm-label">Мои фотографии</span></a></li>
|
||||||
|
<li><a href="/fav.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-star"></i></span><span class="mm-label">Избранные снимки</span></a></li>
|
||||||
|
<li><a href="/logout.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-sign-out-alt"></i></span><span class="mm-label">Выход</span></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue