Problema permessi visualizzazione immagine

sappe

Nuovo Utente
27 Mar 2011
27
0
0
Ciao a tutti! :D Allora ho un problema con la visualizzazione delle immagini. Ho 3 casi: 1) sono l'admin e quindi devo poter vedere l'immagine, 2) sono l'utente che ha postato l'immagine e devo vedere l'immagine che ho messo, 3) sono amico dell'utente che ha postato l'immagine e quindi posso vedere l'immagine. In definitiva quando invio un'immagine io devo specificare se voglio che la possa vedere chiunque o solo i miei amici, per questo questa distinzione. Ora, a me l'admin vede tutte le immagini, però se provo ad accedere come autore dell'immagine oppure come amico dell'autore, mi stampa che devo essere amico dell'autore. Cos'ho sbagliato?
PHP:
include("connessione.inc");
//controllo se l'utente è loggato
if ((isset($_SESSION['login']))&&((isset($_SESSION['password'])))){
$login=$_SESSION['login'];


$sql="SELECT Nickname FROM utenti WHERE Nickname = '$login' AND Admin = '1'";
$res=mysql_query($sql,$conn)or die("Error!".mysql_error());
$lines=mysql_num_rows($res);

$nickname=$_GET["nickname"];//nickname della persona che ha postato l'immagine
//non torna nel visualizza immagini la query che fa visualizzare l'immagine all'utente che l'ha hostata
$sql2="SELECT * FROM utenti JOIN immagini ON utenti.IDutente = immagini.Author AND Nickname = '$nickname'";
$res2=mysql_query($sql2,$conn)or die("Error!".mysql_error());
$lines2=mysql_num_rows($res2);
if ($lines2 == 1){
   echo "<align='center'>You are the author of this image.</align>";
}
//non funziona neanche se sono amici
$sql3="SELECT * FROM utenti JOIN amicizie ON (amicizie.Receiver = utenti.IDutente) or (amicizie.Sender = utenti.IDutente) AND Friend = '1'";
$res3=mysql_query($sql3,$conn)or die("Error!".mysql_error());
$lines3=mysql_num_rows($res3);
$path=$_GET["path"];
$title=$_GET["title"];
$description=$_GET["description"];
$ID=$_GET["ID"];//IDsketch

if ($lines == 1){
   echo <<<MESS
	 <a href="deleteImage.php?ID=$ID"  onclick="return confirm('Do you really want to delete this image?')">Delete Image</a>
MESS;
}

if ($lines == 1 or $lines2 == 1 or $lines3 == 1){
   echo <<<MESS
	 	 <table summary="immagine" border="1" id="image" align="center">
<tr align="center"><td><a href="$_GET[path]"><img src=$_GET[path] style="width: 60%;"></a></td></tr><tr><th>$title</th><tr><td>by $nickname</td></tr><tr><td>$description</td></tr></table>
<a href="comment.php?ID=$ID&nickname=$nickname">See the comments about this image</a></br>
<p><b>Comment</b></br>Write a comment:</br>
   <textarea name="comment" cols="40" rows="4" maxlength="300">
</textarea>
<FORM enctype="multipart/form-data" action="comment.php" id="comment" method="POST" name="modulo">
<index type="hidden" name="$ID" value="ID">
<index type="hidden" name="$nickname" value="nickname">
<button type="submit">Add</button>
MESS;
}
else{
   echo "You can't see this image (you and $nickname aren't friend).";
}

} //chiude l'if del controllo login
   else {
	echo "You are not logged in and you can't see this image!"; 
}
Eppure mi sembrava fatta bene :S aiutino? Grazie mille in anticipo!! :D
 

micio86

Utente Attivo
Ehm

Stampa qui le variabili:
PHP:
echo "LINES:".$lines."<br />";
echo "LINES2:".$lines2."<br />";
echo "LINES3:".$lines3."<br />";

if ($lines == 1 or $lines2 == 1 or $lines3 == 1){

Giusto per capire cosa ti restituisce
Magari facendo le join aumentano i record e quindi dovrai fare:
PHP:
if ($lines || $lines2 || $lines3){
 
Ultima modifica:
Discussioni simili
Autore Titolo Forum Risposte Data
A Problema permessi Linux e Software 2
A GoGo Problema permessi (era: salve scusate o bisognio di una mano) Hosting 5
E problema strano con db per i permessi PHP 1
B problema permessi file PHP 4
C problema asp e db con permessi Classic ASP 2
K Problema form update PHP 2
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
S Problema nel ciclare un json Javascript 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
K Problema Inner join PHP 1
F firefox problema http Linux e Software 0
N Problema con position absolute e overflow HTML e CSS 4
E Problema jquery Success jQuery 2
L Problema con inner join PHP 11
K [php] Problema con inner join PHP 4
E problema selezione sfumata Photoshop 2
K [PHP] Problema con variabili concatenate. PHP 1
A Problema filtro fluidifica Photoshop Photoshop 1
H Problema Bordi Scontorno Photoshop 1
O problema con query PHP 4
R Problema installazione Realtek WiFi USB rtl8821 Reti LAN e Wireless 0
I problema con 2 account Posta Elettronica 1
L problema collegamento file css con html HTML e CSS 1
Y Problema percorso file in rete PHP 1
N Problema SEO "L'URL non si trova su Google" SEO e Posizionamento 4
E Problema accesso a file con app sviluppata con MIT APP INVENTOR 2 Sviluppo app per Android 0
P Problema acquisizione clienti Webdesign e Grafica 1
F NetBeans problema creazione progetto Java Windows e Software 0
M Problema con Try Catch PHP 0
C problema seo + cerco esperto SEO e Posizionamento 11
Sergio Unia Problema con gli eventi del mouse su una data table: Javascript 2
T PROBLEMA CON SESSIONI PHP 3
A Problema, non so, di scale() o transform, oppure altro? HTML e CSS 0
T ALTRO PROBLEMA CON ARRAY PHP PHP 1
R problema con else PHP 0
T PROBLEMA CON ARRAY PHP 8
L problema con query select PHP 2
R Problema query con ricerca id numerico PHP 2
F Problema con risposta PHP 0
S problema con recupero dati tabella mysql PHP 2
Z Problema con il mio tp-l i nk Reti LAN e Wireless 1
I PROBLEMA: Sostituzione sito XAMPP E-Commerce 0
T problema data 30/11/-1 PHP 0
L Problema RAM con Tomcat 8 Apache 0
napuleone problema con sort e asort PHP 4
Y Problema incolonnamento tabella PHP 7
S problema salvataggio immagini Photoshop 0
Z Problema con INT MySQL PHP 1

Discussioni simili