Author Topic: Block passive unregistered users  (Read 3610 times)

0 Members and 1 Guest are viewing this topic.

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Block passive unregistered users
« on: 10 April, 2010, 19:08:55 »
Hello there :)

I need a script that blocks passive unregistered users from search ( just search ) download i don't care about :), to save bandwidh, like http://forum.ptokax.org/index.php?topic=6779.0
But even if i try to convert that one, it works for some minutes and then i get errors
Or if someone has any other suggestions, i would love to get some tips

thanks in advance

PtokaX forum

Block passive unregistered users
« on: 10 April, 2010, 19:08:55 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Block passive unregistered users
« Reply #1 on: 10 April, 2010, 19:24:53 »
What errors do you get exactly? Could you please post the converted code as well?
Everything could have been anything else and it would have just as much meaning.

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Re: Block passive unregistered users
« Reply #2 on: 10 April, 2010, 19:32:15 »
Code: [Select]
--Block passive search for unregistered users, made by Mutor
sBot = "SomeHubsBot"
sFeedNick = "Owner"
SearchArrival = function (user, data)
if not RegMan.GetReg(user.sNick) and not user.bActive then
local s,e,search = string.find(data,"([^%?]+)|$")

local res = "Unknown Path"..string.char(92)..user.sNick..", search is disabled for you :P Only active users can search, type +active (Or register yourself)"..string.rep(" ",350)..search

Core.SendToNick(user.sNick,"$SR "..SetMan.GetString(21).." "..res.." 0 0/0"..

SetMan.GetString(0).." ("..Core.GetHubIP()..":"..SetMan.GetString(4)..")")
Core.SendPmToNick(sFeedNick, sBot, user.sNick.. " with ip " ..user.sIP.. " is trying to search in passive mode ")

return true

end

end

and the error is attemt to concatenate local search  a nil value

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Block passive unregistered users
« Reply #3 on: 10 April, 2010, 20:27:28 »
Oh yeah, you just have to replace string.find to string.match.
Everything could have been anything else and it would have just as much meaning.

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Re: Block passive unregistered users
« Reply #4 on: 10 April, 2010, 20:46:59 »
Well, i must be lost in space, but still same error in line:
local res = "Unknown Path"..string.char(92)..user.sNick..", search is disabled for you :P Only active users can search, type +active (Or register yourself)"..string.rep(" ",350)..search

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Re: Block passive unregistered users
« Reply #5 on: 10 April, 2010, 22:29:57 »
Trying that one right now, thanks bastya_elvtars and Mutor

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Re: Block passive unregistered users
« Reply #6 on: 10 April, 2010, 22:58:54 »
It looks like it's affecting active users to thou, they starting to register.

and if i search in passive mode and then switch to active, i get the blocked message, but when i register, it goes away.
But i'm going to test it more

It affects active users to, any suggestions ?
« Last Edit: 11 April, 2010, 13:33:49 by Scanning »

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Re: Block passive unregistered users
« Reply #7 on: 12 April, 2010, 21:51:24 »
Nah, it's still affects active users to, switched to Mutors regme for now and reg for search and download

dunno what's wrong

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Block passive unregistered users
« Reply #8 on: 12 April, 2010, 22:01:11 »
A fix for you.

Code: [Select]
--[[
Passive search block, by Mutor
Blocks search for unregistered passive users
Returns fraudulent search result.
]]

OnStartup = function()
h,b,i,u = SetMan.GetString(0),SetMan.GetString(21),SetMan.GetString(3):gsub(";.*",""),SetMan.GetString(4)
t,bot = "TTH:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",SetMan.GetString(21)
end

SearchArrival = function (user,data)
local p,n = user.iProfile,user.sNick
if p == -1 and Core.GetUserValue(user,0) ~= "A" then
local _,_,search = string.find(data,"([^?]+)|$")
if search then
local res = "Unknown Path"..string.char(92)..n..", search is "..
"disabled for you :P "..string.rep("\t",15)..search
return Core.SendToUser(user,"$SR "..b.." "..res.." 0 1/2"..t.." ("..i..":"..u..")|"..
"<"..bot.."> "..n..", search is disabled for you. Please close the "..
string.format("%q",search:gsub("%$"," ")).." search window. Thank you.|"),true
end
return true
end
end
Everything could have been anything else and it would have just as much meaning.

Offline Scanning

  • Member
  • ***
  • Posts: 36
  • Karma: +14/-0
Re: Block passive unregistered users
« Reply #9 on: 13 April, 2010, 12:27:23 »
Well, I don't know what was wrong, but now it looks like it's working.

Many thanks to both of you

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Block passive unregistered users
« Reply #10 on: 13 April, 2010, 17:41:23 »
Mutor, you were using Core.GetUserData and the correct one would have been Core.GetUserValue. This was the only thing I have changed in your script.
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

Re: Block passive unregistered users
« Reply #10 on: 13 April, 2010, 17:41:23 »