php-general Digest 5 Jan 2006 06:37:59 -0000 Issue 3888

Topics (messages 228158 through 228191):

Re: Newbie question: need to transfer directory contents fr om my local machine 
to my website
        228158 by: Jochem Maas
        228161 by: Duffy, Scott E
        228167 by: Jim Moseby
        228169 by: Jochem Maas

Re: Graphically displayed number to confirm user is a human
        228159 by: Jason Pappin

Re: php / mysql / js search result question
        228160 by: Michelle Konzack

Access Client IP address
        228162 by: Nilanjan Dasgupta
        228163 by: John Nichel
        228164 by: Ray Hauge
        228165 by: Silvio Porcellana [tradeOver]
        228166 by: Jay Blanchard

Parsing through an Apache Log File?
        228168 by: Jay Paulson \(CE CEN\)
        228170 by: John Nichel
        228172 by: Jay Paulson \(CE CEN\)
        228173 by: Jay Paulson \(CE CEN\)
        228174 by: John Nichel
        228175 by: John Nichel
        228176 by: Jay Paulson \(CE CEN\)

Re: Problem on Instalation ~ several module failed to load
        228171 by: Bagus Nugroho

New extension: the extension formally known as MSession is now MCache
        228177 by: Mark

Counting in Hex
        228178 by: Ben Miller
        228179 by: Ben Miller

failed to open stream warning
        228180 by: zedleon
        228182 by: Michael Hulse
        228183 by: zedleon
        228184 by: Michael Hulse
        228185 by: Travis Doherty

Re: Graphically displayed number to confirm user is a human [SOLVED]
        228181 by: Dave M G

