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
function isLogged() { http://www.php.net/global $mysqli; if (!http://www.php.net/empty($_SESSION['user']) && http://www.php.net/is_numeric($_SESSION['user']) && $_SESSION['user'] > 0) { $user_id = secureEncode($_SESSION['user']); $query = "SELECT COUNT(id) AS count FROM usuarios WHERE id=$user_id"; $sql_query = $mysqli->query($query); $sql_fetch = mysqli_fetch_assoc($sql_query); return $sql_fetch['count']; } }
function getSearchUserInfo($uid) { http://www.php.net/global $mysqli,$sm; $uid = secureEncode($uid); $user = $mysqli->query("SELECT id,name,city,country,online_day,age,fake,gender FROM users WHERE id = '".$uid."'"); $u = $user->fetch_object(); $first_name = http://www.php.net/explode(' ',http://www.php.net/trim($u->name)); $first_name = http://www.php.net/explode('_',http://www.php.net/trim($first_name[0])); //CURENT USER $current_user['id'] = $u->id; $current_user['first_name'] = $first_name[0]; $current_user['name'] = $u->name; $current_user['profile_photo'] = profilePhoto($u->id); $current_user['city'] = $u->city; $current_user['country'] = $u->country; $current_user['age'] = $u->age; $current_user['gender'] = $u->gender; $current_user['link'] = clean($first_name[0]); $current_user['fake'] = $u->fake; $current_user['online_day'] = $u->online_day; $sm['search'] = $current_user; }
if($_GET['id'] != NULL ){ $usid = secureEncode($_GET['id']); getUserInfo($usid,1); }
Nie za bardzo rozumiem w czym masz problem. Może zmień na fetch_assoc? Szukasz użytkowników z ich preferencjami, danymi z bazy; tak? Jeśli np. w formularzu zaznaczyłeś checkbox'y o ile masz, wpisałeś jakich ma danych szukać, to tylko musisz dać odpowiedni warunek w kodzie, po stronie back-end'u.
Na czas testów powyrzucaj wszystkie empty, isset, null'e, redirect'y, itp., ponieważ przez to najprawdopodobniej Ci się dane nie wyświetlają.
Zmienić na fetch_assoc?
Tak, szukam użytkowników przez preferencje z bazy
Mój cały kod strony z wyszukiwaniem wygląda tak
( wszystko działa, lecz niestety tylko gdy jestem zalogowany )
<?php $e_age = http://www.php.net/explode( ',', $sm['user']['s_age'] ); $age = $e_age[2]; $age2 = $e_age[1]; $age1 = $e_age[0]; ?> <script> url = "search"; </script> <div class="search-people-container" style="display:none"> <div class="container relative search-people"> <div class="search-text"> </div> <div class="search-form" style="display:none;"> <h2 class="show-me"><?= $sm['lang'][109]['text']; ?></h2> <input type="hidden" value="0" id="meet_filter_limit" data-filter="meet_filter_limit" /> <select class="select1" data-filter="meet_filter_gender" id="meet_filter_gender"> <option value="2" <?php if($sm[ 'user'][ 's_gender']==2 ) { http://www.php.net/echo 'selected'; } ?>> <?= $sm['lang'][110]['text']; ?> </option> <option value="1" <?php if($sm[ 'user'][ 's_gender']==1 ) { http://www.php.net/echo 'selected'; } ?>> <?= $sm['lang'][111]['text']; ?> </option> <option value="3" <?php if($sm[ 'user'][ 's_gender']==3 ) { http://www.php.net/echo 'selected'; } ?>> <?= $sm['lang'][112]['text']; ?> </option> </select> <input class="select2" style="width: 115px;" value="<?= $age1;?>" type="number" min="18" max="99" data-filter="meet_filter_age1" id="meet_filter_age1" /> <input class="select2" style="width: 115px;left:550px;" value="<?= $age2;?>" type="number" min="18" max="99" data-filter="meet_filter_age2" id="meet_filter_age2"/> <input class="input" type="text" id="meet_filter_city" value="<?= $sm['user']['city']; ?>" /> <div class="input-location"><i class="material-icons">location_on</i></div> <select class="select3" data-filter="meet_filter_radius" id="meet_filter_radius"> <option value="300" <?php if($sm[ 'user'][ 's_radius']==100) { http://www.php.net/echo 'selected'; } ?>>All the city</option> <option value="10000000" <?php if($sm[ 'user'][ 's_radius']==1000) { http://www.php.net/echo 'selected'; } ?>> <?= $sm['twoo_lang'][6]['text']; ?> </option> </select> <select class="select4" id="meet_filter_online" data-filter="meet_filter_online"> <option value="0" selected> <?= $sm['twoo_lang'][9]['text']; ?> </option> <option value="1"> <?= $sm['twoo_lang'][10]['text']; ?> </option> </select> <h2 class="show-me-more"><?= $sm['lang'][109]['text']; ?></h2> </div> </div> </div> <div class="search-result-container"> <div class="container relative margin-bottom-50"> <div class="search-section"> <div id="searching"> <div class="pulse"></div> <div class="pulse-photo" data-back-photo="1" data-src="<?= $sm['user']['profile_photo']; ?>"></div> </div> <div id="meet_section"> </div> </div> </div> <div class="rings" style="display:none"> <div class="user-photo" data-back-photo="1" data-src="<?= $sm['user']['profile_photo']; ?>"></div> <div class="ring__ringlet"></div> <div class="ring__ringlet"></div> <div class="ring__ringlet"></div> </div> </div>
Skoro masz poustawiane warunki, że tylko zalogowani mogą filtrować dane, to jaki problem je usunąć?
if (!http://www.php.net/empty($_SESSION['user']) && http://www.php.net/is_numeric($_SESSION['user']) && $_SESSION['user'] > 0) {
if($_GET['id'] != NULL ){
@Neutral chyba troche za bardzo odplynales... Ok, na pewno on tam ma gdzies sprawdzanie czy user zalogowany czy nie, i trzeba to znalezc i sprawdzic, ale wywalanie kluczowego IFa z funkcji islogged to chyba lekka przesada... Jak juz cos to wywalic trzeba funkcje isLogged gdzies tam w jakims warunku a nie jej srodek.
Podobnie z if($_GET['id'] != NULL ){
Przeciez to jest w funkcji, ktora pobiera dane o jakims tam userze, a info o tym userze jest w GET. Wywalajac warunek na to, to on bedzie lecial do bazy nawet jak ID w GET nie bedzie istnialo...
Jak juz pomagasz to pomysl wpierw sam troche a nie lecisz na oslep
ps: o zamianie fetch_object na fetch_assoc to juz nawet nie bede wspominal... niby jak to ma rozwiazac problem?
@Neutral spróbowałem jak napisałeś. lecz pomimo tego dalej nie mam dostępu.
@nospor. próbowałem usunąć całą funkcje isLogged - niestety nic nie daje.. też spróbowałem
jak napisałeś ( usunąłem if($_GET['id'] != NULL ) ) ale brak tego wywołuje jedynie funkcje
na przeglądanym profilu tak jakbyśmy przeglądali własny profil
( odtwarzają nam się ikony, przyciski itd jak by to było nasze konto )
@nospor wybacz, jestem strasznie narwany. Borykam się z tym problem ponad tydzień.
Znalazłem w tym samym pliku też taką funkcje
function searchUser($q) { http://www.php.net/global $mysqli,$sm; $search = ''; $query = $mysqli->query("SELECT id FROM users where id = '".$q."' OR name LIKE '%$q%' OR email LIKE '%$q%' LIMIT 10"); if ($query->num_rows > 0) { while($user = $query->fetch_object()){ getUserInfo($user->id,6); $search .= ' <tr> <td class="man-photos"><div class="profile-photo" data-src="'.$sm['search']['profile_photo'].'"></td> <td>'.$sm['search']['id'].'</td> <td>'.$sm['search']['name'].' , '.$sm['search']['age'].' '; if($sm['search']['last_access'] >= $time_now) { $search .= ' <i class="fa fa-circle text-success" style="font-size:8px;"></i>'; } $search .= ' </td> <td>'.$sm['search']['email'].'</td> <td>'.$sm['search']['city'].'</td> <td>'.$sm['search']['country'].'</td> <td>'.$sm['search']['credits'].'</td> <td>'.$sm['search']['total_photos'].'</td> <td>'.$sm['search']['join_date'].'</td> <td><a href="index.php?page=profile&id='.$sm['search']['id'].'" target="_blank" class="label label-info">View</a> <a href="index.php?page=admin&p=user&id='.$sm['search']['id'].'" target="_blank" class="label label-primary">Edit</a></td> </tr>'; } } return $search; }
function getUserInfo($uid,$value=0) { http://www.php.net/global $mysqli,$sm; $uid = secureEncode($uid); $user = $mysqli->query("SELECT * FROM users WHERE id = '".$uid."'"); $u = $user->fetch_object(); $first_name = http://www.php.net/explode(' ',http://www.php.net/trim($u->name)); $first_name = http://www.php.net/explode('_',http://www.php.net/trim($first_name[0])); //CURRENT USER $current_user['id'] = $u->id; $current_user['name'] = $u->name; $current_user['email'] = $u->email; $current_user['gender'] = $u->gender; $current_user['facebook_id'] = $u->facebook_id; $current_user['twitter_id'] = $u->twitter_id; $current_user['google_id'] = $u->google_id; $current_user['instagram_id'] = $u->instagram_id; $current_user['first_name'] = $first_name[0]; $current_user['profile_photo'] = profilePhoto($u->id); $current_user['profile_photo_thumb'] = profilePhotoThumb($u->id); $current_user['total_photos'] = getUserTotalPhotos($u->id); $current_user['total_photos_public'] = getUserTotalPhotosPublic($u->id); $current_user['total_photos_private'] = getUserTotalPhotosPrivate($u->id); $current_user['total_likers'] = getUserTotalLikers($u->id); $current_user['total_likes'] = getUserTotalLikes($u->id); $current_user['extended'] = userExtended($u->id); $current_user['interest'] = userInterest($u->id); $current_user['status_info'] = userFilterStatus($u->id); //$current_user['status'] = userStatus($u->id); $current_user['city'] = $u->city; $current_user['country'] = $u->country; $current_user['age'] = $u->age; $current_user['lat'] = $u->lat; $current_user['lng'] = $u->lng; $current_user['birthday'] = $u->birthday; $current_user['last_access'] = $u->last_access; $current_user['admin'] = $u->admin; $current_user['lang'] = $u->lang; $current_user['looking'] = $u->looking; $current_user['premium'] = $u->premium; $current_user['premium_check'] = adminCheckUserPremium($uid); $current_user['verified'] = $u->verified; $current_user['popular'] = $u->popular; $current_user['credits'] = $u->credits; $current_user['link'] = clean($first_name[0]); $current_user['status'] = userStatus($u->id); $current_user['online'] = userStatusIcon($u->id); $current_user['fake'] = $u->fake; $current_user['join_date'] = $u->join_date; $current_user['bio'] = $u->bio; $current_user['s_gender'] = $u->s_gender; $current_user['s_radius'] = $u->s_radious; $current_user['s_age'] = $u->s_age; $current_user['online_day'] = $u->online_day; if($value == 1){ $sm['profile'] = $current_user; } else if($value == 2){ $sm['meet'] = $current_user; } else if($value == 3){ $sm['chat'] = $current_user; } else if($value == 4){ $sm['friend'] = $current_user; } else if($value == 5){ $sm['videocall'] = $current_user; } else if($value == 6){ $sm['search'] = $current_user; } else if($value == 7){ $sm['manage'] = $current_user; } else if($value == 8){ $sm['edit'] = $current_user; } else if($value == 9){ $sm['comment'] = $current_user; } else if($value == 10){ $sm['suggest'] = $current_user; } else if($value == 11){ $sm['gift'] = $current_user; } else if($value == 12){ $sm['mail'] = $current_user; } else{ $sm['user'] = $current_user; } }
function getUserPhotos($uid,$i=0,$x=0,$y=0,$b=0){ http://www.php.net/global $mysqli,$sm; $photo = ""; if($i == 1){ $photos = $mysqli->query("SELECT * FROM users_photos WHERE u_id = '".$uid."' and approved = 1 order by id desc LIMIT 200"); } else if($b == 1){ $photos = $mysqli->query("SELECT * FROM users_photos WHERE approved = 1 and u_id = '".$uid."' and blocked = 1 order by id desc LIMIT 200"); } else { $photos = $mysqli->query("SELECT * FROM users_photos WHERE approved = 1 and u_id = '".$uid."' and blocked = 0 order by id desc LIMIT 200"); } if ($photos->num_rows > 0) { while($up = $photos->fetch_object()){ getUserInfo($uid,1); $photoData['id'] = $up->id; $photoData['src'] = $up->photo; $photoData['desc'] = $up->desc; $photoData['user'] = $sm['profile']['name']; $photoData['photo'] = $sm['profile']['profile_photo']; $photoData['blocked'] = $up->blocked; $photoData['like'] = checkPhotoLike($sm['user']['id'],$up->id); $photoData['likes'] = getPhotoLikes($up->id); $photoData['comments'] = getPhotoComments($up->id); $sm['photo'] = $photoData; if($i == 1 && $x == 0){ $photo .= getPage('profile/mphoto'); } else if($x == 1){ $photo .= requestPage('profile/mphoto'); } else { $photo .= requestPage('profile/photo'); } } } return $photo; }
Zadan z tych funkcji ma sie nijak do zalogowania lub nie.
Swoja droga nie wiem kto to ci pisal, ale mial nie wieksza wiedzie od ciebie teraz.
Z tego co pamiętam pisał wcześniej że to jakiś tam pobrany skrypt który chce przerobić usuwając logowanie. Tylko widać że wiedza nie jest adekwatna do złożoności zadania.
Macie racje, jestem kompletnie zielony.
Sam już nie mam pojęcia jak mógłbym uzyskać ten efekt o który tak ubiegam :/
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)