;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;; Oasiz IRCX Auth Tool ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; VERSION $1.02 $rev 24
;; AUTHOR Rob Hildyard
;; DATE 16.07.10
;; SUPPORT http://www.oasiz.net/forum/?showforum=83
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Status Window Shortcut ;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu status {
Oasiz Auth Tool: $oa_opdg(oa.at)
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Send Auth Data To Server ;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias oa_opdg {
if (!$dialog($1)) dialog -m $1 $1
}
;; Server list
alias oa_issv {
;; directory server
if ($1 == 75.126.226.11) return $true
;; groups server
if ($1 == 75.126.194.89) return $true
;; chat servers
if ($1 == 75.126.194.90) return $true
if ($1 == 75.126.194.91) return $true
if ($1 == 75.126.194.92) return $true
;; local server(s) (testing)
if ($1 == 192.168.0.2) return $true
if ($1 == 94.14.40.174) return $true
return $false
}
;; Sanitize nickname
alias oa_sank {
var %n = $remove($1,>,'Admin_,'Sysop_,'Guide_)
return %n
}
;; Vefify email address
alias eval_email {
var %reg ^[_\.0-9a-zA-Z]+@([0-9a-zA-Z][0-9a-zA-Z]+\.)+[a-zA-Z]{2,3}$
return $regex($1,%reg)
}
ON ^*:LOGON:*: {
%DOPASSPORT = $true
%OASIZCONNX = $oa_issv($server)
if (%OASIZCONNX) {
.MODE ISIRCX
.HALT
}
}
RAW *:*: {
if (%OASIZCONNX) {
if ($numeric == 451) {
.RAW -q NICK $oa_sank($me)
.RAW -q USER $gettok($emailaddr,1,64) * * : $+ $fullname
.HALT
}
if ($numeric == 910) || ($numeric == 912) {
.RAW -q NICK $oa_sank($me)
.RAW -q USER $gettok($emailaddr,1,64) * * : $+ $fullname
}
if ($numeric == 800) && ($2 == 0) {
.RAW -q AUTH $iif(%DOPASSPORT,OAServPassport,OAServ) I :OASSP000000X1A
.HALT
}
if ($1 == OAServPassport) || ($1 == OAServ) && ($2 == S) {
if ($3 == OK) {
if (%DOPASSPORT) {
.RAW -q AUTH OAServPassport S : $+ %_oa.auth
}
else {
.RAW -q NICK $oa_sank($me)
}
}
else {
if ( $oa.nopp() ) {
;; We are trying to connect with a passport that hasn't been updated/validated yet. D'oh!
$oa_opdg(oa.at)
$oa.ppmg(You must select a valid (updated) passport before attempting to connect)
haltdef
}
else {
;; Yipee, we made it! Grab challenge response code
set %_Yta true
$oaGo( 2, $remove($3,OASSP000000) )
}
}
.HALT
}
if ($1 == OAServPassport) || ($1 == OAServ) && ($2 == *) {
.HALT
}
}
}
on *:SOCKOPEN:x.i*:{
sockwrite -n $sockname GET /api?k= $+ %_oa.k $+ &e= $+ %_oa.e $+ &p= $+ %_oa.p $+ &a= $+ %_oa.a $+ &q= $+ %_oa.q HTTP/1.1 $+ $crlf $+ host: chat.oasiz.net $+ $crlf $+ Connection: close $str($crlf,2)
}
on *:SOCKREAD:x.i*:{
if ($sockerr > 0) return
var %z | sockread %z
while ($sockbr > 0) {
tokenize 32 %z
if ($regex($1-,/<challenge>(.*)</challenge>/)) { $_Ys($regml(1)) | return }
if ($regex($1-,/<authcode>(.*)</authcode>/)) { $oa.ppsucc($regml(1)) | return }
if ($regex($1-,/<error>(.*)</error>/)) { $oa.ppfail() | $oa.ppmg(Error: $regml(1)) | return }
return
}
sockread %z
}
alias oaGo {
if ( $1 == 1 ) {
set %_oa.a authcode
}
else {
set %_oa.q $2
set %_oa.a challenge
}
sockopen x.i $+ $rand(000,999) chat.oasiz.net 80
}
alias _Ys {
var %f = AUTH $iif(%DOPASSPORT,OAServPassport,OAServ) S :OASSP000000 $+ $1
if (%_Yta) { .RAW -q %f | unset %_Yta | return }
;; Sock stuff under here
if (%oa.sck) dosock %oa.sck %f
}
alias update_pp_list {
did -r oa.at 1
var %x = 1
var %s = $ini(pp.ini,0)
if ( %s > 0 ) {
while (%x <= %s) {
if ( $ini(pp.ini,%x) == $readini(oa.ini, n, settings, pp) ) var %t = %x
did -a oa.at 1 $ini(pp.ini,%x)
inc %x
}
if (%t) {
did -c oa.at 1 %t
writeini -n oa.ini settings pp $did(oa.at,1).seltext
}
;; Enable "delete/update" buttons
did -e oa.at 365 | did -e oa.at 8
;; Enable "connect" button if it has been updated
if ( ($readini(pp.ini,n,$did(oa.at,1).seltext,u) != 0) && (($did(oa.at,110).state == 1) || ($did(oa.at,130).state == 1)) ) {
did -e oa.at 34
}
else {
did -b oa.at 34
}
$oa.upd()
}
else {
;; Disable "delete/update/connect" buttons if no entries
did -b oa.at 365 | did -b oa.at 8 | did -b oa.at 34
$oa.ppmg(Click "Add" to start the magic..)
}
$oa.dlup()
}
;; Last Updated
alias oa.dlup {
did -r oa.at 45
var %t = $readini(pp.ini,n,$did(oa.at,1).seltext,u)
var %p = $iif(%t != 0, %t, N/A)
did -a oa.at 45 %p
}
alias oa.upd {
set %_oa.k $readini(pp.ini,n,$did(oa.at,1).seltext,k)
set %_oa.e $readini(pp.ini,n,$did(oa.at,1).seltext,e)
set %_oa.p $readini(pp.ini,n,$did(oa.at,1).seltext,p)
}
alias oa.ppsucc {
if (!$dialog(oa.at)) { return }
var %st = Authentication data successfully loaded
;; successful update. What do we do now?
writeini -n pp.ini $did(oa.at,1).seltext a $1
writeini -n pp.ini $did(oa.at,1).seltext u $asctime(dd/mm/yy h:nnTT)
;; Enable add/delete buttons
did -e oa.at 346 | did -e oa.at 365
;; Enable connect button IF we have a server selected
if ( ($did(oa.at,110).state == 1) || ($did(oa.at,130).state == 1) ) {
did -e oa.at 34
}
else {
%st = %st $+ Please select which server(s) to join.
}
$oa.ppmg(%st)
$oa.dlup()
}
alias oa.ppfail {
if (!$dialog(oa.at)) { return }
;; Enable "add/delete" buttons
did -e oa.at 346 | did -e oa.at 365
}
alias oa.nopp {
var %x = $readini(pp.ini,n,$readini(oa.ini, n, settings, pp),u)
if ( (!%x) || (%x == 0) ) return $true
return $false
}
alias oa.ppmg {
if (!$dialog(oa.at)) { echo -s $1- | return }
did -r oa.at 44
did -a oa.at 44 $1-
}
alias oa.svr {
var %c = 0
if ( $did($dname,110).state == 1 ) %c = 3
if ( $did($dname,130).state == 1 ) %c = %c + 5
if ( %c == 3 ) %c = M
if ( %c == 5 ) %c = G
if ( %c == 8 ) %c = B
writeini -n oa.ini settings s %c
$update_pp_list()
}
alias Gs {
if ($1 == G) return 75.126.194.89
return 75.126.194.90
}
alias Doserv {
var %svr = $readini(oa.ini,n,settings,s)
if (%svr != <img src='http://www.tg007.net/forum/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' /> {
server $Gs(%svr)
}
else {
server $Gs(M)
server -m $Gs(G)
}
}
dialog oa.at {
;; ID , LEFT, TOP, WIDTH, HEIGHT
title "Oasiz IRCX Auth Tool v1.02"
size -1 -1 123 147
option dbu
text "API Information:", 42, 6 4 40 8, left
link "click here", 812, 47 4 60 8
list 1,5 15 112 45
text "Last Updated:", 10, 6 60 40 8, left
text "N/A", 45, 45 60 75 8, left
button "Add", 346, 5 70 36 11,
button "Delete", 365, 43 70 36 11,
button "Update", 8, 82 70 36 11,
text "Server:", 100, 6 87 35 8, left
check "Main", 110, 27 87 23 8,
check "Groups", 130, 50 87 26 8,
button "Connect", 34, 82 85 36 11,
box "Status", 4, 6 98 112 33, read multi left
edit -, 44, 11 107 102 19, read multi left
text "Copyright © 2010", 9, 24 134 46 8, left
link "oasiz.net", 12, 70 134 30 8
}
on *:dialog:oa.at:init:*:{
;; Disable "delete/update/connect" buttons if no entries
if ( $ini(pp.ini,0) == 0 ) { did -b $dname 365 | did -b $dname 8 | did -b $dname 34 }
;; Server check boxes
if ( $readini(oa.ini,n,settings,s) == M ) { did -c $dname 110 }
if ( $readini(oa.ini,n,settings,s) == G ) { did -c $dname 130 }
if ( $readini(oa.ini,n,settings,s) == B ) { did -c $dname 110 | did -c $dname 130 }
$update_pp_list()
}
on *:dialog:oa.at:sclick:1:{
;; Selecting passport in list
var %a = $did($dname,1).seltext
if (%a) {
writeini -n oa.ini settings pp $did($dname,1).seltext
$update_pp_list()
}
}
;;; Add new passport
on *:dialog:oa.at:sclick:346:{
var %e = $$?="Step 1 of 3: Enter email address:", %p = $$?*="Step 2 of 3: Enter password:", %k = $$?="Step 3 of 3: Enter API Key:"
;; Validate data
if ( !$eval_email(%e) ) { $oa.ppmg( Input error: Invalid email address ) | return }
if ( $readini(pp.ini,n,%e,e) ) { $oa.ppmg( Input error: This passport already exists ) | return }
if ( $len(%k) != 36 ) { $oa.ppmg( Input error: Incorrect API key ) | return }
;; Looks like we made it. Let's get it updated..
writeini -n pp.ini %e e %e
writeini -n pp.ini %e p $md5(%p)
writeini -n pp.ini %e k %k
writeini -n pp.ini %e u 0
$oa.ppmg( Passport added. Updating/verifying data.. )
writeini -n oa.ini settings pp %e
$update_pp_list()
$oa.updv()
}
;;; Delete passport
on *:dialog:oa.at:sclick:365:{
if ($?!="Are you sure you want to remove this passport?" == $true) {
remini pp.ini $did($dname,1).seltext
;; Lets select the first on the list (if exists)
if ( $ini(pp.ini,0) > 0 ) { writeini -n oa.ini settings pp $ini(pp.ini,1) }
$update_pp_list()
}
}
alias oa.updv {
;; Disable "add/delete/connect" buttons whilst we update
did -b oa.at 346 | did -b oa.at 365 | did -b oa.at 8 | did -b oa.at 34
$oaGo(1)
}
;;; Update passport
on *:dialog:oa.at:sclick:8:{
$oa.updv
}
;;; Server choice (main)
on *:dialog:oa.at:sclick:110:{
$oa.svr()
}
;;; Server choice (groups)
on *:dialog:oa.at:sclick:130:{
$oa.svr()
}
;;; connect button
on *:dialog:oa.at:sclick:34:{
set %_oa.auth $readini(pp.ini,n,$did(oa.at,1).seltext,a)
$Doserv
$oa.ppmg( Connecting. Please wait... )
dialog -x oa.at
}
;; URLs
on *:dialog:oa.at:sclick:12:{ url -an http://www.oasiz.net }
on *:dialog:oa.at:sclick:812:{ url -an http://chat.oasiz.net/chat_api_key }