Jump to content

DevinC

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DevinC's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am not sure why you recommended basename() as it is not what I was looking for. Anyway I have solved my own problem (without using regex) by replacing the line: $val = ltrim($val, $path); // strip path with $val = str_replace($path, "", $val); // strip path Thanks.
  2. Hello, I am new to the regex and I'm hoping someone can assist me here on this: Objective: create a list of files using the glob() function and use regex to strip the path, leaving only the filename. i.e. Array ( [0] => ./dump/INCOMPLETE (do not move)/PERMANENT/123549.dmp [1] => ./dump/INCOMPLETE (do not move)/PERMANENT/139672.dmp [2] => ./dump/INCOMPLETE (do not move)/PERMANENT/dummy.dmp ) to Array ( [0] => 123549.dmp [1] => 139672.dmp [2] => dummy.dmp ) // File list generator without path // Usage: string argument must terminate with a trailing forwardslash function generateFilelistWithoutPath($path) { $pattern = $path . "*.dmp"; $filelist = glob($pattern); // generate list of file // print_r($filelist); if (!empty($filelist)) { //reconstruct array without path while (list($key, $val) = each($filelist)) { $val = ltrim($val, $path); // strip path if (!isset($filelistWithoutPath)) { $filelistWithoutPath = array($key => $val); // initialize } else { $filelistWithoutPath = array_merge($filelistWithoutPath, array($key => $val)); // merge to existing } } if (!isset($counter)) {$counter = 0;} // initialize for ($counter; $counter < count($filelistWithoutPath); ++$counter) { $file = "$filelist[$counter]"; $fileWithoutPath = "$filelistWithoutPath[$counter]"; } } return $filelistWithoutPath; } I realize that the Trim() function require $path in regex format but glob() require actual path so am I correct in thinking that I need to pass on two separate argument instead of 2-in-1? Thanks.
  3. True.. I thought it wouldn't matter but apparently not.
  4. Hi, I'm not exactly new here as I've used PHP in the past. I've tried installing these two application (latest version as of today) but ran into problem getting PHPInfo to display the result. I was baffled by this problem even though I've went through the posted instruction several time. I have discovered that rather than using the PHP "installer" version, you can avoid the problem altogether by extracting the "package" version to your local drive!
  5. Hi Barand, Sorry I should have made this clear earlier. I am an enduser who use a shared webhost server. I do not have administrative privilege to control the server environment. Nevertheless, I have forward this information to my webhost provider's server admin team to review the material and hopefully, they'll implement it if they haven't already. There's no guarantee that they will do it. So at the meantime, I still need a solution to monitor my working database and have it notify me by email if the database has been restored to an older backup by my webhost provider. Thanks, Devin
  6. Hi Kalivos and others, Thank you for clarifying the issue. The code works for me however after playing with it for a while, I have discovered that I get different timestamp result depending on the table being monitored. This is more complicate than I have initially thought because of several tables used by the web application and all of them produce different result. I have already tried all tables and none of them has generated satisfactory result. Basically, I'd like to implement a system to monitor my working database on the webhost's shared webserver. Sometimes, my webhost provider have restored my database to an older backup copy without letting me know. Unaware of the issue, I have modified an older database rather than working with the latest one. As a result, I have inadvertently created two different version of the same database. In order to implement a system to monitor my working database, here's an idea of what I need to do: 1) develop a cron script to obtain the last modification date/time of the database and log the output to a file on the server 2) develop a Scheduled Tasks/cron script to run on my local machine. The script will routinely query the remote database on the server at regular interval (ie. once every 15 minute) and it will automatically obtain the latest timestamp value. 3) the script running on my local machine will then compare the latest data (obtained from the server) with the previous last known good update. 4) if last mod date is newer than the previous last known good update, update the value of last known good update, and reset script for next check (i.e. next 15 minute) 5) if last mod date is older than the previous last known good update, generate an email alert to the admin, set the database on server to read-only mode to prevent further modification, and stop the cron script until it has been restarted by the site admin. In order to do step 2 and 5, I need a way to connect to the server to communicate with the database without phpMyAdmin since my goal is to automate the checking. Perhap there is a more effective solution available for the website admin to monitor their working database? Surely, I can't be the only person experiencing this problem! Thank you in advance for your feedback. Regards, Devin
  7. Hi Barand, Thank you for your quick response. I've checked the function SHOW TABLE STATUS in MySQL's reference and indeed it is in there. Unfortunately, I am not all too familiar with MySQL programming. Is there a similar or quicker way that I can obtain the info by using PHP instead? Basically, I want PHP to output the last modification date made to the database itself when viewing a HTML page (served by PHP) that contain data extracted from a MySQL database. Thanks, Devin
  8. Hello, is there a function available that will do the same thing as PHP's GETLASTMOD but can be use to find out the last modification date/time of a MySQL database? PHP's GETLASTMOD is limit to the current page only. Thanks, Devin
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.