Jump to content

Im lost in a php project


mrkleen340

Recommended Posts

The basic idea for this script is when my apache server gets an error like 403, 404, 500 and so on it writes some info in a text file and emails me that the log is updated with php. I am new to php so I don't know what to exactly do. I am all set with the email, but I am lost here. ???

 

I am guessing I will need to write this to a varible but have it function so that turns into the user's browser data.

 

<!--#echo var="HTTP_USER_AGENT" -->

That with other like codes then have to print to a page and a text file (I would rather not use mysql). How do I go about making the info that code creates?  Also is it possible to have php in a .shtml because thats what I need it to be in.

Link to comment
https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/
Share on other sites

Well like magic says you would use your .htaccess or custome error pages inside the server config file.

 

Basicly you create custom pages for all the errors with the php code you need to send mail and post to text file.  So each time an error page is loaded it does that routine..

 

Example .htaccess file:

ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php

Options -Indexes

 

Your error pages should be placed in the website root along with the .htaccess file.

Then your error pages would be the one writing the error info to the file and emailing it to you, to open the error log, use this:

 

$handle = fopen("/log.txt", 'w');

fwrite($handle, $some_error_info);

fclose($handle);

 

You will then need to have some code that will email you a notification of the update.

Then your error pages would be the one writing the error info to the file and emailing it to you, to open the error log, use this:

 

$handle = fopen("/log.txt", 'w');

fwrite($handle, $some_error_info);

fclose($handle);

 

You will then need to have some code that will email you a notification of the update.

 

Keep in mind you'll need to make sure your permissions for this file are set so you can write to it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.