Last active
July 13, 2021 07:04
-
-
Save ar7eniyan/4aed2891ca614e69c5486a930c0b0a96 to your computer and use it in GitHub Desktop.
Здесь будет более новый код т. к. я пока не могу редактировать сообщения на 4PDA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoTrayIcon | |
#include <GUIConstantsEx.au3> | |
#include <File.au3> | |
#include <FileConstants.au3> | |
#include <StringConstants.au3> | |
#include <SQLite.au3> | |
#include <SQLite.dll.au3> | |
Opt('MustDeclareVars', True) | |
Local $patchesCount, $patchName | |
Local $phoneNumber = '' | |
Local $guiHeight | |
Local $patches[255], $patchCheckboxes[255] | |
Local $fHandle, $dbHandle | |
Local $fileLines[1023], $files | |
Local $encodingFixed | |
Local $dbPath | |
Local $wHandle, $applyPatch, $deletePatches, $statusLabel | |
Local $checkedOne | |
Local $sqliteError | |
$wHandle = GUICreate('ViberPatcher', 256, 390) | |
$files = _FileListToArray(@AppDataDir & '\ViberPC', '*', $FLTA_FOLDERS) | |
If UBound($files) <> 0 Then | |
For $filePath In _ArrayExtract($files, 1) | |
If StringRegExp($filePath, '^\d{11,13}$') Then | |
$phoneNumber = $filePath | |
ExitLoop | |
EndIf | |
Next | |
If $phoneNumber = '' Then | |
MsgBox($MB_OK + $MB_ICONWARNING, 'Error', 'Viber database not found') | |
Exit | |
EndIf | |
$dbPath = @AppDataDir & '\ViberPC\' & $phoneNumber & '\viber.db' | |
ElseIf FileExists(@ScriptDir & '\viber.db') Then | |
$dbPath = @ScriptDir & '\viber.db' | |
Else | |
MsgBox($MB_OK + $MB_ICONWARNING, 'Error', 'Viber database not found') | |
Exit | |
EndIf | |
$files = _ArrayExtract(_FileListToArray('.\', '*.viberpatch', $FLTA_FILES), 1) | |
For $i = 0 to UBound($files) - 1 | |
$fHandle = FileOpen($files[$i], $FO_ANSI) | |
$fileLines = FileReadToArray($fHandle) | |
FileClose($fHandle) | |
For $line In $fileLines | |
$patches[$i] &= BinaryToString(StringToBinary($line), $SB_UTF8) & @CRLF | |
Next | |
$encodingFixed = BinaryToString(StringToBinary($fileLines[0]), $SB_UTF8) | |
$patchCheckboxes[$i] = GUICtrlCreateCheckbox(StringTrimLeft($encodingFixed, 2), 20, $guiHeight + 20) | |
$guiHeight += 18 | |
$patchesCount += 1 | |
Next | |
GUICtrlCreateGroup('Выберите патчи для БД', 12, 6, 232, $guiHeight + 24) | |
$guiHeight += 24 | |
$applyPatch = GUICtrlCreateButton('Пропатчить базу', 12, $guiHeight + 8, 232) | |
$deletePatches = GUICtrlCreateButton('Удалить все патчи', 12, $guiHeight + 36, 232) | |
If $phoneNumber = '' Then | |
$statusLabel = GUICtrlCreateLabel('Выбрана viber.db в текущей папке', 12, $guiHeight + 30 + 36, 200) | |
Else | |
$statusLabel = GUICtrlCreateLabel('Выбран номер +' & $phoneNumber, 12, $guiHeight + 30 + 36, 200) | |
EndIf | |
$guiHeight += 60 | |
WinMove($wHandle, Null, 0, 0, 256, $guiHeight + 54) | |
_SQLite_Startup() | |
$dbHandle = _SQLite_Open($dbPath) | |
GUISetState(@SW_SHOW) | |
While 1 | |
Switch GUIGetMsg() | |
Case $GUI_EVENT_CLOSE | |
_SQLite_Close($dbHandle) | |
ExitLoop | |
Case $applyPatch | |
$checkedOne = False | |
$sqliteError = False | |
For $i = 0 To $patchesCount - 1 | |
If GUICtrlRead($patchCheckboxes[$i]) = $GUI_CHECKED Then | |
$checkedOne = True | |
_SQLite_Exec($dbHandle, $patches[$i]) | |
If _SQLite_ErrCode($dbHandle) = 1 Then | |
$sqliteError = True | |
EndIf | |
EndIf | |
Next | |
If Not $checkedOne Then | |
GUICtrlSetData($statusLabel, 'Вы не выбрали ни одного патча') | |
ElseIf $sqliteError Then | |
GUICtrlSetData($statusLabel, 'Ошибка при применении патчей') | |
Else | |
GUICtrlSetData($statusLabel, 'Все патчи успешно применены') | |
EndIf | |
Case $deletePatches | |
$fHandle = FileOpen('.\remove_all') | |
_SQLite_Exec($dbHandle, FileRead($fHandle)) | |
If _SQLite_ErrCode($dbHandle) = 0 Then | |
GUICtrlSetData($statusLabel, 'Все патчи успешно удалены') | |
Else | |
GUICtrlSetData($statusLabel, 'Ошибка при удалении патчей') | |
EndIf | |
FileClose($fHandle) | |
EndSwitch | |
WEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment