FANDOM


-- <nowiki>
-- @authors Noreplyz
 
--------------------------------------------------------------------------
--[[ 
                                Module:Report
 
     Module for report templates. Proofreads user input.
 
     This module is invoked using Template:Report spam, 
     Template:Report vandalism, Template:Report profile and
     Template:Report filter.
 
--]]
--------------------------------------------------------------------------
 
local p = {}
local fallback = require('Module:Fallback')
local i18n = require('Module:Report/i18n')
 
-- remove excess or wrongly entered content
function trim(s)
    s = s:match( "^%s*(.-)%s*$" )
    return s
end
 
function trim_wiki(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("http:%/%/","")
    s = s:gsub("%.wikia%.com.*", "")
    return s
end
 
function trim_page(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("http:%/%/","")
    s = s:gsub("^.*%.wikia%.com%/wiki%/","")
    s = s:gsub("^.*%.wikia%.com%/","")
    s = s:gsub(" ","_")
    return s
end
 
function trim_user(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("http:%/%/","")
    s = s:gsub("^.*%.wikia%.com%/wiki%/","")
    s = s:gsub("^.*%.wikia%.com%/","")
    s = s:gsub("User:","")
    s = s:gsub("Special:Contributions%/","")
    s = s:gsub("Special:Contribs%/","")
    s = s:gsub(" ","_")
    s = s:gsub("&","%%26")
    return s
end
 
function trim_reason(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub( "\\\\", "|" )
    return s
end
 
function trim_id(s)
    s = s:match( "^%s*(.-)%s*$" )
    s = s:gsub("#","")
    return s
end
 
function crosswikilinks(user, wiki)
    local ippattern = "[^%d+%.%d+%.%d+%.%d+$]"
    local cwret = {}
    cwret[#cwret + 1] = '<span style="font-size:11px;margin-left:10px;">'
    if (string.match(user, ippattern) == nil) then
        cwret[#cwret + 1] = '([http://c.wikia.com/wiki/Special:MultiLookup?target=' .. user .. ' ML] &bull; '
    else
        cwret[#cwret + 1] = '([http://c.wikia.com/wiki/Special:LookupContribs?target=' .. user .. ' LC] &bull; '
    end
    cwret[#cwret + 1] = '[http://' .. wiki .. '.wikia.com/wiki/Special:CheckUser?user=' .. user .. ' CU] &bull; ' .. 
                        '[http://c.wikia.com/wiki/Special:Phalanx?type=8&target=' .. user .. '&wpPhalanxCheckBlocker=' .. user .. ' Phalanx])'
    cwret[#cwret + 1] = '</span>'
    return table.concat(cwret)
end 
 
-- creates the general format of the report
-- reportType: string of the type of user (Spammer, Vandal, Profile, Phalanx)
function createReport(frame, reportType)
    local tArgs = frame:getParent()     -- all arguments
    local ret = {}                      -- the return string
 
    -- check how many total users
    local numArgs = 0
    for key, value in ipairs(tArgs.args) do numArgs = numArgs + 1 end
 
    -- report params
    local wiki = trim_wiki(tArgs.args[1] or "")
    local reason = trim_reason(tArgs.args[2] or "")
    local user = ""
    local crosswiki = trim(tArgs.args["crosswiki"] or "")
    local socks = trim(tArgs.args["socks"] or "")
    local reporter = tArgs.args[numArgs - 1] or ""
    local time = tArgs.args[numArgs] or ""
 
    local lang = frame:preprocess( "{{int:lang}}" )
 
    -- report-specific params
    local skin = ""
    if reportType == "Profile" then
        skin = "?useskin=wikia"
    end
    local page = ""
    local blockId = ""
    if reportType == "Phalanx" then
        page = trim_page(tArgs.args[2] or "")
        blockId = trim_id(tArgs.args[3] or "")
        reason = tArgs.args[4] or ""
    end
 
    -- start report creation
    ret[#ret + 1] = '<div class="reports">\n'
    ret[#ret + 1] = '*' .. fallback.langSwitchCode(i18n, lang, "wiki") .. ': <span class="plainlinks">http://' .. wiki .. '.wikia.com</span>\n'
    if reportType == "Phalanx" then
        -- Filter problem only
        ret[#ret + 1] = '*'.. fallback.langSwitchCode(i18n, lang, "page") .. ': <span class="plainlinks">http://' .. wiki .. '.wikia.com/wiki/' .. page .. '</span>\n'
        ret[#ret + 1] = '*'.. fallback.langSwitchCode(i18n, lang, "blockid") .. ': <span class="plainlinks">http://community.wikia.com/wiki/Special:PhalanxStats/' .. blockId .. '</span>\n'
    else
        if crosswiki == "yes" then
            ret[#ret + 1] = "*''" .. fallback.langSwitchCode(i18n, lang, "cwmsg") .. "''\n"
        end
        -- Spam, Vandalism or Profile report
        for key, value in ipairs(tArgs.args) do 
            if (key >= 3 and key <= (numArgs - 2)) then
                user = trim_user(value) or ""
                ret[#ret + 1] = '*' .. reportType .. ': <span class="plainlinks">http://' .. wiki .. '.wikia.com/wiki/Special:Contributions/' .. user .. skin .. '</span>'
                -- add c/w links
                if (crosswiki == "yes") then
                    ret[#ret + 1] = crosswikilinks(user, wiki)
                end
                ret[#ret + 1] = '\n'
            end
        end
        if socks ~= "" then
            ret[#ret + 1] = "*''".. fallback.langSwitchCode(i18n, lang, "spmsg") .. "''\n"
            for sock in string.gmatch(socks, '([^\n]+)') do
                sock = trim_user(sock) or ""
                ret[#ret + 1] = '**' .. fallback.langSwitchCode(i18n, lang, "sock") .. ': [[w:c:' .. wiki .. ':Special:Contributions/' .. sock .. '|' .. sock .. ']]'
                ret[#ret + 1] = crosswikilinks(sock, wiki)
                ret[#ret + 1] = '\n'
            end
        end
 
    end
    ret[#ret + 1] = '*' .. fallback.langSwitchCode(i18n, lang, "reason") .. ': '.. reason ..'\n'
    ret[#ret + 1] = '*' .. fallback.langSwitchCode(i18n, lang, "sig") .. ': -- [[User:'.. reporter ..'|' .. reporter .. ']] ([[User talk:'.. reporter .. '|' .. fallback.langSwitchCode(i18n, lang, "talk") .. ']]) ' .. time .. '\n'
    ret[#ret + 1] = '</div>'
 
    return table.concat(ret)
end
 
function p.spam(frame)
    local lang = frame:preprocess( "{{int:lang}}" )
    return createReport(frame, fallback.langSwitchCode(i18n, lang, "spammer"))
end
 
function p.vandalism(frame)
    local lang = frame:preprocess( "{{int:lang}}" )
    return createReport(frame, fallback.langSwitchCode(i18n, lang, "vandal"))
end
 
function p.profile(frame)
    local lang = frame:preprocess( "{{int:lang}}" )
    return createReport(frame, fallback.langSwitchCode(i18n, lang, "profile"))
end
 
function p.filter_problem(frame)
    return createReport(frame, "Phalanx")
end
 
return p
-- </nowiki>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.