‚ ‚°‚Ü‚ñy¡”N‚̃L[ƒ[ƒhz‚ ‚°‚¿‚ñ
        228186 by: zws5

How to: Search web for specific file type?
        228187 by: Michael Hulse

Re: PHPMailer inserting unwanted spaces
        228188 by: Curt Zirzow

Re: fread problem
        228189 by: Curt Zirzow

Re: are these db stats normal?
        228190 by: Curt Zirzow

Re: Curl Question
        228191 by: Curt Zirzow

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Jim Moseby wrote:
Hi Jon, welcome.


I'm really new at PHP and will probably embarrass myself many times over asking questions that have been asked gazillions of times before, so let this serve as a blanket apology.


You will get a cold response from the regulars on this list if you "ask
questions that have been asked gazillions of times before".  Friendly
advice: always take a little time to search the archives of this list and
google a bit to see if your question has already been answered.  Can you
imagine what this list would be like if every newbie asked the same
questions every day?  That said, on to your questions.


amen.


I'm not really asking for anyone to write the code for me, but I am looking for suggestions for PHP functions to use to accomplish the inspection of my local computer's folders. I'd also need to know what additional information I'd need to store in the database so that subsequent updates can be automated (i.e., do I need to somehow store my IP address?).


You will not be able to do what you propose with a purely PHP solution.  PHP
is a server-side technology.  That means all the processing is done at the
server, then output to your browser.  PHP, to my knowledge, has no way to
inspect your computer's folders.  You would need to look to a client-side

er??? stick the following in a file (localfiles.php):

<?php

function readDirWin($dir) {
   $d = dir($dir);
   while (false !== ($entry = $d->read())) {
       if($entry!="." && $entry!="..") {
           echo ($entry = $dir."\\".$entry), "\n";
           if(is_dir($entry)) {
               readDirWin($entry);
           }
       }
   }
   $d->close();
}
var_dump( readDirWin("C:") );

?>

and call it like so:
C:\path\to\your\CLI\php.exe C:\path\to\your\localfiles.php


technology, like Java, for that.

STOP RIGHT THERE - php might have been designed for spitting out webpages
and the like but these days you can run it as a general purpose scripting
language in all sorts of situations - including running a CLI version on
your windows desktop machine.

go here and install - not only will you have a CLI version of php
to play with - it will try to setup a webserver SAPI for whatever
webserver you have installed locally (within reason - personally
i only use Apache)

you can have a php script inspect your local machine by running
locally and stick its results in a database that lives on a machine
on the otherside of the world.

QUESTIONS:

1. what is the local machine?
2. where does the DB live? (is it a different machine?)
3. do you need reporting/information about the local machine
inspection anywhere other than the local machine?
4. will there be more than one local machine?
5. why do you want to do this?


However, you can upload data to your website using PHP to process the
uploaded file. So, at your convienience, you can have a "Browse" button on
an update page that will allow you to browse and find your data to upload.
After the upload you can have PHP process the uploaded file any way you
wish.

You can also use cron to kick off scheduled tasks with PHP CLI scripts that
will, for instance, open an FTP connection to your machine and download data
files to the server for processing.

windows also has a task scheduler ... how good it is I don't really know

Also I would suggest that it would be better for the local machine to
push data to a server than for the server to pull data from the
local machine.


JM


--- End Message ---
--- Begin Message ---
I would take a look at glob.

http://us2.php.net/manual/en/function.glob.php

Scott

-----Original Message-----
From: Jason Pappin [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 04, 2006 10:48 AM
To: Jon Westcot; PHP General
Subject: Re: [PHP] Newbie question: need to transfer directory contents
frommy local machine to my website

Hi,

You should perhaps look at setting up a web server on your computer. PHP
as stated works server-side and if those folders/files you wish to
transfer reside in the web root, then PHP can process those files.

Perhaps look at how a web based FTP client written in PHP works for how
to copy/move/delete files in PHP. If you can't set up Apache with PHP on
Windows, try something like phpdev5 for a click and use solution.

As for your IP, it won't really matter unless you want the server to
send data back to your computer. If a static IP or hostname is in order,
then they are easy enough to set up even if you are on a dial up
connection.

Regards
Jason

Jon Westcot wrote:
> Hi all:
> 
> I'm really new at PHP and will probably embarrass myself many times
> over asking questions that have been asked gazillions of times
> before, so let this serve as a blanket apology.
> 
> Now, to my question.  Here's what I'm trying to do.  I have a simple
> database on my website that I wish to populate with information from
> various directories on my local computer.  The website is running
> Linux; my computer is running Windows XP.  Once the data are stored,
> I want to be able to update the information as things change on my
> local computer (not in real time, mind you, but at my request).
> 
> I can set up the database access easily enough, and I know how to
> both populate and query it.  What I don't know is how to obtain the
> information from my local computer via the website.  Initially, I'd
> like to be able to specify the folder on my local computer to access
> and whether or not to process any subfolders that are found.  After
> the data have been added, I'd like the web application to be able to
> access the individual folders without having to specify them again
> (although I'd still be able to identify new folders to include in
> subsequent updates).
> 
> I'm not really asking for anyone to write the code for me, but I am
> looking for suggestions for PHP functions to use to accomplish the
> inspection of my local computer's folders.  I'd also need to know
> what additional information I'd need to store in the database so that
> subsequent updates can be automated (i.e., do I need to somehow store
> my IP address?).
> 
> Any help you can send my way will be greatly appreciated!  Thanks in
> advance.
> 
> Sincerely,
> 
> Jon
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
> > 
> > You will not be able to do what you propose with a purely 
> PHP solution.  PHP
> > is a server-side technology.  That means all the processing 
> is done at the
> > server, then output to your browser.  PHP, to my knowledge, 
> has no way to
> > inspect your computer's folders.  You would need to look to 
> a client-side
> 
> er??? stick the following in a file (localfiles.php):
> 
> <?php
> 
> function readDirWin($dir) {
>     $d = dir($dir);
>     while (false !== ($entry = $d->read())) {
>         if($entry!="." && $entry!="..") {
>             echo ($entry = $dir."\\".$entry), "\n";
>             if(is_dir($entry)) {
>                 readDirWin($entry);
>             }
>         }
>     }
>     $d->close();
> }
> var_dump( readDirWin("C:") );
> 
> ?>
> 
> and call it like so:
> C:\path\to\your\CLI\php.exe C:\path\to\your\localfiles.php


Perhaps I misunderstand what the OP wanted.  I thought he was running a
webserver somewhere, and that he wanted his remote webserver to be able to
grab a file listing on his local machine by just visiting a webpage there.

Of course PHP can query the local filesystem.  I thought he wanted it to
query a remote filesystem.

JM

--- End Message ---
--- Begin Message ---
Jim Moseby wrote:

...




Perhaps I misunderstand what the OP wanted.  I thought he was running a
webserver somewhere, and that he wanted his remote webserver to be able to
grab a file listing on his local machine by just visiting a webpage there.

if you ask me it wasn't very clear what the OP wanted, I was concerned that
the reference to php being a 'server-side' tool/language would be confusing
to the OP (or give him the wrong impression about php's capabilities).

to the OP: php being serverside is only relevant in terms of using php
as a webserver module; the 'client side' is the browser and php does not
run inside the browser (i.e. a php website can not directly interact with
anything on your own PC (unless the website lives physically on your own pc))

[actually Wez Furlong wrong a plugin for IE IIRC that allows you to use php
in the same way as you might use javascript inside the browser]


Of course PHP can query the local filesystem.  I thought he wanted it to
query a remote filesystem.

JM

--- End Message ---
--- Begin Message ---
John Meyer wrote:
> Duncan Hill wrote:
> 
>>On Wednesday 04 January 2006 16:56, Dave M G wrote:
>>
>>  
>>
>>>     First, is there a term for these kinds of images, or that kind of
>>>verification system? What would be the best search terms to look for
>>>source scripts?
>>>    
>>
>>captcha
>>
>>  
> 
> I've been looking for this term for a while as well.

Me too. Geez the things I Googled for without luck makes me cringe.
Thanks a bunch.

--- End Message ---
--- Begin Message ---
Am 2005-12-27 08:03:42, schrieb Dave Carrera:
> Hi List,

> User input is "a" so the list moves to first instance of "a".  User 
> continues to input "ap" so the list moves to "2 Apple Customer" and so on.

This can only be done from a JavaScript.

> Thank you in advance
> 
> Dave c

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

--- End Message ---
--- Begin Message ---
Hi,
Is there any way to client's IP address inside a php document. I am trying to generate a code that depends on the IP address of the client.

thanks a lot,
Nilanjan

--- End Message ---
--- Begin Message ---
Nilanjan Dasgupta wrote:
Hi,
Is there any way to client's IP address inside a php document. I am trying to generate a code that depends on the IP address of the client.

Yes.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
$_SERVER['REMOTE_ADDR']

http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server

HTH

Nilanjan Dasgupta wrote:

Hi,
Is there any way to client's IP address inside a php document. I am trying to generate a code that depends on the IP address of the client.

thanks a lot,
Nilanjan


--- End Message ---
--- Begin Message ---
Nilanjan Dasgupta wrote:
> Hi,
>     Is there any way to client's IP address inside a php document. I am
> trying to generate a code that depends on the IP address of the client.
> 
> thanks a lot,
> Nilanjan
> 

Give a look at $_SERVER, and more specifically $_SERVER["REMOTE_ADDR"]
http://php.net/manual/en/reserved.variables.php#reserved.variables.server

HTH, cheers.
Silvio

-- 
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

--- End Message ---
--- Begin Message ---
[snip]
     Is there any way to client's IP address inside a php document. I am 
trying to generate a code that depends on the IP address of the client.
[/snip]

http://us3.php.net/manual/en/reserved.variables.php#reserved.variables.serve
r

$_SERVER['REMOTE_ADDR']

but it may not always be reliable

--- End Message ---
--- Begin Message ---
Hello everyone!  I've been given the responsiblity of coding an apache 
access_log parser.  What my tasks are to do is to return the number of hits for 
certain file extensions that happen on certain dates with specific IP address.

As of now I'm only going back 7 days in the log looking for this information 
and I'm only looking for 5 file types (.doc, .pdf, .html, .php, and .flv).  I'm 
using the fgets() function so I can read the file line by line and do the 
matches that I need to do and increment the counters as needed.  Right now I 
have 3 loops looking for everything, which seems to me not to be the best way 
of doing this.  I've also encountered that a line may have the file extension I 
want but it's actually the soucre of another file.  (see below for example)

Log file example:
I want the first line but not the second line.  The second line has a .css file 
which was used by the .html file therefore I don't want this line.  I do want 
the first line that all it has is .html and no other files.

10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /home.html HTTP/1.1" 200 8220 
"-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /styles/redesign.css 
HTTP/1.1" 200 2381 "http://wfmu.wfm.pvt/home.html"; "Mozilla/4.0 (compatible; 
MSIE 6.0; Windows NT 5.1; SV1)"

At any rate, here's some of my psudo code/code for what I'm trying to 
accomplish.  I know there has to be a better way for this and I'm looking for 
suggestions!


//path to log file
$path = "./";
//name of log file
$log_filename = "access_log";

if (!file_exists($path.$log_filename)) {
        echo "file does not exists!";
        die;
}

//open log file
if (!$handle = fopen($path.$log_filename, "r")) {
        echo "error in loading file!";
        die;
}

//get date range from past 7 days put into array for comparision of log file
$dates = array();
$days = 7;
for ($i=1;$i<=$days;$i++) {
        $dates[] = date("d/M/Y", strtotime("-$i day"));
}

//get document types that need to match
$docs = array();
$docs[] = ".doc";
$docs[] = ".pdf";
$docs[] = ".html";
$docs[] = ".htm";
$docs[] = ".php";
$docs[] = ".flv";

$contents = "";
while (!feof($handle)) {
        $line = fgets($handle);
        //look to see if the line has a date we are looking for
        foreach ($dates as $date) {
                //if date is in the line look for the doc type we want
                if (strpos($line, $date)) {
                        //look to see if the line has the doc type we want
                        foreach ($docs as $doc) {
                                //if the line has the doc type we want then 
grab the region
                                //and increment the counter for page hit
                                //make sure to break out of the loops once found
                                //need to add functionality for lines that have 
file extensions
                                //that are not wanted but also have file 
extensions that are wanted
                                if (strpos($line, $doc) {
                                        
                                        break;                                  
                                } //end if
                        } //end foreach ($docs as $doc)
                        break;
                } //end if
        } //end foreach ($dates as $date)
}


//close log file
fclose($handle);

Thanks!
Jay

--- End Message ---
--- Begin Message ---
Jay Paulson (CE CEN) wrote:
Hello everyone!  I've been given the responsiblity of coding an apache 
access_log parser.  What my tasks are to do is to return the number of hits for 
certain file extensions that happen on certain dates with specific IP address.

As of now I'm only going back 7 days in the log looking for this information 
and I'm only looking for 5 file types (.doc, .pdf, .html, .php, and .flv).  I'm 
using the fgets() function so I can read the file line by line and do the 
matches that I need to do and increment the counters as needed.  Right now I 
have 3 loops looking for everything, which seems to me not to be the best way 
of doing this.  I've also encountered that a line may have the file extension I 
want but it's actually the soucre of another file.  (see below for example)

Log file example:
I want the first line but not the second line.  The second line has a .css file 
which was used by the .html file therefore I don't want this line.  I do want 
the first line that all it has is .html and no other files.

10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /home.html HTTP/1.1" 200 8220 "-" 
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /styles/redesign.css HTTP/1.1" 200 2381 
"http://wfmu.wfm.pvt/home.html"; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"

At any rate, here's some of my psudo code/code for what I'm trying to 
accomplish.  I know there has to be a better way for this and I'm looking for 
suggestions!
<snip>

Save yourself a ton of work. Dump the raw logs into a db, and you can do all the queries on the db. Something like this...

CREATE TABLE `rawLogs` (
  `ipAddress` int(15) NOT NULL default '0',
  `rfcIdentity` varchar(32) NOT NULL default '',
  `apacheUser` varchar(32) NOT NULL default '',
  `date` int(15) NOT NULL default '0',
  `request` longtext NOT NULL,
  `statusCode` varchar(32) NOT NULL default '',
  `sizeBytes` int(11) NOT NULL default '0',
  `referer` longtext NOT NULL,
  `userAgent` longtext NOT NULL,
  KEY `ipAddress` (`ipAddress`),
  FULLTEXT KEY `search` (`request`,`referer`,`userAgent`)
) TYPE=MyISAM;

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Jay Paulson (CE CEN) wrote:
> Hello everyone!  I've been given the responsiblity of coding an apache 
> access_log parser.  What my tasks are to do is to return the number of hits 
> for certain file extensions that happen on certain dates with specific IP 
> address.
> 
> As of now I'm only going back 7 days in the log looking for this information 
> and I'm only looking for 5 file types (.doc, .pdf, .html, .php, and .flv).  
> I'm using the fgets() function so I can read the file line by line and do the 
> matches that I need to do and increment the counters as needed.  Right now I 
> have 3 loops looking for everything, which seems to me not to be the best way 
> of doing this.  I've also encountered that a line may have the file extension 
> I want but it's actually the soucre of another file.  (see below for example)
> 
> Log file example:
> I want the first line but not the second line.  The second line has a .css 
> file which was used by the .html file therefore I don't want this line.  I do 
> want the first line that all it has is .html and no other files.
> 
> 10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /home.html HTTP/1.1" 200 
> 8220 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
> 10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /styles/redesign.css 
> HTTP/1.1" 200 2381 "http://wfmu.wfm.pvt/home.html"; "Mozilla/4.0 (compatible; 
> MSIE 6.0; Windows NT 5.1; SV1)"
> 
> At any rate, here's some of my psudo code/code for what I'm trying to 
> accomplish.  I know there has to be a better way for this and I'm looking for 
> suggestions!
<snip>

Save yourself a ton of work.  Dump the raw logs into a db, and you can 
do all the queries on the db.  Something like this...

CREATE TABLE `rawLogs` (
   `ipAddress` int(15) NOT NULL default '0',
   `rfcIdentity` varchar(32) NOT NULL default '',
   `apacheUser` varchar(32) NOT NULL default '',
   `date` int(15) NOT NULL default '0',
   `request` longtext NOT NULL,
   `statusCode` varchar(32) NOT NULL default '',
   `sizeBytes` int(11) NOT NULL default '0',
   `referer` longtext NOT NULL,
   `userAgent` longtext NOT NULL,
   KEY `ipAddress` (`ipAddress`),
   FULLTEXT KEY `search` (`request`,`referer`,`userAgent`)
) TYPE=MyISAM;

A few questions with this train of thought.  I can see the advantages of 
putting the raw log file into a database but I would still need to parse the 
file and get the information out of it for each column.  I'm also not quite 
sure what some of your feilds are for 'rfcIdentity'??  What is that?  Why would 
I need an 'apacheUser' also?  Anyway, not too sure how I would get this 
information in an easy way for the massive amounts of inserts I would have to 
do on a 10 meg log file.

jay

--- End Message ---
--- Begin Message ---
Jay Paulson (CE CEN) wrote:
> Hello everyone!  I've been given the responsiblity of coding an apache 
> access_log parser.  What my tasks are to do is to return the number of hits 
> for certain file extensions that happen on certain dates with specific IP 
> address.
> 
> As of now I'm only going back 7 days in the log looking for this information 
> and I'm only looking for 5 file types (.doc, .pdf, .html, .php, and .flv).  
> I'm using the fgets() function so I can read the file line by line and do the 
> matches that I need to do and increment the counters as needed.  Right now I 
> have 3 loops looking for everything, which seems to me not to be the best way 
> of doing this.  I've also encountered that a line may have the file extension 
> I want but it's actually the soucre of another file.  (see below for example)
> 
> Log file example:
> I want the first line but not the second line.  The second line has a .css 
> file which was used by the .html file therefore I don't want this line.  I do 
> want the first line that all it has is .html and no other files.
> 
> 10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /home.html HTTP/1.1" 200 
> 8220 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
> 10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /styles/redesign.css 
> HTTP/1.1" 200 2381 "http://wfmu.wfm.pvt/home.html"; "Mozilla/4.0 (compatible; 
> MSIE 6.0; Windows NT 5.1; SV1)"
> 
> At any rate, here's some of my psudo code/code for what I'm trying to 
> accomplish.  I know there has to be a better way for this and I'm looking for 
> suggestions!
<snip>

Save yourself a ton of work.  Dump the raw logs into a db, and you can 
do all the queries on the db.  Something like this...

I took your idea and did a search on Google and found that this has already 
been done for me!  Check it out!

http://www.php-scripts.com/php_diary/012103.php3

Very cool :)

jay

--- End Message ---
--- Begin Message ---
Jay Paulson (CE CEN) wrote:
Jay Paulson (CE CEN) wrote:

Hello everyone!  I've been given the responsiblity of coding an apache 
access_log parser.  What my tasks are to do is to return the number of hits for 
certain file extensions that happen on certain dates with specific IP address.

As of now I'm only going back 7 days in the log looking for this information 
and I'm only looking for 5 file types (.doc, .pdf, .html, .php, and .flv).  I'm 
using the fgets() function so I can read the file line by line and do the 
matches that I need to do and increment the counters as needed.  Right now I 
have 3 loops looking for everything, which seems to me not to be the best way 
of doing this.  I've also encountered that a line may have the file extension I 
want but it's actually the soucre of another file.  (see below for example)

Log file example:
I want the first line but not the second line.  The second line has a .css file 
which was used by the .html file therefore I don't want this line.  I do want 
the first line that all it has is .html and no other files.

10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /home.html HTTP/1.1" 200 8220 "-" 
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /styles/redesign.css HTTP/1.1" 200 2381 
"http://wfmu.wfm.pvt/home.html"; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"

At any rate, here's some of my psudo code/code for what I'm trying to 
accomplish.  I know there has to be a better way for this and I'm looking for 
suggestions!

<snip>

Save yourself a ton of work. Dump the raw logs into a db, and you can do all the queries on the db. Something like this...

CREATE TABLE `rawLogs` (
   `ipAddress` int(15) NOT NULL default '0',
   `rfcIdentity` varchar(32) NOT NULL default '',
   `apacheUser` varchar(32) NOT NULL default '',
   `date` int(15) NOT NULL default '0',
   `request` longtext NOT NULL,
   `statusCode` varchar(32) NOT NULL default '',
   `sizeBytes` int(11) NOT NULL default '0',
   `referer` longtext NOT NULL,
   `userAgent` longtext NOT NULL,
   KEY `ipAddress` (`ipAddress`),
   FULLTEXT KEY `search` (`request`,`referer`,`userAgent`)
) TYPE=MyISAM;

A few questions with this train of thought.  I can see the advantages of 
putting the raw log file into a database but I would still need to parse the 
file and get the information out of it for each column.

Correct, but putting it into a db, you only have to parse the file once instead of every time you want to sort your data.

I'm also not quite sure what some of your feilds are for 'rfcIdentity'??  What 
is that?  Why would I need an 'apacheUser' also?

In the output example of your logs, it looks as if your using the format of Apache logs which contain this data (the two dashes after the IP). Most of the time, that's what they will be; dashes, no data. Look here:

http://httpd.apache.org/docs/1.3/logs.html

Anyway, not too sure how I would get this information in an easy way for the 
massive amounts of inserts I would have to do on a 10 meg log file.

Script it. Just like you're parsing each line right now, but split the line on the tab (I assume that's your separator), and you'll have an array of the values in that line. Use that array to insert your values. I do this with daily logs on our sites (some of the files are over 100mb) I also convert the IP and date into integers for easier searching before inserting them into the db. YMMV.

Once you have them in the db, it's easy to run your queries on that table (or break the data up into other tables for different search criteria). On our system, I dump the raw log table every month (because it's already been broken down to other tables and better normalized), as trying to put two months of data into it would put it beyond the 4gb limit on our system.

If this is just a one time thing you're looking to do, all of this may be over the top. However, if the bosses are going to want to review this data month in and month out, I think the time spent doing something like this will be worth it.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Jay Paulson (CE CEN) wrote:
Jay Paulson (CE CEN) wrote:

Hello everyone!  I've been given the responsiblity of coding an apache 
access_log parser.  What my tasks are to do is to return the number of hits for 
certain file extensions that happen on certain dates with specific IP address.

As of now I'm only going back 7 days in the log looking for this information 
and I'm only looking for 5 file types (.doc, .pdf, .html, .php, and .flv).  I'm 
using the fgets() function so I can read the file line by line and do the 
matches that I need to do and increment the counters as needed.  Right now I 
have 3 loops looking for everything, which seems to me not to be the best way 
of doing this.  I've also encountered that a line may have the file extension I 
want but it's actually the soucre of another file.  (see below for example)

Log file example:
I want the first line but not the second line.  The second line has a .css file 
which was used by the .html file therefore I don't want this line.  I do want 
the first line that all it has is .html and no other files.

10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /home.html HTTP/1.1" 200 8220 "-" 
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
10.25.40.64 - - [01/Jan/2006:07:33:18 -0600] "GET /styles/redesign.css HTTP/1.1" 200 2381 
"http://wfmu.wfm.pvt/home.html"; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"

At any rate, here's some of my psudo code/code for what I'm trying to 
accomplish.  I know there has to be a better way for this and I'm looking for 
suggestions!

<snip>

Save yourself a ton of work. Dump the raw logs into a db, and you can do all the queries on the db. Something like this...

I took your idea and did a search on Google and found that this has already 
been done for me!  Check it out!

http://www.php-scripts.com/php_diary/012103.php3

Very cool :)

This is the script I wrote when we first started this project a few months ago to parse the 2+ years of log files, and intially get them into the db. If you want to use parts of it, feel free.

http://john.nichel.net/parse.phps

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
> If this is just a one time thing you're looking to do, all of this may be 
> over the top.  However, if the bosses are going to want to review this data 
> month in and month out, I think the time spent doing something like this will 
> be worth it.

As of now I've got it working and inserting the data into the database!  I did 
see your code and since you are being so generious as to let me use it I'll 
probably tweak it (a very little bit!) as we are going to be using this script 
once a week to read the log files.  We are using it to get some numbers out of 
it so make our own custome stats thing based off of a lot more numbers that 
included this as part of the number getting.

Thanks so much for your help!

jay

--- End Message ---
--- Begin Message ---
I was trying used php 5.1, but it still same problem appear, several
modules succesfully load 
(mbstring, bz2, dba, dbase, exif, filepro, gd2, gettext, imap, ldap,
mime_magic, ming, pgsql, shmop, snmp, socket, tidy, xmlrpc, xsl.)
 
and several others are failed to load :
(curl, fdf, ifx, interbase, mcrypt, mhash, mssql, mysql, mysqli, oci8,
openssl, sybase_ct).
 
Also, I was re-install my apache(2.0)
 
Is this problem related with php or apache or my OS(XPSP2)?
 
Hopefully, someone can help me to solve my problem.
 
Thanks & Regards
 
 

________________________________

From: Bagus Nugroho 
Sent: Friday, December 09, 2005 10:31 PM
To: [email protected]
Subject: RE: [PHP] Problem on Instalation ~ several module unable to
download


here is my last list of module which bale to load and unable to load
excerpt php.ini
--------------------
extension=php_mbstring.dll
;extension=php_bz2.dll
extension=php_cpdf.dll
;extension=php_curl.dll
extension=php_dba.dll
extension=php_dbase.dll
extension=php_dbx.dll
;extension=php_exif.dll
;extension=php_fdf.dll
extension=php_filepro.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
extension=php_mime_magic.dll
extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
extension=php_pgsql.dll
extension=php_shmop.dll
extension=php_snmp.dll
extension=php_sockets.dll
;extension=php_sybase_ct.dll
extension=php_tidy.dll
;extension=php_w32api.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
;extension=php_yaz.dll
;extension=php_zip.dll
--------------------------
 
I was re-check that php_mysql.dll, php_mysqli.dll etc is on c:\php\ext
as others.
 
Any idea how come
 
Thanks
 

________________________________

From: Bagus Nugroho [mailto:[EMAIL PROTECTED]
Sent: Fri 09-Dec-2005 21:06
To: [email protected]
Subject: [PHP] Problem on Instalation ~ several module unable to
download



Hi All,

Previously I always succed to instalation PHP, but currently I have
strange problem as several module is unable to download(i.e :
php_mysql.dll, php_mysqli.dll), while several other are succesfully
download(i.e : mbstring, gd).

I have re-installed or copy PHP folder from my succeded instalation, but
it is not work.

I'm used WindowsXP, Apache2.0, PHP5

May be someone out there could help me to solve it.

Thanks in advance

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--- End Message ---
--- Begin Message ---
Just want to open a discussion about what used to be called msession.

As many of you may be aware, msession had some problems with later Linux
kernels as well as stability issues on Apache 2.

MCache is redesign of msession is is intended to more or less replace
msession.

For more info, go to www.mohawksoft.org. MCache and its PHP extension code
is available via CVS.

It is in alpha state and not all functions are working, but the basic
session management should be working.

--- End Message ---
--- Begin Message ---
Is there a way in PHP to count using hex instead of numerals so that the
following statement

$var = 237F;
$var++;
echo "$var";

would result in

2380

Thanks a bunch.

Ben

--- End Message ---
--- Begin Message ---
Never mind - wasn't adding properly.  Found it after all on php.net, anyway.
Thanks anyway.

-----Original Message-----
From: Ben Miller [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 04, 2006 5:01 PM
To: [email protected]
Subject: [PHP] Counting in Hex


Is there a way in PHP to count using hex instead of numerals so that the
following statement

$var = 237F;
$var++;
echo "$var";

would result in

2380

Thanks a bunch.

Ben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Has anybody had any experience in resolving this kind of issue?

Warning: fopen(home/path/temp") failed to open stream: No such file or
directory
I am trying to write a script to work with GnuPG, but can't get past this
basic problem.
Everything I try gives me the same warning.

Here is the code:

$fp = fopen("home/path/temp "w+");
puts($fp, $msg);
 fclose($fp);

any suggestion would be appreciated,

Thanks

zed

--- End Message ---
--- Begin Message ---

On Jan 4, 2006, at 4:28 PM, zedleon wrote:
$fp = fopen("home/path/temp "w+");

You only got 3 quotes in the above code...
 try this:

$fp = fopen("home/path/temp", "w+");

--- End Message ---
--- Begin Message ---
I just corrected the code...I had it correct but posted it in correctly.

$fp = fopen("home/path/temp" "w+");
puts($fp, $msg);
fclose($fp);

Still getting the same warning...

Thanks

""zedleon"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Has anybody had any experience in resolving this kind of issue?
>
> Warning: fopen(home/path/temp") failed to open stream: No such file or
> directory
> I am trying to write a script to work with GnuPG, but can't get past this
> basic problem.
> Everything I try gives me the same warning.
>
> Here is the code:
>
> $fp = fopen("home/path/temp "w+");
> puts($fp, $msg);
>  fclose($fp);
>
> any suggestion would be appreciated,
>
> Thanks
>
> zed

--- End Message ---
--- Begin Message ---

On Jan 4, 2006, at 4:56 PM, zedleon wrote:

I just corrected the code...I had it correct but posted it in correctly.

$fp = fopen("home/path/temp" "w+");
puts($fp, $msg);
fclose($fp);

Still getting the same warning...


I think you forgot a comma this time...

$fp = fopen("home/path/temp", "w+");

Other than that, do you have a file you can specify? Also, you should make sure your permissions are set correctly... check the parent folder and the file you want to open.

I am sure you have been here already, but:

http://us2.php.net/manual/en/function.fopen.php

Good luck,
Micky

--- End Message ---
--- Begin Message ---
zedleon wrote:

>>Warning: fopen(home/path/temp") failed to open stream: No such file or
>>directory
>>I am trying to write a script to work with GnuPG, but can't get past this
>>basic problem.
>>Everything I try gives me the same warning.
>
>I just corrected the code...I had it correct but posted it in correctly.
>
>$fp = fopen("home/path/temp" "w+");
>puts($fp, $msg);
>fclose($fp);
>
>Still getting the same warning...
>  
>
There is still an error in that code (missing comma) and the error
message also has an unmatched quote.

The actual error message seems clear "No such file or directory" - does
"home/path/temp" exist, did you mean "/home/path/temp".

Travis

--- End Message ---
--- Begin Message ---
        Thank you all for pointing me in the right direction.
        I was extremely unlikely to come across the term "CAPTCHA" by starting
with the search terms I was using. I'm really glad I asked here.

        Your time taken to answer my query is much appreciated.

--
Dave M G

--- End Message ---
--- Begin Message ---
是非、無料サイトでゲットしてください。
http://4525234.com/1292/
問)
[EMAIL PROTECTED]
11:28:39

--- End Message ---
--- Begin Message ---
Hello,

Just curious if anyone could give me some google keywords/links/suggestions/tips/comments/feedback on a good place to start for writing a search engine script.

I think I might have a good idea for a specific type of search engine. Basically it would crawl web and index links to a specific type of file... really simple. Obviously making the results searchable is a must.

Not sure where to start though.

Thanks!
Cheers,
Micky

--- End Message ---
--- Begin Message ---
On Tue, Jan 03, 2006 at 10:37:10AM -0700, Ren Fournier wrote:
> Actually, I can send the example messages but here is another  
> description of the same problem. (So PHPMailer is inserting line  
> breaks, not spaces�or something is...)
> 
> http://sourceforge.net/tracker/index.php? 
> func=detail&aid=1267539&group_id=26031&atid=385708

I've never seen phpmailer convert spaces into <br>'s, the html I
give it is the html it sends. There probably is something wrong
with the html or how your using phpmailer.

In order to help with your issue, you'll have to provide a small
example of:
  1) The raw html you are using.
  2) the row email message that is delivered 


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Mon, Jan 02, 2006 at 09:35:21PM +0100, Mario de Frutos Dieguez wrote:
> Hi!
> 
> I have a problem using fread with a XML document. When i read some nodes
> with a great amount of text it cuts in the same place of the text. There
> are any limitation of text or something? I have in the php.ini the amount
> of memory in 256M.

The limitation is what you specify in your fread's second argument.
If I understand the problem you are incrementally reading a file
that is parsed for matching begin and ending elements, so if you
have a document like:

  <anode>
  // 2048 characters of data
  </anode>

And you do a:

  $line = fread($fp, 2048);

You wont get the closing element within the fread.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Tue, Jan 03, 2006 at 12:29:14PM -0500, James Tu wrote:
> I used phpMyAdmin to look at the stats for this mysql server.
> 
> http://www.2-bit-toys.com/db_info/server_status.html
> 
> What concerns me mainly are the stats at the top-right...'Failed  
> attempts' and 'Aborted.'
> When would these situations occur?  Is it normal to see these?

This is more of a mysql issue, a nice google of 'mysql connections
aborted' works pretty good [1].


> I'm using PHP's mysql_pconnect for all my scripts.  Could this be  
> causing the failed/aborted attempts?  What is not clear is if  
> mysql_pconnect will open another connection if the current one is  
> being used.

Becareful with pconnect:

  http://php.net/mysql_pconnect
  http://php.net/manual/en/features.persistent-connections.php


Historically, both _connect and _pconnect will reuse an existing
connection based on the username, password and server it is
connecting to, within the same script so if you have

$dbh = mysql_pconnect('localhost', 'username', 'password');
$dbh2 = mysql_pconnect('localhost', 'username', 'password');

Both $dbh and $dbh2 are using the same resource. mysql_connect has
an option to remove this feature/flaw/annoyance.

As far as the 'Aborted' connections, and how php could affect the
value is with the _pconnect....  Consider you have a peak hour and
you have 100 requests (at one time), php now has reserved 100 connections to 
the db.
And after the peak, you just get about 10-50 requests.  Those other
50-90 connections that php had made a connection to earlier become
stale (based on the mysql's wait_timeout or interactive_timeout
setting [1]) so an aborted connection is registered when a stale
connection is accessed.

[1] http://dev.mysql.com/communication-errors.html

HTH,

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
On Tue, Jan 03, 2006 at 01:52:44PM -0700, Ray Hauge wrote:
> Hello everyone,
> 
> I just wanted to see if anyone knew if there was any difference in 
> performance between using curl in an exec() statement and when using the 
> libCurl functions within PHP.

You might notice a difference if you loop though the code 100,000
times or so.

One advantage of using libCurl vs exec() is that you dont have to
worry about where the location of the actual 'curl' binary is:

  exec('/usr/local/bin/curl');
  exec('/usr/bin/curl');
  exec('/bin/curl');
  exec('C:/windows/curl.exe');
  exec('C:/Program Files/Curl/curl.exe');
  exec('X:/shared apps/curl/curl.exe')'
  etc.. 

With libCurl, you just ensure that curl is enabled in php.

Curt. 
-- 
cat .signature: No such file or directory

--- End Message ---

Reply via email to