Forum Posts

This script is used to submit a forum post on a community website, including some interesting code to stop spamming:

if (GetUserExtendedField("UserID")=="Guest") then
   if (NotExists(#input/EMail)) then
      error "If you're not logged in, you must provide an email address to post. We won't display it. Why not create an account?"
   else
          warning "To verify you're not a computer, check the checkbox to left and post again"
     end if
    var #lastPostDate = (AddMinutes(Now(), -30))
    if (Exists(load(&root/Page[Title="General"]/Folder[IPAddress=IPAddress(), Date>#lastPostDate]))) then
      error "Sorry, to stop spam, guest users can only send one post every 30 minutes. Why not create an account?"
    end if
 else
    set #input/Author = GetUserExtendedField("FullName")
 end if
 var #rec = new record for &root/Page
 set #rec/Title = #input/Summary
 set #rec/Content = #input/Text
 set #rec/AllowUserPost = true
 set #rec/PriorityKey = #input/PriorityKey
 if (Exists(#input/EMail)) then
    set #rec/EMail = #input/EMail
 else
    if (Exists(GetUserExtendedField("EMail"))) then
      set #rec/EMail = GetUserExtendedField("EMail")
    end if
 end if
 set #rec/IPAddress = IPAddress()
 set #rec/Date = Now()
 set #rec/Author = #input/Author
 insert #rec at &path/Folder
 


Next Topic:
v4.2.0.956 (beta)
Up Since 2/29/2024 12:02:23 AM