./others/pastebin.py

0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
# Uploads source files to pastebin.com 
# or other subdomain of pastebin. Supports
# several filetypes. Username and subdomain
# constants provided.  In order to use this 
# to its full potential you can make some registry 
# edits to allow a right click 'Upload To Pastebin' 
# option. I will have a script that automates that for you.
# Until then follow this guide 
#     http://www.jfitz.com/tips/rclick_custom.html
#
# This is the value I used in my registry:
# C:\Python26\pythonw.exe  C:\Python26\pastebin.py "%1"
#
# Enjoy, 
# LogicKills
 
 
import urllib
import httplib
import sys
import string
import os.path
 
# Constants
URL = "http://SubDomain.pastebin.com"  
USER = "darkc0de supporter"
 
 
# Returns actual source code from file
def readFile():
   fileIn = open(sys.argv[1],"r")
   content = fileIn.read()
   return content
 
# Returns the file's extension (ex: .cpp)
def getExtension():
   fileName = sys.argv[1]
   extension = os.path.splitext(fileName)[1]
   return extension
 
# Returns extensions corelated label
def getCodeType(ext):
   codeType = ""
   extensions = [
      ".py","python",
      ".cpp","cpp",
      ".sh","bash",
      ".pl","perl",
      ".php","php",
      ".LUA","lua",
      ".js", "javascript",
      ".java","java",
      ".html","html4strict",
      ".cs","csharp"
      ]
 
   x = 0
   while x < 5:
      if extensions[x] == ext:
         codeType = extensions[x + 1]
         break
      else:
         x += 2
 
   return codeType
 
 
 
 
def postIt(codeType,theCode):
   POST = "/pastebin.php parent_pid=&format=" + codeType + "&code2=" + theCode + "&poster=" + USER + "&paste=Send&expiry=f&email="
 
   urllib.urlopen(URL,POST);
 
 
def main():
   content = readFile()
   extension = getExtension()
   codeType = getCodeType(extension)
   postIt(codeType,content)
 
 
 
if __name__ == "__main__":
   main()
 

Back