From 8a896c9cfb4eb6275dacd9325e8358d6804d57fd Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Fri, 5 Jul 2024 06:33:46 +0300 Subject: [PATCH] update profiles --- app/Controllers/Api/Register.php | 2 +- app/Controllers/ProfileController.php | 22 ++++++ app/Core/Routes.php | 5 +- app/Models/User.php | 4 + app/Services/Auth.php | 2 +- static/img/avatar.png | Bin 0 -> 9354 bytes views/pages/Profile/Index.php | 107 ++++++++++++++++++++++++++ views/pages/Profile/LK.php | 45 +++++++++++ 8 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 app/Controllers/ProfileController.php create mode 100644 static/img/avatar.png create mode 100644 views/pages/Profile/LK.php diff --git a/app/Controllers/Api/Register.php b/app/Controllers/Api/Register.php index c4d99dd..b384585 100644 --- a/app/Controllers/Api/Register.php +++ b/app/Controllers/Api/Register.php @@ -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']; diff --git a/app/Controllers/ProfileController.php b/app/Controllers/ProfileController.php new file mode 100644 index 0000000..0798df0 --- /dev/null +++ b/app/Controllers/ProfileController.php @@ -0,0 +1,22 @@ + 0) { - + Router::get('/lk', 'ProfileController@lk'); } else { - //Router::redirect('/login?return='.$_SERVER['HTTP_REFERER']); + Router::redirect('/login?return='.$_SERVER['HTTP_REFERER']); } } } diff --git a/app/Models/User.php b/app/Models/User.php index 3a42772..6587593 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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]; + } } \ No newline at end of file diff --git a/app/Services/Auth.php b/app/Services/Auth.php index 437ef3e..92fcdd0 100644 --- a/app/Services/Auth.php +++ b/app/Services/Auth.php @@ -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())); } } diff --git a/static/img/avatar.png b/static/img/avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..730037c1d6f5e4106472e5af6fd1917e7ed0a14f GIT binary patch literal 9354 zcmeHtdpMNa`}af?6%{e$P`i@$3o+5gxV$IL5))m5i?G;(Jn%c zI}AD2AmxzEI13F!jKObBd++!9zVG$^^S*z7U6;$V*1Ffd)_U%H-S_AIJRV*!H`ya7 zDF}nX_FzoUSi)dDWbW@ye$bEWZ1b};ISni6l9~pM?QW;epMt^uOxVS7;sb4g zTc%h2U@)OZ?(eo1pTg@f7(y0v=9G1?{oL>ki-TX@yczwuwbdxb6Cy|0DRk=4ncsIt zZwS536na1ASnV2j^;jwPt>Ikx$*B3y7Bj0`GTUH>9-;(cMv{0@*c~k@5(e{ta4;AR z4mL(Xp|`s7e$1N;OB1^o;T4P6iR^IHlI3)=_| z30W(lN7SoqN-(>5o^`*0*bTWvw;kLz>5?WeX61F%?7RmJNjnT%a z0$HW-j@3UIlY8&=JMs}-Af8w;vS$1x?;UQPe}=fD9^n6=b_bla+?LV>=My^;uS$)M zMTwK=r=|*Z*b~+q$#B`i_-8y=aHn4%XjCp~hjPSB4q)-#51UJuS*%_iKC!>xe6Dil z)h*>I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{`HCxAZMk$OT%&>Zz5mP94F}uwiS9 zE~{d9H{d{G4!lIWC9$KwB&LngBuYP<`-R|djd`rYV8RW6e|P`AuDm@T*oZtn38>er zs;yNCZ#5;cF5TLRPm=$NRl^Ku>)c1RiQuhCWj7kvEv@^S!^7wE2FuPsgf z@Zzb~M2Gl>gk0s^0lO`Ra6-Uqzy}7z9Jm;VAzT)mOrnIXZ*HvrD@!2Y{!@00!>L)_ z2DWxhf-Ln8KK_vVdbGi=;AA}%8e{`k$d|h%0&h=Cf~*{7pei^|>-!{=xdmHEJ%Y7) U6c7mhe+Y&-YksEWwBzsp0};asb^rhX literal 0 HcmV?d00001 diff --git a/views/pages/Profile/Index.php b/views/pages/Profile/Index.php index e69de29..c0a6821 100644 --- a/views/pages/Profile/Index.php +++ b/views/pages/Profile/Index.php @@ -0,0 +1,107 @@ + + + + + + + + + + + + +
+ + + + + +
+

i('username') ?>

+ i('id') === Auth::userid()) { ?> +

Редактировать мой профиль

+ + + + + + +
+
+ + + content('location') !== null) { ?> + + + + + + + + + + + + + + + + + + + + + +
Откуда:content('location') ?>
Дата регистрации:content('regdate')) ?>
Рейтинг:фото 0, комментарии +1
Время у пользователя:06:22
Был на сайте:i('online')) ?> i('online')) { ?>(online)
+

+
+
Пользователей, подписанных на мои фотографии: 2

+ +

Отправить личное сообщение пользователю

+
+ + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/views/pages/Profile/LK.php b/views/pages/Profile/LK.php new file mode 100644 index 0000000..66dfcf8 --- /dev/null +++ b/views/pages/Profile/LK.php @@ -0,0 +1,45 @@ + + + + + + + + + + + + +
+ + + + + + + +
+

Общая информация

+

Здравствуйте, i('username')?>!

+

+ Количество ваших фотографий на сайте: Auth::userid()))[0]['COUNT(*)']?>

+

Всего фотографий в очереди на публикацию: 2175


+

Индекс загрузки

+

Текущее значение индекса загрузки: i('uploadindex')?>

+
+ + +
+ + +
  + +
+ + + + \ No newline at end of file