예제 #1
0
 def do_POST(self):
     print('start')
     lenn = int(self.headers['Content-Length'])
     data = self.rfile.read(lenn)
     self.send_response(200)
     self.send_header("Content-type", "text/html; charset=utf-8")
     self.end_headers()
     self.wfile.write(
         bytes(
             '<html><head><meta http-equiv="refresh" content="1;URL=."></meta></head></html>',
             "utf-8"))
     data = bytearray(data)
     rn = bytearray('\r\n', 'utf-8')
     data = data.split(rn)
     print(data)
     if len(data) and data[0][:6] == bytearray('------', 'utf-8'):
         fn = data[1].decode()
         fn = fn[:-1][::-1]
         fn = fn[:fn.index('"')][::-1]
         print(self.path + fn)
         f = []
         for w in range(len(data)):
             if len(data[w]) == 0:
                 f += [w]
         #print(f)
         data = data[f[0] + 1:f[-1] - 1]
         ext = data[0]
         while len(data) > 1:
             data = data[1:]
             ext += rn + data[0]
         if len(fn):
             path = '.' + uqu(self.path).replace(arhvstin, '..')
             fil = path + fn
             if os.path.exists(fil):
                 d = 0
                 while os.path.exists(fil + str(d)):
                     d += 1
                 a = open(fil + str(d), 'wb')
             else:
                 a = open(fil, 'wb')
             a.write(ext)
             a.close()
     else:
         ext = data[0]
         while len(data) > 1:
             data = data[1:]
             ext += rn + data[0]
         clip = ext.decode()[2:]
         clip = uqu(clip)
         print(clip)
         a = open('clip', 'w')
         a.write(clip)
         a.close()
     print('end')
예제 #2
0
파일: get.py 프로젝트: sudo-gera/videoget
    def do_GET(self):
        self.send_response(200)
        path = self.path.split('?', 1)[1:] + ['']
        path = path[0]
        path = path.split('&')
        path = [w.split('=') + [''] for w in path]
        path = [(uqu(w[0].replace('+', ' ')), uqu(w[1].replace('+', ' ')))
                for w in path]
        path = dict(path)
        global longer, skey
        if 'longer' in path:
            longer = path['longer']
            # longer=longer[:3]
        # longer=list(map(int,longer))
    #  longer=longer[0]*3600+longer[1]*60+longer[2]
#   longer=str(longer)
        if 'skey' in path:
            skey = path['skey']
        ext = run(skey, longer)
        self.send_header("Content-type", "text/html; charset=utf-8")
        self.end_headers()
        self.wfile.write('''
  <form>
   <textarea name="skey">{}</textarea>
   <textarea name="longer">{}</textarea>
   <input type="submit" value="search">
  </form>
  '''.format(skey, longer).encode())
        self.wfile.write(('<html><body>').encode())
        for w in ext:
            u, c, d, t, f = w
            self.wfile.write(('<a href=' +
                              f +
                              ' download><img src=' +
                              u +
                              '>' +
                              str(d //
                                  3600) +
                              ':' +
                              str(d %
                                  3600 //
                                  60) +
                              ':' +
                              str(d %
                                  60) +
                              '\t' +
                              t +
                              '.mp4</a><br>\n<pre>' +
                              '-' *
                              12800 +
                              '</pre>\n<br>').encode())
        self.wfile.write('<!DOCTYPE html></body></html>'.encode())
예제 #3
0
  def do_GET(self):
      if os.path.exists('hexit'):
          raise KeyboardInterrupt
      if self.path == '/favicon.ico':
          pass
      else:
          if os.path.exists('exit'):
              raise KeyboardInterrupt
          #print('start')
          self.send_response(200)
          path = uqu(self.path)
          #print(path)
          global hostName
          global hostPort
          global exex
          port = exex()
          #print(hostPort,hostName)
          #print(1)
          self.send_header("Content-type", "text/html; charset=utf-8")
          self.end_headers()
          #print(":"*8,port,path)
          self.wfile.write(
              bytes(
                  '''
 <html>
 <head>
 <meta http-equiv="refresh" content="1;URL=http://''' + hostName + ':' +
                  port + '''/0/">
 </meta>
 </head>
 </html>''', "utf-8"))
