Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Auto-Updater


Rekomendowane odpowiedzi

Opublikowano
If RegRead("HKEY_CURRENT_USER\Software\NAZWA PROGRAMU", "KLUCZ") = "" Then                            ; Sprawdza czy istnieje dany klucz w rejestrze
RegWrite("HKEY_CURRENT_USER\Software\NAZWA PROGRAMU", "KLUCZ", "REG_SZ", @ScriptFullPath)            ; Jezlei nie to zapisuje go (pelna sciezkla)
EndIf

If @ScriptFullPath <> RegRead("HKEY_CURRENT_USER\Software\NAZWA PROGRAMU", "KLUCZ") Then                ; Jezeli sciezka programu rozni sie od tej w rejstrze
RegWrite("HKEY_CURRENT_USER\Software\NAZWA PROGRAMU", "KLUCZ", "REG_SZ", @ScriptFullPath)            ; to zamienia ja na tą normalna 
EndIf

#Region AutoUpdate
Global $Message = "" ; Zmienna z wiadomoscią
Global $Update = 0   ; Zmienna do której zostaną zwrócone wiadomosci z servera
Global $Version = "1.0"   ; Wersja programu
_Login("www.default_page.com", "/lol/skrypt.php", "haslo", "user") ; Funkcja która wysyła zapytanie do servera wraz z argumentami
$Split = StringSplit($Update, "|") ; Kiedy funkcja _Login Coś zwróci to usuwa bajery z wiadomosci zeby mozna było odczytac
If $Split[1] <> $Version Then ; Pierwszym argumentem jest wersja pliku, jezeli sie rózni to uruchamia autoupdater
MsgBox(0, "Updater", "Update Avilable, click 'Ok'") ; prosty msgbox ktory informuje o update
$sFilePathURL = $Split[2] ; Zmienna z linkiem = $Splitowi
_Update() ; Funkcja update
EndIf
$Message = $Split[3] ; Split3 = wiadomosc na serverze, pozniej mozna zrobic gdzies tabelke i cos przekazac uzytkownikom
#EndRegion AutoUpdate

 

 

Funkcja Update :

Func _Update()
    Local $hGUI, $iButton, $iLabel, $iProgressBar, $sFilePath

    $hGUI = GUICreate("MPCForum Tool | Updater", 370, 90, -1, -1, $DS_MODALFRAME, -1, WinGetHandle(AutoItWinGetTitle()))
    $iLabel = GUICtrlCreateLabel("", 5, 5, 270, 40)
    $iButton = GUICtrlCreateButton("Download", 270, 2.5, 90, 25)
    $iProgressBar = GUICtrlCreateProgress(5, 60, 360, 20)
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit

            Case $iButton
				GuiCtrlSetData($iLabel, "Downloading :")
                $sFilePath = _InetGetGUI($sFilePathURL, $iLabel, $iProgressBar, $iButton, @ScriptDir)
                If @error Then
                    Switch @extended ; Check what the actual error was by using the @extended command.
                        Case 0
                            MsgBox(64, "Error", "Check the URL or your Internet Connection!")

                        Case 1
                            MsgBox(64, "Fail", "Seems the download was canecelled, but the file was >> " & $sFilePath)

                    EndSwitch
                Else
                    MsgBox(64, "Success", "Downloaded >> " & $sFilePath & @CRLF & "Click 'OK' to run updated program !")
					Run(@ScriptDir & "\" & $sFilePath)
					Exit
                EndIf

        EndSwitch
    WEnd
EndFunc   ;==>_Update

 

Funckcja WINHTTTP :

Func _Login($site, $file, $l, $p)
	
	$Open = _WinHttpOpen() 																					 ; otwieranie sesji
	$Connect = _WinHttpConnect($Open, $site)																 ; łaczenie z serverem
	$Send = _WinHttpSimpleSendRequest($Connect, "POST", $file, Default, "user=" & $l & "&" & "pass=" & $p)   ; wysyłanie zapytrania, tryb post, user i pass
	If $Send = 0 Then 
	MsgBox(262160,"Error","Can't connect to update server !" & @CRLF & "Contact with Keniger !" & @CRLF & "www.mpcforum.pl",0)
	Exit
	EndIf

	If $Send Then
		$a = _WinHttpSimpleReadData($Send) 																	 ; czytanie zwróconych wartości
		
		_WinHttpCloseHandle($Open) 																			 ; zamykanie
		_WinHttpCloseHandle($Connect)																		 ; zamykanie
		
		$Update = $a
		Return
	EndIf
EndFunc

 

 

Tutaj UDF do okienka UPDATE :

 

 

; _InetGetGUI: Download a file updating a GUICtrlCreateProgress.
; ===============================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _InetGetGUI()
; Description ...: Download a file updating a GUICtrlCreateProgress().
; Syntax.........: _InetGetGUI($sURL, $iLabel, $iProgress, $iButton, [$sDirectory = @ScriptDir])
;                 $sURL - A valid URL that contains the filename too.
;                 $iLabel - ControlID of a GUICtrlCreateLabel.
;                 $iProgress - ControlID of a GUICtrlCreateProgress.
;                 $iButton - ControlID of a GUICtrlCreateButton.
;                 $sDirectory - [Optional] Directory of where to download to. Default = @ScriptDir
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
;                  Failure - Returns downloaded filename & sets @error = 1 (@extended = 0 if internal error or @extended = 1 if cancelled was selected.)
; Author ........: Keniger, Thanks to Guiness & M3
; Example........; Yes
;=====================================================================================================================
Func _InetGetGUI($sURL, $iLabel, $iProgress, $iButton, $sDirectory = @ScriptDir)
    Local $hDownload, $iBytesRead = 0, $iError = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sFilePath, $sProgressText, $sRead = GUICtrlRead($iButton), $sSpeed
    $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf

    $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & "\" & $sFilePath
    $iFileSize = InetGetSize($sURL, 1)
    $hDownload = InetGet($sURL, $sDirectory, 0, 1)
    If @error Then
        Return SetError(1, $iError, $sFilePath)
    EndIf
    GUICtrlSetData($iButton, "&Cancel")

    $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
    $iTimer = TimerInit()
    While InetGetInfo($hDownload, 2) = 0
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iButton
                GUICtrlSetData($iLabel, "Download Cancelled!")
                $iError = 1
                ExitLoop
        EndSwitch

        $iBytesRead = InetGetInfo($hDownload, 0)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = "Downloading " & _ByteSuffix($iBytesRead, 0) & " Of " & _ByteSuffix($iFileSize, 0) & @LF & $sSpeed
        GUICtrlSetData($iLabel, $sProgressText)
        GUICtrlSetData($iProgress, $iPercentage)

        If TimerDiff($iTimer) > 1000 Then
            $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
            $iSpeed = $iBytesRead
            $iTimer = TimerInit()
        EndIf
        Sleep(100)
    WEnd
    InetClose($hDownload)
    GUICtrlSetData($iButton, $sRead)
    Return SetError($iError, $iError, $sFilePath)
EndFunc   ;==>_InetGetGUI

;=============================================================================================================
Func _ByteSuffix($iBytes, $iRound = 2)
    Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
    While $iBytes > 1023
        $A += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$A]
EndFunc   ;==>_ByteSuffix
;==============================================================================================================

 

 

 

Skrypt php :

<?php
    If( !isSet( $_POST ) ) exit( "Brak danych" );
    If( !isSet( $_POST[ 'user' ] ) or !isSet( $_POST[ 'pass' ] ) ) exit( "Formularz niewła¶ciwie wypełniony" );
    
    If( $_POST[ 'user' ] != "USER" or $_POST[ 'pass' ] != "PASSr" ) exit( "Brak autoryzacji" );
    
    If ( $_POST[ ' user' ] = "USER" AND $_POST[ 'pass' ] = "PASS" ) exit( "1.0|0|WIADOMOSC TESTOWA" );
?>

 

Jak to uzywać ? Pierwsze dajemy do kodu, pozniej gdzies dwie funkcje, modyfikujemy na nasze. Nastepnie zmieniamy w skrypcie php wersje pliku (1.1|LINK_JAK_ZMIENIONA_WERSJA|wiadomosc)

Do tego skryptu musisz załączyć coś co usunie ten program 1.0, wiec po to były wpisy w rejestrze teraz wystarczy napisac program :

FileDelete(RegRead("HKEY_CURRENT_USER\Software\PROGRAM", "KLUCZ"))

FileInstall(Twoja_sciezka, sciezka do pliku na kogos kompie)

Albo po prostu 7-zipem

 

Fell free to edit. Wszystko wykonane przeze mnie, tutaj przykład programu z wykorzystaniem tego :

http://www.mpcforum.pl/topic/958849-tutdl-mpc-forum-tool-by-keniger-v10-battlefield-play4free-new-click/#entry7627247

OndteAw.png
Opublikowano

Fell free to edit. Wszystko wykonane przeze mnie, tutaj przykład programu z wykorzystaniem tego :

http://www.mpcforum.pl/topic/921530-return-value/

 

Update nie powinien wykonywać się po zalogowaniu. Często aktualizuje się program w wypadku zmiany strony.

Skrypt php jest banalny i zdecydowanie do tego nada się MySQL (można stworzyć swoją własną bazę, powiedzmy każda linijka to info: login, pass, ip, date, last login i ją aktualizować, lecz to jest niepraktyczne w przypadku znajomości mysql, czy większych list użytkowników)

 

$Split = StringSplit($Update, "|")

Wywali błąd, gdy się nie zalogujesz, korzystasz potem z drugiego indexu, który w tamtym przypadku nie istnieje.

WSZYSTKIE PLIKI W CHMURZE DLA MPCFORUM ZOSTAŁY USUNIĘTE. NIE KORZYSTAĆ Z MOICH PROGRAMÓW.

Proszę nie ingerować w moje posty/tematy, w razie potrzeby usunąć całą zawartość. Nie pomagam.

Opublikowano

No wywali :P

Ale przed odpaleniem programu jeszcze jest sprawdzanie czy net jest :P I w pętli to samo jezeli nie ma to program się automatycznie wyłacza.

OndteAw.png

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...