From 4daacf6639ed546134f8892314dc5b80bfb39e55 Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:03:35 +0300 Subject: [PATCH] Profile update! --- app/Controllers/Api/Profile/Update.php | 56 +++++ app/Controllers/ApiController.php | 4 + app/Controllers/ProfileController.php | 4 + app/Core/Routes.php | 2 + app/Models/Comment.php | 10 +- views/components/Navbar.php | 2 +- views/pages/Profile/Index.php | 16 +- views/pages/Profile/LK/Index.php | 2 +- views/pages/Profile/LK/Profile.php | 291 +++++++++++++++++++++++++ 9 files changed, 383 insertions(+), 4 deletions(-) create mode 100644 app/Controllers/Api/Profile/Update.php create mode 100644 views/pages/Profile/LK/Profile.php diff --git a/app/Controllers/Api/Profile/Update.php b/app/Controllers/Api/Profile/Update.php new file mode 100644 index 0000000..3e18ce1 --- /dev/null +++ b/app/Controllers/Api/Profile/Update.php @@ -0,0 +1,56 @@ + $value) { + if (strpos($key, 'about') === 0) { + $paramKey = $key; + + if (!isset($dataArray[$paramKey])) { + $dataArray[$paramKey] = []; + } + + if (strpos($key, 'OnMain') === false) { + $dataArray[$paramKey]['value'] = $value; + } + } + } + + $user = new \App\Models\User(Auth::userid()); + $content = json_decode($user->i('content'), true); + $existingArray = array_replace_recursive($content, $dataArray); + + $newJson = json_encode($existingArray, JSON_PRETTY_PRINT); + + if (isset($_FILES['userphoto'])) { + $upload = new UploadPhoto($_FILES['userphoto'], 'cdn/img/'); + if ($upload->getType() !== null) { + $this->photourl = $upload->getSrc(); + } else { + $this->photourl = $user->i('photourl'); + } + } else { + $this->photourl = $user->i('photourl'); + } + + DB::query('UPDATE users SET content=:c, photourl=:ph WHERE id=:id', [':id' => Auth::userid(), ':c' => $newJson, ':ph'=>$this->photourl]); + + + } +} diff --git a/app/Controllers/ApiController.php b/app/Controllers/ApiController.php index 9146f13..921150a 100644 --- a/app/Controllers/ApiController.php +++ b/app/Controllers/ApiController.php @@ -9,6 +9,7 @@ use \App\Controllers\Api\Images\{Upload}; use \App\Controllers\Api\Images\Rate as PhotoVote; use \App\Controllers\Api\Images\Comment as PhotoComment; use \App\Controllers\Api\Images\CommentsLoad as PhotoCommentLoad; +use \App\Controllers\Api\Profile\Update as ProfileUpdate; class ApiController { @@ -31,6 +32,9 @@ class ApiController public static function photocommentload() { return new PhotoCommentLoad(); } + public static function updateprofile() { + return new ProfileUpdate(); + } } \ No newline at end of file diff --git a/app/Controllers/ProfileController.php b/app/Controllers/ProfileController.php index e7f05af..91eb4c5 100644 --- a/app/Controllers/ProfileController.php +++ b/app/Controllers/ProfileController.php @@ -25,6 +25,10 @@ class ProfileController { Page::set('Profile/LK/History'); } + public static function lkprofile() + { + Page::set('Profile/LK/Profile'); + } } \ No newline at end of file diff --git a/app/Core/Routes.php b/app/Core/Routes.php index 8d64dc0..fa9556b 100644 --- a/app/Core/Routes.php +++ b/app/Core/Routes.php @@ -29,7 +29,9 @@ class Routes Router::get('/lk', 'ProfileController@lk'); Router::get('/lk/upload', 'ProfileController@upload'); Router::get('/lk/history', 'ProfileController@lkhistory'); + Router::get('/lk/profile', 'ProfileController@lkprofile'); Router::post('/api/upload', 'ApiController@upload'); + Router::post('/api/profile/update', 'ApiController@updateprofile'); Router::post('/api/photo/comment', 'ApiController@photocomment'); Router::post('/api/photo/getcomments/$id', 'ApiController@photocommentload'); } else { diff --git a/app/Models/Comment.php b/app/Models/Comment.php index 5507faf..26d6427 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -17,7 +17,15 @@ class Comment { '.Date::zmdate($this->c['posted_at']).'
-
'.$user->i('username').' ·
+
'.$user->i('username').' · + '; + if (json_decode($user->i('content'), true)['aboutrid']['value'] != null) { + echo ''; + } + if (json_decode($user->i('content'), true)['aboutlive']['value'] != null) { + echo ' '.json_decode($user->i('content'), true)['aboutlive']['value']; + } + echo '
Фото: '.Photo::fetchAll($this->c['user_id']).'
'.$this->c['body'].'
diff --git a/views/components/Navbar.php b/views/components/Navbar.php index 592cce2..d170d65 100644 --- a/views/components/Navbar.php +++ b/views/components/Navbar.php @@ -69,7 +69,7 @@ $user = new \App\Models\User(Auth::userid());
  • Правка БД
  • Мои видео
  • Мои заявки
  • -
  • Настройки профиля
  • +
  • Настройки профиля
  • Личные сообщения
  • Мои фотографии
  • Избранные снимки
  • diff --git a/views/pages/Profile/Index.php b/views/pages/Profile/Index.php index a96e480..6707946 100644 --- a/views/pages/Profile/Index.php +++ b/views/pages/Profile/Index.php @@ -39,6 +39,13 @@ $userprofile = new User(explode('/', $_SERVER['REQUEST_URI'])[2]); content('location') ?> + i('content'), true)['aboutlive']['value'] != null) { ?> + + Откуда: + i('content'), true)['aboutlive']['value'] ?> + + Дата регистрации: content('regdate')) ?> @@ -50,8 +57,15 @@ $userprofile = new User(explode('/', $_SERVER['REQUEST_URI'])[2]);

    - + i('content'), true)['aboutmemo']['value'] != null) { ?> +
    +

    О себе

    +i('content'), true)['aboutmemo']['value'])?> +
    + + + + + + +

    Ссылка на публичный профиль: i('username')?>

    +
    + + + + + + + + + + + + + + + + i('content'), true)['aboutrid']['value']; + return $result; + } + + + $selectedCountryId = getSelectedCountryId(); + $optionsHtml = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + function addSelectedAttribute($optionsHtml, $selectedValue) { + return preg_replace_callback( + '/'; + }, + $optionsHtml + ); + } + ?> +
    + +

    Информация

    + + + +
    Страна:
    + +
    Откуда:
    + + +
    + + + + +
    + +

    О себе

    + +
    + + +
    + +
    Фотография
    +
    + +
    +
    Для загрузки принимаются файлы JPEG объемом до 200 КБ и шириной не более 800 пикселей
    +
    + +
    + +
    +
    + +
    +
    + + + + + + + + + + \ No newline at end of file