ID:               33552
 User updated by:  badocs at tbaytel dot net
 Reported By:      badocs at tbaytel dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         Filesystem function related
 Operating System: Linux
 PHP Version:      4.3.10
 New Comment:

I do not have access to the server's php stuff. It's a hosting server.

It's alright, i did another solution instead.

First off, I figured that since upload is the way stuff gets
modified...

when a file is uploaded..
 $l = "$path/day.txt";
 $hand = fopen($l, 'w');
 $string = date("ymdHi");
 fwrite($hand, $string);
 fclose($hand);

I basically open/create a file and dump the current date and time of
the upload.

This is actually even better then what i wanted...because new users
don't even have this file, so when i pull this textfile out of their
directory (or lack thereof), users that uploaded will have a date
sorted by year, month, day, hour, minure, while new ones...have
nothing.

I do this by collecting a list of all the directories i need to check.

my directory is
/user1
/user2
/user3
scripts to upload
display
delete
rename
etc.
----
so, i get the folders (user1, user2, etc..)


$i=1;
while ($file = readdir($dir_handle)) {
 if (!strstr($file, '.')) {
  if ($file!='error_log') {
  // this narrowed it down to a folder
  $sitearray[$i]=$file;
  $i++;
  }
 }
}
closedir($dir_handle);

-----

then i proceed to pull out the string in my file (day.txt) out of each
user directory
for ($ii=1; $ii<$i; $ii++ ) {
 $toscan="$WWW$sitearray[$ii]";
 $dayfile="$WWW$sitearray[$ii]/day.txt";
 $handle=fopen($dayfile, "r");
 $string=fread($handle, filesize($dayfile));
 $lastupdate[$ii]=$string;
 fclose($handle);
}

I'm now left with 2 arrays, (the array of folders and the array of
dates). These arrays are sidebyside, so now i sort them together.

array_multisort($lastupdate, SORT_DESC, $sitearray);

I now have at the top of the array the most recently updated folder and
at the bottom...the new guys.
now...i just make it distinglishable.

echo "<table>";
$setbrk="True";
for ($ii=0; $ii<$i-1; $ii++ ) {
 if ($lastupdate[$ii]=="") {
  if ($setbrk=="True"){
   echo "</table><tr><td><center>New Sites (Empty)<table>";
   $setbrk="False";
  }
 }
 echo "<tr><td class=\"post\" bgcolor=\"#777777\" width=100><center><a 
href=\"httptomysite/WWW/$sitearray[$ii]\"><font
color=#000000>$sitearray[$ii]</font></a></center></td></tr>";
}
echo "</table>";

----

what that did was it dumped the whole sorted array into the table and
inserted ONE hoz. line when we reached the point where $lastupdate[$ii]
is empty.

There, what do you think?


Previous Comments:
------------------------------------------------------------------------

[2005-07-03 21:18:22] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------

[2005-07-03 08:39:20] badocs at tbaytel dot net

Description:
------------
I've noticed a very annoying bug.

I use a upload script with php to allow clients to upload their own web
pages. My intent was to have a table on the front page displaying the
most recently modified site. I do this by scanning the toplevel
directory for their usernames.

ie)
user1/
user2/

...And i find the most recently modified file and use that, compare
that date to other sites and generate a sorted list of sites. This was
also to be used for inactivity with accounts, so that a website that
wasn't being updated after a bit..would alert me to think about
removing it to save space.

Unfortunely, php does not set the file modification date when the file
is uploaded, and i've tried chmod() and touch() to attempt to correct
that by setting a date to no avail. I'm wondering how I can set the
modified date. I must be a noob if i'm not getting this correct.

Reproduce code:
---------------
// The code to automatically set the modification date, since php won't
automatically.
// so we upload a file to ($path . "/" . $filename), path is where the
file is to be uploaded to..

//now to manually set the damn modified time.
$newfile = "$path/$filename";
echo $newfile; // looks correct
chmod ($l, 0777); // set write.
touch ($l); // if i put this in a if state, it says it worked...but it
didn't.

// so far, no matter what, any file uploaded has the date of December
31 1969 18:00:00.

Expected result:
----------------
So, the one thing i could see as my screwup would be offering touch its
second argument, but the docs said that touch would auto-do it......

Other then that....I'm lost..and it's very annoying.

Can someone please offer a solution that sets the damned modification
date....with just php...because i'm under hosting and i don't know if i
have access to the ftp stuff with php that would probably solve this
problem in a alternate way...

OR...

does anyone know the function(s) that will display the creation
date...and if php even writes that on upload...



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33552&edit=1

Reply via email to