News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Add an Apache Error Handler to SMF

Started by Deprecated, September 02, 2008, 04:15:47 AM

Previous topic - Next topic

Nathaniel

I have to agree with Sabre™, it would be nice to have a separate 404 error log. ;)

Although I think that filters should work....
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Deprecated

Th
Quote from: Sabre™ on September 03, 2008, 08:32:54 AM
Nice job mate. :)
Could you add an area, where under your maintenance section in the AP, you would have 404 separate?
eg.
before:
Forum Maintenance
Generate Reports
Forum Error Log
Moderation Log


after:

Forum Maintenance
Generate Reports

404 error log
Forum Error Log
Moderation Log


Or would this be too heavy?

regards

Thanks for the compliment. :)

I don't think you need any work at all to get what you want. In your SMF error log, just look at the error record for the little magnifying glass next to the words "Error 404 - Not found." Click it and it will apply a filter and show you only the 404 errors in your log. Then you can analyze them or mass delete them.

I believe the advanced filters are available only in SMF 2.0. I don't intend to write any code for SMF 1.1.5 to fix new features that it doesn't have. Just upgrade if this is a problem for you. I hear that new Beta 4 is just around the corner! :)

Sabre™

Yeah ok.
I'll wait till SMF 2 is ready for me  lol    >> stable

Anyway for you to make a section to edit what is displayed?
I grew rather fond of my 404 page  lol    but agree that this looks more.......... structured with the forum.
So I would like to add what I have aswell, but would be easy if you had it like your rules section, where you can add the content like a post.

Just an idea for those of us new to the field ;)
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Deprecated

I just did some more checking. The error filters work, but they work too well. I just checked some 404s I created myself, and when you use the error filter it finds all the 404 errors but only on that specific URL. This is not a very useful filter because once you know the URL you know where to look to fix it. Getting more of the same error provides no additional utility.

Everybody should understand that this modification does not create or format the error log. It merely uses the existing interface to add errors to SMF's log. The interface allows calling routines (e.g. my error handler) to supply only one alphanumeric string. The string I'm supplying gives the error type (Error 404 - Not Found) plus the URL (e.g. http://www.example.com/smf/forum.php). I don't have any other interface to the logging function, and I'm not going to rewrite the logging code. I could take the URL out to make all the 404 file not found errors filter together, but without the URL the function would be useless!

To sum it up, your request is impossible to deliver without rewriting SMF's logging routines. Sorry! :)

Deprecated

@Sabre:

I hear what you're saying but I'm not interested in writing logging functions nor am I interested in modifying SMF's existing logging code. Perhaps some young, hungry, up and coming mod author might like to write an advanced logging tool for SMF, but I'm just an old grizzled programmer getting too decrepit to be useful for anything beyond serving as a bad example. ;)

The issue of logging the 404s separately is an SMF logging issue, not an Apache Error Handler issue. I can't fix that from my side of the fence, and I'm not going to climb over the fence! :)

Sabre™

Quote from: Deprecated on September 03, 2008, 09:35:34 AM
..........I'm just an old grizzled programmer getting too decrepit to be useful for anything beyond serving as a bad example. ;)
lol

Quote from: Deprecated on September 03, 2008, 09:35:34 AM
The issue of logging the 404s separately is an SMF logging issue, not an Apache Error Handler issue. I can't fix that from my side of the fence, and I'm not going to climb over the fence! :)
This is in response to post 19 or 22?
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Deprecated

#26
Quote from: Sabre™ on September 03, 2008, 09:42:05 AM
Quote from: Deprecated on September 03, 2008, 09:35:34 AM
The issue of logging the 404s separately is an SMF logging issue, not an Apache Error Handler issue. I can't fix that from my side of the fence, and I'm not going to climb over the fence! :)
This is in response to post 19 or 22?

Yes! :D

It's in response to both of them and also to all the questions regarding logging the 404s. That is not part of my error handler modification. The way that SMF logs errors is beyond my control. That is a function of the error logging routines, and I'm not interested in rewriting them. I have only one way to interface to SMF's error logging and that is through SMF's log_error() function. It allows me to pass to it only one thing, the error description that you see in the log, a single alphanumeric string.

The only way you can change that as far as I know is to rewrite SMF's logging routines, and I'm not interested in that job. Perhaps some other aspiring mod package author might take it on and you should post your request in the Mod Requests board.

It is not a deficiency in my Apache Error Handler. It is a deficiency in SMF's logging function. I can't help that. :)

Sabre™

O yep ok.
With post no.22, I have a swf file(animation) I use for my 404, and was suggesting another way to add it, without manually adding it into the template. Like how you add content to a post.
It would make it easier for others, and adds another level of flexibility, usability, and fun to the dreaded 404   lol
Its understandable that you dont feel the need to play with this, it is not a necessity. Im just hoping someone strolls along and adopts the idea.

Thanks once again :)
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


kizer

I haven't installed it as of yet, but is there an off/on switch? I'm asking because "if I do" have errors and I need to fix them which is obvious, but it would be nice not to have 100's of errors simply because it was hard to fix or hard to get to, to fix.
Own a Jeep? Links4Jeeps.com

Deprecated

The easiest way to turn it on and off would be to turn your redirection on and off. If you have no other mods that depend on your .htaccess file, you can just temporarily rename your file via FTP. Then change the name back to turn it on.

The mods to SMF actually have nothing to do with the errors. The mods just create the logging for it.

Bancherd

Looks promising, I will try this out.

Would this work if my smf is behind a portal?  ???

Deprecated

I don't have a portal to try it on, but I would think so, or can't think of any reason why not. Please let us know how it works out.

Bancherd

Installed this with smf2beta4 and PortaMx, looking good!  :D

Thanks for the mod  :)

Deprecated

Ah good, glad you like it!

Each time I see a post to this thread I get nervous. Thinkin', "Oh God! Somebody's .htaccess file mods burned down their site..." :)

There's really no worry of that because the mod saves your old .htaccess file if you had one. You can fix it all by FTP if anything untowards happens, and without the .htaccess file the mod is dormant.

Hey, I forgot to tell you, there's an Easter egg in this mod. Try ?action=error with no error code. ;)


edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

bluegray

Quote from: Charles Hill on September 02, 2008, 03:52:00 PM
I have weighed the usefulness of Pretty URLs mod vs this mod.  I have chosen this mod.  I had to add a little code to auto-redirect users from old "pretty" URLs to their un-pretty counterparts, but I like this mod :)
Could you please share how you did this? Is it just a few .htaccess RewriteRules? Would like to try it out, but I currently have PrettyUrls installed.

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Deprecated

Quote from: bluegray on September 15, 2008, 07:18:07 AM
Quote from: Charles Hill on September 02, 2008, 03:52:00 PM
I have weighed the usefulness of Pretty URLs mod vs this mod.  I have chosen this mod.  I had to add a little code to auto-redirect users from old "pretty" URLs to their un-pretty counterparts, but I like this mod :)
Could you please share how you did this? Is it just a few .htaccess RewriteRules? Would like to try it out, but I currently have PrettyUrls installed.

I'm sorry that I missed your question before. Yes, the modification is a combination of two things: It adds a series of Apache directives in the form "ErrorDocument 404 /index.php?action=error;code=404" to your .htaccess file or creates the .htaccess file if none exists. And it adds an error handler to respond to the "?action=error" requests which logs the error event and then displays an error page to the user.

I have no idea if it works with the PrettyURLs mod but it would be interesting to find out.

Deprecated

This modification has been verified to work properly with both SMF 1.1.6 and SMF 2.0 Beta 4.

Advertisement: