Jump to content

_FPTPutFile() Fails... :(


Recommended Posts

I've tried _FTPPutFile() and _FTP_UploadProgress() both in the UDF I have, works perfect for Win7 computers... But for the life of me can't get it working on XP, tried two completely separate installs... ;)

Here is the main source...

http://dl.dropbox.com/u/78219/ClosedSource/ShareQuick/forums/main.au3

FTP UDF I'm using... (I think it's Yashied's UDF, not sure...)

http://dl.dropbox.com/u/78219/ClosedSource/ShareQuick/forums/FTP_Ex.au3

James Brooks Aero Functions...

http://dl.dropbox.com/u/78219/ClosedSource/ShareQuick/forums/Aero.au3

Yes I am fully aware of how insecure this is etc... :/ I'm going to implement post functions later instead of FTP, etc... :evil:

Tested machines...

XP Pro SP3 (Fail) With the _FTPPutFile() exiting with '0' meaning no success...

Win7 x64 (Pass)

Win7 x86 (Pass)

For those of you who want to see the src here....

Main Src

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=1260210882_Camera.ico
#AutoIt3Wrapper_outfile=ShareQuickXP.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=http://www.BinaryBrother.com
#AutoIt3Wrapper_Res_Description=A free screen sharing utility
#AutoIt3Wrapper_Res_Fileversion=2.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=BinaryBrother
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include "Aero.au3"
#include <Misc.au3>
#include <Array.au3>
#include "FTP_Ex.au3"
#include <Inet.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
Dim $aArea[4]
$aArea[0] = 360
$aArea[1] = 115
$aArea[2] = @DesktopWidth / 2 - $aArea[0] / 2;192
$aArea[3] = -300;124

Global $SSButton, $SFButton, $Progress, $UID, $vSize

Opt("GUIResizeMode", 802)
$Form1 = GUICreate("ShareQuick", $aArea[0], $aArea[1], $aArea[2], $aArea[3], $WS_POPUP + $WS_THICKFRAME, $WS_EX_TOPMOST);, $WS_EX_STATICEDGE )
If _Vista_ICE() Then
    _Vista_EnableBlurBehind($Form1)
    GUICtrlSetDefBkColor(0x000000)
    GUICtrlSetDefColor(0xFFFFFF)
EndIf
;_Vista_ApplyGlassArea($Form1,$aArea)
$SRButton = GUICtrlCreateButton("Screen-Record", 192, 24, 121, 57, $WS_GROUP)
GUICtrlSetOnEvent($SRButton, "ScreenRecord")
$SSButton = GUICtrlCreateButton("Screen-Shot", 32, 24, 121, 57, $WS_GROUP)
GUICtrlSetOnEvent($SSButton, "ScreenShot")
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Hide = GUICtrlCreateLabel("{Hide}", 313, 6)
GUICtrlSetOnEvent($Hide, "Hide")

$ES = GUICtrlCreateButton("Entire Screen", 20, $aArea[1], 100, 50)
$SS = GUICtrlCreateButton("Screen Selection", 225, $aArea[1], 100, 50)
GUICtrlSetState($ES, $GUI_HIDE)
GUICtrlSetState($SS, $GUI_HIDE)
GUICtrlSetState($Progress, $GUI_HIDE)

GUICtrlSetOnEvent($SS, "ScreenSelection")
GUICtrlSetOnEvent($ES, "EntireScreen")
$Version = RegRead("HKLM\Software\ShareQuick", "Version")
If Not $Version <> "" Then
    RegDelete("HKLM\Software\ShareQuick", "UID")
EndIf

$UID = RegRead("HKLM\Software\ShareQuick", "UID")
If Not $UID <> "" Then
    $UID = GetUID()
    MsgBox(0, "Hello!", "This is the first-run of ShareQuick." & @CRLF & "Your account will now be set-up.")
    FileInstall("E:\DropBox\DropBox (BinaryBrother)\My Dropbox\Public\ClosedSource\ShareQuick\index.php", @TempDir & "\index.php", 1)
    $Pass = Upload("setup")
    If Not IsArray($Pass) Then
        MsgBox(16,"ERROR","Check internet connectivity or Firewall settings." & @CRLF & "Account creation failed." & @CRLF & "$Pass was not an array")
        Exit
    Else
        For $N = 0 To 3
            If $Pass[$N] = 0 Then
                MsgBox(16,"ERROR","Check internet connectivity or Firewall settings." & @CRLF & "Account creation failed." & @CRLF & "@ERROR = $Pass[" & $N & "]")
                RegDelete("HKLM\Software\ShareQuick", "UID")
                Exit
            EndIf
        Next
    EndIf
    TrayTip("Success!","Your account has been created, you may access your uploaded media at any time by using the tray icon!",50)
    RegWrite("HKLM\Software\ShareQuick", "Version", "REG_SZ", "2")
    RegWrite("HKLM\Software\ShareQuick", "UID", "REG_SZ", $UID)
EndIf
Reset()
Show()
SetTray()
#EndRegion ### END Koda GUI section ###

While 1
    $ID = GUIGetCursorInfo($Form1)
    While $ID[4] = $Hide
        $ID = GUIGetCursorInfo($Form1)
        If GUICtrlRead($Hide) <> "[Hide]" Then
            GUICtrlSetData($Hide, "[Hide]")
            GUICtrlSetState($Hide, @SW_SHOW)
        EndIf
    WEnd
    If GUICtrlRead($Hide) <> "{Hide}" Then
        GUICtrlSetData($Hide, "{Hide}")
        GUICtrlSetState($Hide, @SW_SHOW)
    EndIf
    Sleep(50)
WEnd

Func GetUID()
    $UID = _INetGetSource("http://www.BinaryBrother.com/ShareQuick/uid.php")
    If $UID <> "" Then
        Return $UID
    Else
        MsgBox(16,"Error","UID could not be acquired, check connectivity.")
        Exit
    EndIf
EndFunc ;==>GetUID

Func ScreenRecord()

EndFunc


Func ScreenSelection()
    Hide()
    $aRect = Mark_Rect()
    If IsArray($aRect) Then
        _ScreenCapture_Capture(@TempDir & "\ScreenShot.jpg", $aRect[1], $aRect[2], $aRect[3], $aRect[4], False)
        $int = Upload(@TempDir & "\ScreenShot.jpg")
        If $int[0] = 1 Then
            ClipPut("http://www.BinaryBrother.com/ShareQuick/" & $int[1])
            TrayTip("Complete", "Your file has been uploaded, and the URL has been copied to your clipboard!", 5)
            Hide()
        Else
            TrayTip("Error", "Please check Internet connectivity and Firewall settings!", 5, 2)
            Hide()
        EndIf
    EndIf
    ;Reset()
    ;Show()
EndFunc ;==>ScreenSelection

Func EntireScreen()
    Hide()
    _ScreenCapture_Capture(@TempDir & "\ScreenShot.jpg", 0, 0, -1, -1, False)
    $int = Upload(@TempDir & "\ScreenShot.jpg")
    If $int[0] = 1 Then
        ClipPut("http://www.BinaryBrother.com/ShareQuick/" & $int[1])
        TrayTip("Complete", "Your file has been uploaded, and the URL has been copied to your clipboard!", 5)
        Hide()
    Else
        TrayTip("Error", "Please check Internet connectivity and Firewall settings!", 5, 2)
        Hide()
    EndIf
    ;Reset()
    ;Show()
EndFunc ;==>EntireScreen

Func ScreenShot()
    SlideDown()
EndFunc ;==>ScreenShot

;Func FileSelect()
;   ;MsgBox(0, "Disabled", "This function is disabled until I secure it a bit more... :)")
;   $File = FileOpenDialog("Select File", @DesktopDir, "All (*.*)")
;   If @error Then
;       TrayTip("Action Canceled", "No file selected!", 5)
;   Else
;       $int = Upload($File)
;       If $int[0] = 1 Then
;           ClipPut("http://www.BinaryBrother.com/ShareQuick/" & $int[1])
;           TrayTip("Complete", "Your file has been uploaded, and the URL has been copied to your clipboard!", 5)
;           Hide()
;       ElseIf $int[0] = 2 Then
;           TrayTip("Error","That FileType is not allowed!",5,3)
;       Else
;           TrayTip("Error", "Please check Internet connectivity and Firewall settings!", 5, 2)
;       EndIf
;   EndIf
;EndFunc ;==>FileSelect

Func Close()
    Exit
EndFunc ;==>Close

Func SetTray()
    TraySetToolTip("ShareQuick")
    $Show = TrayCreateItem("Show ShareQuick")
    $MyCaptures = TrayCreateItem("My Captures")
    $MyRecordings = TrayCreateItem("My Recordings")
    $About = TrayCreateItem("About")
    TrayCreateItem("")
    $Exit = TrayCreateItem("Exit")
    TrayItemSetOnEvent($Show, "Show")
    TrayItemSetOnEvent($MyRecordings, "MyRecordings")
    TrayItemSetOnEvent($MyCaptures, "MyCaptures")
    TrayItemSetOnEvent($About, "About")
    TrayItemSetOnEvent($Exit, "Close")
    TraySetState()
EndFunc ;==>SetTray

Func About()
    MsgBox(0, "v2.0", "Created by: BinaryBrother")
EndFunc ;==>About

Func MyCaptures()
    ShellExecute("http://www.binarybrother.com/ShareQuick/" & $UID & "/capture/")
EndFunc ;==>MyAccount
Func MyRecordings()
    ShellExecute("http://www.binarybrother.com/ShareQuick/" & $UID & "/recording/")
EndFunc ;==>MyAccount

Func Mark_Rect()
    Local $hPM = WinGetHandle("[CLASS:Progman]")
    $vSize = WinGetClientSize($hPM)
    Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp
    Local $UserDLL = DllOpen("user32.dll")

    Global $hRectangle_GUI = GUICreate("", $vSize[0], $vSize[1], 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    _GUICreateInvRect($hRectangle_GUI, 0, 0, 1, 1)
    GUISetBkColor(0)
    WinSetTrans($hRectangle_GUI, "", 100)
    GUISetState(@SW_SHOW, $hRectangle_GUI)
    GUISetCursor(3, 1, $hRectangle_GUI)

    ; Wait until mouse button pressed
    While Not _IsPressed("01", $UserDLL)
        Sleep(10)
    WEnd

    ; Get first mouse position
    $aMouse_Pos = MouseGetPos()
    $iX1 = $aMouse_Pos[0]
    $iY1 = $aMouse_Pos[1]

    ; Draw rectangle while mouse button pressed
    While _IsPressed("01", $UserDLL)

        $aMouse_Pos = MouseGetPos()

        ; Set in correct order if required
        If $aMouse_Pos[0] < $iX1 Then
            $iX_Pos = $aMouse_Pos[0]
            $iWidth = $iX1 - $aMouse_Pos[0]
        Else
            $iX_Pos = $iX1
            $iWidth = $aMouse_Pos[0] - $iX1
        EndIf
        If $aMouse_Pos[1] < $iY1 Then
            $iY_Pos = $aMouse_Pos[1]
            $iHeight = $iY1 - $aMouse_Pos[1]
        Else
            $iY_Pos = $iY1
            $iHeight = $aMouse_Pos[1] - $iY1
        EndIf

        _GUICreateInvRect($hRectangle_GUI, $iX_Pos, $iY_Pos, $iWidth, $iHeight)

        Sleep(10)

    WEnd

    ; Get second mouse position
    $iX2 = $aMouse_Pos[0]
    $iY2 = $aMouse_Pos[1]

    ; Set in correct order if required
    If $iX2 < $iX1 Then
        $iTemp = $iX1
        $iX1 = $iX2
        $iX2 = $iTemp
    EndIf
    If $iY2 < $iY1 Then
        $iTemp = $iY1
        $iY1 = $iY2
        $iY2 = $iTemp
    EndIf

    GUIDelete($hRectangle_GUI)
    DllClose($UserDLL)
    Dim $aRect[5]
    $aRect[1] = $iX1
    $aRect[2] = $iY1
    $aRect[3] = $iX2
    $aRect[4] = $iY2
    If $iX1 = $iX2 And $iY1 = $iY2 Then
        TrayTip("Canceled", "No selection...", 25)
        Return 0
    Else
        Return $aRect
    EndIf



EndFunc ;==>Mark_Rect
Func _GUICreateInvRect($hWnd, $iX, $iY, $iW, $iH)

    $hMask_1 = _WinAPI_CreateRectRgn(0, 0, $vSize[0], $iY)
    $hMask_2 = _WinAPI_CreateRectRgn(0, 0, $iX, $vSize[1])
    $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, 0, $vSize[0], $vSize[1])
    $hMask_4 = _WinAPI_CreateRectRgn(0, $iY + $iH, $vSize[0], $vSize[1])

    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2)
    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2)
    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2)

    _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1)

EndFunc ;==>_GUICreateInvRect

Func Upload($Var)
    Dim $aNew[2]
    Dim $aRestricted[3]
    Dim $Success[4]
    Local $server = ''
    Local $FTP_User = ''
    Local $FTP_Pass = ''
    If $Var = "setup" Then
        $FTP = _FTPOpen("AutoIt v3")
        $FTPServer = _FTPConnect($FTP, $server, $FTP_User, $FTP_Pass, 1)
        $Success[0] = _FTPMakeDir($FTPServer, $UID)
        $Success[1] = _FTPMakeDir($FTPServer, $UID & "/recording/")
        $Success[2] = _FTPMakeDir($FTPServer, $UID & "/capture/")
        If @OSVersion = "WIN_XP" Then
            TrayTip("Uploading...","Working, please wait!",5)
            $Success[3] = _FTPPutFile($FTPServer, @TempDir & "\index.php", $UID & "/capture/index.php")
        Else
            ShowProgress()
            $Success[3] = _FTP_UploadProgress($FTPServer, @TempDir & "\index.php", $UID & "/capture/index.php", "_UpdateParts")
            Hide()
        EndIf
        _FTPClose($FTP)
        Return $Success
    EndIf
    If $Var = @TempDir & "\ScreenShot.jpg" Then
        $Name = $UID & "/capture/" & @MON & "-" & @MDAY & "-" & @YEAR & "---" & StringStripWS(_NowTime(), 8) & ".jpg"
        $aNew[1] = $Name
    Else
        $aFileName = StringSplit($Var, "\")
        If Not IsArray($aFileName) Then
            MsgBox(0, "ERROR", "Error in Path!" & @CRLF & "You can report this error, and help get it fixed by" & @CRLF & "sending me an email, BinaryBrother@Gmail.com" & @CRLF & "In this email, please provide the below info" & @CRLF & "INFO: " & $Var)
            $aNew[0] = 0
            Return $aNew
        EndIf
        $aExt = StringSplit($aFileName[$aFileName[0]], ".")
        $FileName = $aFileName[$aFileName[0]]
        $Extension = $aExt[$aExt[0]]
        $aRestricted[0] = "php"
        $aRestricted[1] = "php4"
        $aRestricted[2] = "php5"
        For $N = 0 To 2
            If $Extension = $aRestricted[$N] Then
                $aNew[0] = 2
                Return $aNew
            EndIf
        Next

        $Name = $UID & "/recording/" & $FileName
        $aNew[1] = $Name
    EndIf

    $FTP = _FTPOpen("AutoIt v3")
    TrayTip("ShareQuick", "Connecting to Server...", 5)
    $FTPServer = _FTPConnect($FTP, $server, $FTP_User, $FTP_Pass, 1)
    ;_FTPMakeDir($FTPServer, $UID)

    ;ProgressOn("Upload", "Uploading file [Cancel with F8]")
    If @OSVersion = "WIN_XP" Then
        TrayTip("Progress","Uploading File, please wait...",5)
        $x = _FTPPutFile($FTPServer, $Var, $Name)
    Else
        TrayTip("","",0)
        ShowProgress()
        $x = _FTP_UploadProgress($FTPServer, $Var, $Name, "_UpdateParts")
    EndIf

    $aNew[0] = $x
    _FTPClose($FTP)
    FileDelete(@TempDir & '\ScreenShot.jpg')
    Return $aNew
EndFunc ;==>Upload

Func _UpdateParts($percent)
    GUICtrlSetData($Progress, $percent)
    ;If _IsPressed("77") Then Return 0
    Return 1
EndFunc ;==>_UpdateParts

Func ShowProgress()
    Show()

    $aSize = WinGetPos($Form1)
    $Progress = GUICtrlCreateProgress(2, $aSize[3], $aSize[2] - 20, 20)
    GUICtrlSetState($Progress, $GUI_SHOW)
    For $N = $aSize[3] To $aSize[3] + 50
        WinMove($Form1, "", $aSize[0], $aSize[1], $aSize[2], $N)
        Sleep(1)
    Next
EndFunc ;==>ShowProgress

Func Hide()
    $aSize = WinGetPos($Form1)
    ;For $N = $aSize[1] To $aSize[1] - 200 Step -1
    ;   WinMove($Form1, "", $aSize[0], $N)
    ;   Sleep(1)
    ;Next
    WinMove($Form1, "", $aSize[0], -200,Default,Default,5)
    GUISetState(@SW_HIDE, $Form1)
    Reset()
EndFunc ;==>Hide

Func Show()
    GUISetState(@SW_SHOW, $Form1)
    $aSize = WinGetPos($Form1)
    ;For $N = $aSize[1] To 1 Step 1
    ;   WinMove($Form1, "", $aSize[0], $N)
    ;   Sleep(1)
    ;Next
    WinMove($Form1, "", $aSize[0], 1,Default,Default,5)
EndFunc ;==>Show

Func Reset()
    GUICtrlSetPos($SSButton, 32, 24, 121, 57)
    GUICtrlSetPos($SRButton, 192, 24, 121, 57)
    WinMove($Form1, "", $aArea[2], $aArea[3], $aArea[0], $aArea[1])
    GUICtrlSetState($ES, $GUI_HIDE)
    GUICtrlSetState($SS, $GUI_HIDE)
    ;GUICtrlSetState($Progress, $GUI_HIDE)
    GUICtrlDelete($Progress)
    GUICtrlSetState($SRButton, $GUI_ENABLE)
    GUICtrlSetState($SSButton, $GUI_ENABLE)
EndFunc ;==>Reset

Func SlideDown()
    ;GUISetState(@SW_LOCK, $Form1)

    Local $I
    $I = 192
    GUICtrlSetState($SRButton, $GUI_DISABLE)
    GUICtrlSetState($SSButton, $GUI_DISABLE)
    GUICtrlSetState($ES, $GUI_SHOW)
    GUICtrlSetState($SS, $GUI_SHOW)
    $aSize = WinGetPos($Form1)
    For $N = 32 To 112 Step 1
        GUICtrlSetPos($SRButton, $I, 24)
        GUICtrlSetPos($SSButton, $N, 24)
        WinMove($Form1, "", $aSize[0], $aSize[1], $aSize[2], $N + 80)
        ;GUICtrlSetState($SSButton, $GUI_FOCUS)
        $I -= 1
        Sleep(1)
    Next
        ;GUISetState(@SW_UNLOCK, $Form1)
    ;For $N = $aSize[3] To $aSize[3] + 80

    ;   Sleep(10)
    ;Next

EndFunc ;==>SlideDown
Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

For my scripts I have to set the flag to

Const $INTERNET_FLAG_PASSIVE = 0x08000000

like this

_FTPConnect($Open, $server, $username, $pass, 0, 1, 0x08000000)
$ftpp = _FtpPutFile($Conn, $sSource[$n], $sTarget[$n], 0x08000000)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Forgive me if I'm wrong, but I think this particular UDF defines passive when connecting?

_FTPConnect($FTP, $server, $FTP_User, $FTP_Pass, 1); 1 = passive.

I'm no wininet guru, so I'm not entirely sure... But if not, then _FTP_UploadProgress() doesn't even have a way to pass the passive flag?

I'm off to try with _FTPPutFile() ;)

Passive failed... :/

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Any help would be completely appreciated... The examples I gave above are complete reproducers, if you don't have an FTP server to test with, I will provide a test account...

This is a pretty cool app, but I can't get it to work on XP with the PutFile function at all.

Other notes...

_FTPMakeDir() seems to be working perfectly... :/

The only time FTP is called in my script is in "Func Upload($Var)"

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...