예제 #4
0
파일: server.py 프로젝트: sudo-gera/testbot
 def do_GET(self):
     try:
         open(path, 'rb')
         self.send_response(200)
     except:
         self.send_response(404)
     path = '.' + uqu(self.path).split('?')[0]
     path += 'index.html' if path[-1] == '/' else ''
     self.send_header("Content-type", "text/html; charset=utf-8")
     self.end_headers()
     self.wfile.write(open(path, 'rb').read())
예제 #5
0
파일: se.py 프로젝트: sudo-gera/c
 def do_GET(self):
     self.send_response(200)
     path = '.' + uqu(self.path)
     #print(path)
     if '?' in path:
         self.send_header("Content-type", "text/html; charset=utf-8")
         self.end_headers()
         self.wfile.write(
             bytes(
                 '<html><head><meta http-equiv="refresh" content="1;URL=."></meta></head></html>',
                 "utf-8"))
     elif os.path.isdir(path):
         self.send_header("Content-type", "text/html; charset=utf-8")
         self.end_headers()
         self.wfile.write(
             bytes("<html><head><title>" + path + "</title></head>",
                   "utf-8"))
         self.wfile.write(bytes("<body><p>\n", "utf-8"))
         for w in os.listdir(path):
             self.wfile.write(bytes('<form><button', 'utf-8'))
             self.wfile.write(bytes(' formaction="' + w + '/">', 'utf-8'))
             self.wfile.write(
                 bytes(w + '/' * int(os.path.isdir(path + w)), 'utf-8'))
             self.wfile.write(bytes('</button></form>\n', 'utf-8'))
         self.wfile.write(bytes("</p></body></html>", "utf-8"))
     elif os.path.isfile(path):
         self.send_header("Content-type", "file/file")
         self.end_headers()
         q = path
         q = open(q, 'br').read()
         self.wfile.write(q)
     elif os.path.isfile(path[:-1]) and path[-1] == '/':
         self.send_header("Content-type", "text/html; charset=utf-8")
         self.end_headers()
         self.wfile.write(
             bytes("<html><head><title>" + path + "</title></head>",
                   "utf-8"))
         self.wfile.write(bytes("<body><p>download<br>", "utf-8"))
         self.wfile.write(
             bytes('<a href="' + path[1:-1] + '">' + path[1:-1] + '</a>',
                   'utf-8'))
         self.wfile.write(bytes("</p></body></html>", "utf-8"))
     else:
         self.send_header("Content-type", "text/html; charset=utf-8")
         self.end_headers()
         self.wfile.write(
             bytes("<html><head><title>" + path + "</title></head>",
                   "utf-8"))
         self.wfile.write(
             bytes(
                 '<body><p>not found<br>' + path[1:] + '</p></body></html>',
                 "utf-8"))
예제 #6
0
   def do_GET(self):
       self.send_response(200)
       path = '.' + uqu(self.path)
       global qwtoken, vktoken
       if '?qw=' in path:
           qwtoken = path.split('?qw=')[1].strip()
       if '?vk=' in path:
           vktoken = path.split('?vk=')[1].strip()
       js['qw'] = qwtoken
       js['vk'] = vktoken
       open('../qiwiman.json', 'w').write(dumps(js))
       self.send_header("Content-type", "text/html; charset=utf-8")
       self.end_headers()
       self.wfile.write('''
 <form>
  <textarea name="qw">{}</textarea><br/>
  <input type="submit" value="save qiwi token">
 </form>
 <form>
  <textarea name="vk">{}</textarea><br/>
  <input type="submit" value="save vk token">
 </form>
 '''.format(qwtoken, vktoken).encode())
예제 #7
0
 def do_POST(self):
     global admin
     lenn = int(self.headers['Content-Length'])
     path = '.' + uqu(self.path)
     data = loads(self.rfile.read(lenn).decode())
     self.send_response(200)
     self.send_header("Content-type", "text/html; charset=utf-8")
     self.end_headers()
     if data['type'] == 'confirmation':
         self.wfile.write('2b1def61'.encode())
     elif data['type'] == 'message_new':
         data = data['object']['message']
         global minid
         if data['conversation_message_id'] > minid and data[
                 'from_id'] in vkid:
             minid = data['conversation_message_id']
             m = data['text'].lower()
             id = data['peer_id']
             m = m.split()
             if m[0] == 'ls':
                 if qwtoken:
                     bal = ls()
                     try:
                         bal = bal['accounts']
                         bal = [[
                             w['balance']['amount'],
                             w['balance']['currency']
                         ] for w in bal if w['hasBalance']]
                         d = {
                             643:
                             'баланс в рублях: %s',
                             0:
                             'баланс в валюте номер %s по стандарту ISO-4217: %s'
                         }
                         bal = [
                             d[w[1]] % w[0] if w[1] in d else d[0] %
                             (w[1], w[0]) for w in bal
                         ]
                         bal = '\n'.join(bal)
                     except:
                         pass
                     bal = str(bal)
                     bal = bal.replace(qwtoken, '##token##')
                     send(bal, id)
                 else:
                     send('qwtoken is not set', id)
             if m[0] == 'mv':
                 if len(m) < 3:
                     send(
                         'usage: mv <sum> <phone> \nexample: mv 123.45 +79123456789',
                         id)
                 else:
                     try:
                         m[1] = float(m[1])
                     except:
                         send(
                             'usage: mv <sum> <phone> \nexample: mv 123.45 79123456789',
                             id)
                     else:
                         if m[2][0] != '+':
                             m[2] = '+' + m[2]
                         if qwtoken:
                             mov = mv(m[1], m[2])
                             try:
                                 if mov['transaction']['state'][
                                         'code'] == 'Accepted':
                                     mov = 'transaction id: {}'.format(
                                         mov['transaction']['id'])
                             except:
                                 pass
                             mov = str(mov)
                             mov = mov.replace(qwtoken, '##token##')
                             send(mov, id)
                         else:
                             send('qwtoken is not set', id)
         self.wfile.write('ok'.encode())
