Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region include
- #include <ButtonConstants.au3>
- #include <ComboConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <EditConstants.au3>
- #include <WindowsConstants.au3>
- #include <array.au3>
- #include <String.au3>
- #endregion include
- Opt("GUIOnEventMode", 1)
- Opt("GUIResizeMode", 544)
- ;Orginal by i2c @www.autoit.de | Login & New API support by Sprenger120
- #region
- Global $oReceived, $cLoginPasswort, $toggle = 0
- Global $settings = @ScriptDir & "\settings.ini"
- Global $aSyntax[139][2] = [["abap", "ABAP"], _
- ["actionscript", "ActionScript"], _
- ["actionscript3", "ActionScript 3"], _
- ["ada", "Ada"], _
- ["apache", "ApacheLog"], _
- ["applescript", "AppleScript"], _
- ["apt_sources", "APT Sources"], _
- ["asm", "ASM"], _
- ["asp", "ASP"], _
- ["autoit", "AutoIt"], _
- ["avisynth", "Avisynth"], _
- ["bash", "Bash"], _
- ["basic4gl", "Basic4GL"], _
- ["bibtex", "BibTeX"], _
- ["blitzbasic", "Blitz Basic"], _
- ["bnf", "BNF"], _
- ["boo", "BOO"], _
- ["bf", "BrainFuck"], _
- ["c", "C"], _
- ["c_mac", "C for Macs"], _
- ["cill", "C Intermediate Language"], _
- ["csharp", "C#"], _
- ["cpp", "C++"], _
- ["caddcl", "CAD DCL"], _
- ["cadlisp", "CAD Lisp"], _
- ["cfdg", "CFDG"], _
- ["klonec", "Clone C"], _
- ["klonecpp", "Clone C++"], _
- ["cmake", "CMake"], _
- ["cobol", "COBOL"], _
- ["cfm", "ColdFusion"], _
- ["css", "CSS"], _
- ["d", "D"], _
- ["dcs", "DCS"], _
- ["delphi", "Delphi"], _
- ["dff", "Diff"], _
- ["div", "DIV"], _
- ["dos", "DOS"], _
- ["dot", "DOT"], _
- ["eiffel", "Eiffel"], _
- ["email", "Email"], _
- ["erlang", "Erlang"], _
- ["fo", "FO Language"], _
- ["fortran", "Fortran"], _
- ["freebasic", "FreeBasic"], _
- ["gml", "Game Maker"], _
- ["genero", "Genero"], _
- ["gettext", "GetText"], _
- ["groovy", "Groovy"], _
- ["haskell", "Haskell"], _
- ["hq9plus", "HQ9 Plus"], _
- ["html4strict", "HTML"], _
- ["idl", "IDL"], _
- ["ini", "INI file"], _
- ["inno", "Inno Script"], _
- ["intercal", "INTERCAL"], _
- ["io", "IO"], _
- ["java", "Java"], _
- ["java5", "Java 5"], _
- ["javascript", "JavaScript"], _
- ["kixtart", "KiXtart"], _
- ["latex", "Latex"], _
- ["lsl2", "Linden Scripting"], _
- ["lisp", "Lisp"], _
- ["locobasic", "Loco Basic"], _
- ["lolcode", "LOL Code"], _
- ["lotusformulas", "Lotus Formulas"], _
- ["lotusscript", "Lotus Script"], _
- ["lscript", "LScript"], _
- ["lua", "Lua"], _
- ["m68k", "M68000 Assembler"], _
- ["make", "Make"], _
- ["matlab", "MatLab"], _
- ["mirc", "mIRC"], _
- ["modula3", "Modula 3"], _
- ["mpasm", "MPASM"], _
- ["mxml", "MXML"], _
- ["mysql", "MySQL"], _
- ["text", "None"], _
- ["nsis", "NullSoft Installer"], _
- ["oberon2", "Oberon 2"], _
- ["objc", "Objective C"], _
- ["ocaml-brief", "OCalm Brief"], _
- ["ocaml", "OCaml"], _
- ["glsl", "OpenGL Shading"], _
- ["oobas", "Openoffice BASIC"], _
- ["oracle11", "Oracle 11"], _
- ["oracle8", "Oracle 8"], _
- ["pascal", "Pascal"], _
- ["pawn", "PAWN"], _
- ["per", "Per"], _
- ["perl", "Perl"], _
- ["php", "PHP"], _
- ["php-brief", "PHP Brief"], _
- ["pic16", "Pic 16"], _
- ["pixelbender", "Pixel Bender"], _
- ["plsql", "PL/SQL"], _
- ["povray", "POV-Ray"], _
- ["powershell", "Power Shell"], _
- ["progress", "Progress"], _
- ["prolog", "Prolog"], _
- ["properties", "Properties"], _
- ["providex", "ProvideX"], _
- ["python", "Python"], _
- ["qbasic", "QBasic"], _
- ["rails", "Rails"], _
- ["rebol", "REBOL"], _
- ["reg", "REG"], _
- ["robots", "Robots"], _
- ["ruby", "Ruby"], _
- ["gnuplot", "Ruby Gnuplot"], _
- ["sas", "SAS"], _
- ["scala", "Scala"], _
- ["scheme", "Scheme"], _
- ["scilab", "Scilab"], _
- ["sdlbasic", "SdlBasic"], _
- ["smalltalk", "Smalltalk"], _
- ["smarty", "Smarty"], _
- ["sql", "SQL"], _
- ["tsql", "T-SQL"], _
- ["tcl", "TCL"], _
- ["teraterm", "Tera Term"], _
- ["thinbasic", "thinBasic"], _
- ["typoscript", "TypoScript"], _
- ["unreal", "unrealScript"], _
- ["vbnet", "VB.NET"], _
- ["verilog", "VeriLog"], _
- ["vhdl", "VHDL"], _
- ["vim", "VIM"], _
- ["visualprolog", "Visual Pro Log"], _
- ["vb", "VisualBasic"], _
- ["visualfoxpro", "VisualFoxPro"], _
- ["whitespace", "WhiteSpace"], _
- ["8whois", "WHOIS"], _
- ["winbatch", "Win Batch"], _
- ["xml", "XML"], _
- ["xorg_conf", "Xorg Config"], _
- ["xpp", "XPP"], _
- ["z80", "Z80 Assembler"]]
- Global $aExposure[2][2] = [["0", "public"], _
- ["1", "private"]]
- Global $aExpiration[5][2] = [["N", "Never"], _
- ["10M", "10 Minutes"], _
- ["1H", "1 Hour"], _
- ["1D", "1 Day"], _
- ["1M", "1 Month"]]
- #endregion
- #region write/read .ini
- If Not FileExists($settings) Then
- IniWrite($settings, "main", "syntax", "autoit")
- IniWrite($settings, "main", "expiration", "N")
- IniWrite($settings, "main", "exposure", "0")
- IniWrite($settings, "main", "Username", "")
- IniWrite($settings, "main", "Password", "")
- IniWrite($settings, "main", "PostAsGuest", "1")
- IniWrite($settings, "main", "SavePassword", "4")
- EndIf
- $syntax = _FindInArray($aSyntax, IniRead($settings, "main", "syntax", "autoit"), 1)
- $expiration = _FindInArray($aExpiration, IniRead($settings, "main", "expiration", "N"), 1)
- $exposure = _FindInArray($aExposure, IniRead($settings, "main", "exposure", "0"), 1)
- $DevKey = IniRead($settings, "main", "DevKey", "")
- $Username = IniRead($settings, "main", "Username", "")
- $Passwort = IniRead($settings, "main", "Password", "")
- If $Passwort <> "" Then $Passwort = _StringEncrypt(0, $Passwort, "sdfSFDSsr24234")
- If $Passwort = "0" Then $Passwort = ""
- $SavePassword = IniRead($settings, "main", "SavePassword", "4")
- $PostAsGuest = IniRead($settings, "main", "PostAsGuest", "1")
- #endregion write/read .ini
- #region gui
- $gui = GUICreate("Send To Pastebin", 613, 145, -1, -1)
- GUICtrlCreateGroup("Send", 8, 8, 161, 130)
- GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
- $rFile = GUICtrlCreateRadio("complete file", 24, 32, 113, 17)
- $rSelected = GUICtrlCreateRadio("selected code", 24, 56, 113, 17)
- $bSend = GUICtrlCreateButton("send", 50, 92, 75, 25, $WS_GROUP)
- GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- GUICtrlCreateGroup("Settings", 176, 8, 262, 130)
- GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
- GUICtrlCreateLabel("Syntax highlighting:", 184, 36, 95, 17)
- GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
- $cSyntax = GUICtrlCreateCombo($syntax, 288, 32, 145, 25)
- GUICtrlCreateLabel("Post expiration:", 184, 60, 76, 17)
- GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
- $cExpiration = GUICtrlCreateCombo($expiration, 288, 56, 145, 25)
- GUICtrlCreateLabel("Post exposure:", 184, 84, 88, 17)
- GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
- $cExposure = GUICtrlCreateCombo($exposure, 288, 80, 145, 25)
- GUICtrlCreateLabel("Name / Title: ", 184, 110, 83, 17)
- GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
- $iName = GUICtrlCreateInput("", 288, 104, 145, 25)
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- ;Login
- GUICtrlCreateGroup("Login", 445, 8, 161, 130)
- GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
- GUICtrlCreateLabel("Name:", 455, 38, 70, 17)
- GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
- GUICtrlCreateLabel("Passwort: ", 455, 66, 83, 17)
- GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
- $cLoginName = GUICtrlCreateInput($Username, 510, 32, 83, 25)
- $cLoginPasswort = GUICtrlCreateInput($Passwort, 510, 60, 83, 25, BitOR($ES_PASSWORD, $GUI_SS_DEFAULT_INPUT))
- $cGuest = GUICtrlCreateCheckbox("als Gast posten", 455, 88, 100, 20)
- GUICtrlSetState(-1, $PostAsGuest)
- $cSavePassword = GUICtrlCreateCheckbox("Password speichern", 455, 106, 120, 20)
- GUICtrlSetState(-1, $SavePassword)
- If BitAND($PostAsGuest, $Gui_CHECKED) Then
- GUICtrlSetState($cLoginName, $GUI_DISABLE)
- GUICtrlSetState($cLoginPasswort, $GUI_DISABLE)
- GUICtrlSetState($cSavePassword, $GUI_DISABLE)
- EndIf
- GUISetState(@SW_SHOW)
- #endregion gui
- #region events
- GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
- GUICtrlSetOnEvent($bSend, "_send")
- GUICtrlSetOnEvent($cGuest, "_Checkbox")
- #endregion events
- #region set data
- If $cmdline[0] < 1 Then
- MsgBox(64, "Error", "missing parameter")
- Exit
- EndIf
- If $cmdline[2] <> "" Then
- GUICtrlSetState($rSelected, $Gui_CHECKED)
- Else
- GUICtrlSetState($rFile, $Gui_CHECKED)
- GUICtrlSetState($rSelected, $GUI_DISABLE)
- EndIf
- For $i = 0 To UBound($aSyntax) - 1
- GUICtrlSetData($cSyntax, $aSyntax[$i][1])
- Next
- For $i = 0 To UBound($aExpiration) - 1
- GUICtrlSetData($cExpiration, $aExpiration[$i][1])
- Next
- For $i = 0 To UBound($aExposure) - 1
- GUICtrlSetData($cExposure, $aExposure[$i][1])
- Next
- #endregion set data
- While 1
- Sleep(100)
- WEnd
- Func _Checkbox()
- Switch BitAND(GUICtrlRead($cGuest), $Gui_CHECKED)
- Case True
- GUICtrlSetState($cLoginName, $GUI_DISABLE)
- GUICtrlSetState($cLoginPasswort, $GUI_DISABLE)
- GUICtrlSetState($cSavePassword, $GUI_DISABLE)
- Case False
- GUICtrlSetState($cLoginName, $GUI_ENABLE)
- GUICtrlSetState($cLoginPasswort, $GUI_ENABLE)
- GUICtrlSetState($cSavePassword, $GUI_ENABLE)
- EndSwitch
- EndFunc ;==>_Checkbox
- Func _FindInArray($array, $value, $switch)
- $index = _ArraySearch($array, $value)
- If $index = -1 Then Return -1
- If $switch = 0 Then
- $result = $array[$index][0]
- ElseIf $switch = 1 Then
- $result = $array[$index][1]
- Else
- SetError(1, 0, False)
- EndIf
- Return $result
- EndFunc ;==>_FindInArray
- Func _URIEncode($sData)
- ; Prog@ndy
- Local $aData = StringSplit(BinaryToString(StringToBinary($sData, 4), 1), "")
- Local $nChar
- $sData = ""
- For $i = 1 To $aData[0]
- $nChar = Asc($aData[$i])
- Switch $nChar
- Case 45, 46, 48 - 57, 65 To 90, 95, 97 To 122, 126
- $sData &= $aData[$i]
- Case 32
- $sData &= "+"
- Case Else
- $sData &= "%" & Hex($nChar, 2)
- EndSwitch
- Next
- Return $sData
- EndFunc ;==>_URIEncode
- Func _send()
- Local $bPostAsGuest, $LoginKey
- Local Static $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
- GUISetState(@SW_DISABLE, $gui)
- If BitAND(GUICtrlRead($rFile), $Gui_CHECKED) = $Gui_CHECKED Then
- $open = FileOpen($cmdline[1], 0)
- $paste_code = _URIEncode(FileRead($open))
- FileClose($open)
- ElseIf BitAND(GUICtrlRead($rSelected), $Gui_CHECKED) = $Gui_CHECKED Then
- $paste_code = _URIEncode($cmdline[2])
- EndIf
- $paste_name = GUICtrlRead($iName)
- $paste_private = _FindInArray($aExposure, GUICtrlRead($cExposure), 0)
- $paste_expire_date = _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0)
- $paste_format = _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0)
- $paste_devkey = "52b07d8a33022af5c03f899c734818c8"
- $Username = GUICtrlRead($cLoginName)
- $Passwort = GUICtrlRead($cLoginPasswort)
- $bPostAsGuest = GUICtrlRead($cGuest)
- If BitAND($bPostAsGuest, $Gui_CHECKED) Then
- $bPostAsGuest = True
- Else
- $bPostAsGuest = False
- EndIf
- ;Login
- If Not $bPostAsGuest Then
- $oHTTP.Open("POST", "http://pastebin.com/api/api_login.php", False)
- $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
- $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
- $oHTTP.Send("api_dev_key=" & $paste_devkey & "&api_user_name=" & $Username & "&api_user_password=" & $Passwort)
- $oReceived = $oHTTP.ResponseText
- If Not StringRegExp($oReceived, "^[\d\w]+$") Then
- MsgBox(48, "SciTe Send to Pastebin", "Fehler beim Login. Quellcode wird als Gast gepostet." & @CRLF & $oReceived)
- $LoginKey = ""
- Else
- $LoginKey = "&api_user_key=" & $oReceived
- EndIf
- Else
- $LoginKey = ""
- EndIf
- $oHTTP.Open("POST", "http://pastebin.com/api/api_post.php", False)
- $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
- $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
- $oHTTP.Send("api_dev_key=" & $paste_devkey & "&api_paste_code=" & $paste_code & "&api_option=paste" & "&api_paste_name=" & $paste_name & "&api_paste_private=" & $paste_private & _
- "&api_paste_expire_date=" & $paste_expire_date & "&api_paste_format=" & $paste_format & $LoginKey)
- $oReceived = $oHTTP.ResponseText
- If $oReceived <> "" Then
- $gui2 = GUICreate("url", 258, 76, 192, 124)
- GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
- $Input = GUICtrlCreateInput($oReceived, 8, 8, 241, 21)
- $Button1 = GUICtrlCreateButton("copy to clipboard", 24, 40, 115, 25, $WS_GROUP)
- GUICtrlSetOnEvent(-1, "_clipput")
- $Button2 = GUICtrlCreateButton("open url", 152, 40, 75, 25, $WS_GROUP)
- GUICtrlSetOnEvent(-1, "_execute")
- GUISetState(@SW_SHOW)
- Else
- MsgBox(64, "Error", "no response")
- EndIf
- EndFunc ;==>_send
- Func _execute()
- ShellExecute($oReceived)
- EndFunc ;==>_execute
- Func _clipput()
- If ClipPut($oReceived) Then
- _exit()
- Else
- MsgBox(64, "Error", "unable to copy url to clipboard")
- EndIf
- EndFunc ;==>_clipput
- Func _exit()
- If $cmdline[0] < 1 Then Return
- IniWrite($settings, "main", "syntax", _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0))
- IniWrite($settings, "main", "expiration", _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0))
- IniWrite($settings, "main", "exposure", _FindInArray($aExposure, GUICtrlRead($cExposure), 0))
- IniWrite($settings, "main", "Username", GUICtrlRead($cLoginName))
- If BitAND(GUICtrlRead($cSavePassword), $Gui_CHECKED) Then
- IniWrite($settings, "main", "Password", _StringEncrypt(1, GUICtrlRead($cLoginPasswort), "sdfSFDSsr24234"))
- Else
- IniWrite($settings, "main", "Password", "")
- EndIf
- IniWrite($settings, "main", "PostAsGuest", GUICtrlRead($cGuest))
- IniWrite($settings, "main", "SavePassword", GUICtrlRead($cSavePassword))
- Exit
- EndFunc ;==>_exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement