home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.0)
-
- import sys
- import httplib
- import re
- import urlparse
- import string
- import os.path as os
- TRUE = 1
- FALSE = 0
- ERROR = 0
- SUCCESS = 1
- TERMINATE = 2
- IGNORE = 3
- TERMINATE_SUCCESS = 4
- EXIT = 5
- SUCCESS_EXIT = 6
-
- def parse_url(url, protocol = ''):
- '''\x95\xd4\x92l\x82\xcdurl\x8f\xee\x95\xf1\x82\xcc\x93\xfc\x82\xc1\x82\xbd\x8e\xab\x8f\x91 protocol://user:pass@host:port/path?query'''
- u = {
- 'protocol': 'http',
- 'host': '',
- 'port': '',
- 'user': '',
- 'password': '',
- 'path': '/',
- 'dir': '/',
- 'filename': 'index.html',
- 'query': '' }
- u['url'] = url
- tmp = url
- protocol = string.lower(protocol)
- idx = string.find(tmp, '://')
- if idx == -1:
- u['protocol'] = protocol
- else:
- u['protocol'] = tmp[0:idx]
- tmp = tmp[idx + 3:]
- idx = string.find(tmp, '/')
- if idx == -1:
- host = tmp[0:]
- tmp = '/'
- else:
- host = tmp[0:idx]
- tmp = tmp[idx:]
- u['path'] = tmp
- u['dir'] = os.path.dirname(tmp)
- u['filename'] = os.path.basename(tmp)
- idx = string.find(u['filename'], '?')
- if idx > -1:
- u['query'] = u['filename'][idx + 1:]
-
- idx = string.find(host, '@')
- if idx == -1:
- idx = string.find(host, ':')
- if idx == -1:
- u['host'] = host
- else:
- u['host'] = host[0:idx]
- u['port'] = host[idx + 1:]
- else:
- tmp2 = host[0:idx]
- tmp3 = host[idx + 1:]
- idx = string.find(tmp2, ':')
- if idx > -1:
- u['user'] = tmp2[0:idx]
- u['password'] = tmp2[idx + 1:]
-
- idx = string.find(tmp3, ':')
- if idx == -1:
- u['host'] = tmp3
- else:
- u['host'] = tmp3[0:idx]
- u['port'] = tmp3[idx + 1:]
- return u
-
-
- def extract_url(url, proxy = ''):
- '''\x95\xd4\x92l\x82\xcd host,port,path\x82\xcc\x83^\x83v\x83\x8b'''
- url_info = parse_url(url, 'http')
- if proxy:
- if url_info['port']:
- path = url_info['protocol'] + '://' + url_info['host'] + ':' + url_info['port'] + url_info['path']
- else:
- path = url_info['protocol'] + '://' + url_info['host'] + url_info['path']
- proxy_info = parse_url(proxy)
- host = proxy_info['host']
-
- try:
- port = string.atoi(proxy_info['port'])
- except:
- port = 8080
-
- else:
- path = url_info['path']
- host = url_info['host']
-
- try:
- port = string.atoi(url_info['port'])
- except:
- port = 80
-
- return (host, port, path)
-
-
- def restore_webjump(url):
- '''\x95\xd4\x92l\x82\xcd webjump\x82\xcc\x8c\xb3\x82\xccUrl
- http://freehosting1.at.webjump.com/0919a3cc8/ac/acount-webjump/filename.jpg'''
- m = re.search('freehosting[0-9]*\\.at\\.webjump\\.com', url, re.IGNORECASE)
- if m:
- m = re.search('/[^/]+-webjump/', url, re.IGNORECASE)
- if m:
- acount = url[m.start(0) + 1:m.end(0) - 9]
- path = url[m.end(0) - 1:]
- return 'http://' + acount + '.webjump.com' + path
-
-
- return url
-
-
- def restore_homestead(url):
- '''\x95\xd4\x92l\x82\xcdhomestead\x82\xcc\x8c\xb3\x82\xccurl
- http://freeload.homestead.com/_ksi0701961600708147/acount/files/filename'''
- m = re.search('freeload.*\\.homestead\\.com/', url, re.IGNORECASE)
- if m:
- path = url[m.end(0) - 1:]
- m = re.search('/[^/]*/files/.*', path, re.IGNORECASE)
- if m:
- return 'http://www.homestead.com' + path[m.start(0):]
-
-
- return url
-
-