- Ein markierter Abschnitt oder die gesammte Datei wird per POST an apaste.square7.ch verschickt und der Link geholt.
- Die aktuellen Einstellungen zu Syntax und Ablaufdatum werden in einer .ini abgelegt und beim nächsten Skriptaufruf wieder geladen.
- Starten per Tool-Menü oder Ctrl+Shift+Alt+A.
[Blockierte Grafik: http://www.abload.de/img/unbenanntyfucz.png]
"in \AutoIt3\SciTE\aPaste\apaste.au3 speichern"
#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)
#region
Global $oReceived, $sLink
Global $settings = @ScriptDir & "\settings.ini"
Global $aSyntax[158][2] = [["autoit", "AutoIt"], _
["bash", "BASH"], _
["c", "C"], _
["cpp", "C++"], _
["css", "CSS"], _
["html4strict", "HTML 4.01 strict"], _
["java", "Java"], _
["javascript", "JavaScript"], _
["mirc", "mIRC"], _
["perl", "Perl"], _
["php", "PHP"], _
["text", "Plain text"], _
["python", "Python"], _
["rails", "Ruby on Rails"], _
["ruby", "Ruby"], _
["sql", "SQL"], _
["tcl", "TCL"], _
["whois", "WHOIS (RPSL format)"], _
["xml", "XML"], _
["xorg_conf", "xorg.conf"], _
["text", "Plain Text"], _
["abap", "ABAP"], _
["actionscript", "ActionScript"], _
["actionscript3", "ActionScript 3"], _
["ada", "Ada"], _
["apache", "Apache"], _
["applescript", "AppleScript"], _
["apt_sources", "Apt sources.list"], _
["asm", "ASM"], _
["asp", "ASP"], _
["autoit", "AutoIt"], _
["avisynth", "AviSynth"], _
["bash", "BASH"], _
["basic4gl", "Basic4GL"], _
["bf", "Brainfuck"], _
["bibtex", "BibTeX"], _
["blitzbasic", "BlitzBasic"], _
["bnf", "BNF"], _
["boo", "Boo"], _
["c", "C"], _
["c_mac", "C for Macs"], _
["caddcl", "CADDCL"], _
["cadlisp", "CADLisp"], _
["cfdg", "CFDG"], _
["cfm", "ColdFusion"], _
["cil", "CIL"], _
["cmake", "CMake"], _
["cobol", "COBOL"], _
["cpp-qt", "C++ (with QT extensions)"], _
["cpp", "C++"], _
["csharp", "C#"], _
["css", "CSS"], _
["d", "D"], _
["dcs", "DCS"], _
["delphi", "Delphi"], _
["diff", "Diff-output"], _
["div", "DIV"], _
["dos", "DOS"], _
["dot", "dot"], _
["eiffel", "Eiffel"], _
["email", "E-mail (mbox\eml\RFC format)"], _
["erlang", "Erlang"], _
["fo", "FO"], _
["fortran", "Fortran"], _
["freebasic", "FreeBasic"], _
["genero", "Genero"], _
["gettext", "GNU Gettext .po/.pot"], _
["glsl", "glSlang"], _
["gml", "GML"], _
["gnuplot", "GNUPlot"], _
["groovy", "Groovy"], _
["haskell", "Haskell"], _
["hq9plus", "HQ9+"], _
["html4strict", "HTML 4.01 strict"], _
["idl", "Unoidl"], _
["ini", "INI"], _
["inno", "Inno Script"], _
["intercal", "INTERCAL"], _
["io", "IO"], _
["java", "Java"], _
["java5", "Java 5"], _
["javascript", "JavaScript"], _
["kixtart", "KiXtart"], _
["klonec", "KLone with C"], _
["klonecpp", "KLone with C++"], _
["latex", "LaTeX"], _
["lisp", "Generic Lisp"], _
["locobasic", "Locomotive Basic"], _
["lolcode", "LOLcode"], _
["lotusformulas", "@Formula/@Command"], _
["lotusscript", "LotusScript"], _
["lscript", "Lightwave Script"], _
["lsl2", "Linden Script"], _
["lua", "LUA"], _
["m68k", "Motorola 68000 Assembler"], _
["make", "GNU make"], _
["matlab", "Matlab"], _
["mirc", "mIRC"], _
["modula3", "Modula-3"], _
["mpasm", "Microchip Assembler"], _
["mxml", "MXML"], _
["mysql", "MySQL"], _
["nsis", "NSIS"], _
["oberon2", "Oberon-2"], _
["objc", "Objective-C"], _
["ocaml-brief", "Objective Caml"], _
["oobas", "OOo Basic"], _
["oracle11", "Oracle 11i"], _
["oracle8", "Oracle 8"], _
["pascal", "Pascal"], _
["per", "Per (forms)"], _
["perl", "Perl"], _
["php-brief", "PHP (Brief version)"], _
["php", "PHP"], _
["pic16", "PIC16 Assembler"], _
["pixelbender", "Pixel Bender"], _
["text", "Plain text"], _
["plsql", "Oracle 9.2 PL/SQL"], _
["povray", "Povray"], _
["powershell", "PowerShell"], _
["progress", "Progress"], _
["prolog", "Prolog"], _
["properties", "Property"], _
["providex", "ProvideX"], _
["python", "Python"], _
["qbasic", "QuickBASIC"], _
["rails", "Ruby on Rails"], _
["rebol", "Rebol"], _
["reg", "Microsoft REGEDIT"], _
["robots", "Robots.txt"], _
["ruby", "Ruby"], _
["sas", "SAS"], _
["scala", "Scala"], _
["scheme", "Scheme"], _
["scilab", "SciLab"], _
["sdlbasic", "sdlBasic"], _
["smalltalk", "Smalltalk"], _
["smarty", "Smarty"], _
["sql", "SQL"], _
["tcl", "TCL"], _
["teraterm", "Tera Term Macro"], _
["thinbasic", "thinBasic"], _
["tsql", "T-SQL"], _
["typoscript", "TypoScript"], _
["vb", "Visual Basic"], _
["vbnet", "Visual Basic .NET"], _
["verilog", "Verilog"], _
["vhdl", "VHDL"], _
["vim", "Vim"], _
["visualfoxpro", "Visual FoxPro"], _
["visualprolog", "Visual Prolog"], _
["whitespace", "Whitespace"], _
["whois", "WHOIS (RPSL format)"], _
["winbatch", "WinBatch"], _
["xml", "XML"], _
["xorg_conf", "xorg.conf"], _
["xpp", "Axapta/Dynamics Ax X++"], _
["z80", "ZiLOG Z80 Assembler"]]
Global $aExpiration[3][2] = [["d", "1 Tag"], _
["m", "1 Monat"], _
["f", "Nie"]]
#endregion
#region write/read .ini
If Not FileExists($settings) Then
IniWrite($settings, "main", "syntax", "autoit")
IniWrite($settings, "main", "expiration", "f")
EndIf
$syntax = _FindInArray($aSyntax, IniRead($settings, "main", "syntax", "autoit"), 1)
$expiration = _FindInArray($aExpiration, IniRead($settings, "main", "expiration", "f"), 1)
#endregion write/read .ini
#region gui
$gui = GUICreate("Send To aPaste", 445, 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("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)
#endregion gui
#region events
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUICtrlSetOnEvent($bSend, "_send")
#endregion events
GUISetState()
#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], $syntax)
Next
For $i = 0 To UBound($aExpiration) - 1
GUICtrlSetData($cExpiration, $aExpiration[$i][1], $expiration)
Next
#endregion set data
While 1
Sleep(100)
WEnd
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_expire_date = _FindInArray($aExpiration, GUICtrlRead($cExpiration), 0)
$paste_format = _FindInArray($aSyntax, GUICtrlRead($cSyntax), 0)
$paste_devkey = "52b07d8a33022af5c03f899c734818c8"
;Login
$oHTTP.Open("POST", "http://apaste.square7.ch/index.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("?form=editor&paste=Submit&poster=" & $paste_name & "&format=" & $paste_format & "&expiry=" & $paste_expire_date & "&code2=" & $paste_code)
[/autoit] [autoit][/autoit] [autoit]$oReceived = $oHTTP.ResponseText
If $oReceived <> "" Then
$aResult = StringRegExp($oReceived, '<div id="topInfo"><h1>.*?<br/><a href="(.*?)" title="Download this paste">', 1, 1)
$sLink = StringReplace($aResult[0], "?dl=", "")
$gui2 = GUICreate("url", 258, 76, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Input = GUICtrlCreateInput($sLink, 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($sLink)
EndFunc ;==>_execute
Func _clipput()
If ClipPut($sLink) 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))
Exit
EndFunc ;==>_exit