Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Log the user agent and IP address for each comment

  • Loading branch information...
commit 9805670e85147f1187067d2b04f21d668005aeb1 1 parent 254cc51
Hans-Christian Espérer authored
8 modules/mod_comment/models/m_comment.erl
@@ -112,7 +112,9 @@ insert(RscId, Name, Email, Message, Is_visible, Context) ->
112 112 Name1 = z_html:escape(z_string:trim(Name)),
113 113 Message1 = z_html:escape_link(z_string:trim(Message)),
114 114 KeepInformed = z_convert:to_bool(z_context:get_q("keep_informed", Context, false)),
115   - Props = [
  115 + UserAgent = z_context:get_q("user_agent", Context, <<"">>),
  116 + IPAddress = wrq:peer(z_context:get_reqdata(Context)),
  117 + Props = [
116 118 {rsc_id, z_convert:to_integer(RscId)},
117 119 {is_visible, Is_visible},
118 120 {user_id, z_acl:user(Context)},
@@ -122,8 +124,8 @@ insert(RscId, Name, Email, Message, Is_visible, Context) ->
122 124 {email, Email},
123 125 {gravatar_code, gravatar_code(Email)},
124 126 {keep_informed, KeepInformed},
125   - {ip_address, ""},
126   - {user_agent, ""}
  127 + {ip_address, IPAddress},
  128 + {user_agent, UserAgent}
127 129 ],
128 130 case z_db:insert(comment, Props, Context) of
129 131 {ok, CommentId} = Result ->
4 modules/mod_comment/templates/_comments_form.tpl
@@ -50,6 +50,10 @@
50 50 <button class="btn btn-primary" type="submit">{_ Send _}</button>
51 51 </div>
52 52 </div>
  53 +
  54 + <div>
  55 + <input type="hidden" name="user_agent" value="{{ m.req.user_agent }}" />
  56 + </div>
53 57
54 58 </fieldset>
55 59 </form>

0 comments on commit 9805670

Please sign in to comment.
Something went wrong with that request. Please try again.