
Originally Posted by
sweatje
That sounds like a one shot operation, not something that is being done each request? If
so, then it does not really matter what the performance is. Do whatever is easier for you to write

That's the trouble, it's not easy for me to write it because what I was trying was not working.
After rereading the suggestions, I have used the suggestion from Dangermouse and have accomplised a portion of the task.
Now the $path variable holds /folder1/folder2/folder3/filename.swf and the $fragment and $query vars are empty.
Can someone help me in splitting the filename into $query var.
Here is the current solution I am useing.
PHP Code:
<?PHP
session_start();
/***************************************
** **
** Log_Cleaner.php **
** **
***************************************/
include('dbconnect.php');
//-------------------------------------
// getting the info from the file into variables
// --------------------------------------
// assign file name to a variable
$file_name = "buffer.txt";
$opfile = "buffer_clean3.txt";
// open the file for reading
$fd = fopen($file_name, 'r');
// open the file for writeing
$fp = fopen($opfile,"w+");
// put the entire file into an array
$all_lines = file($file_name);
// count the number of lines in the file and store it in a variable
$how_many_lines = count($all_lines);
// Take each line and
// 1. separate each line into its individual elements (aka fields aka pieces of information)
// 2. grab the value(s) you are going to test and place them in a variable. Remember the
// count for the elements starts at 0 (zero). Also be careful that your variables don't
// contain extraneous parts (like extra spaces, newlines and tabs). Use the trim() function to
// clean up.
// 3. do your evaluation.
// put the file lines into an array
for ($i = 0; $i < $how_many_lines; $i++) {
$all_fields[$i] = explode(" ", $all_lines[$i]);
$date = ($all_fields[$i] [0]);
$name = ($all_fields[$i] [1]);
$url = ($all_fields[$i] [2]);
// write the contents of the url to the screen
echo $url;
echo '<BR>';
{
$url_parts = parse_url($url);
$scheme = $url_parts['scheme'];
$user = $url_parts['user'];
$pass = $url_parts['pass'];
$host = $url_parts['host'];
$port = $url_parts['port'];
$path = $url_parts['path'];
$fragment = $url_parts['fragment'];
$query = $url_parts['query'];
$sql_insert = "INSERT IGNORE INTO files (scheme,user,pass,host,port,path,fragment,query)
VALUES('$scheme', '$user', '$pass', '$host', '$port', '$path', '$fragment', '$query')";
# RUN THE QUERY
mysql_query($sql_insert,$db);
mysql_checkerror();
}
// write the contents of the url to the file
fwrite ($fp, $url);fwrite($fp,"\n");
}
// close the file connections
fclose ($fd);fclose ($fp);
?>
Thank you all for your help.
Bookmarks