Registered Users across Hubs script request
 

Registered Users across Hubs script request

Started by Psycho_Chihuahua, 11 September, 2004, 11:48:31

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Psycho_Chihuahua

Could someone write a script to compare and edit the userdatabase between 2 (or more) hubs running on the same computer with different Ports?

For example:

User registers himself (or gets registered) in Hub A, and at the same time he gets registered in Hub B allowing connection to that Hub as well.

Hub A should register the new User in Hub B automaticaly

i dont need any cmd's for this as it should be done completly on it's own.
the only thing i would have to be able to edit are the hubadresses and ports or the path to the RegisteredUsers.dat whichever would be needed to accomplish the task.

any help would be appreciated
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

bastya_elvtars

If both hubs are ptokax, then we can do a script that copies RegisteredUsers.dat to the folders between the 2 ptokax lol, but i dont know what to trigger it with. Altho i can make it for ya.
Everything could have been anything else and it would have just as much meaning.

plop

QuoteOriginally posted by bastya_elvtars
If both hubs are ptokax, then we can do a script that copies RegisteredUsers.dat to the folders between the 2 ptokax lol, but i dont know what to trigger it with. Altho i can make it for ya.
the idea is good but not the files.
ptokax only reads those on startup, so you need a seperate files.
have both hub's write new users 2 there own file, and let the hub's read eachothers files on a timer and delete it after processing.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

bastya_elvtars

U mean by triggering a regusers.dat reading process and if the users aint registered, ptokax adds them auto? Ok, gonna deal with that l8r...
Everything could have been anything else and it would have just as much meaning.

Psycho_Chihuahua

well there's a website registration script whizzing round somewhere here that also allows registering from outside the hub. just that it doesnt check if username is registered already so when 2 ppl use the same nick the passwords get messed up.

but it would be gr8 if someone could accomplish this task and i'm sure Admins of Hub Networks would find something like this somewhat usefull
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

plop

QuoteOriginally posted by bastya_elvtars
U mean by triggering a regusers.dat reading process and if the users aint registered, ptokax adds them auto? Ok, gonna deal with that l8r...
no seperate files.
hub1 has addnewregfile1.txt.
when some1 regs himself in hub1 the nick/pw is written 2 this file.
every x minutes hub2 checks if this file is found, if yes it processes the file and adds the new users.
when done it deletes the file.
this works a lot faster as nothing has 2 be done if the file isn't found, no need 2 check if it's a old or a new user.
hub2 offcourse saves 2 addnewregfile2.txt and hub1 checks for that file.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Psycho_Chihuahua

#6
got an example Plop?

Can someone do this for me please?
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Psycho_Chihuahua

anyone got a solution to this request?


pleeeease  ;(
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

Hi,

I can try to make one. How many HUBs are you runnig on your PC ??? You want to refresh the reg file from which time ??

Best regards, nErBoS
--## nErBoS Spot ##--

Psycho_Chihuahua

Hi nerbos

Well i'm running 2 Hubs on my PC and i would like the refresh to be done at the same time or shortly after the the user gets registered to the hub if thats possible

otherwise a refresh intervall of 30 mins would be just fine.
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

#10
Hi,

Try out this one...

--## REG HUBs BOT
--## Requested by Psycho_Chihuahua
--## Will only work with HUBs running in the same PC 
--## Made by nErBoS

sBot = "RH-Bot"

sec = 1000
min = 60*sec
hour = 60*min

--## Configuration ##--

fReg = "RegisteredUsers.dat"	-- Path of the RegisteredUsers.dat of the other HUB
iTime = 30*min			-- Time that will refresh the register 

--## END ##--

function Main()
	SetTimer(iTime)
	StartTimer()
end

function OnTimer()
	if (readfrom(fReg) == nil) then
		SendToOps(sBot, "The file with the register of the other HUB wasn't found.")
	else
		local count,time = 0,clock()
		readfrom(fReg)
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				time = clock() - time
				time = format("%0.10f", time*1000)
				SendToOps(sBot, "The reg file was refresh.")
				SendToOps(sBot, "New entries: "..count..". Time taken: "..time.." seconds")
				break
			else
				local s,e,nick,pass,level = strfind(sLine, "(.+)|(.+)|(%d+)")
				if (nick ~= nil and CheckReg(nick) == 0) then
					AddRegUser(nick, pass, tonumber(level))
					count = count + 1
				end
			end
		end
		readfrom()
	end
end
				
function CheckReg(nick)
	local aux,profiles,usr
	for aux, profiles in GetProfiles() do
		for aux, usr in GetUsersByProfile(profiles) do
			if (usr == nick) then
				return 1
			end
		end
	end
	return 0
end

Best regards, nErBoS
--## nErBoS Spot ##--

UwV

cool .. been looking for something like that ..


but ..

[02:14:18] New entries: 363. Time taken: 38891.0000000000 seconds
[02:14:39] The reg file was refresh.
[02:14:39] New entries: 0. Time taken: 19891.0000000000 seconds
[02:15:00] The reg file was refresh.
[02:15:00] New entries: 0. Time taken: 19860.0000000000 seconds
[02:15:21] The reg file was refresh.
[02:15:21] New entries: 0. Time taken: 19687.0000000000 seconds
[02:15:42] The reg file was refresh.
[02:15:42] New entries: 0. Time taken: 20422.0000000000 seconds
[02:16:01] The reg file was refresh.
[02:16:01] New entries: 0. Time taken: 17953.0000000000 seconds
[02:16:21] The reg file was refresh.
[02:16:21] New entries: 0. Time taken: 18578.0000000001 seconds
[02:16:42] The reg file was refresh.
[02:16:42] New entries: 0. Time taken: 20812.0000000000 seconds
[02:17:03] The reg file was refresh.
[02:17:03] New entries: 0. Time taken: 20108.9999999999 seconds
[02:17:25] The reg file was refresh.
[02:17:25] New entries: 0. Time taken: 20468.9999999999 seconds
[02:17:45] The reg file was refresh.
[02:17:45] New entries: 0. Time taken: 18844.0000000001 seconds


and it won't stop ... keeps on trying to ad and add and add ..

i haven't changed the " iTime = 30*min "
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

nErBoS

Hi,

LOL, i have forgot to remove the 5 seconds i had to test it. Fixed the script above.

Best regards, nErBoS
--## nErBoS Spot ##--

Psycho_Chihuahua

;(  ;(  ;(  it crashes my hub when i try to add a user  ;(  ;(  ;(


i get an error box with a whole lot of writing and the reference that it cant write the RegisteredUsers.dat

I've testet with TD 4, TD 4.99 and 0.330 build 15.25 all with the same result.

in the Filepath to the file i have tried with \ and / and even //. Either i get..cant find file or it crashes/locks the hub untill the error box has been clicked away (buil 15.25 - with 4 and 4.99 the whole thing crashed)

Any Idea's?
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

Hi,

Well in my script i don't write anything in the file, because if i did it would crach like you said. You said that you tried to add a user, how ??? by a command or by hubsoftware i suppose. If you tryied to write in the file, off course it will fail and give you a error. Here is a example of how to catch the userregister file of the other HUB....

"C:\\WorkFolder\\Ptokax\\RegisteredUsers.dat"

Best regards, nErBoS
--## nErBoS Spot ##--

Psycho_Chihuahua

Doh, the only version i didn't try lol

I'll check it out just now
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Psycho_Chihuahua

Well i tried that now to

i get a "what looks like linux or macintosh" error box containing the following:
Exeption 'EFCreate Error' in module PtokaX.exe at 000C0FFD
Cannot create file D:\hub\pto2\RegisteredUsers.dat

Using
QuoteD:\\hub\\pto2\\RegisteredUsers.dat

The funny thing though is that it still does the entry's to the file just that it locks up until the error messages are one by one clicked away. once per new user
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Psycho_Chihuahua

that would be a solution, exept for that each hub uses slightly different scripts and has a different MOTD, so finding a way to it script wise is probably the only way

The funny thing is on 1 hub it works and on an identical (made from the same exe just in different folder) it fails in full

so one way it works and the other not, randomly
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

#18
Hi,

Yes i have tested and it gaves me the same error, then i have tried another aproach, i copy the file to your script folder and will check from there, try this script...

--## REG HUBs BOT
--## Requested by Psycho_Chihuahua
--## Will only work with HUBs running in the same PC 
--## Made by nErBoS

sBot = "RH-Bot"

sec = 1000
min = 60*sec
hour = 60*min

--## Configuration ##--

fReg = "RegisteredUsers.dat"	-- Path of the RegisteredUsers.dat of the other HUB
iTime = 30*min			-- Time that will refresh the register 

--## END ##--

function Main()
	SetTimer(iTime)
	StartTimer()
end

function OnExit()
	StopTimer()
end

function OnTimer()
	execute("copy "..fReg)
	if (readfrom("RegisteredUsers.dat") == nil) then
		SendToOps(sBot, "The file with the register of the other HUB wasn't found.")
	else
		local count,time = 0,clock()
		local handle = openfile ("RegisteredUsers.dat", "r+")
		while 1 do
			local sLine = read(handle)
			if (sLine == nil) then
				time = clock() - time
				time = format("%0.10f", time*1000)
				SendToOps(sBot, "The reg file was refresh.")
				SendToOps(sBot, "New entries: "..count..". Time taken: "..time.." seconds")
				break
			else
				local s,e,nick,pass,level = strfind(sLine, "(.+)|(.+)|(%d+)")
				if (nick ~= nil and CheckReg(nick) == 0) then
					AddRegUser(nick, pass, tonumber(level))
					count = count + 1
				end
			end
		end
		closefile(handle)
		remove("RegisteredUsers.dat")
	end
end
				
function CheckReg(nick)
	local aux,profiles,usr
	for aux, profiles in GetProfiles() do
		for aux, usr in GetUsersByProfile(profiles) do
			if (usr == nick) then
				return 1
			end
		end
	end
	return 0
end

Best regards, nErBoS
--## nErBoS Spot ##--

Psycho_Chihuahua

yeah gr8
It works fine now thnx Nerbos. Just 1 more thing - as long as the hub's running it's fine. when i shutdown the hub however i get a couple of error Boxes.

Got an Idea why? No other script running during tests.
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

Hi,

That happens to all versions of ptokax or just one in particular ?? If one in particular, which is it ??

Best regards, nErBoS
--## nErBoS Spot ##--

Psycho_Chihuahua

#21
Well with 0.330 build 15.25 it happens already when i stop the hub




with 0.326 TestDrive 4 only when i've stopped the hub and then want to close it.



otherwise the script does the job fine  :D
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

Hi,

I have test it and didn't gave me any error.

Best regards, nErBoS
--## nErBoS Spot ##--

BoJlk

Unfortunetlly it gave me the same Errors...
both of the Versions.

bastya_elvtars

this occurs when ptokax wants to write to an already used file.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk