diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-02-05 22:08:48 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-02-05 22:08:48 +0100 |
commit | b4aa60892fb60efd57f593006f35f94868a646da (patch) | |
tree | 20e3dc3d8487269c5167e5cc73dabcd8261a4826 /module/web/cnl | |
parent | fixed gui config error (diff) | |
download | pyload-b4aa60892fb60efd57f593006f35f94868a646da.tar.xz |
FlashGot + ClickNLoad Support + Webif. improvm.!! pyLoad FTW !!
Diffstat (limited to 'module/web/cnl')
-rw-r--r-- | module/web/cnl/__init__.py | 0 | ||||
-rw-r--r-- | module/web/cnl/models.py | 3 | ||||
-rw-r--r-- | module/web/cnl/tests.py | 23 | ||||
-rw-r--r-- | module/web/cnl/urls.py | 18 | ||||
-rw-r--r-- | module/web/cnl/views.py | 83 |
5 files changed, 127 insertions, 0 deletions
diff --git a/module/web/cnl/__init__.py b/module/web/cnl/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/module/web/cnl/__init__.py diff --git a/module/web/cnl/models.py b/module/web/cnl/models.py new file mode 100644 index 000000000..71a836239 --- /dev/null +++ b/module/web/cnl/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/module/web/cnl/tests.py b/module/web/cnl/tests.py new file mode 100644 index 000000000..2247054b3 --- /dev/null +++ b/module/web/cnl/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/module/web/cnl/urls.py b/module/web/cnl/urls.py new file mode 100644 index 000000000..5e06b639f --- /dev/null +++ b/module/web/cnl/urls.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from django.conf.urls.defaults import * + + +urlpatterns = patterns('cnl', + # Example: + # (r'^pyload/', include('pyload.foo.urls')), + + # Uncomment the admin/doc line below and add 'django.contrib.admindocs' + # to INSTALLED_APPS to enable admin documentation: + # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + (r'^add$', 'views.add'), + (r'^addcrypted$', 'views.addcrypted'), + (r'^addcrypted2$', 'views.addcrypted2'), + (r'', 'views.flash') + )
\ No newline at end of file diff --git a/module/web/cnl/views.py b/module/web/cnl/views.py new file mode 100644 index 000000000..490a445f1 --- /dev/null +++ b/module/web/cnl/views.py @@ -0,0 +1,83 @@ +# Create your views here. + + +from django.conf import settings +from django.http import HttpResponse +from django.http import HttpResponseServerError +from os.path import join +import binascii +from urllib import unquote +import re +import base64 + +try: + from Crypto.Cipher import AES +except: + pass + +def flash(request): + return HttpResponse() + +def add(request): + package = request.POST.get('referer','ClickAndLoad Package') + urls = filter(lambda x: x != "", request.POST['urls'].split("\n")) + + settings.PYLOAD.add_package(package, urls, False) + + return HttpResponse() + +def addcrypted(request): + + package = request.POST.get('referer','ClickAndLoad Package') + dlc = request.POST['crypted'].replace(" ","+") + + dlc_path = join(settings.DL_ROOT, package.replace("/","").replace("\\","").replace(":","")+".dlc") + dlc_file = file(dlc_path, "wb") + dlc_file.write(dlc) + dlc_file.close() + + + settings.PYLOAD.add_package(package, [dlc_path], False) + + return HttpResponse() + +def addcrypted2(request): + + package = request.POST.get("source", "ClickAndLoad Package") + crypted = request.POST["crypted"] + jk = request.POST["jk"] + + crypted = base64.standard_b64decode(unquote(crypted.replace(" ","+"))) + + jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1] + + Key = binascii.unhexlify(jk) + IV = Key + + obj = AES.new(Key, AES.MODE_CBC, IV) + result = obj.decrypt(crypted).replace("\x00","").split("\n") + + settings.PYLOAD.add_package(package, result, False) + + return HttpResponse() + +def flashgot(request): + if request.META['HTTP_REFERER'] != "http://localhost:9666/flashgot" and request.META['HTTP_REFERER'] != "http://127.0.0.1:9666/flashgot": + return HttpResponseServerError() + + autostart = int(request.POST.get('autostart',0)) + package = request.POST.get('package', "FlashGot") + urls = request.POST['urls'].split("\n") + folder = request.POST.get('dir', None) + + settings.PYLOAD.add_package(package, urls, autostart) + + return HttpResponse("") + +def crossdomain(request): + rep = "<?xml version=\"1.0\"?>\r\n" + rep += "<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\r\n" + rep += "<cross-domain-policy>\r\n" + rep += "<allow-access-from domain=\"*\" />\r\n" + rep += "</cross-domain-policy>\r\n" + return HttpResponse(rep)
\ No newline at end of file |