예제 #8
0
    def do_GET(self):
        if os.path.exists('exit'):
            raise KeyboardInterrupt
        print('start')
        self.send_response(200)
        path = '.' + uqu(self.path).replace(arhvstin, '..')
        #print(path)
        if '?' in path:
            self.send_header("Content-type", "text/html; charset=utf-8")
            self.end_headers()
            self.wfile.write(
                bytes(
                    '''
   <html>
   <head>
   <meta http-equiv="refresh" content="1;URL=.">
   </meta>
   </head>
   <body>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <div id="neko">
    <img src="''' + img + '''" width="100%"><br>
    <img src="''' + img + '''" width="100%"><br>
    <img src="''' + img + '''" width="100%"></div>
   </body>
   </html>''', "utf-8"))

        elif os.path.isdir(path):
            if img == '/nekopara.jpg':
                os.system('cp nekopara/' +
                          random.choice(os.listdir('nekopara')) +
                          ' nekopara.jpg')
            a = open('clip')
            clip = a.read()
            a.close()
            self.send_header("Content-type", "text/html; charset=utf-8")
            self.end_headers()
            self.wfile.write(
                bytes(
                    '''
   <html>
   <head>
   <title>''' + path + '''</title>
   </head>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <body>
   <div id="neko">
    <img src="''' + img + '''" width="100%"><br>
    <img src="''' + img + '''" width="100%"><br>
    <img src="''' + img + '''" width="100%"></div>

   <div id="main">
    <h1>
    <form enctype="multipart/form-data" method="post">
     <wi><input type="file" name="u">
     <input type="submit" value="upload"></form></wi>
    </h1>
    <wi>===</wi>

   <wi><form method="post">
   <textarea name="c">''' + clip + '''</textarea><br>
   <input type="submit" value="save"></form></wi>
   <wi>===</wi>

   <form><button formaction="../">
   <h1>..<img src="/favicon.ico" height="25"></h1>
   </button></form>
   <wi>===</wi>

   ''', 'utf-8'))

            for w in os.listdir(path):
                self.wfile.write(
                    bytes(
                        '''
    <form><button formaction="''' + w + '''/">
    <h1>''' + w + '''
    <img src="/favicon.ico" height="25">''' * int(os.path.isdir(path + w)) +
                        '''
    </h1></button></form>''', 'utf-8'))

            self.wfile.write(bytes('''</div></body></html>''', "utf-8"))

        elif os.path.isfile(path):
            self.send_header("Content-type", "file/file")
            self.end_headers()
            q = open(path, 'br').read()
            self.wfile.write(q)

        elif os.path.isfile(path[:-1]) and path[-1] == '/':
            self.send_header("Content-type", "text/html; charset=utf-8")
            self.end_headers()
            self.wfile.write(
                bytes(
                    '''
   <html><head><title>''' + path + '''</title>
   </head>
   <body>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <div id="neko">
    <img src="''' + img + '''" width="100%"><br>
    <img src="''' + img + '''" width="100%"><br>
    <img src="''' + img + '''" width="100%"></div>
   <div id="main">
   <h1>
   <form><button formaction="../">
   ..<img src="/favicon.ico" height="25">
   </button></form>
   <wi>''' + path[1:-1] + '''</wi><br>
   </h1>
   <a href="''' + path[1:-1].replace('..', arhvstin) +
                    '''"><img src='/download.png' width=100%></a><br>
   </div></body></html>
   ''', "utf-8"))
        else:
            self.send_header("Content-type", "text/html; charset=utf-8")
            self.end_headers()
            self.wfile.write(
                bytes("<html><head><title>" + path + "</title></head>",
                      "utf-8"))
            self.wfile.write(
                bytes(
                    '<body><p>not found<br>' + path[1:] + '</p></body></html>',
                    "utf-8"))
        print('end')
예제 #9
0
 def do_GET(self):
  if os.path.exists('exit'):
   raise KeyboardInterrupt
  global admin
  self.send_response(200)
  path='.'+uqu(self.path)
  if path =='./0/0/' and admin==1:
   self.send_header("Content-type", "text/html; charset=utf-8")
   self.end_headers()
   self.wfile.write(bytes('''
   <html>
   <head>
   <title>'''+path+'''</title>
   </head>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <body>
   <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>

   <div id="main">
   <h1><wi>Enter password</wi></h1>

   <wi><form method="post">
   <textarea name="a"></textarea><br>
   <input type="submit" value="enter"></form></wi>
   <wi>===</wi>

   <form><button formaction="../">
   <h1>..<img src="/favicon.ico" height="25"></h1>
   </button></form>
   <wi>===</wi>

   </div></body></html>''', "utf-8"))
   return None

  if '?' in path:
   self.send_header("Content-type", "text/html; charset=utf-8")
   self.end_headers()
   self.wfile.write(bytes('''
   <html>
   <head>
   <meta http-equiv="refresh" content="0;URL=.">
   </meta>
   </head>
   <body>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>
   </body>
   </html>''', "utf-8"))

  elif path in ['./','.']:
   self.send_header("Content-type", "text/html; charset=utf-8")
   self.end_headers()
   self.wfile.write(bytes('''
   <html>
   <head>
   <meta http-equiv="refresh" content="1;URL=0/">
   </meta>
   </head>
   <body>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>
   </body>
   </html>''', "utf-8"))

  elif os.path.isdir(path):
   if img == '/nekopara.jpg':
    os.system('pwd')
    os.system('cp nekopara/'+random.choice(os.listdir('./nekopara'))+' nekopara.jpg')
   a=open('clip')
   clip=a.read()
   a.close()
   self.send_header("Content-type", "text/html; charset=utf-8")
   self.end_headers()
   self.wfile.write(bytes('''
   <html>
   <head>
   <title>'''+path+'''</title>
   </head>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <body>
   <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>

   <div id="main">
     ''','utf-8'))
   if path == './0/':
    self.wfile.write(bytes('''
    <h1>
     <form enctype="multipart/form-data" method="post" name="sendfile">
      <wi>
       <input type="file" name="u">
       <inp id="inp">
        <input type="submit">
       </inp>
      </wi>
     </form>
    </h1>
    <div id="log"></div>
    <wi>===</wi>

   <script>
    document.forms.sendfile.onchange=function(){
     var file=this.elements.u.files[0]
     if (file) {
      document.getElementById('maincont').innerHTML=''
      document.getElementById('inp').innerHTML=''
      x=new XMLHttpRequest();
      x.upload.onprogress=function(){
       if (event.loaded!=event.total){
        document.getElementById('log') .innerHTML='<wi>'+event.loaded+'<br/>'+event.total+'</wi>'
        }
       else{
        location.reload(true)
       }
      }
      x.open("POST",'.')
      var a=file.name
      var e=''
      var w=0
      for (w=0;w<a.length;w+=1){
       e+=a.charCodeAt(w).toString()+'a'
      }
      x.setRequestHeader("fn",e)
      x.send(file)
     }
    }
   </script>

     ''','utf-8'))
   self.wfile.write(bytes('''
   <maincont id="maincont">

     ''','utf-8'))
   if path == './0/':
    self.wfile.write(bytes('''

   <wi><form method="post">
   <textarea name="c">'''+clip+'''</textarea><br>
   <input type="submit" value="save"></form></wi>
   <wi>===</wi>

   ''','utf-8'))
   self.wfile.write(bytes('''
   <form><button formaction="../">
   <h1>..<img src="/favicon.ico" height="25"></h1>
   </button></form>
   <wi>===</wi>
   ''','utf-8'))
   if admin==2:
    self.wfile.write(bytes('''
   <form method="post"><button formaction="/0/" name="e" value="1">
   <h1>exit</h1>
   </button></form>
   <wi>===</wi>
   ''','utf-8'))

   ld=list(dlistdir(path))
   ld=ld[::-1]
   for w in ld:
    self.wfile.write(bytes('''
    <form><button formaction="'''+w+'''/">
    <h1>'''+w+'''
    <img src="/favicon.ico" height="25">'''*int(os.path.isdir(path+w))+'''
    </h1></button></form>''','utf-8'))

   self.wfile.write(bytes('''</maincont></div></body></html>''', "utf-8"))

  elif os.path.isfile(path):
   if ngrok or path[:4]!='./0/':
    q=open(path,'br')
    di=l(open('0/...').read())
    if path in di.keys():
     tosend=l(open('0/...').read())[path]
     toread=0
     self.send_header("Content-type", "file/file")
     self.send_header("Content-Length", str(tosend))
     self.end_headers()
     while toread<tosend:
      read=q.read()
      self.wfile.write(read)
      toread+=len(read)
    else:
     self.send_header("Content-type", "file/file")
     self.send_header("Content-Length", str(os.path.getsize(path)))
     self.end_headers()
     self.wfile.write(q.read())
    if ngrok == 2:
     raise KeyboardInterrupt
   else:
    self.send_response(200)
    global hostName
    global hostPort
    global exex
    port=exex()
    self.send_header("Content-type", "text/html; charset=utf-8")
    self.end_headers()
    self.wfile.write(bytes('''
   <html><head><title>'''+path+'''</title>
   <meta http-equiv="refresh" content="1;URL=http://'''+hostName+':'+port+path[1:]+'''"></meta>
   </head>
   <body>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>
   <div id="main">
   <h1>
   <form><button formaction="./">..<img src="/favicon.ico" height="25"></button>
   </form>
   </h1>
   </div></body></html>
   ''', "utf-8"))
  elif os.path.isfile(path[:-1]) and path[-1] == '/':
   self.send_header("Content-type", "text/html; charset=utf-8")
   self.end_headers()
   self.wfile.write(bytes('''
   <html><head><title>'''+path+'''</title>
   </head>
   <body>
   <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
   <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>
   <div id="main">
   <h1>
   <form><button formaction="../">..<img src="/favicon.ico" height="25"></button>
   </form>
   <wi><br>'''+path[1:-1]+'<br>size:'+str(os.path.getsize(path[:-1]))+'''</wi><br>
   </h1>
   <a href="'''+path[1:-1]+'''"><img src='/download.png' width=100%></a><br>
   </div></body></html>
   ''', "utf-8"))
  else:
   self.send_header("Content-type", "text/html; charset=utf-8")
   self.end_headers()
   self.wfile.write(bytes("<html><head><title>"+path+"</title></head>", "utf-8"))
   self.wfile.write(bytes('<body><p>not found<br>'+path[1:]+'</p></body></html>', "utf-8"))
