<?php

$filename = "PSP-M4M-i024-";
$ext = ".jpg";

$dir = ".";
$dh = opendir( $dir ) or die( "Cannot open image directory" );
$page = $_GET['page'];

while ( ! ( ( $file = readdir ( $dh ) ) === false ) ) {
	if ( is_dir( $dir."/".$file ) || !strstr( $file, ".jpg" ) ){
		print "";
	} else {
		$images[] = $file;
	}
}

sort( $images );

$time = mktime ( 0, 0, 0, 09, 24, 2008 );

for ( $i = 0; $i < count( $images ); $i++ ) {
	
	$no = $i + 1;

	if ( $no < 10 )
		$no = "00".$no;
	else if ( $no > 9 && $no < 100 )
		$no = "0".$no;
	
	$oldname = $images[$i];
	
	rename( $images[$i], $filename.( $no ).$ext );
	$images[$i] = $filename.( $no ).$ext;
	print $oldname.", ".$images[$i]." - ".date( "r", $time )."<br/>";
	touch( $images[$i], $time );
	$time+=60;
}

?>