Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.47 KB | None | 0 0
  1. #region include
  2. #include <ButtonConstants.au3>
  3. #include <ComboConstants.au3>
  4. #include <GUIConstantsEx.au3>
  5. #include <StaticConstants.au3>
  6. #include <EditConstants.au3>
  7. #include <WindowsConstants.au3>
  8. #include <array.au3>
  9. #include <String.au3>
  10. #endregion include
  11.  
  12. Opt("GUIOnEventMode", 1)
  13. Opt("GUIResizeMode", 544)
  14. ;Orginal by i2c @www.autoit.de | Login & New API support by Sprenger120
  15. #region
  16. Global $oReceived, $cLoginPasswort, $toggle = 0
  17. Global $settings = @ScriptDir & "\settings.ini"
  18. Global $aSyntax[139][2] = [["abap", "ABAP"], _
  19.         ["actionscript", "ActionScript"], _
  20.         ["actionscript3", "ActionScript 3"], _
  21.         ["ada", "Ada"], _
  22.         ["apache", "ApacheLog"], _
  23.         ["applescript", "AppleScript"], _
  24.         ["apt_sources", "APT Sources"], _
  25.         ["asm", "ASM"], _
  26.         ["asp", "ASP"], _
  27.         ["autoit", "AutoIt"], _
  28.         ["avisynth", "Avisynth"], _
  29.         ["bash", "Bash"], _
  30.         ["basic4gl", "Basic4GL"], _
  31.         ["bibtex", "BibTeX"], _
  32.         ["blitzbasic", "Blitz Basic"], _
  33.         ["bnf", "BNF"], _
  34.         ["boo", "BOO"], _
  35.         ["bf", "BrainFuck"], _
  36.         ["c", "C"], _
  37.         ["c_mac", "C for Macs"], _
  38.         ["cill", "C Intermediate Language"], _
  39.         ["csharp", "C#"], _
  40.         ["cpp", "C++"], _
  41.         ["caddcl", "CAD DCL"], _
  42.         ["cadlisp", "CAD Lisp"], _
  43.         ["cfdg", "CFDG"], _
  44.         ["klonec", "Clone C"], _
  45.         ["klonecpp", "Clone C++"], _
  46.         ["cmake", "CMake"], _
  47.         ["cobol", "COBOL"], _
  48.         ["cfm", "ColdFusion"], _
  49.         ["css", "CSS"], _
  50.         ["d", "D"], _
  51.         ["dcs", "DCS"], _
  52.         ["delphi", "Delphi"], _
  53.         ["dff", "Diff"], _
  54.         ["div", "DIV"], _
  55.         ["dos", "DOS"], _
  56.         ["dot", "DOT"], _
  57.         ["eiffel", "Eiffel"], _
  58.         ["email", "Email"], _
  59.         ["erlang", "Erlang"], _
  60.         ["fo", "FO Language"], _
  61.         ["fortran", "Fortran"], _
  62.         ["freebasic", "FreeBasic"], _
  63.         ["gml", "Game Maker"], _
  64.         ["genero", "Genero"], _
  65.         ["gettext", "GetText"], _
  66.         ["groovy", "Groovy"], _
  67.         ["haskell", "Haskell"], _
  68.         ["hq9plus", "HQ9 Plus"], _
  69.         ["html4strict", "HTML"], _
  70.         ["idl", "IDL"], _
  71.         ["ini", "INI file"], _
  72.         ["inno", "Inno Script"], _
  73.         ["intercal", "INTERCAL"], _
  74.         ["io", "IO"], _
  75.         ["java", "Java"], _
  76.         ["java5", "Java 5"], _
  77.         ["javascript", "JavaScript"], _
  78.         ["kixtart", "KiXtart"], _
  79.         ["latex", "Latex"], _
  80.         ["lsl2", "Linden Scripting"], _
  81.         ["lisp", "Lisp"], _
  82.         ["locobasic", "Loco Basic"], _
  83.         ["lolcode", "LOL Code"], _
  84.         ["lotusformulas", "Lotus Formulas"], _
  85.         ["lotusscript", "Lotus Script"], _
  86.         ["lscript", "LScript"], _
  87.         ["lua", "Lua"], _
  88.         ["m68k", "M68000 Assembler"], _
  89.         ["make", "Make"], _
  90.         ["matlab", "MatLab"], _
  91.         ["mirc", "mIRC"], _
  92.         ["modula3", "Modula 3"], _
  93.         ["mpasm", "MPASM"], _
  94.         ["mxml", "MXML"], _
  95.         ["mysql", "MySQL"], _
  96.         ["text", "None"], _
  97.         ["nsis", "NullSoft Installer"], _
  98.         ["oberon2", "Oberon 2"], _
  99.         ["objc", "Objective C"], _
  100.         ["ocaml-brief", "OCalm Brief"], _
  101.         ["ocaml", "OCaml"], _
  102.         ["glsl", "OpenGL Shading"], _
  103.         ["oobas", "Openoffice BASIC"], _
  104.         ["oracle11", "Oracle 11"], _
  105.         ["oracle8", "Oracle 8"], _
  106.         ["pascal", "Pascal"], _
  107.         ["pawn", "PAWN"], _
  108.         ["per", "Per"], _
  109.         ["perl", "Perl"], _
  110.         ["php", "PHP"], _
  111.         ["php-brief", "PHP Brief"], _
  112.         ["pic16", "Pic 16"], _
  113.         ["pixelbender", "Pixel Bender"], _
  114.         ["plsql", "PL/SQL"], _
  115.         ["povray", "POV-Ray"], _
  116.         ["powershell", "Power Shell"], _
  117.         ["progress", "Progress"], _
  118.         ["prolog", "Prolog"], _
  119.         ["properties", "Properties"], _
  120.         ["providex", "ProvideX"], _
  121.         ["python", "Python"], _
  122.         ["qbasic", "QBasic"], _
  123.         ["rails", "Rails"], _
  124.         ["rebol", "REBOL"], _
  125.         ["reg", "REG"], _
  126.         ["robots", "Robots"], _
  127.         ["ruby", "Ruby"], _
  128.         ["gnuplot", "Ruby Gnuplot"], _
  129.         ["sas", "SAS"], _
  130.         ["scala", "Scala"], _
  131.         ["scheme", "Scheme"], _
  132.         ["scilab", "Scilab"], _
  133.         ["sdlbasic", "SdlBasic"], _
  134.         ["smalltalk", "Smalltalk"], _
  135.         ["smarty", "Smarty"], _
  136.         ["sql", "SQL"], _
  137.         ["tsql", "T-SQL"], _
  138.         ["tcl", "TCL"], _
  139.         ["teraterm", "Tera Term"], _
  140.         ["thinbasic", "thinBasic"], _
  141.         ["typoscript", "TypoScript"], _
  142.         ["unreal", "unrealScript"], _
  143.         ["vbnet", "VB.NET"], _
  144.         ["verilog", "VeriLog"], _
  145.         ["vhdl", "VHDL"], _
  146.         ["vim", "VIM"], _
  147.         ["visualprolog", "Visual Pro Log"], _
  148.         ["vb", "VisualBasic"], _
  149.         ["visualfoxpro", "VisualFoxPro"], _
  150.         ["whitespace", "WhiteSpace"], _
  151.         ["8whois", "WHOIS"], _
  152.         ["winbatch", "Win Batch"], _
  153.         ["xml", "XML"], _
  154.         ["xorg_conf", "Xorg Config"], _
  155.         ["xpp", "XPP"], _
  156.         ["z80", "Z80 Assembler"]]
  157.  
  158. Global $aExposure[2][2] = [["0", "public"], _
  159.         ["1", "private"]]
  160.  
  161. Global $aExpiration[5][2] = [["N", "Never"], _
  162.         ["10M", "10 Minutes"], _
  163.         ["1H", "1 Hour"], _
  164.         ["1D", "1 Day"], _
  165.         ["1M", "1 Month"]]
  166. #endregion
  167.  
  168. #region write/read .ini
  169. If Not FileExists($settings) Then
  170.     IniWrite($settings, "main", "syntax", "autoit")
  171.     IniWrite($settings, "main", "expiration", "N")
  172.     IniWrite($settings, "main", "exposure", "0")
  173.     IniWrite($settings, "main", "Username", "")
  174.     IniWrite($settings, "main", "Password", "")
  175.     IniWrite($settings, "main", "PostAsGuest", "1")
  176.     IniWrite($settings, "main", "SavePassword", "4")
  177. EndIf
  178. $syntax = _FindInArray($aSyntax, IniRead($settings, "main", "syntax", "autoit"), 1)
  179. $expiration = _FindInArray($aExpiration, IniRead($settings, "main", "expiration", "N"), 1)
  180. $exposure = _FindInArray($aExposure, IniRead($settings, "main", "exposure", "0"), 1)
  181. $DevKey = IniRead($settings, "main", "DevKey", "")
  182. $Username = IniRead($settings, "main", "Username", "")
  183. $Passwort = IniRead($settings, "main", "Password", "")
  184. If $Passwort <> "" Then $Passwort = _StringEncrypt(0, $Passwort, "sdfSFDSsr24234")
  185. If $Passwort = "0" Then $Passwort = ""
  186. $SavePassword = IniRead($settings, "main", "SavePassword", "4")
  187. $PostAsGuest = IniRead($settings, "main", "PostAsGuest", "1")
  188. #endregion write/read .ini
  189.  
  190. #region gui
  191. $gui = GUICreate("Send To Pastebin", 613, 145, -1, -1)
  192.  
  193. GUICtrlCreateGroup("Send", 8, 8, 161, 130)
  194. GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
  195. $rFile = GUICtrlCreateRadio("complete file", 24, 32, 113, 17)
  196. $rSelected = GUICtrlCreateRadio("selected code", 24, 56, 113, 17)
  197. $bSend = GUICtrlCreateButton("send", 50, 92, 75, 25, $WS_GROUP)
  198. GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
  199. GUICtrlCreateGroup("", -99, -99, 1, 1)
  200.  
  201. GUICtrlCreateGroup("Settings", 176, 8, 262, 130)
  202. GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
  203. GUICtrlCreateLabel("Syntax highlighting:", 184, 36, 95, 17)
  204. GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
  205. $cSyntax = GUICtrlCreateCombo($syntax, 288, 32, 145, 25)
  206. GUICtrlCreateLabel("Post expiration:", 184, 60, 76, 17)
  207. GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
  208. $cExpiration = GUICtrlCreateCombo($expiration, 288, 56, 145, 25)
  209. GUICtrlCreateLabel("Post exposure:", 184, 84, 88, 17)
  210. GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
  211. $cExposure = GUICtrlCreateCombo($exposure, 288, 80, 145, 25)
  212. GUICtrlCreateLabel("Name / Title: ", 184, 110, 83, 17)
  213. GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
  214. $iName = GUICtrlCreateInput("", 288, 104, 145, 25)
  215. GUICtrlCreateGroup("", -99, -99, 1, 1)
  216.  
  217. ;Login
  218. GUICtrlCreateGroup("Login", 445, 8, 161, 130)
  219. GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
  220. GUICtrlCreateLabel("Name:", 455, 38, 70, 17)
  221. GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
  222. GUICtrlCreateLabel("Passwort: ", 455, 66, 83, 17)
  223. GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
  224. $cLoginName = GUICtrlCreateInput($Username, 510, 32, 83, 25)
  225. $cLoginPasswort = GUICtrlCreateInput($Passwort, 510, 60, 83, 25, BitOR($ES_PASSWORD, $GUI_SS_DEFAULT_INPUT))
  226. $cGuest = GUICtrlCreateCheckbox("als Gast posten", 455, 88, 100, 20)
  227. GUICtrlSetState(-1, $PostAsGuest)
  228. $cSavePassword = GUICtrlCreateCheckbox("Password speichern", 455, 106, 120, 20)
  229. GUICtrlSetState(-1, $SavePassword)
  230. If BitAND($PostAsGuest, $Gui_CHECKED) Then
  231.     GUICtrlSetState($cLoginName, $GUI_DISABLE)
  232.     GUICtrlSetState($cLoginPasswort, $GUI_DISABLE)
  233.     GUICtrlSetState($cSavePassword, $GUI_DISABLE)
  234. EndIf
  235. GUISetState(@SW_SHOW)
  236. #endregion gui
  237.  
  238. #region events
  239. GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
  240. GUICtrlSetOnEvent($bSend, "_send")
  241. GUICtrlSetOnEvent($cGuest, "_Checkbox")
  242. #endregion events
  243.  
  244. #region set data
  245. If $cmdline[0] < 1 Then
  246.     MsgBox(64, "Error", "missing parameter")
  247.     Exit
  248. EndIf
  249. If $cmdline[2] <> "" Then
  250.     GUICtrlSetState($rSelected, $Gui_CHECKED)
  251. Else
  252.     GUICtrlSetState($rFile, $Gui_CHECKED)
  253.     GUICtrlSetState($rSelected, $GUI_DISABLE)
  254. EndIf
  255. For $i = 0 To UBound($aSyntax) - 1
  256.     GUICtrlSetData($cSyntax, $aSyntax[$i][1])
  257. Next
  258. For $i = 0 To UBound($aExpiration) - 1
  259.     GUICtrlSetData($cExpiration, $aExpiration[$i][1])
  260. Next
  261. For $i = 0 To UBound($aExposure) - 1
  262.     GUICtrlSetData($cExposure, $aExposure[$i][1])
  263. Next
  264. #endregion set data
  265.  
  266. While 1
  267.     Sleep(100)
  268. WEnd
  269.  
  270. Func _Checkbox()
  271.     Switch BitAND(GUICtrlRead($cGuest), $Gui_CHECKED)
  272.         Case True
  273.             GUICtrlSetState($cLoginName, $GUI_DISABLE)
  274.             GUICtrlSetState($cLoginPasswort, $GUI_DISABLE)
  275.             GUICtrlSetState($cSavePassword, $GUI_DISABLE)
  276.         Case False
  277.             GUICtrlSetState($cLoginName, $GUI_ENABLE)
  278.             GUICtrlSetState($cLoginPasswort, $GUI_ENABLE)
  279.             GUICtrlSetState($cSavePassword, $GUI_ENABLE)
  280.     EndSwitch
  281. EndFunc   ;==>_Checkbox
  282.  
  283. Func _FindInArray($array, $value, $switch)
  284.     $index = _ArraySearch($array, $value)
  285.     If $index = -1 Then Return -1
  286.  
  287.     If $switch = 0 Then
  288.         $result = $array[$index][0]
  289.     ElseIf $switch = 1 Then
  290.         $result = $array[$index][1]
  291.     Else
  292.         SetError(1, 0, False)
  293.     EndIf
  294.     Return $result
  295. EndFunc   ;==>_FindInArray
  296.  
  297. Func _URIEncode($sData)
  298.     ; Prog@ndy
  299.     Local $aData = StringSplit(BinaryToString(StringToBinary($sData, 4), 1), "")
  300.     Local $nChar
  301.     $sData = ""
  302.     For $i = 1 To $aData[0]
  303.         $nChar = Asc($aData[$i])
  304.         Switch $nChar
  305.             Case 45, 46, 48 - 57, 65 To 90, 95, 97 To 122, 126
  306.                 $sData &= $aData[$i]
  307.             Case 32
  308.                 $sData &= "+"
  309.             Case Else
  310.                 $sData &= "%" & Hex($nChar, 2)
  311.         EndSwitch
  312.     Next
  313.     Return $sData
  314. EndFunc   ;==>_URIEncode
  315.  
  316. Func _send()
  317.     Local $bPostAsGuest, $LoginKey
  318.     Local Static $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
  319.     GUISetState(@SW_DISABLE, $gui)
  320.     If BitAND(GUICtrlRead($rFile), $Gui_CHECKED) = $Gui_CHECKED Then
  321.         $open = FileOpen($cmdline[1], 0)
  322.         $paste_code = _URIEncode(FileRead($open))
  323.         FileClose($open)
  324.     ElseIf BitAND(GUICtrlRead($rSelected), $Gui_CHECKED) = $Gui_CHECKED Then
  325.         $paste_code = _URIEncode($cmdline[2])
  326.     EndIf
  327.     $paste_name = GUICtrlRead($iName)
  328.     $paste_private = _FindInArray($aExposure, GUICtrlRead($cExposure), 0)
  329.     $paste_expire_date = _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0)
  330.     $paste_format = _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0)
  331.     $paste_devkey = "52b07d8a33022af5c03f899c734818c8"
  332.     $Username = GUICtrlRead($cLoginName)
  333.     $Passwort = GUICtrlRead($cLoginPasswort)
  334.     $bPostAsGuest = GUICtrlRead($cGuest)
  335.     If BitAND($bPostAsGuest, $Gui_CHECKED) Then
  336.         $bPostAsGuest = True
  337.     Else
  338.         $bPostAsGuest = False
  339.     EndIf
  340.  
  341.     ;Login
  342.     If Not $bPostAsGuest Then
  343.         $oHTTP.Open("POST", "http://pastebin.com/api/api_login.php", False)
  344.         $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)")
  345.         $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
  346.         $oHTTP.Send("api_dev_key=" & $paste_devkey & "&api_user_name=" & $Username & "&api_user_password=" & $Passwort)
  347.  
  348.         $oReceived = $oHTTP.ResponseText
  349.         If Not StringRegExp($oReceived, "^[\d\w]+$") Then
  350.             MsgBox(48, "SciTe Send to Pastebin", "Fehler beim Login. Quellcode wird als Gast gepostet." & @CRLF & $oReceived)
  351.             $LoginKey = ""
  352.         Else
  353.             $LoginKey = "&api_user_key=" & $oReceived
  354.         EndIf
  355.     Else
  356.         $LoginKey = ""
  357.     EndIf
  358.  
  359.     $oHTTP.Open("POST", "http://pastebin.com/api/api_post.php", False)
  360.     $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)")
  361.     $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
  362.  
  363.     $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 & _
  364.             "&api_paste_expire_date=" & $paste_expire_date & "&api_paste_format=" & $paste_format & $LoginKey)
  365.  
  366.     $oReceived = $oHTTP.ResponseText
  367.     If $oReceived <> "" Then
  368.         $gui2 = GUICreate("url", 258, 76, 192, 124)
  369.         GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
  370.         $Input = GUICtrlCreateInput($oReceived, 8, 8, 241, 21)
  371.         $Button1 = GUICtrlCreateButton("copy to clipboard", 24, 40, 115, 25, $WS_GROUP)
  372.         GUICtrlSetOnEvent(-1, "_clipput")
  373.         $Button2 = GUICtrlCreateButton("open url", 152, 40, 75, 25, $WS_GROUP)
  374.         GUICtrlSetOnEvent(-1, "_execute")
  375.         GUISetState(@SW_SHOW)
  376.     Else
  377.         MsgBox(64, "Error", "no response")
  378.     EndIf
  379. EndFunc   ;==>_send
  380.  
  381. Func _execute()
  382.     ShellExecute($oReceived)
  383. EndFunc   ;==>_execute
  384.  
  385. Func _clipput()
  386.     If ClipPut($oReceived) Then
  387.         _exit()
  388.     Else
  389.         MsgBox(64, "Error", "unable to copy url to clipboard")
  390.     EndIf
  391. EndFunc   ;==>_clipput
  392.  
  393. Func _exit()
  394.     If $cmdline[0] < 1 Then Return
  395.     IniWrite($settings, "main", "syntax", _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0))
  396.     IniWrite($settings, "main", "expiration", _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0))
  397.     IniWrite($settings, "main", "exposure", _FindInArray($aExposure, GUICtrlRead($cExposure), 0))
  398.     IniWrite($settings, "main", "Username", GUICtrlRead($cLoginName))
  399.     If BitAND(GUICtrlRead($cSavePassword), $Gui_CHECKED) Then
  400.         IniWrite($settings, "main", "Password", _StringEncrypt(1, GUICtrlRead($cLoginPasswort), "sdfSFDSsr24234"))
  401.     Else
  402.         IniWrite($settings, "main", "Password", "")
  403.     EndIf
  404.     IniWrite($settings, "main", "PostAsGuest", GUICtrlRead($cGuest))
  405.     IniWrite($settings, "main", "SavePassword", GUICtrlRead($cSavePassword))
  406.     Exit
  407. EndFunc   ;==>_exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement