Self registration, passwd sent via email
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Self registration, passwd sent via email

Started by Skrollster, 17 April, 2004, 12:16:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Skrollster

Hi every one, first script i have written for a while...

this script generate a password with 15 chars [0-9,A-z]

and send it to the user typing +regme the@email.address.com

but in order to make it work you need to have a webserver with PHP support...

regme.lua
function main()
	sHost = "localhost"
	sPahtToPHP = "lua/mail.php"
end

function DataArrival(tUser, sData)
	local _,_,sCmd,sArg1 = strfind(sData, "%b<>%s+(%S+)%s+(%S+)%s*.*|" )
	if sCmd then
		sCmd = strlower(sCmd)
	end
	if (sCmd=="+regme") then
		local userProfile = tUser.iProfile
		if userProfile < 0 then 
			if not sArg1 then
				user:SendData("Reg Bot", "You need to enter a email adress.")
				return 1
			else
				regUserViaEmail(tUser, sArg1)
			end
		else
			user:SendData("Reg Bot", "You are already registered on this hub.")
		end
	end
end

-- tUser ?r anv?ndaren som ska registreras, allts? ett anv?ndar objekt
-- sEmail ?r email adressen som l?senordet ska skickas till
function regUserViaEmail(tUser, sEmail)
	local sPasswd = ""
	local sHexPasswd = ""
	for i = 1, 15 do
		sHexPasswd = sHexPasswd .. strchar(37)
		local char = 0
		if random(1,62) < 10 then
			char = random(48,57)
		elseif random(1,10) > 5 then
			char = random(65,90)
		else
			char = random(97,122)
		end
		sHexPasswd = sHexPasswd .. strupper(format("%x", char))
		sPasswd = sPasswd .. strchar(char)
	end
	local sMessage = "You have now been registered with username: "..tUser.sName.."%0A%0DAnd password: "..sHexPasswd
	local FullPHPCommand = sPahtToPHP.."?mailTo="..sEmail.."&mailSubject=Registration at "..frmHub:GetHubName().."&mailMessage="..sMessage..""
	FullPHPCommand = gsub(FullPHPCommand,"%s", "%%20")
	FullPHPCommand = gsub(FullPHPCommand, "?", "%%E5")
	FullPHPCommand = gsub(FullPHPCommand, "?", "%%E4")
	FullPHPCommand = gsub(FullPHPCommand, "?", "%%F6")
	FullPHPCommand = gsub(FullPHPCommand, "?", "%%C5")
	FullPHPCommand = gsub(FullPHPCommand, "?", "%%C4")
	FullPHPCommand = gsub(FullPHPCommand, "?", "%%D6")
	local GETHTML = "GET /"..FullPHPCommand.." HTTP/1.1\r\nHost: "..sHost.."\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"
	local socket, sErr = connect(sHost, 80)
	local sStatus = ""
	if not sErr then
		socket:timeout(2)
		socket:send(GETHTML..strchar(13,10))
		local sLine = ""
		while not sErr do
			if (strsub(sLine, 1, 9) == "Status = ") then
				sStatus = sLine
				break
			end
			sLine, sErr = socket:receive("*l")
		end
		socket:close()
	end
	socket:close()
	if sStatus == "Status = Sent" then
		tUser:SendData("Reg Bot", "Email sent to "..sEmail..", with login info")
		tUser:SendData("Reg Bot", (adduser(tUser, sPasswd, GetProfileIdx("Reg"))) )
		return
	else
		tUser:SendData("Reg Bot",sStatus)
		return sStatus
	end
end

function adduser(User, sPasswd, iUserlevel)
	local isreg = -1
	local sStatus = ""
	if type(User) == "string" then
		if GetItemByName(User) then
			isreg = GetItemByName(User).iProfile or reguserLevel(User.sName)
		else
			isreg = reguserLevel(User.sName)
		end
	elseif type(User) == "table" and User.iProfile then
		isreg = User.iProfile
	end

	if isreg == -1 then
		AddRegUser(User.sName, sPasswd, iUserlevel)
		sStatus = "Registation successful for "..User.sName.." ( "..GetProfileName(iUserlevel).." )."
	elseif tonumber(isreg) then
		sStatus = "The user is already registered as: "..GetProfileName(isreg).." and nothing is changed"
	else
		sStatus = "The user is already registered as: "..isreg.." and nothing is changed"
	end
	return sStatus
end

function reguserLevel(sUserName)
	sUserName = strlower(sUserName)
	local allprofiles = GetProfiles()
	local index, profile, index2, user
	for index, profile in allprofiles do
		local users = GetUsersByProfile(profile)
		for index2, user in users do
			if strlower(user) == sUserName then
				return GetProfileIdx(profile)
			end
		end
	end
	return -1
end


this is the mail.php script that need to be at sHost/sPahtToPHP

<?php 
$mailTo 
$_GET['mailTo']; 
$mailSubject $_GET['mailSubject']; 
$mailMessage $_GET['mailMessage']; 
mail($mailTo$mailSubject$mailMessage) or die ("Status = Failed to send email to: ".$_GET['mailTo']); 
echo(
"Status = Sent");
?>


you also need to make sure you have some paremeters set in php.ini in your %SYSTEM% folder

[mail function]
; For Win32 only.
SMTP = your.smtp.server

; For Win32 only.
smtp_port = 25

; For Win32 only.
sendmail_from = from@adress.se

Stravides

Any chance of getting this script for ASP (not .net)

I have cdosys and have relevant ASP code for mailing, I just dont understand how to use external html/web pages

many thanks

CDOSYS Version (XP)
<%
htmlBody = "

Thanks for Registering at RPGBooks

" htmlBody = htmlBody & "

Your password is

" Set oMail = Server.CreateObject("CDO.Message") Set iConf = Server.CreateObject("CDO.Configuration") Set Flds = iConf.Fields iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")= 2 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "mailserver" iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup" iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = smport iConf.Fields.Update Set oMail.Configuration = iConf oMail.To = strREmail oMail.From = "REGISTRATION@RPGBOOKS-CYMRU.NO-IP.ORG" oMail.Subject = "User Password" oMail.HTMLBody = htmlBody oMail.Send Set iConf = Nothing Set Flds = Nothing %>
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

SMF spam blocked by CleanTalk