I am just in the process of installing some new web content filtering software, and conveniently, the log files it produces are tab delimited, making it perfect for entering into a database with an SQL statement.
What I want to know is, using the directory functions(or whatever else), how can I insert only .log files into a database?
Current code:
$handle=opendir('.');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$sql_insert = "LOAD DATA LOCAL INFILE 'X:\$file' INTO TABLE WSLog.log FIELDS TERMINATED BY '\t' (date,time,user_id,user,ip,details)";
mysql_query($sql_insert);
}
}
closedir($handle);
Works fine but I only want .log files inserted...
Thanks