/* $VER: AmiIPWatcher 1.7 (1999-05-05) */ options results libs = "rexxtricks.library rxsocket.library rexxkuang11.library rmh.library" DO UNTIL libs='';PARSE VAR libs lib libs IF EXISTS('libs:'lib)|EXISTS('Libs/'lib)|EXISTS(lib) THEN DO IF ~show('L',lib) THEN call addlib(lib,0,-30,0);END;ELSE DO Say 'Library Error. Unable to open 'lib address AmiIPWatcher ;quit END;END call tags SELECT WHEN arg(1)="REFRESH" then call gethostip WHEN arg(1)="IPCOPY" then call copyip WHEN arg(1)="HOSTCOPY" then call copyhost WHEN arg(1)="CHECKVERSION" then call download('info') WHEN arg(1)="DOWNLOAD" then call download('AIPW') WHEN arg(1)="GOTOURL" then openurl('http://members.xoom.com/snorslex/') WHEN arg(1)="VIEWLOG" then call vlog WHEN arg(1)="SAVELOG" then call slog WHEN arg(1)="CLOSELOG" then call clog WHEN arg(1)="CLEARLOG" then call cllog WHEN arg(1)="CLEARLOGY" then call cllogy WHEN arg(1)="CHECKVERSIONGUI" then call checkversiongui WHEN arg(1)="ABOUT" then call about OTHERWISE call init end exit vlog: 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 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 MUIA_Weight 10 label "Delete Entry" button ID LOGSA COMMAND '"AmiIPWatcher.rexx SAVELOG"' ATTRS MUIA_CycleChain 1 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 slog: 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 clog: 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 cllog: 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 cllogy: 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 checkversiongui: 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 about: address AmiIPWatcher window ID ABOUT Title '"About AmiIPWatcher 1.7"' COMMAND '"window ID ABOUT close"' PORT AmiIPWatcher text label "\033c\033bAmiIPWatcher v1.7\033n\n\033cFreely Distributable Emailware\n\n\033cReleased: 1999-05-05\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 init: address AmiIPWatcher window ID AIPW TITLE '"AmiIPWatcher v1.7"' COMMAND '"quit"' PORT AmiIPWatcher ATTRS MUIA_Window_ScreenTitle '"AmiIPWatcher 1.7 ©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 REFRESH"' ATTRS MUIA_Menuitem_Shortcut 'R' LABEL "Refresh Now" 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 '"AmiIPWatcher.rexx ABOUT"' ATTRS MUIA_Menuitem_Shortcut 'A' LABEL "About" item COMMAND '"method 'MUIM_Application_AboutMUI' 0"' PORT AmiIPWatcher ATTRS MUIA_Menuitem_Shortcut 'M' LABEL "About MUI" item ATTRS MUIA_Menuitem_Title '-1' item COMMAND '"quit"' PORT AmiIPWatcher ATTRS MUIA_Menuitem_Shortcut 'Q' LABEL "Quit" endmenu menu LABEL "Settings" item COMMAND '"method 'MUIM_Application_OpenConfigWindow'"' PORT AmiIPWatcher LABEL "MUI Prefs..." endmenu text help '"AmiIPWatcher v1.7 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 v1.7\033n\n\033cLorens Johansson\n\033cFreely Distributable Emailware" group node "HowTo_Main" group label "IP" 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 MUIA_String_Format MUIV_String_Format_Center help '"Shows your IP!"' endgroup group label "HostName" 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 endwindow Address AmiIPWatcher call gethostip exit gethostip: if ~IsLibOn("SOCKET") then do call nosock 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 call nosock 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 nosock: 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 return 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_Shortcut = 0x80422030 MUIA_Menuitem_Title = 0x804218be MUIA_Selected = 0x8042654b MUIA_String_Format = 0x80427484 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 MUIV_String_Format_Center = 1 R = '0A'X VERSION = 1.7 Return 0