The Serendipity Handbook

You can now read the (german) handbook here: PDF - (LaTeX source).


Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Plugins Overriding commentInfo['ip']?

Creating and modifying plugins.
Posts: 34
Joined: Sun Sep 02, 2007 6:32 pm

Postby FishNiX » Sun Jan 20, 2013 1:17 am

Hey all -

I'm trying to write in support for X-Forwarded-For without hacking core functions. I've been trying to work with the frontend_saveComment event hook. It looks like eventData and addData come through with some information about the comment, but setting

Code: Select all
eventData['ip'] = getenv('HTTP_X_FORWARDED_FOR') != '' ? getenv('HTTP_X_FORWARDED_FOR') : $_SERVER['REMOTE_ADDR'];


Code: Select all
addData['ip'] = getenv('HTTP_X_FORWARDED_FOR') != '' ? getenv('HTTP_X_FORWARDED_FOR') : $_SERVER['REMOTE_ADDR'];

doesn't override commentInfo. I'm not sure if this is possible? I don't really want to hack include/ if I don't have to since it will make upgrades, etc harder.


User avatar
Core Developer
Posts: 29919
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Sun Jan 20, 2013 2:40 am


Have you tried editing your with somethin glike this:

Code: Select all
if (getenv('HTTP_X_FORWARDED_FOR') != '') {

then you shouldn't need to patch any code, because the proper IP you want is always contained in the right variable that everything accesses?

# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy:
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby:

Posts: 34
Joined: Sun Sep 02, 2007 6:32 pm

Postby FishNiX » Sun Jan 20, 2013 4:25 am

I didn't know I could do that. I'll give it a shot.

Thanks as always!

Return to Plugins

Who is online

Users browsing this forum: No registered users and 1 guest