...

View Full Version : display images based on last login



mrjameer
02-22-2007, 06:18 PM
hi,

i have a image upload system in my site.in admin control panel i can see all the uploaded images with in particular dates
for example 10-jan-2007 to 20-jan-2007 like this.
now i want to put a button so that when i click that button it should display only those images that are uploaded after my last login and till to date.how i can do this.any of your help will be greatly appreciated

thanks
mrjameer

aedrin
02-22-2007, 06:39 PM
In your user/login table, have 2 fields 'lastlogin' and 'previouslogin' that you update when you login.



$today = /* however you store dates */;
$sql = "UPDATE users SET previouslogin = lastlogin, lastlogin = {$today} WHERE id = 123";


Then when you need to display the pictures since your previous login:



$sql = "SELECT p.* FROM photos AS p, users AS s WHERE p.date > s.previouslogin WHERE s.id = 123";

mlseim
02-22-2007, 06:58 PM
This is what I came up with. You would then use a cookie to remember
the last time you viewed the images. See if you can do something with this:



<?php

//create a timestamp for a particular date.
//when you view your files, you save today's
//date in a cookie, so the next time you run
//this script, it uses the cookie date.

//the date entered here manually for testing.
$date=strtotime("05/28/2006");

// open specified directory where your photos are kept.
$dir = './myphotos';
$dirHandle = opendir($dir);
while ($file = readdir($dirHandle)) {

// if not a subdirectory and if filename contains the string '.jpg'
if(!is_dir($file) && strpos($file, '.jpg')>0) {
$ffile=$dir."/".$file;
$timestamp=filemtime($ffile);

// if $timestamp is greater than the target date, display it
if($timestamp >= $date){
echo $file." -- ".$timestamp." <br>\n";
}
}
}

// then, you would save today's date in the cookie.
// so it would always look for the latest photos.
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum