mrkleen340 Posted February 27, 2007 Share Posted February 27, 2007 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 More sharing options...
magic2goodil Posted February 27, 2007 Share Posted February 27, 2007 Look at .htaccess this would be yur best bet I would imagine. You can have it detect the page error code, and then write your code for what you want it to do. Link to comment https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/#findComment-194922 Share on other sites More sharing options...
TRI0N Posted February 27, 2007 Share Posted February 27, 2007 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. Link to comment https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/#findComment-194932 Share on other sites More sharing options...
HaLo2FrEeEk Posted February 27, 2007 Share Posted February 27, 2007 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. Link to comment https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/#findComment-194935 Share on other sites More sharing options...
magic2goodil Posted February 27, 2007 Share Posted February 27, 2007 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. Link to comment https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/#findComment-194938 Share on other sites More sharing options...
corbin Posted February 27, 2007 Share Posted February 27, 2007 Also, make sure you make the file path relative to the root or if someone goes to site.com/a/a/a/a/this/d/o/e/s/n/t/exist/page.php, it will try to make the file in the last folder + what ever you set the file path as. Link to comment https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/#findComment-194940 Share on other sites More sharing options...
HaLo2FrEeEk Posted February 27, 2007 Share Posted February 27, 2007 Yes, magic, no corbin, if you use ./log.txt, then it would search the folder from which the script is being run, if you use /log.txt, it uses [root]/log.txt, I believe. Link to comment https://forums.phpfreaks.com/topic/40288-im-lost-in-a-php-project/#findComment-194961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.