/* $VER: AmiIPWatcher 1.6 (1999-01-21) MUI */ options results lib.0 = 3 lib.1 = "rexxtricks.library" lib.2 = "rxsocket.library" lib.3 = "rexxkuang11.library" do x=1 to lib.0 if exists('libs:'lib.x) then do if ~show('L',lib.x) then call addlib(lib.x,0,-30,0) end else do say 'Library Error. Unable to open 'lib.x address AmiIPWatcher ;quit exit end end call tags if arg(1)="REFRESH" then do call gethostip exit end if arg(1)="IPCOPY" then do call copyip exit end if arg(1)="HOSTCOPY" then do call copyhost exit end if arg(1)="CHECKVERSION" then do call download('info') exit end if arg(1)="DOWNLOAD" then do call download('AIPW') exit end if arg(1)="GOTOURL" then do BrowserPath = "PROG:Kommunikation/Browsers/IBrowse1.22/IBrowse" Browser = "IBrowse" NewWin = 0 AutoBrowser = 1 if exists(AmiIPWatcher.url) then do call open(url,"AmiIPWatcher.url","r") BrowserPath = readln(url) Browser = readln(url) NewWin = readln(url) call close(url) end url='http://members.xoom.com/snorslex/' UB = UPPER(Browser) IF AutoBrowser=1 THEN DO IF SHOW('P','IBROWSE') THEN UB='IBROWSE' ELSE IF SHOW('P','VOYAGER') THEN UB='VOYAGER' ELSE IF SHOW('P','AWEB.1') THEN UB='AWEB' END SELECT WHEN UB='IBROWSE' THEN port='IBROWSE' WHEN UB='VOYAGER' THEN port='VOYAGER' WHEN UB='AWEB' THEN port='AWEB.1' OTHERWISE EXIT 10 END IF ~SHOW('P',port) THEN DO ADDRESS COMMAND 'RUN >NIL:' browserpath ADDRESS COMMAND 'SYS:rexxc/WaitForPort' port END INTERPRET 'ADDRESS' port SELECT WHEN UB='IBROWSE' THEN DO IF NewWin=1 THEN 'NewWindow "'url'"' ELSE 'GotoURL "'url'"' END WHEN UB='VOYAGER' THEN DO IF NewWin=1 THEN 'OpenURL "'url'" NEWWIN' ELSE 'OpenURL "'url'"' END WHEN UB='AWEB' THEN DO IF NewWin=1 THEN 'New "'url'"' ELSE 'Open "'url'"' END END exit end if arg(1)="VIEWLOG" then do if exists("AmiIPWatcher.config") then do call open(prefs,"AmiIPWatcher.config","r") loglocal=readln(prefs) call close(prefs) end address AmiIPWatcher window ID LOG Title '"IP/HostName Log"' COMMAND '"AmiIPWatcher.rexx CLOSELOG"' text node "HowTo_Log" label "\033cView the AmiIPWatcher.log" list ID LOGVI node "HowTo_Log" NODUP TITLE """\0333Date,\0333Time,\0333IP,\0333HostName""" ATTRS MUIA_List_Format """MIW=15 BAR,MIW=10 BAR,MIW=20 BAR,MIW=30""" help '"This list shows you the logfile."' group node "HowTo_Log" ATTRS MUIA_Group_Columns 6 button ID LOGCL COMMAND '"AmiIPWatcher.rexx CLEARLOG"' ATTRS MUIA_CycleChain 1 ATTRS MUIA_Weight 10 help '"Deletes all entries in the log file."' label "Clear Log" button ID LOGDE help '"Deletes the marked entry in the list.\nIt does not delete the entry from\nthe logfile, you must save the log."' COMMAND '"list ID LOGVI REMOVE POS -1"' PORT AmiIPWatcher ATTRS MUIA_CycleChain 1 ATTRS MUIA_Weight 10 label "Delete Entry" button ID LOGSA COMMAND '"AmiIPWatcher.rexx SAVELOG"' ATTRS MUIA_CycleChain 1 ATTRS MUIA_Weight 10 help '"Saves the log to AmiIPWatcher.log."' label "Save Log" space HORIZ label "Log LocalHost:" check ID LOGLO ATTRS MUIA_Selected loglocal help '"Check this if you want to\nsave localhost in the log file."' endgroup endwindow if exists("AmiIPWatcher.log") then do call open(loadlog,"AmiIPWatcher.log","r") do until eof(loadlog) LINE = readln(loadlog) if length(LINE) > 10 then do date = subword(LINE,1,3) time = subword(LINE,4,1) ip = subword(LINE,6,1) hostname = subword(LINE,8,1) STR = date||","||time||","||ip||","||hostname list ID LOGVI INSERT STRING STR end end call close(loadlog) end exit end if arg(1)="SAVELOG" then do call open(log,"AmiIPWatcher.log","w") address AmiIPWatcher list ID LOGVI MUIA_List_Entries entries = result do until entries = 0 entries = entries - 1 address AmiIPWatcher list ID LOGVI POS entries RES = result parse var RES DATE "," TIME "," IP "," HOST LINE = DATE||" "||TIME||" IP: "||IP||" HostName: "||HOST call writeln(log,LINE) end call close(log) exit end if arg(1)="CLOSELOG" then do address AmiIPWatcher check ID LOGLO save = result call open(prefs,"AmiIPWatcher.config","w") call writeln(prefs,save) call close(prefs) address AmiIPWatcher window ID LOG close exit end if arg(1)="CLEARLOG" then do options results;address AmiIPWatcher window ID CLYN ATTRS MUIA_Window_DragBar 0 MUIA_Window_DepthGadget 0 MUIA_Window_SizeGadget 0 text label "\033cAre you sure that you\nwant to clear the log file?" group MUIA_Group_Columns 3 button ID CLYES COMMAND '"AmiIPWatcher.rexx CLEARLOGY"' ATTRS MUIA_CycleChain 1 label "Yes" space HORIZ button ID CLNO COMMAND '"window ID CLYN close"' PORT AmiIPWatcher ATTRS MUIA_CycleChain 1 label "No" endgroup endwindow exit end if arg(1)="CLEARLOGY" then do call open(logfile,"AmiIPWatcher.log","w") call writeln(logfile,"") call close(logfile) address AmiIPWatcher list ID LOGVI ATTRS MUIA_List_Entries number = result do number list ID LOGVI REMOVE POS 0 end address AmiIPWatcher window ID CLYN close exit end if arg(1)="CHECKVERSIONGUI" then do options results;address AmiIPWatcher window ID CHVER Title '"Check Version"' COMMAND '"window ID CHVER close"' PORT AmiIPWatcher text label "\033cCheck for a new Version of AmiIPWatcher." group HORIZ node "HowTo_Version" group ATTRS MUIA_Group_Columns 2 label "This version:" string ID OLDV help '"Shows what version you are using."' content VERSION label "Available version:" string ID NEWV help '"Shows what version that\nis available on my homepage."' endgroup group button ID CHCHE COMMAND '"AmiIPWatcher.rexx CHECKVERSION"' ATTRS MUIA_CycleChain 1 help '"Connects via http to a file and\nchecks whats the newest version is."' label "Check Version" button ID CHDOW COMMAND '"AmiIPWatcher.rexx DOWNLOAD"' ATTRS MUIA_CycleChain 1 MUIA_Disabled 1 help '"Connects via http and downloads\nthe AmiIPWatcher archive."' label "Download AmiIPWatcher" endgroup endgroup endwindow string ID THISV content VERSION exit end if arg(1)="NOSOCKET" then do options results;address AmiIPWatcher window ID NOSOC ATTRS MUIA_Window_DragBar 0 MUIA_Window_DepthGadget 0 MUIA_Window_SizeGadget 0 text label "\033cCouldn't find bsdsocket.library!\nMake sure you have started a\nTCP/IP stack, like Miami." button ID NOSCL COMMAND '"window ID NOSOC close"' PORT AmiIPWatcher ATTRS MUIA_CycleChain 1 label "Ok" endwindow exit end if arg(1)="ABOUT" then do options results;address AmiIPWatcher window ID ABOUT Title '"About AmiIPWatcher 1.6"' COMMAND '"window ID ABOUT close"' PORT AmiIPWatcher text label "\033c\033bAmiIPWatcher v"||VERSION||"\033n\n\033cFreely Distributable Emailware\n\n\033cReleased: 1999-01-21\n\nThe idea is from a friends IPWatcher for PC.\nThanks LowSpirit (http://lowdimension.tsx.org)\n\n\033cPlease visit my homepage:\nhttp://members.xoom.com/snorslex/\n\nPlease E-Mail me if you like/hate the program!\nSnorsleX@SoftHome.net\n\n\033r©Copyright 1998-1999 Lorens Johansson" group HORIZ button ID ABGOU COMMAND '"AmiIPWatcher.rexx GOTOURL"' ATTRS MUIA_CycleChain 1 label "Visit Homepage" space HORIZ button ID CAB COMMAND '"window ID ABOUT close"' PORT AmiIPWatcher ATTRS MUIA_CycleChain 1 label "Ok" endgroup endwindow exit end address AmiIPWatcher window ID AIPW TITLE '"AmiIPWatcher v1.6"' COMMAND '"quit"' PORT AmiIPWatcher ATTRS MUIA_Window_ScreenTitle '"AmiIPWatcher 1.6 ©1998-1999 Lorens Johansson Freely Distributable Emailware"' menu LABEL "AmiIPWatcher" item COMMAND '"AmiIPWatcher.rexx CHECKVERSIONGUI"' ATTRS MUIA_Menuitem_Shortcut 'V' LABEL "Check version" item COMMAND '"AmiIPWatcher.rexx GOTOURL"' ATTRS MUIA_Menuitem_Shortcut 'P' LABEL "Visit Homepage" item COMMAND '"AmiIPWatcher.rexx VIEWLOG"' ATTRS MUIA_Menuitem_Shortcut 'L' LABEL "View Logfile" item ATTRS MUIA_Menuitem_Title '-1' item COMMAND '"AmiIPWatcher.rexx IPCOPY"' ATTRS MUIA_Menuitem_Shortcut 'I' LABEL "Copy IP to clipboard" item COMMAND '"AmiIPWatcher.rexx HOSTCOPY"' ATTRS MUIA_Menuitem_Shortcut 'H' LABEL "Copy HostName to clipboard" item ATTRS MUIA_Menuitem_Title '-1' item COMMAND '"method 'MUIM_Application_AboutMUI' 0"' PORT AmiIPWatcher ATTRS MUIA_Menuitem_Shortcut 'M' LABEL "About MUI" item COMMAND '"AmiIPWatcher.rexx ABOUT"' ATTRS MUIA_Menuitem_Shortcut 'A' LABEL "About" item ATTRS MUIA_Menuitem_Title '-1' item COMMAND '"quit"' PORT AmiIPWatcher ATTRS MUIA_Menuitem_Shortcut 'Q' LABEL "Quit" endmenu menu LABEL "Settings" menu LABEL "Refresh Rate" item COMMAND '"AmiIPWatcher.rexx REFRESH"' ATTRS MUIA_Menuitem_Shortcut 'R' LABEL "Refresh Now" item ATTRS MUIA_Menuitem_Enabled 0 MUIA_Menuitem_Shortcut 'O' LABEL "Off..." item ATTRS MUIA_Menuitem_Enabled 0 MUIA_Menuitem_Shortcut 'S' LABEL "Every second" item ATTRS MUIA_Menuitem_Enabled 0 MUIA_Menuitem_Shortcut 'M' LABEL "Every minute" endmenu item COMMAND '"method 'MUIM_Application_OpenConfigWindow'"' PORT AmiIPWatcher LABEL "MUI Prefs..." endmenu text help '"AmiIPWatcher v1.6 by\nLorens Johansson (http://members.xoom.com/snorslex)\nIf you use this program, you are required to\nEmail the author (SnorsleX@SoftHome.net). Otherwise,\nhow is he supposed to know to keep supporting\nAmiIPWatcher ?!?\n\033rLorens Johansson"', label "\033c\033bAmiIPWatcher v"||VERSION||"\033n\n\033cLorens Johansson\n\033cFreely Distributable Emailware" group node "HowTo_Main" group frame label "IP" group menu LABEL "IP" item COMMAND '"AmiIPWatcher.rexx IPCOPY"' LABEL "Copy IP to clipboard" item COMMAND '"AmiIPWatcher.rexx REFRESH"' LABEL "Refresh" endmenu string ID IP ATTRS MUIA_CycleChain 1 help '"Shows your IP!"' endgroup endgroup group frame label "HostName" group menu LABEL "HostName" item COMMAND '"AmiIPWatcher.rexx HOSTCOPY"' LABEL "Copy HostName to clipboard" item COMMAND '"AmiIPWatcher.rexx REFRESH"' LABEL "Refresh" endmenu string ID HOS ATTRS MUIA_CycleChain 1 help '"Shows your HostName!"' endgroup endgroup endgroup endwindow Address AmiIPWatcher call gethostip exit gethostip: if ~IsLibOn("SOCKET") then do address command "rx AmiIPWatcher.rexx NOSOCKET" exit end if exists("AmiIPWatcher.config") then do call open(prefs,"AmiIPWatcher.config","r") loglocal=readln(prefs) call close(prefs) end got_ip = GetHostID() Address AmiIPWatcher string ID IP old_ip = result string ID IP content got_ip host = GetHostName(got_host) Address AmiIPWatcher string ID HOS old_host = result string ID HOS content got_host YES = 0 if old_ip ~= got_ip then YES = 1 if old_host ~= got_host then YES = 1 if loglocal = 0 then if got_host = "localhost" then YES = 0 if YES = 1 then do if ~exists("AmiIPWatcher.log") then call open(iplog,"AmiIPWatcher.log","w") if exists("AmiIPWatcher.log") then call open(iplog,"AmiIPWatcher.log","a") LINE = date()||" "||time()||" IP: "||got_ip||" HostName: "||got_host call writeln(iplog,LINE) call close(iplog) end return 0 copyip: address AmiIPWatcher string ID IP IP = result IF ~WRITECLIPBOARD(0,IP) THEN say 'Could not copy 'got_ip' to the clipboard!' return 0 copyhost: address AmiIPWatcher string ID HOS HOST = result IF ~WRITECLIPBOARD(0,HOST) THEN say 'Could not copy 'got_host' to the clipboard!' return 0 download: if ~IsLibOn("SOCKET") then do address command "rx AmiIPWatcher.rexx NOSOCKET" exit end if arg(1) = "info" then do IF ~FWRITEURL('T:information.txt','HTTP://members.xoom.com/snorslex/information.txt') THEN exit call open(info,'T:information.txt',"r") RAD = readln(info) call close(info) RAD = delstr(RAD,1,14) address AmiIPWatcher string ID NEWV content RAD if VERSION ~= RAD then button ID CHDOW ATTRS MUIA_Disabled 0 end if arg(1) = "AIPW" then do address AmiIPWatcher IF ~FWRITEURL('RAM:AmiIPWatcher.LHA','HTTP://members.xoom.com/snorslex/files/amiipwatcher.lha') THEN exit end return 0 tags: MUIA_Application_Sleep = 0x80425711 MUIA_AppMessage = 0x80421955 MUIA_CycleChain = 0x80421ce7 MUIA_Disabled = 0x80423661 MUIA_Group_Columns = 0x8042f416 MUIA_List_Entries = 0x80421654 MUIA_List_Format = 0x80423c0a MUIA_Menuitem_Enabled = 0x8042ae0f MUIA_Menuitem_Shortcut = 0x80422030 MUIA_Menuitem_Title = 0x804218be MUIA_Selected = 0x8042654b MUIA_Weight = 0x80421d1f MUIA_Window_DepthGadget = 0x80421923 MUIA_Window_DragBar = 0x8042045d MUIA_Window_ScreenTitle = 0x804234b0 MUIA_Window_SizeGadget = 0x8042e33d MUIM_Application_AboutMUI = 0x8042d21d MUIM_Application_OpenConfigWindow = 0x804299ba TRUE = 1 FALSE = 0 R = '0A'X VERSION = 1.6 Return 0