'********************************************************************************************* '** ** '** Make sure this file has .vbs extension ** '** ** '** Place this file in the root of WebTrends installation drive ** '** ** '** Change line 2 (ConfigLocation line) to be path to your WebTrends '\config\' folder ** '** ** '** Run this script from the command line as follows, (assuming you're running from C:) ** '** ** '** C:\>cscript dump_custom_report_configs.vbs //nologo > c:\outputfilename.tsv ** '** ** '********************************************************************************************* '********************************************************************************************* '** ** '** Key ** '** ** '** (OOTB) followed by a string means it is an Out Of The Box dimension, not custom ** '** (OOTB) by itself in the Dimension2 column means there is no secondary dimension ** '** (hit) means the dimension or filter is a hit dimension or filter ** '** (visit) means the dimension or filter is a visit dimension or filter ** '** (eleven-character-string) is the GUID of the dimension or hit in case you want to ** '** look it up in the original ini file ** '** ** '** ** '** If a given report has more than one Exclude or Include filter, they will be in the ** '** output file separated by a pipe character | ** '** In Excel, pipes can be changed to within-cell new line breaks by replacing with ** '** "Alt-0010" (alt-key + zero-zero-one-zero typed on the numeric keypad) ** '** ** '********************************************************************************************* '********************************************************************************************* '** ** '** Changelog ** '** ** '** v1.0 - 2009-06-22 - first stable release ** '** ** '** v1.1 - 2009-06-22 - added (OOTB) to indicate "out of the box" dimensions ** '** ** '** ** '********************************************************************************************* 'CHANGE LOCATION IN NEXT LINE TO \CONFIG LOCATION RELATIVE TO LOCATION OF THIS SCRIPT ConfigLocation = "X:\Program Files\WebTrends\storage\config\" ' Create Some global objects Set fso = CreateObject("Scripting.FileSystemObject") Set objFso = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") ' Create the global INIfile objects for any INI files needed later set cstm = new iniFile cstm.LoadIni(ConfigLocation & "wtm_wtx\datfiles\customtables\default.ini") set categoryini = new iniFile categoryini.LoadIni(ConfigLocation & "wtm_wtx\datfiles\categories\customtables.ini") set dimini = new iniFile dimini.LoadIni(ConfigLocation & "wtm_wtx\datfiles\hitproperties\dimensions.ini") set filtini = new iniFile filtini.LoadIni(ConfigLocation & "wtm_wtx\datfiles\hitproperties\filters.ini") set vdimini = new iniFile vdimini.LoadIni(ConfigLocation & "wtm_wtx\datfiles\visitproperties\dimensions.ini") set vfiltini = new iniFile vfiltini.LoadIni(ConfigLocation & "wtm_wtx\datfiles\visitproperties\filters.ini") strLocation = WshShell.CurrentDirectory & "\" ' Define some constants const ForReading=1, ForWriting=2, ForAppending=8, TristateUseDefault=0 ' for FileSystemObject const COL_DESTINATION = 2, COL_ACTION = 3 ' for Lookup object ' Create iniFile object and load the customtables\default.ini wscript.echo "IniSection" & vbtab & "ReportName" & vbtab & "ReportGUID" & vbtab & "ProfileCategory" & vbtab & "Dimension1" & vbtab & "Dimension2" & vbtab & "ExcludeFilters" & vbtab & "IncludeFilters" ' Loop through each entry in custom table ini (cstm) for x = 1 to ubound(cstm.arrSection,2) exfiltlist="" infiltlist="" ' skip over the [default] section If Not cstm.arrSection(1,x)="[default]" Then ' build a pipe (|) delimited list of exculde filters for this custom table for each exfilt in split(trim(cstm.strGetItem(cstm.arrSection(1,x),"excludefilters"))," ") exfiltlist = exfiltlist & getFilter(exfilt) & "|" next ' build a pipe (|) delimited list of inculde filters for this custom table for each incfilt in split(trim(cstm.strGetItem(cstm.arrSection(1,x),"includefilters"))," ") infiltlist = infiltlist & getFilter(incfilt) & "|" next ' Lookup all the other pieces (filters already done) and output ' FIX this is not a pretty way to lookup and output all of this information ' it makes the code more difficult to understand and thus modify wscript.echo cstm.arrSection(1,x) & vbtab & cstm.strGetItem(cstm.arrSection(1,x),"profilename") & vbtab & cstm.strGetItem(cstm.arrSection(1,x),"profileid") & vbtab & getCategory(cstm.strGetItem(cstm.arrSection(1,x),"profilecategory")) & vbtab & getDimension(cstm.strGetItem(cstm.arrSection(1,x),"dimension0guid")) & vbtab & getDimension(cstm.strGetItem(cstm.arrSection(1,x),"dimension1guid")) & vbtab & exfiltlist & vbtab & infiltlist End If next wscript.quit function strUpToFirst(strSource,strLookFor) if instr(strSource,strLookFor) then arrJunk = split(strSource,strLookFor) strUpToFirst = arrJunk(0) else strUpToFirst = strSource end if end Function function getCategory(id) 'wscript.echo id getCategory=id for jj = 1 to ubound(categoryini.arrSection,2) If Not categoryini.arrSection(1,jj)="[DEFAULT]" Then 'wscript.echo categoryini.strGetItem(categoryini.arrSection(1,jj),"Profileid") if categoryini.strGetItem(categoryini.arrSection(1,jj),"profileid")=id then getCategory = categoryini.strGetItem(categoryini.arrSection(1,jj),"profilename") end if end if next end function function getDimension(id) 'wscript.echo "GetDimension: " & id getDimension=id for jj = 1 to ubound(dimini.arrSection,2) If Not dimini.arrSection(1,jj)="[default]" Then 'wscript.echo dimini.strGetItem(dimini.arrSection(1,jj),"profileid") if dimini.strGetItem(dimini.arrSection(1,jj),"profileid")=id then 'wscript.echo "THEY MATCH" getDimension = "(hit) " & dimini.strGetItem(dimini.arrSection(1,jj),"profilename") & " (" & id & ")" end if end if next if getDimension=id then for jj = 1 to ubound(vdimini.arrSection,2) If Not vdimini.arrSection(1,jj)="[default]" Then 'wscript.echo vdimini.strGetItem(vdimini.arrSection(1,jj),"profileid") if vdimini.strGetItem(vdimini.arrSection(1,jj),"profileid")=id then 'wscript.echo "THEY MATCH: " & vdimini.strGetItem(vdimini.arrSection(1,jj),"profileid") & " is " & id getDimension = "(visit) " & vdimini.strGetItem(vdimini.arrSection(1,jj),"profilename") & " (" & id & ")" end if end if next end if 'wscript.echo "Result: " & getDimension if getDimension=id then getDimension="(OOTB) " & id end if end function function getFilter(id) 'wscript.echo id getFilter=id for jj = 1 to ubound(filtini.arrSection,2) If Not filtini.arrSection(1,jj)="[default]" Then 'wscript.echo id & vbtab & filtini.strGetItem(filtini.arrSection(1,jj),"profileid") if filtini.strGetItem(filtini.arrSection(1,jj),"profileid")=id then getFilter = "(hit) " & filtini.strGetItem(filtini.arrSection(1,jj),"profilename") end if end if next if getFilter=id then for jj = 1 to ubound(vfiltini.arrSection,2) If Not vfiltini.arrSection(1,jj)="[default]" Then 'wscript.echo id & vbtab & vfiltini.strGetItem(vfiltini.arrSection(1,jj),"profileid") if vfiltini.strGetItem(vfiltini.arrSection(1,jj),"profileid")=id then getFilter = "(visit) " & vfiltini.strGetItem(vfiltini.arrSection(1,jj),"profilename") end if end if next end if end function '******************************************************************************* '** iniFile Class ************************************************************** '******************************************************************************* '** The iniFile class opens any ini-like file and parses the contents to ** '** populate some arrays. ** '** ** '** set x = new iniFile ** '** x.LoadIni("C:\fakefile.ini") ** '******************************************************************************* class iniFile private intCurrentSection private intCurrentItem public arrSection() public arrItems() public AtEndOfSections public AtEndOfItems private sub Class_Initialize() redim arrSection(2,0) redim arrItems(0) end sub private sub Class_Terminate() end sub public sub LoadIni(strFileName) if objFso.fileexists(strFileName) Then set tsInfFile = objFso.getfile(strFileName).OpenAsTextStream(ForReading, TristateUseDefault) do until tsInfFile.AtEndOfStream strLine = trim(tsInfFile.Readline) if Not strLine = "" Then if InStr(strLine,";") > 0 Then if Not Trim(Left(strLine,inStr(strLine,";")-1)) = "" Then ProcessLine Trim(Left(strLine,inStr(strLine,";")-1)) ' Process line as non comment/whitespace end If else ProcessLine strLine ' Process line as non comment/whitespace end If end if loop end if if UBound(arrSection,2) < 1 Then AtEndOfSections = True AtEndOfItems = True else AtEndOfSections = False intCurrentSection = 1 if arrSection(2,1) = "" then AtEndOfItems = True else intCurrentItem = 0 end if end if end sub private sub ProcessLine(strLine) ' If we've hit a section definition, change current section pointer, or add it if Left(strLine,1) = "[" Then intTempIndex = GetSectionIndex(strLine) if intTempIndex = 0 Then AddNewSection(strLine) intCurrentSection = GetSectionIndex(strLine) else intCurrentSection = intTempIndex end if exit sub end if ' If we've got a standard line item AddLineToSection strLine,intCurrentSection end sub private sub AddNewSection(strSection) redim preserve arrSection(2,UBound(arrSection,2)+1) arrSection(1,UBound(arrSection,2)) = strSection end sub private function GetSectionIndex(strSection) GetSectionIndex = "0" for idxCnt = 1 to UBound(arrSection,2) if arrSection(1,idxCnt) = strSection Then GetSectionIndex = idxCnt exit function end if next end function private sub AddLineToSection(strline, intSectionIndex) if intSectionIndex = 0 then wscript.echo "##### " & strline end if ' Add Room in arrItems redim Preserve arrItems(UBound(arrItems)+1) ' Add Text to arrItem arrItems(UBound(arrItems)) = strline if arrSection(2,intSectionIndex) = "" then arrSection(2,intSectionIndex) = UBound(arrItems) else arrSection(2,intSectionIndex) = arrSection(2,intSectionIndex) & "|" & UBound(arrItems) end if end sub public function arrGetItems(strSection) dim arrResults() tmpvar = arrSection(2,GetSectionIndex(strSection)) itemarr = split(tmpvar,"|") for t = 0 to UBound(itemarr) redim preserve arrResults(t) arrResults(t) = arrItems(itemarr(t)) next arrGetItems = arrResults end function public function intNumberOfItems(strSection) tmpvar = arrSection(2,GetSectionIndex(strSection)) 'wscript.echo "**" & vbtab & tmpvar itemarr = split(tmpvar,"|") intNumberOfItems = UBound(itemarr) + 1 end function public function strGetItem(strSection,strItemName) arrTmpSectionItems = arrGetItems(strSection) 'wscript.echo strSection for each one in arrTmpSectionItems 'wscript.echo vbtab & one next for intCount = 0 to intNumberOfItems(strSection)-1 'wscript.echo arrTmpSectionItems(intCount) if trim(strUpToFirst(arrTmpSectionItems(intCount),"=")) = strItemName then arrTmpItem = split(arrTmpSectionItems(intCount),"=") strGetItem = trim(arrTmpItem(1)) exit function end if next end function end class