Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Logowanie - dostęp do podstron
buddha
post
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 7.09.2017

Ostrzeżenie: (0%)
-----


Witajcie.

Postaram się wam opisać mój problem.

Moim głównym założeniem jest ustawienie na stronie głównej
formularza do wyszukiwania innych użytkowników, lecz niestety
po przejściu dalej zdjęcia oraz inne szczegółowe dane
użytkowników są nie widoczne.

Próbowałem wyłączyć logowanie czy też ustawić standard
na zalogowany, lecz cały portal ma w sobie bardzo wiele złożonych
funkcji. Myślę że jednym z sposobów będzie ustawienie dla każdej
nie zalogowanej osoby id

  1. function isLogged() {
  2.  
  3. global $mysqli;
  4.  
  5.  
  6.  
  7. if (!empty($_SESSION['user']) && is_numeric($_SESSION['user']) && $_SESSION['user'] > 0) {
  8.  
  9. $user_id = secureEncode($_SESSION['user']);
  10.  
  11. $query = "SELECT COUNT(id) AS count FROM usuarios WHERE id=$user_id";
  12.  
  13. $sql_query = $mysqli->query($query);
  14.  
  15. $sql_fetch = mysqli_fetch_assoc($sql_query);
  16.  
  17.  
  18.  
  19. return $sql_fetch['count'];
  20.  
  21. }
  22.  
  23. }


oraz

  1. function getSearchUserInfo($uid) {
  2. global $mysqli,$sm;
  3. $uid = secureEncode($uid);
  4. $user = $mysqli->query("SELECT id,name,city,country,online_day,age,fake,gender FROM users WHERE id = '".$uid."'");
  5. $u = $user->fetch_object();
  6. $first_name = explode(' ',trim($u->name));
  7. $first_name = explode('_',trim($first_name[0]));
  8. //CURENT USER
  9. $current_user['id'] = $u->id;
  10. $current_user['first_name'] = $first_name[0];
  11. $current_user['name'] = $u->name;
  12. $current_user['profile_photo'] = profilePhoto($u->id);
  13. $current_user['city'] = $u->city;
  14. $current_user['country'] = $u->country;
  15. $current_user['age'] = $u->age;
  16. $current_user['gender'] = $u->gender;
  17. $current_user['link'] = clean($first_name[0]);
  18. $current_user['fake'] = $u->fake;
  19. $current_user['online_day'] = $u->online_day;
  20. $sm['search'] = $current_user;
  21. }


Macie jakieś pomysły? Rozwiązanie zapewne banalne, ale cos nie moge wymyślić.

_____________________


Na początku pliku profile/content.php mam taki kod

  1. if($_GET['id'] != NULL ){
  2.  
  3. $usid = secureEncode($_GET['id']);
  4.  
  5. getUserInfo($usid,1);
  6.  
  7. }




Ten post edytował buddha 12.10.2017, 19:42:03
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
buddha
post
Post #2





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 7.09.2017

Ostrzeżenie: (0%)
-----


@nospor wybacz, jestem strasznie narwany. Borykam się z tym problem ponad tydzień.

Znalazłem w tym samym pliku też taką funkcje

  1. function searchUser($q) {
  2.  
  3. global $mysqli,$sm;
  4.  
  5. $search = '';
  6.  
  7. $query = $mysqli->query("SELECT id FROM users where id = '".$q."' OR name LIKE '%$q%' OR email LIKE '%$q%' LIMIT 10");
  8.  
  9.  
  10.  
  11. if ($query->num_rows > 0) {
  12.  
  13. while($user = $query->fetch_object()){
  14.  
  15. getUserInfo($user->id,6);
  16.  
  17. $search .= ' <tr>
  18.  
  19. <td class="man-photos"><div class="profile-photo" data-src="'.$sm['search']['profile_photo'].'"></td>
  20.  
  21. <td>'.$sm['search']['id'].'</td>
  22.  
  23. <td>'.$sm['search']['name'].' , '.$sm['search']['age'].'
  24.  
  25. '; if($sm['search']['last_access'] >= $time_now) {
  26.  
  27. $search .= ' <i class="fa fa-circle text-success" style="font-size:8px;"></i>';
  28.  
  29. }
  30.  
  31.  
  32.  
  33. $search .= '
  34.  
  35. </td>
  36.  
  37. <td>'.$sm['search']['email'].'</td>
  38.  
  39. <td>'.$sm['search']['city'].'</td>
  40.  
  41. <td>'.$sm['search']['country'].'</td>
  42.  
  43. <td>'.$sm['search']['credits'].'</td>
  44.  
  45. <td>'.$sm['search']['total_photos'].'</td>
  46.  
  47. <td>'.$sm['search']['join_date'].'</td>
  48.  
  49. <td><a href="index.php?page=profile&id='.$sm['search']['id'].'" target="_blank" class="label label-info">View</a>
  50.  
  51. <a href="index.php?page=admin&p=user&id='.$sm['search']['id'].'" target="_blank" class="label label-primary">Edit</a></td>
  52.  
  53. </tr>';
  54.  
  55. }
  56.  
  57. }
  58.  
  59. return $search;
  60.  
  61. }


