/* cliDyndns module - part server - 09/2004 */ /* author : iri - http://www.irizone.net */ /* this is a beta version !! */ /* Demande de mise à jour de l'IP (au lancement du site ou avec une action) : - vérifie que l'IP est bien différente de celle précédemment updatée (sinon rien ne se passe) - concatène l'url de mise à jour vers le serveur déterminé dans l'éditeur - envoie l'url - reçoit la réponse du serveur - affiche la réponse (typiquement : OK ou ECHEC */ /* dyndns : url non supportée de façon transparente. http[s]://username:password@members.dyndns.org/nic/update? system=dyndns& hostname=yourhost.ourdomain.ext,yourhost2.dyndns.org& myip=ipaddress& wildcard=OFF& mx=mail.exchanger.ext& backmx=NO& offline=NO */ typeof typeSrv = S;; typeof username = S;; typeof password = S;; typeof domain = S;; typeof refresh = I;; typeof datatmp = S;; // fun msgErr : fun [S] I fun msgErr(m)= _DLGMessageBox _channel DMSwin _loc this "title" nil m 0; 0;; // fun err : fun [S] I fun err(code)= if !strcmp typeSrv "DynamicDNS (dyndns.org)" then //msgErr _loc this "notsupported" nil if !strcmp code "good" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "StaticDNS (dyndns.org)" then //msgErr _loc this "notsupported" nil if !strcmp code "good" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "CustomDNS (dyndns.org)" then //msgErr _loc this "notsupported" nil if !strcmp code "good" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.no-ip.com" then if !strcmp code "status=1" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.2mydns.com" then if !strcmp code "1000" then msgErr _loc this "error_ok" nil else if (!strcmp code "1002") || (!strcmp code "1022") then msgErr _loc this "error_3" nil else if ((atoi code) > 1009) && ((atoi code) < 1021) then msgErr _loc this "error_4" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "dns.blueline.be" then if !strcmp code "200" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.changeip.com" then if !strcmp code "successful update" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.cjb.net" then if !strcmp code "has been updated" then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.dnsexit.com" then if (strfind "0" code 0) != nil then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.dyns.net" then if (strfind "updated" code 0) != nil then msgErr _loc this "error_ok" nil else msgErr strcat _loc this "error_2" nil code else if !strcmp typeSrv "www.sitelutions.com" then if !strcmp code "success" then msgErr _loc this "error_ok" nil else if !strcmp code "noauth" then msgErr _loc this "error_4" nil else msgErr strcat _loc this "error_2" nil code else 0;; // fun reponse : fun [INET I S I] I fun reponse(inet, u, data, state)= if state == 0 then (set datatmp = strcat datatmp data; 0) else if state == 1 then err datatmp else msgErr _loc this "error_1" nil;; // fun updateIP : fun [S] I fun updateIP(url)= INETGetURL _channel url 0 @reponse 0; 0;; // fun concUrl : fun [S] I fun concUrl(ip)= _createpack ip _getmodifypack strcat DMSpathname "myip.txt"; if !strcmp typeSrv "DynamicDNS (dyndns.org)" then /* not supported directly */ let strcatn "https://":: //(base64_encode username):: /* encodage base64 required */ username:: ":":: //(base64_encode password):: /* encodage base64 required */ password:: "@members.dyndns.org/nic/update?system=dyndns&hostname=":: domain:: "&myip=":: ip:: "&wildcard=OFF&mx=mail.exchanger.ext&backmx=NO&offline=NO":: nil -> url in (_openbrowserhttp url; //updateIP url 0) else if !strcmp typeSrv "StaticDNS (dyndns.org)" then /* not supported directly */ let strcatn "https://":: //(base64_encode username):: /* encodage base64 required */ username:: ":":: //(base64_encode password):: /* encodage base64 required */ password:: "@members.dyndns.org/nic/update?system=statdns&hostname=":: domain:: "&myip=":: ip:: "&wildcard=OFF&mx=mail.exchanger.ext&backmx=NO&offline=NO":: nil -> url in (_openbrowserhttp url; //updateIP url 0) else if !strcmp typeSrv "CustomDNS (dyndns.org)" then /* not supported directly */ let strcatn "https://":: //(base64_encode username):: /* encodage base64 required */ username:: ":":: //(base64_encode password):: /* encodage base64 required */ password:: "@members.dyndns.org/nic/update?system=custom&hostname=":: domain:: "&myip=":: ip:: "&wildcard=OFF&mx=mail.exchanger.ext&backmx=NO&offline=NO":: nil -> url in (_openbrowserhttp url; //updateIP url 0) else if !strcmp typeSrv "www.no-ip.com" then let strcatn "http://dynupdate.no-ip.com:8245/update.php?username=":: username:: "&pass=":: password:: "&host=":: domain:: "&ip=":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.2mydns.com" then let strcatn "http://dyn.2mydns.com/dyn.asp?username=":: username:: "&password=":: password:: "&hostname=":: domain:: "&myip=":: ip:: "&wildcard=NO&backmx=YES&mx=mail.mydom.com&offline=NO":: nil -> url in updateIP url else if !strcmp typeSrv "dns.blueline.be" then let strcatn "http://dns.blueline.be/upd.php?user=":: username:: "&pwd=":: password:: "&host=":: domain:: "&ip=":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.changeip.com" then let strcatn "https://www.ChangeIP.com/nic/update.asp?u=":: (base64_encode username):: /* encodage base64 */ "&p=":: (base64_encode password):: /* encodage base64 */ "&set=1&ip=":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.cjb.net" then let strcatn "http://www.cjb.net/cgi-bin/dynip.cgi?username=":: username:: "&password=":: password:: "&ip=":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.dnsexit.com" then let strcatn "http://www.dnsexit.com/RemoteUpdate.sv?login=":: username:: "&password=":: password:: "&host=":: domain:: "&myip=":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.dyns.net" then let strcatn "http://www.dyns.net/postscript011.php?username=":: username:: "&password=":: password:: "&host=":: domain:: "&ip":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.sitelutions.com" then let strcatn "https://www.sitelutions.com/dnsup?id=":: domain:: "&user=":: username:: "&pass=":: password:: "&ip=":: ip:: nil -> url in updateIP url else if !strcmp typeSrv "www.ovh.com (dynHost)" then /* not sure */ let strcatn "http://":: username:: ":":: password:: "@www.ovh.com/nic/update?hostname=":: domain:: "&myip=":: ip:: "&wildcard=OFF&mx=mail.exchanger.ext&backmx=NO&offline=NO":: nil -> url in (_openbrowserhttp url; //updateIP url 0) else if !strcmp typeSrv "www.myip.us" then let strfind "." domain 0 -> r in let substr domain 0 r-1 -> host in let substr domain r strlen domain -> dom in let strcatn "http://myip.us/cgi-bin/cgi_updateip?accountname=":: username:: "&password=":: password:: "&hostname=":: host:: "&domainname=":: dom:: "&ipaddress=":: ip:: nil -> url in updateIP url else 0;; // fun verifyIpChanged : fun [] I fun verifyIpChanged()= let _getpack _checkpack strcat DMSpathname "myip.txt" -> lastIP in if !strcmp _hostIP lastIP then 0 else if !strcmp _hostIP "127.0.0.1" then 0 else 1;; // fun updateDD : fun [] I fun updateDD()= if verifyIpChanged then concUrl _hostIP else 0;; // fun updateOFF : fun [] I fun updateOFF()= concUrl "127.0.0.1";; // fun cbOKIP : fun [ObjButton [ObjText ObjText ObjText ObjText ObjWin]] I fun cbOKIP(btn, u)= let u -> [ip1 ip2 ip3 ip4 win] in let strcatn (_GETtext ip1)::"."::(_GETtext ip2)::"."::(_GETtext ip3)::"."::(_GETtext ip4)::nil -> ip in if (_GETtext ip1) == nil || (_GETtext ip2) == nil || (_GETtext ip3) == nil || (_GETtext ip4) == nil then msgErr _loc this "error_ip" nil else (_DSwindow win; concUrl ip);; // fun cbTextIP : fun [ObjText [ObjText ObjText ObjText ObjText]] ObjText fun cbTextIP(text, u)= if (atoi _GETtext text) > 255 then _SETtext text "255" else nil; let u -> [ip1 ip2 ip3 ip4] in if (strlen _GETtext text) == 3 then if text == ip1 then _SETtextFocus ip2 else if text == ip2 then _SETtextFocus ip3 else if text == ip3 then _SETtextFocus ip4 else nil else nil;; // fun enterIP : fun [] I fun enterIP()= let _GETscreenPos -> [x y] in let _CRwindow _channel DMSwin x y 185 30 WN_MENU _loc this "title_ip" nil -> win in let _CReditText _channel win 5 5 35 20 ET_NUMBER|ET_DOWN|ET_TABFOCUS nil -> ip1 in let _CReditText _channel win 41 5 35 20 ET_NUMBER|ET_DOWN|ET_TABFOCUS nil -> ip2 in let _CReditText _channel win 77 5 35 20 ET_NUMBER|ET_DOWN|ET_TABFOCUS nil -> ip3 in let _CReditText _channel win 113 5 35 20 ET_NUMBER|ET_DOWN|ET_TABFOCUS nil -> ip4 in let _CRbutton _channel win 150 5 30 20 PB_TABFOCUS "OK" -> bouton in ( _SETtextFocus ip1; _CBtext ip1 @cbTextIP [ip1 ip2 ip3 ip4]; _CBtext ip2 @cbTextIP [ip1 ip2 ip3 ip4]; _CBtext ip3 @cbTextIP [ip1 ip2 ip3 ip4]; _CBtext ip4 @cbTextIP [ip1 ip2 ip3 ip4]; _CBbutton bouton @cbOKIP [ip1 ip2 ip3 ip4 win]; ); 0;; // fun cbTimer : fun [Timer I] I fun cbTimer(t, u)= updateDD;; // fun activate : fun [DMI CLIENT S S S] I fun activate(from, cli, action, param, rep)= if !strcmp action "update" then updateDD else if !strcmp action "offline" then updateOFF else if !strcmp action "enterIP" then if param != nil then concUrl param else enterIP else 0;; // fun IniDMI : fun [S] I fun IniDMI(file)= let strextr _getpack _checkpack file -> l in ( set typeSrv = getInfo l "typeSrv"; set username = getInfo l "username"; set password = getInfo l "password"; set domain = getInfo l "domain"; set refresh = atoi getInfo l "refresh"; ); updateDD; _DMSregisterDMI this @activate nil nil nil; if refresh then _rfltimer _starttimer _channel 3600000 @cbTimer 0 else nil; 0;;