From: Daniel W. <d...@ni...> - 2005-11-24 02:32:22
|
Paul Lesneiwski wrote: >>--- list_calendars.php.orig 2005-04-29 18:29:21.000000000 +0100 >>+++ list_calendars.php 2005-11-23 16:32:21.000000000 +0000 >>@@ -140,8 +140,9 @@ >> // >> if ($migrateOldCalendarData) >> { >>- $todaysYear = date('Y'); >>- $oldFilename = getHashedFile($username, $data_dir, >>"$username.$todaysYear.cal"); >>+ $existsOldFilesCmd = "ls $data_dir | grep $username | grep cal | >>grep -vE \"\.bak$\" "; >>+ exec($existsOldFilesCmd, $oldFilenamesArray, $val); >>+ $oldFilenameExists = $oldFilenamesArray[0]; > > > This breaks hashing and who knows what else. I won't include code that > does not use SM library for accessing pref files. If I have time, I > might try to rewrite this to iterate thru years back to 1970 (epoch). > ah right. i don't think i quite understood the hashing part. this could be fixed using: $existsOldFilesCmd = "find $data_dir -name "$username*" | grep cal | grep -vE \"\.bak$\" "; that would then go into any hashing structure and report all of their cal files. > > >>@@ -180,7 +181,7 @@ >> >> // migrate old calendar data if necessary >> // >>-else if ($migrateOldCalendarData && file_exists($oldFilename)) >>+else if ($migrateOldCalendarData && $oldFilenameExists && $username) > > > What's with the username check? I didn't read your other posts closely > w/out the unified diff... but there was something about paranoia? This > will never be empty, and if it is, well, then, the admin has other problems. > fair enough - i just noticed a potential disaster if username was empty so put in this extra check to make sure. > >> { >> >> $script = SM_PATH . 'plugins/calendar/scripts/convert_cal_to_ical.pl'; >>@@ -190,7 +191,13 @@ >> if(is_executable($script)) >> { >> >>- $messages[] = _("Converting old calendar. . ."); >>+ $getCalFilesCmd = "ls $data_dir | grep $username | grep cal | >>grep -vE \"\.bak$\" "; >>+ exec($getCalFilesCmd, $calFiles, $retVal); > > > Is there a good reason you do this twice? > only really so i didnt change your code too much. quite easily do this file search once and then check if the array of files is non-empty. > > Thanks, > > Paul I'm not a pro php programmer - please bear with me =) |