Re: How do I retrieve images dynamically based on the login username?



FayeC wrote:
I have created a site in Joomla with a login (no self registration,
users are provided with username and password by the admin).
The users are supposed to login to a specific page where they can see
4 images.
I have the following code:
<?php
// define directory path
$dir = "images/user1/";

// iterate through files
// look for JPEGs
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (preg_match("/.jpg/", $file)) {
                // read EXIF headers
                $exif = exif_read_data($file, 0, true);
                echo "<tr>";
                // get thumbnail
                // link to full image
                echo "<td valign=top><a
href=$dir/$file><imgsrc=thumbnail.php?file=$file></a><td>";
                echo "<td valign=top><font size=-1>";
                // get file name
                echo "File: <b>" . $exif['FILE']['FileName'] .
"</b><br/>";
                // get timestamp
                echo "Timestamp: "  . $exif['IFD0']['DateTime'] .
"<br/>";
                // get image dimensions
                echo "Dimensions: " . $exif['COMPUTED']['Height'] . "
x " . $exif['COMPUTED']['Height'] . " <br/>";
                // get camera make and model
                echo "Camera: " . $exif['IFD0']['Model'];
                echo "</font></td>";
                echo "</tr>";
           }
        }
       closedir($dh);
   }
}
?>

The question now is how to change the code to dimamically replace the
folder name by the login username used.
For example....if user2 logs in the images loaded will be only those
in the folder images/user2, if user3 logs in it will be from the
folder images/user3, etc...
I am a little confused as to how to implement that in Joomla but as
long as I have the code right I thinkI can just insert the code into
the appropriate page using a mambot.
If anybody here has any tips on how to accomplish that it would be
extremely appreciated.
Thank you in advance,


FayeC
I'm not sure if your question is as easy as it seems, but it seems like all you need to do is instead of
$dir = "images/user1/";
you go $dir="image/$username";



.



Relevant Pages

  • Re: Reading from txt file
    ... The login is a simple login using POST and the page receiving the POST ... data is a page where images are displayed. ... And then parsing the "familyname" out of the file. ... The problem is that I was able to parse the username out of the txt ...
    (comp.lang.php)
  • Re: how to create a gallery without using the EXIF function?
    ... >will have the same username as the user's login. ... >After login the user is taken to a page that will contain the 4 images ... >in the folder arranged in a table or div. ...
    (comp.lang.php)
  • Re: Login control and restricted member pages
    ... As you said the login dialog prompts each time the page loading a image, ... protected folder. ... When a page display some images file, ... NTFS permission limitation. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Login control and restricted member pages
    ... As you said the login dialog prompts each time the page loading a image, ... protected folder. ... When a page display some images file, ... the root members folder isn't. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: security between serving files from a fileshare
    ... I am serving images from the share. ... Microsoft MVP - Windows Security ... On virtual directory on server two you can specify which username ... with iis. ...
    (microsoft.public.inetserver.iis.security)