i znalazłem też

  1. function getUserInfo($uid,$value=0) {
  2.  
  3. global $mysqli,$sm;
  4.  
  5.  
  6.  
  7. $uid = secureEncode($uid);
  8.  
  9. $user = $mysqli->query("SELECT * FROM users WHERE id = '".$uid."'");
  10.  
  11. $u = $user->fetch_object();
  12.  
  13. $first_name = explode(' ',trim($u->name));
  14.  
  15. $first_name = explode('_',trim($first_name[0]));
  16.  
  17. //CURRENT USER
  18.  
  19. $current_user['id'] = $u->id;
  20.  
  21. $current_user['name'] = $u->name;
  22.  
  23. $current_user['email'] = $u->email;
  24.  
  25. $current_user['gender'] = $u->gender;
  26.  
  27. $current_user['facebook_id'] = $u->facebook_id;
  28.  
  29. $current_user['twitter_id'] = $u->twitter_id;
  30.  
  31. $current_user['google_id'] = $u->google_id;
  32.  
  33. $current_user['instagram_id'] = $u->instagram_id;
  34.  
  35. $current_user['first_name'] = $first_name[0];
  36.  
  37. $current_user['profile_photo'] = profilePhoto($u->id);
  38.  
  39. $current_user['profile_photo_thumb'] = profilePhotoThumb($u->id);
  40.  
  41. $current_user['total_photos'] = getUserTotalPhotos($u->id);
  42.  
  43. $current_user['total_photos_public'] = getUserTotalPhotosPublic($u->id);
  44.  
  45. $current_user['total_photos_private'] = getUserTotalPhotosPrivate($u->id);
  46.  
  47. $current_user['total_likers'] = getUserTotalLikers($u->id);
  48.  
  49. $current_user['total_likes'] = getUserTotalLikes($u->id);
  50.  
  51. $current_user['extended'] = userExtended($u->id);
  52.  
  53. $current_user['interest'] = userInterest($u->id);
  54.  
  55. $current_user['status_info'] = userFilterStatus($u->id);
  56.  
  57. //$current_user['status'] = userStatus($u->id);
  58.  
  59. $current_user['city'] = $u->city;
  60.  
  61. $current_user['country'] = $u->country;
  62.  
  63. $current_user['age'] = $u->age;
  64.  
  65. $current_user['lat'] = $u->lat;
  66.  
  67. $current_user['lng'] = $u->lng;
  68.  
  69. $current_user['birthday'] = $u->birthday;
  70.  
  71. $current_user['last_access'] = $u->last_access;
  72.  
  73. $current_user['admin'] = $u->admin;
  74.  
  75. $current_user['lang'] = $u->lang;
  76.  
  77. $current_user['looking'] = $u->looking;
  78.  
  79. $current_user['premium'] = $u->premium;
  80.  
  81. $current_user['premium_check'] = adminCheckUserPremium($uid);
  82.  
  83. $current_user['verified'] = $u->verified;
  84.  
  85. $current_user['popular'] = $u->popular;
  86.  
  87. $current_user['credits'] = $u->credits;
  88.  
  89. $current_user['link'] = clean($first_name[0]);
  90.  
  91. $current_user['status'] = userStatus($u->id);
  92.  
  93. $current_user['online'] = userStatusIcon($u->id);
  94.  
  95. $current_user['fake'] = $u->fake;
  96.  
  97. $current_user['join_date'] = $u->join_date;
  98.  
  99. $current_user['bio'] = $u->bio;
  100.  
  101. $current_user['s_gender'] = $u->s_gender;
  102.  
  103. $current_user['s_radius'] = $u->s_radious;
  104.  
  105. $current_user['s_age'] = $u->s_age;
  106.  
  107. $current_user['online_day'] = $u->online_day;
  108.  
  109. if($value == 1){
  110.  
  111. $sm['profile'] = $current_user;
  112.  
  113. } else if($value == 2){
  114.  
  115. $sm['meet'] = $current_user;
  116.  
  117. } else if($value == 3){
  118.  
  119. $sm['chat'] = $current_user;
  120.  
  121. } else if($value == 4){
  122.  
  123. $sm['friend'] = $current_user;
  124.  
  125. } else if($value == 5){
  126.  
  127. $sm['videocall'] = $current_user;
  128.  
  129. } else if($value == 6){
  130.  
  131. $sm['search'] = $current_user;
  132.  
  133. } else if($value == 7){
  134.  
  135. $sm['manage'] = $current_user;
  136.  
  137. } else if($value == 8){
  138.  
  139. $sm['edit'] = $current_user;
  140.  
  141. } else if($value == 9){
  142.  
  143. $sm['comment'] = $current_user;
  144.  
  145. } else if($value == 10){
  146.  
  147. $sm['suggest'] = $current_user;
  148.  
  149. } else if($value == 11){
  150.  
  151. $sm['gift'] = $current_user;
  152.  
  153. } else if($value == 12){
  154.  
  155. $sm['mail'] = $current_user;
  156.  
  157. } else{
  158.  
  159. $sm['user'] = $current_user;
  160.  
  161. }
  162.  
  163. }



  1. function getUserPhotos($uid,$i=0,$x=0,$y=0,$b=0){
  2.  
  3. global $mysqli,$sm;
  4.  
  5. $photo = "";
  6.  
  7. if($i == 1){
  8.  
  9. $photos = $mysqli->query("SELECT * FROM users_photos WHERE u_id = '".$uid."' and approved = 1 order by id desc LIMIT 200");
  10.  
  11. } else if($b == 1){
  12.  
  13. $photos = $mysqli->query("SELECT * FROM users_photos WHERE approved = 1 and u_id = '".$uid."' and blocked = 1 order by id desc LIMIT 200");
  14.  
  15. } else {
  16.  
  17. $photos = $mysqli->query("SELECT * FROM users_photos WHERE approved = 1 and u_id = '".$uid."' and blocked = 0 order by id desc LIMIT 200");
  18.  
  19. }
  20.  
  21. if ($photos->num_rows > 0) {
  22.  
  23. while($up = $photos->fetch_object()){
  24.  
  25. getUserInfo($uid,1);
  26.  
  27. $photoData['id'] = $up->id;
  28.  
  29. $photoData['src'] = $up->photo;
  30.  
  31. $photoData['desc'] = $up->desc;
  32.  
  33. $photoData['user'] = $sm['profile']['name'];
  34.  
  35. $photoData['photo'] = $sm['profile']['profile_photo'];
  36.  
  37. $photoData['blocked'] = $up->blocked;
  38.  
  39. $photoData['like'] = checkPhotoLike($sm['user']['id'],$up->id);
  40.  
  41. $photoData['likes'] = getPhotoLikes($up->id);
  42.  
  43. $photoData['comments'] = getPhotoComments($up->id);
  44.  
  45. $sm['photo'] = $photoData;
  46.  
  47. if($i == 1 && $x == 0){
  48.  
  49. $photo .= getPage('profile/mphoto');
  50.  
  51. } else if($x == 1){
  52.  
  53. $photo .= requestPage('profile/mphoto');
  54.  
  55. } else {
  56.  
  57. $photo .= requestPage('profile/photo');
  58.  
  59. }
  60.  
  61. }
  62.  
  63. }
  64.  
  65. return $photo;
  66.  
  67. }

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 18.10.2025 - 12:42