예제 #10
0
 def do_POST(self):
  global admin
  lenn=int(self.headers['Content-Length'])
  ct=self.headers['Content-Type']
  ct=str(ct).split('/')
  o=ct[1:]
  ct=ct[0]

  print(self.headers)
  if ct=='multipart':
   blen=len(o[0].split('=')[1])+8
   if 1:
    data=bytearray()
    while data[-4:]!=bytearray('\r\n\r\n','utf-8'):
     data+=self.rfile.read(1)
     lenn-=1
    toread=lenn-blen
    fn=uqu(data.decode().replace('+',' ')).split('filename',1)[1].split('"')[1]
    file=fn
    fn='.'+self.path+file
    tosave=0
    while os.path.exists(fn):
     tosave+=1
     fn='.'+self.path+str(tosave)+file
    a=l(open('0/...').read())
    a[fn]=toread
    open('0/...','w').write(str(a).replace("'",'"'))
    open(fn,'w').close()
    a=open(fn,'ab')
    rsize=1024
    while toread>0:
     read=min(toread,rsize,102400)
     toread-=read
     ti=time.time()
     a.write(self.rfile.read(read))
     rsize=int(min(rsize/(time.time()-ti)+1,2**22))
    self.rfile.read(blen)
  elif self.headers['fn']:
   name=self.headers['fn']
   name=name[:-1].split('a')
   name=[chr(int(w)) for w in name]
   name=''.join(name)
   if 1:
    toread=lenn
    file=name
    fn='.'+self.path+file
    tosave=0
    while os.path.exists(fn):
     tosave+=1
     fn='.'+self.path+str(tosave)+file
    a=l(open('0/...').read())
    a[fn]=toread
    open('0/...','w').write(str(a).replace("'",'"'))
    open(fn,'w').close()
    a=open(fn,'ab')
    rsize=1024
    while toread>0:
     read=min(toread,rsize,102400)
     toread-=read
     ti=time.time()
     a.write(self.rfile.read(read))
     rsize=max(int(min(rsize/(time.time()-ti),2**22)),1)
  else:
    data=self.rfile.read(lenn)
    data=data.decode().replace('+',' ')
    data=uqu(data)
    dec,data=data.split('=',1)
    if dec=='c':
     open('clip','w').write(data)
    if dec=='a':
     s=' '.join(time.asctime().split(':')).split()
     s0=str((int(s[2])+int(s[4]))%100)+s[3][-1]
     print(s0)
     a1='qwertyuiop'
     a2='asdfghjkl1'
     a3='zxcvbnm098'
     s1=a1[int(s0[0])]
     s2=a2[int(s0[1])]
     s3=a3[int(s0[2])]
     pas=(s1+s2+s3)*((int(s[3][-1])+int(s[4][-1]))//3+1)
     print(pas)
     if data==pas:
      admin=2
    if dec=='e':
     admin=1

  self.send_response(200)
  self.send_header("Content-type", "text/html; charset=utf-8")
  self.end_headers()
  self.wfile.write(bytes('''
     <html>
     <head>
    <meta http-equiv="refresh" content="1;URL=.">
    </meta>
    </head>
    <body>
    <style type=text/css>
    #neko {position: fixed; top:0; botom:0; left:0; right:0}
    #main {position: absolute; top:0; left:0}
    wi {background: #00ff00}
    </style>
    <div id="neko">
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"><br>
    <img src="'''+img+'''" width="100%"></div>
    </body>
    </html>
    ''', "utf-8"))
예제 #11
0
 def do_GET(self):
     global cache, repo
     path = self.path
     path = path.split('?')
     path, pathargs = (path + [''])[:2]
     path = uqu(path)
     if path[0] == '/':
         path = path[1:]
     if pathargs == '' == path:
         path = 'redirect.html'
         self.send_response(200)
         self.send_header("Content-type", "text/html")
         self.end_headers()
         self.wfile.write(open(repo + path, 'rb').read())
         return
     pathargs = parse_qs(pathargs)
     if path == '':
         path = 'index.html'
         self.send_response(200)
         self.send_header("Content-type", "text/html")
         self.end_headers()
         self.wfile.write(open(repo + path, 'rb').read())
         return
     if path == 'json':
         try:
             db = sorted(listdir('post/'))[::-1]
         except:
             db = []
         if len(db) == 0:
             db = ['00_0']
         db = [{'url': w} for w in db]
         self.send_response(200)
         self.send_header("Content-type", "text/json; charset=utf-8")
         self.end_headers()
         db = dumps(db)
         self.wfile.write(db.encode())
         return
     if path == 'post/00_0':
         self.send_response(200)
         self.send_header("Content-type", "file/file")
         self.end_headers()
         self.wfile.write(
             dumps({
                 'date': '0',
                 'public': 'vkfeed',
                 'orig': '0_0',
                 'text':
                 'creating cache...\nconnect to wifi, wait 10 minutes and refresh the page',
                 'photos': []
             }).encode())
     path = path.split('/')
     if path[0] == 'localstorage':
         ls = loads(open('localstorage').read())
         if path[1] == 'set':
             ls[path[2]] = path[3]
             open('localstorage', 'w').write(dumps(ls))
             ls = '""'
         elif path[1] == 'get':
             try:
                 ls = ls[path[2]]
             except:
                 ls = dumps(None)
         self.send_response(200)
         self.send_header("Content-type", "file/file")
         self.end_headers()
         self.wfile.write(ls.encode())
     else:
         if len(path) == 1:
             path = [repo] + path
         if path[0] == 'brython':
             path[0] = repo + 'brython'
         if len(path) == 2 and path[0] in [repo, 'post', repo + 'brython']:
             post = 0
             if path[0] == 'post':
                 post = 1
             path = '/'.join(path)
             if exists(path):
                 self.send_response(200)
                 if path.endswith('.html'):
                     self.send_header("Content-type", "text/html")
                 else:
                     self.send_header("Content-type", "file/file")
                 self.end_headers()
                 file = open(path, 'rb').read()
                 if post:
                     file = bytearray(file)
                     file = file.split('\0'.encode(), 1)
                     j = loads(file[0].decode())
                     p = j['photos']
                     w = 0
                     while w != len(p):
                         p[w] = file[1][p[w]:p[w + 1] if w +
                                        1 < len(p) else len(file[1])]
                         w += 1
                     p = [b64encode(w).decode() for w in p]
                     j['photos'] = p
                     file = dumps(j)
                     file = file.encode()
                 self.wfile.write(file)
             else:
                 self.send_response(404)
                 self.send_header("Content-type", "file/file")
                 self.end_headers()