Şifre kullanıcı resim albümü korumak

1 Cevap php

Im yapmak i fotoğraf sharint sitesi

Ben bir şifre ile onların albümleri acces kamu önlemek için benim kullanıcılar için yeteneği vermek istiyorum. Sonra onlar bunu görmek mümkün olmak istiyorum olanlar için şifre verebilirsiniz.

Şifre albümleri korumak.

Im böyle bir şey düşünme, cant bu bilgisayarda test, ok çalışması gerekir. ama bir php / mysql acemi im gibi i uzmanlar ne düşündüğünü duymak istiyorsan gidecekseniz daha iyi bir yolu / yaklaşım

<h3>Albums</h3>
- id
- name
- owner
- password (if it isnt null the album is considered password protected)

<h3>The code</h3>

    $id = isset($_GET['albumID']) ? intval($_GET['albumID']) : 0;
    $result = mysql_query("SELECT * FROM albums
                           WHERE id = $id");


    $row = mysql_fetch_object($result);

    // IS it password protected?
    if ($row->password != NULL) {

    echo "This album is password protected.";

    // User pressed "Enter"
    if (!empty($_POST['password'])) {

     $result = mysql_query("SELECT password FROM albums
                              WHERE password = '".mysql_real_escape_string($_POST['password'])."'");

  // Was It right password?
        if (mysql_num_rows($result) == 1) 
     {
         $authed=1;
     }


 echo <<<EOT

     <form method="post">
            <input type="text" name="password" />
   <input type="submit" value="enter" />
        </form>
    EOT;

    exit;
    } else $authed=1;

    if $authed==1 {
     // render albumimages etc   
    }

1 Cevap

images itself must be protected too, not only album page.
and that could be harder to implement.

fikir edinmek için, Menalto galeriye bir göz atın ve http://shiftingpixel.com/2008/03/03/smart-image-resizer/

Also you need to set up a session after successful password entry.
With all these features it could be hard for a newbie. May be you have to look at ready made solutions