SpiffyTek
/
SMACheck
Archived
1
0
Fork 0
This repository has been archived on 2022-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
SMACheck/main.au3

230 lines
9.1 KiB
AutoIt
Raw Permalink Blame History

; Copyright (c) 2012-2015 SpiffyTek (http://spiffytek.de).
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * Neither the name SpiffyTek nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include-once
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Clipboard.au3>
#include "includes/ext/resources.au3"
#include "includes/ext/_XMLDomWrapper.au3"
Global $gVersionChecked = 0, $iniDisableMinVer = 0, $iniResolveTimeout = 1500, $iniConnectTimeout = 1500, $iniSendTimeout = 3000, $iniReceiveTimeout = 10000
Global $iniApiUrl = "http://api.spiffytek.com/pub/smacheck/steamid/"
;; Check for & read config
Global $ini
If FileExists(@ScriptDir & "\smacheck.ini") Then
$ini = IniReadSection(@ScriptDir & "\smacheck.ini", "options")
If IsArray($ini) Then
For $i = 1 to $ini[0][0]
If $ini[$i][0] = "disableUpdate" Then
$gVersionChecked = $ini[$i][1]
EndIf
If $ini[$i][0] = "disableMinVer" Then
$iniDisableMinVer = $ini[$i][1]
EndIf
If $ini[$i][0] = "resolveTimeout" Then
$iniResolveTimeout = $ini[$i][1]
EndIf
If $ini[$i][0] = "connectTimeout" Then
$iniConnectTimeout = $ini[$i][1]
EndIf
If $ini[$i][0] = "sendTimeout" Then
$iniSendTimeout = $ini[$i][1]
EndIf
If $ini[$i][0] = "receiveTimeout" Then
$iniReceiveTimeout = $ini[$i][1]
EndIf
If $ini[$i][0] = "apiUrl" Then
$iniApiUrl = $ini[$i][1]
EndIf
Next
EndIf
EndIf
#include "includes/functions.inc.au3"
Global $oErrorHandler = ObjEvent("AutoIt.Error", "_printError");
;; Main
_main()
Func _main()
Global $GuiWidth = 370, $GuiHeight = 177
Local $GuiPosX = (@DesktopWidth - $GuiWidth) / 2, $GuiPosY = (@DesktopHeight - $GuiHeight) / 2
Global $GUi = GUICreate("SMACheck - smacbans.com", $GuiWidth, $GuiHeight, $GuiPosX, $GuiPosY)
$GUiBG = GUICtrlCreatePic("", 0, 0, $GuiWidth, $GuiHeight)
_ResourceSetImageToCtrl(-1, "img_bg", $RT_RCDATA)
GUICtrlSetState(-1, $GUI_DISABLE)
$gInput = GUICtrlCreateLabel("SteamID:", 0, 50, 368, 17, $SS_CENTER)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gSteamId = GUICtrlCreateInput("", 112, 70, 145, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gButton_GetClipb = GUICtrlCreateButton("", 260, 68, 24, 24)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
_ResourceSetImageToCtrl(-1, "paste.png", $RT_RCDATA)
$gButton_Submit = GUICtrlCreateButton("Check", 144, 104, 83, 25, $BS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GuiCtrlSetState(-1, 512)
$gCopyright = GUICtrlCreateLabel("<EFBFBD>2012-2014 SpiffyTek && smacBANS", 0, 159, 368, 17, $SS_RIGHT)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gVersion = GUICtrlCreateLabel("v" & $VERSION, 2, 159, 369, 17, $SS_LEFT)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $gButton_GetClipb
_ClipBoard_Open($GUi)
$hMemory = _ClipBoard_GetDataEx($CF_TEXT)
_ClipBoard_Close()
$tData = DllStructCreate("char Text[8192]", $hMemory)
GUICtrlSetData($gSteamId, DllStructGetData($tData, "Text"))
Case $gButton_Submit
$iSteamId = StringStripWS(GUICtrlRead($gSteamId), 8)
If StringLeft($iSteamId, 6) = 765611 Then
$iSteamId = steamId64ToSteamId($iSteamId)
EndIf
If StringLeft($iSteamId, 6) = "STEAM_" Then
GUISetState(@SW_DISABLE, $GUi)
gui_Info($iSteamId)
GUISetState(@SW_ENABLE, $GUi)
WinActivate($GUi)
GUISwitch($GUi)
Else
GUISetState(@SW_DISABLE, $GUi)
_printError("wrongid")
GUISetState(@SW_ENABLE, $GUi)
WinActivate($GUi)
GUISwitch($GUi)
EndIf
resetInput($gSteamId)
EndSwitch
WEnd
GUIDelete()
EndFunc
Func gui_Info($output)
Local $pInfo = lookupSteamId($output)
If IsArray($pInfo) Then
Global $GUi
Local $overlayWidth = 312, $overlayHeight = 154, $pos = WinGetPos($GUi)
$GUI2 = GUICreate("INFO (" & $output & ")", $overlayWidth, $overlayHeight, $pos[0] + 20, $pos[1] + 20, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
$GUiBG2 = GUICtrlCreatePic("", 0, 0, $overlayWidth, $overlayHeight)
_ResourceSetImageToCtrl(-1, "img_bg_popup", $RT_RCDATA)
GUICtrlSetState(-1, $GUI_DISABLE)
$bClose = GUICtrlCreateButton("OK", 120, 125, 65, 25, $BS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GuiCtrlSetState(-1, 512)
$gStatus = GUICtrlCreateLabel("Status:", 24, 12, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
If $pInfo[0] = "1" Then
$oStatus = GUICtrlCreateLabel("SteamID is listed on SMACbans", 72, 12, 215, 17)
GUICtrlSetFont(-1, 8.5, 800)
GUICtrlSetColor(-1, 0xD11313)
ElseIf $pInfo[0] = 0 Then
$oStatus = GUICtrlCreateLabel("SteamID is not listed on SMACbans", 72, 12, 215, 17)
GUICtrlSetFont(-1, 8.5, 800)
GUICtrlSetColor(-1, 0x245E00)
ElseIf $pInfo[0] = -1 Then
$oStatus = GUICtrlCreateLabel("Could not fetch info from SMACbans", 72, 12, 215, 17)
GUICtrlSetFont(-1, 8.5, 800)
GUICtrlSetColor(-1, 0xFF8000)
EndIf
GUICtrlSetBkColor($oStatus, $GUI_BKCOLOR_TRANSPARENT)
$gNick = GUICtrlCreateLabel("Nick:", 24, 36, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oCc = GUICtrlCreatePic("", 72, 36, 50, 17)
_ResourceSetImageToCtrl($oCc, $pInfo[7] & ".png", $RT_RCDATA)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetTip($oCc, StringUpper($pInfo[7]))
$oNick = GUICtrlCreateLabel($pInfo[1], 93, 36, 215, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gReason = GUICtrlCreateLabel("Reason:", 24, 60, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oReason = GUICtrlCreateLabel($pInfo[2], 72, 60, 215, 40)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gDate = GUICtrlCreateLabel("Date:", 24, 84, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oDate = GUICtrlCreateLabel($pInfo[3], 72, 84, 215, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gMod = GUICtrlCreateLabel("Mod:", 120, 84, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oMod = GUICtrlCreateLabel($pInfo[6], 150, 84, 215, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gVac = GUICtrlCreateLabel("VAC:", 50, 105, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oVac = GUICtrlCreatePic("", 80, 104, 16, 16)
_setStatusIcon(-1, $pInfo[5])
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gEsea = GUICtrlCreateLabel("ESEA:", 100, 105, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oEsea = GUICtrlCreatePic("", 140, 104, 16, 16)
_setStatusIcon(-1, $pInfo[9])
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$gKac = GUICtrlCreateLabel("KAC:", 160, 105, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$oKac = GUICtrlCreatePic("", 190, 104, 16, 16)
_setStatusIcon(-1, $pInfo[10])
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()
While 1
; We can only get messages from the second GUI
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIDelete($GUI2)
ExitLoop
Case $bClose
GUIDelete($GUI2)
ExitLoop
EndSwitch
WEnd
EndIf
EndFunc