#69257 - 2002-08-21 05:05 PM
how to improve this
|
Anonymous
Anonymous
Unregistered
|
any ideas how to improve this? it locks a little bit ugly to me...
code:
SELECT CASE INGROUP("GL helpdesk-telebilling") $override1 = "helpdesk.telebilling.dk" CASE INGROUP("GL Servicerufnummern") $override2 = "www.ihre-servicerufnummer.de" CASE INGROUP("GL Call Center") $override3 = "www.teleauskunft.de;www.bankleitzahlen.de" ;CASE INGROUP("Team Intranet") ; $override4 = "bla.de" ENDSELECT
; Write ProxyOverride IF $override1 IF $proxyoverride $proxyoverride = "$proxyoverride;$override1" ELSE $proxyoverride = "$override1" ENDIF ENDIF IF $override2 IF $proxyoverride $proxyoverride = "$proxyoverride;$override2" ELSE $proxyoverride = "$override2" ENDIF ENDIF IF $override3 IF $proxyoverride $proxyoverride = "$proxyoverride;$override3" ELSE $proxyoverride = "$override3" ENDIF ENDIF
IF $override4 IF $proxyoverride $proxyoverride = "$proxyoverride;$override4" ELSE $proxyoverride = "$override4" ENDIF ENDIF
IF $proxyoverride $proxyoverride = "$proxyoverride;nc*;192.168.*;*.nordcom.net;10.2.6.7;jurcom5.juris.de;www.alexanderschneeweis.de;<local>" ELSE $proxyoverride = "nc*;192.168.*;*.nordcom.net;10.2.6.7;jurcom5.juris.de;www.alexanderschneeweis.de;<local>" ENDIF
;LogEvent( 0 , 1 , "$proxyoverride") Writevalue ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyOverride",$proxyoverride,"REG_SZ")
[ 21. August 2002, 17:05: Message edited by: icu ]
|
|
Top
|
|
|
|
#69259 - 2002-08-21 05:15 PM
Re: how to improve this
|
Anonymous
Anonymous
Unregistered
|
i had it that way ... but it is possible that a user is member of multiple groups handled in this script...
|
|
Top
|
|
|
|
#69261 - 2002-08-21 05:17 PM
Re: how to improve this
|
Anonymous
Anonymous
Unregistered
|
let me guess. select stops on the first match? ;-)
*sigh*
"if" is my friend
|
|
Top
|
|
|
|
#69264 - 2002-08-21 05:52 PM
Re: how to improve this
|
Anonymous
Anonymous
Unregistered
|
quote: mmmm... what proxyoverride variable keeps inside?
nothing at the beginning. i'm just playing around with diffrent solutions.
what if 1 person is in both groups. so only the last $override is set.
|
|
Top
|
|
|
|
#69266 - 2002-08-21 06:09 PM
Re: how to improve this
|
Anonymous
Anonymous
Unregistered
|
thx for your help
|
|
Top
|
|
|
|
#69267 - 2002-08-21 11:43 PM
Re: how to improve this
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
I'm new to KiXtart (2 days and I only wrote a couple of lines of code in it), but I think you could take advantage of the ini-file reading routines and simplify your code.
Having an ini like this (OVERRIDE.INI):
code:
[GL helpdesk-telebilling] Site 1 = helpdesk.telebilling.dk [GL Servicerufnummern] Site 1 = www.ihre-servicerufnummer.de [GL Call Center] Site 1 = www.teleauskunft.de Site 2 = www.bankleitzahlen.de [Team Intranet] Site 1 = override=bla.de [Everyone] Site 1 = site.for.everyone.com
The actual key names (Site 1, 2, etc) are not important but have to be present; you can use whatever you like the most...
Then change the program to something like this:
code:
dim $Overrides ; Declare $Overrides $OverrideIni = ".\overrides.ini" ; Choose ini filename and location $Sep = "|" ; Character or string to seperate overrides $Groups = ReadProfileString( $OverrideIni, "", "" ) ; Get all Groups defined in the .ini if @ERROR = 0 ; If all went well for each $Group in split( $Groups, Chr(10) ) ; Process each returned line in turn if $Group ; Accounts for last "empty" item returned above if InGroup( $Group ) ; If user is in this group $Items = ReadProfileString( $OverrideIni, $Group, "" ) ; Get all overrides for the selected Group for each $Item in split( $Items, Chr(10) ) ; Process each override in turn if $Item ; Accounts for last "empty" item returned above $Value = ReadProfileString( $OverrideIni, $Group, $Item ) ; Read it's value $Overrides = $Overrides + $Sep + $Value ; And add it to the Overrides list endif ; End if $Item next ; End for each $Item in split( $Items, Chr(10) ) endif ; End if InGroup( $Group ) endif ; End if $Group next ; End for each $Group in split( $Groups, Chr(10) ) if $Overrides ; If some override present $Overrides = substr( $Overrides, 2 ) ; Eliminate spurious $Sep added at start ? $Overrides ; Print it or do whatever needed else ; else (no overrides found) ? "No overrides found..." ; Act accordingly endif ; End if $Overrides else ; Else (error reading INI file) ? "Error reading $OverrideIni" ; Complain endif ; End if @ERROR = 0
Sorry if it doesn't fit nicely on most displays, but I use a 1600x1200 desktop resolution on my Dell Latitude C810 and I tend to use that resolution...
I've "sort of" tested this, and it should work... I say "sort of", because I'm at home now and InGroup seems to require a "live" DC present to work properly...
This way of doing things has the advantage that the core script stays the same and you just have to edit the .INI file to add/delete/change stuff...
Hope this helps, Fernando Madruga [ 22. August 2002, 00:06: Message edited by: Fernando Madruga ]
_________________________
Later,
[b]Mad[/b]ruga
|
|
Top
|
|
|
|
#69269 - 2002-08-22 12:12 AM
Re: how to improve this
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
If so, instead of using
code:
$Groups = ReadProfileString( $OverrideIni, "", "" )
to read ALL the sections, it should read all the keys from a specific section and process them in turn. An easy change to this script.
I did like the idea of adding the ini data to the end of the script itself! Does KiXtart have some sort of __END__ token as perl does to stop processing the file?
The advantage of having code separated from data is that one data mistake won't break the code syntax... And it's easier to "delegate", that is, in my company, we have 3 ppl in charge of sys admin tasks: I'm the one with 20+ years of programming on my back, and the other two don't carry the same experience. It's easier for them to simply change the .INI (there are even tools to let you change an .INI file!), and leave the coding to me...
Bye, Fernando Madruga
_________________________
Later,
[b]Mad[/b]ruga
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 871 anonymous users online.
|
|
|