From 8640a29d00720881e05ac55533588c43a9cf4af7 Mon Sep 17 00:00:00 2001 From: Q Date: Sun, 10 Oct 2021 08:46:04 +0300 Subject: [PATCH] removing obsolete scripts, fixing few --- bin/clockcurses | 5 +- bin/rsync-queue | 1 - bin/sqlite3ncsv | 1 - bin/sqlite3tabview | 1 + files/rsync-queue | 175 ----- tsv/{sqlite3ncsv => sqlite3tabview} | 16 +- tsv/tsv2sc.py | 13 +- web/curl-header | 7 +- web/droopy | 972 ---------------------------- web/droopysend | 25 - web/index.php | 90 --- web/scotty | 49 -- 12 files changed, 18 insertions(+), 1337 deletions(-) delete mode 120000 bin/rsync-queue delete mode 120000 bin/sqlite3ncsv create mode 120000 bin/sqlite3tabview delete mode 100755 files/rsync-queue rename tsv/{sqlite3ncsv => sqlite3tabview} (71%) delete mode 100755 web/droopy delete mode 100755 web/droopysend delete mode 100644 web/index.php delete mode 100755 web/scotty diff --git a/bin/clockcurses b/bin/clockcurses index 409d5a0..fe4e8a3 100755 --- a/bin/clockcurses +++ b/bin/clockcurses @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import curses -import os,sys +import os +import sys import time,datetime import math import signal @@ -32,7 +33,7 @@ def drawcircle(win,cy,cx,r): def drawline(win,cy,cx,a,s,r,char): prec=2 - for l in range(r*prec): + for l in range(int(r*prec)): if l>s: ly=int(round(cy-float(l)*math.cos(a)/prec)) lx=int(round(cx+2.0*float(l)*math.sin(a)/prec)) diff --git a/bin/rsync-queue b/bin/rsync-queue deleted file mode 120000 index 1ad0c92..0000000 --- a/bin/rsync-queue +++ /dev/null @@ -1 +0,0 @@ -../files/rsync-queue \ No newline at end of file diff --git a/bin/sqlite3ncsv b/bin/sqlite3ncsv deleted file mode 120000 index a012a69..0000000 --- a/bin/sqlite3ncsv +++ /dev/null @@ -1 +0,0 @@ -../tsv/sqlite3ncsv \ No newline at end of file diff --git a/bin/sqlite3tabview b/bin/sqlite3tabview new file mode 120000 index 0000000..3e7c4fa --- /dev/null +++ b/bin/sqlite3tabview @@ -0,0 +1 @@ +../tsv/sqlite3tabview \ No newline at end of file diff --git a/files/rsync-queue b/files/rsync-queue deleted file mode 100755 index b4c6fbf..0000000 --- a/files/rsync-queue +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env python3 -# coding=UTF-8 -from __future__ import print_function -import sys -import os,time,datetime -import sqlite3 -import subprocess,shlex -from argparse import ArgumentParser - -SQLFILE=os.path.expandvars('$HOME/.rsync-queue.sqlite') - -def setup_options(): - parser=ArgumentParser(description="Maintain a queue for file synchronization") - parser.add_argument("-r",action="store_true",dest="run",default=False, - help="Start rsync") - parser.add_argument("-R",action="store_true",dest="forever",default=False, - help="Start rsync in a loop, never exit") - parser.add_argument("--rerun",action="store_true",dest="rerun",default=False, - help="When running, run even the correctly exited.") - parser.add_argument("-l",action="store_true",dest="listDB",default=False, - help="List DB contents") - parser.add_argument("-L",action="store_true",dest="listAllDB",default=False, - help="List DB contents, even the completed") - parser.add_argument("-f",action="store",dest="sqlfile",default=SQLFILE, - help="SQL file name to use [%(default)s]") - parser.add_argument("-c",action="store_true",dest="clear",default=False, - help="Clear DB of completed entries") - parser.add_argument("-C",action="store_true",dest="clearAll",default=False, - help="Clear DB of all entries") - parser.add_argument("-o",action="store",dest="options",default="-vaP", - help="Options to rsync") - parser.add_argument('SRC', action="store",default='', nargs='?') - parser.add_argument('TGT', action="store",default='', nargs='?') - - options=parser.parse_args() - if options.forever: - options.run=True - if options.clearAll: - options.clear=True - if options.SRC!='': - options.SRC=path_to_abs(options.SRC) - if options.TGT!='': - options.TGT=path_to_abs(options.TGT) - return options - -def path_to_abs(path): - append="" - if path.endswith("/"): - append="/" - return os.path.abspath(path)+append - - -def createdb(fname): - conn=sqlite3.connect(fname) - db=conn.cursor() - conn.text_factory=str - db.execute('CREATE TABLE list (id INTEGER PRIMARY KEY AUTOINCREMENT,\ - SRC TEXT,TGT TEXT, exitcode INTEGER)') - conn.commit() - return - -def mark_done(options, SRC,TGT, exitcode): - conn=sqlite3.connect(options.sqlfile) - conn.text_factory=str - db=conn.cursor() - db.execute("UPDATE list SET exitcode=? \ - WHERE SRC=? AND TGT=?",(exitcode,SRC,TGT)) - conn.commit() - return - -def add(options): - conn=sqlite3.connect(options.sqlfile) - conn.text_factory=str - db=conn.cursor() - db.execute("INSERT INTO list(SRC,TGT,exitcode)\ - VALUES(?,?,?)",(options.SRC,options.TGT,1)) - conn.commit() - return - -def clear(options,everything=False): - conn=sqlite3.connect(options.sqlfile) - conn.text_factory=str - db=conn.cursor() - db.execute("DELETE FROM list WHERE exitcode == 0") - if everything: - db.execute("DELETE FROM list WHERE SRC LIKE '%'") - conn.commit() - return - -def get_list(options): - conn=sqlite3.connect(options.sqlfile) - conn.text_factory=str - db=conn.cursor() - if options.rerun: - db.execute("SELECT SRC,TGT FROM list ORDER BY id") - else: - db.execute("SELECT SRC,TGT FROM list WHERE exitcode > 0 ORDER BY id") - nextEnt=db.fetchall() - return nextEnt - -def list_URLs(options): - conn=sqlite3.connect(options.sqlfile) - conn.text_factory=str - db=conn.cursor() - if options.listAllDB: - db.execute("SELECT * FROM list ORDER BY id") - else: - db.execute("SELECT * FROM list WHERE exitcode > 0 ORDER BY id") - print("EC\tSRC\tTGT") - for row in db: - print("%s\t%s\t%s" % (row[3],row[1],row[2])) - return - -def start_sync(options): - sync_list=get_list(options) - for i,sync in enumerate(sync_list): - (SRC,TGT)=sync - if not SRC: - return - print("Starting: #%d %s ─▶ %s"%(i+1,SRC,TGT)) - syncopts=shlex.split(options.options) - command=['rsync'] - command.extend(syncopts) - command.extend([SRC,TGT]) - popen = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=8) - j=1 - try: - line=popen.stdout.read(8) - while line: - if '\n' in line: - j+=1 - if j%50==0: - line=line.replace("\n","\n#%d/%d %s ─▶ %s\n"%(i+1,len(sync_list),SRC,TGT),1) - j=1 - sys.stdout.write(line) - sys.stdout.flush() - line=popen.stdout.read(8) - except KeyboardInterrupt: - popen.kill() - sys.exit(1) - mark_done(options,SRC,TGT,popen.wait()) - if popen.returncode>0: - lines_iterator = iter(popen.stderr.readline, b"") - for line in lines_iterator: - sys.stdout.write(line) - print("FAILED: EC: %d, %s ─▶ %s"%(popen.returncode,SRC,TGT)) - print("Finished: #%d %s ─▶ %s"%(i+1,SRC,TGT)) - -def main(): - options=setup_options(); - - if not os.path.exists(options.sqlfile): - createdb(options.sqlfile); - if options.SRC!='' and options.TGT!='': - print("Adding: %s ─▶ %s"%(options.SRC,options.TGT)) - add(options) - if options.clear: - print("Clearing database") - clear(options,options.clearAll) - if options.listDB: - list_URLs(options) - if options.listAllDB: - list_URLs(options) - if options.run: - print("Start synchronization. ctrl-c to exit") - while True: - start_sync(options) - if not options.forever: - break - else: - time.sleep(5) - sys.exit(0) - -main() diff --git a/tsv/sqlite3ncsv b/tsv/sqlite3tabview similarity index 71% rename from tsv/sqlite3ncsv rename to tsv/sqlite3tabview index 68853d0..98ade31 100755 --- a/tsv/sqlite3ncsv +++ b/tsv/sqlite3tabview @@ -1,15 +1,14 @@ #!/bin/bash help() { -echo 'Sqlite3NCSV: view sqlite3 DB with ncsv. - Usage: sqlite3ncsv [FILE] [TABLE/QUERY/-l] - +echo 'sqlite3tabview: view sqlite3 DB with tabview. + Usage: sqlite3tabview [FILE] [TABLE/QUERY/-l] + first argument: sqlite3 file - second, optional argument: + second, optional argument: TABLE: If not given, first in schema used. QUERY: If the second argument contains spaces, it is assumed to be a query. -l: List table names - note: will try for tabview if ncsv not installed ' } [[ "$1" == "-h" ]] && { @@ -35,11 +34,8 @@ sqlfile="$1" } || { query="$table" } -VIEWER=ncsv -which ncsv > /dev/null || { - VIEWER="tabview -w max -" - which tabview > /dev/null || VIEWER="cat -" -} +VIEWER="tabview -w max -" +which tabview > /dev/null || VIEWER="cat -" sqlite3 -header -separator ' ' -nullvalue NA "$sqlfile" "$query" | $VIEWER diff --git a/tsv/tsv2sc.py b/tsv/tsv2sc.py index b47e902..d9bb4ea 100755 --- a/tsv/tsv2sc.py +++ b/tsv/tsv2sc.py @@ -17,17 +17,8 @@ # '''TSV 2 SC convert.''' -from __future__ import division -from __future__ import print_function - -from builtins import chr -from builtins import str -from builtins import range -from builtins import object -from past.utils import old_div __author__ = "Ville Rantanen" - -__version__ = "0.2" +__version__ = "0.3" import sys,os import csv @@ -100,7 +91,7 @@ class SCWriter(object): ''' Returns a column alphabet from column number ''' o=chr(column+64+1) if column>25: - return self.column_to_alpha((old_div(column, 26)) -1) + self.column_to_alpha(column % 26); + return self.column_to_alpha((int(column/ 26)) -1) + self.column_to_alpha(column % 26); return o def write_row(self,row): diff --git a/web/curl-header b/web/curl-header index df282de..f9c1bc0 100755 --- a/web/curl-header +++ b/web/curl-header @@ -1,4 +1,9 @@ -#!/bin/sh +#!/bin/bash + +if [[ "$1" = "-h" ]]; then + echo Prints the header for a URL + exit +fi # head trick to prevent unable to write -error. curl -s -D /dev/stderr "$1" | head -c 1 | head -c 0 diff --git a/web/droopy b/web/droopy deleted file mode 100755 index 11429f7..0000000 --- a/web/droopy +++ /dev/null @@ -1,972 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Droopy (http://stackp.online.fr/droopy) -# Copyright 2008-2012 (c) Pierre Duquesne -# Licensed under the New BSD License. - -# Changelog -# 20120108 * Taiwanese translation by Li-cheng Hsu. -# 20110928 * Correctly save message with --save-config. Fix by Sven Radde. -# 20110708 * Polish translation by Jacek Politowski. -# 20110625 * Fix bug regarding filesystem name encoding. -# * Save the --dl option when --save-config is passed. -# 20110501 * Add the --dl option to let clients download files. -# * CSS speech bubble. -# 20101130 * CSS and HTML update. Switch to the new BSD License. -# 20100523 * Simplified Chinese translation by Ye Wei. -# 20100521 * Hungarian translation by Csaba Szigetvári. -# * Russian translation by muromec. -# * Use %APPDATA% Windows environment variable -- fix by Maik. -# 20091229 * Brazilian Portuguese translation by -# Carlos Eduardo Moreira dos Santos and Toony Poony. -# * IE layout fix by Carlos Eduardo Moreira dos Santos. -# * Galician translation by Miguel Anxo Bouzada. -# 20090721 * Indonesian translation by Kemas. -# 20090205 * Japanese translation by Satoru Matsumoto. -# * Slovak translation by CyberBoBaK. -# 20090203 * Norwegian translation by Preben Olav Pedersen. -# 20090202 * Korean translation by xissy. -# * Fix for unicode filenames by xissy. -# * Relies on 127.0.0.1 instead of "localhost" hostname. -# 20090129 * Serbian translation by kotnik. -# 20090125 * Danish translation by jan. -# 20081210 * Greek translation by n2j3. -# 20081128 * Slovene translation by david. -# * Romanian translation by Licaon. -# 20081022 * Swedish translation by David Eurenius. -# 20081001 * Droopy gets pretty (css and html rework). -# * Finnish translation by ipppe. -# 20080926 * Configuration saving and loading. -# 20080906 * Extract the file base name (some browsers send the full path). -# 20080905 * File is uploaded directly into the specified directory. -# 20080904 * Arabic translation by Djalel Chefrour. -# * Italian translation by fabius and d1s4st3r. -# * Dutch translation by Tonio Voerman. -# * Portuguese translation by Pedro Palma. -# * Turkish translation by Heartsmagic. -# 20080727 * Spanish translation by Federico Kereki. -# 20080624 * Option -d or --directory to specify the upload directory. -# 20080622 * File numbering to avoid overwriting. -# 20080620 * Czech translation by Jiří. -# * German translation by Michael. -# 20080408 * First release. - -from __future__ import print_function -from future import standard_library -standard_library.install_aliases() -from builtins import str -import http.server -import socketserver -import cgi -import os -import posixpath -import macpath -import ntpath -import sys -import getopt -import mimetypes -import copy -import shutil -import tempfile -import socket -import locale -import urllib.request, urllib.parse, urllib.error - -LOGO = '''\ - _____ -| \.----.-----.-----.-----.--.--. -| -- | _| _ | _ | _ | | | -|_____/|__| |_____|_____| __|___ | - |__| |_____| -''' - -USAGE='''\ -Usage: droopy [options] [PORT] - -Options: - -h, --help show this help message and exit - -d DIRECTORY, --directory DIRECTORY set the directory to upload files to - -m MESSAGE, --message MESSAGE set the message - -p PICTURE, --picture PICTURE set the picture - --dl provide download links - --save-config save options in a configuration file - --delete-config delete the configuration file and exit - -Example: - droopy -m "Hi, this is Bob. You can send me a file." -p avatar.png -''' - -picture = None -message = "" -port = 8686 -directory = os.curdir -must_save_options = False -publish_files = False - -# -- HTML templates - -style = '''''' - -userinfo = ''' -
- %(message)s - %(divpicture)s -
-''' - -maintmpl = '''%(maintitle)s -''' + style + ''' - - -%(linkurl)s -
-
-
- - - -
-
-
%(sending)s   - -
-
-
-
-''' + userinfo + ''' -%(files)s - -''' - -successtmpl = ''' - - %(successtitle)s -''' + style + ''' - - -
-
- %(received)s - %(another)s -
-
-''' + userinfo + ''' - - -''' - -errortmpl = ''' - - %(errortitle)s -''' + style + ''' - - -
-
- %(problem)s - %(retry)s -
-
-''' + userinfo + ''' - - -''' - -linkurltmpl = '''''' - - -templates = {"main": maintmpl, "success": successtmpl, "error": errortmpl} - -# -- Translations - -ar = {"maintitle": u"إرسال ملف", - "submit": u"إرسال", - "sending": u"الملف قيد الإرسال", - "successtitle": u"تم استقبال الملف", - "received": u"تم استقبال الملف !", - "another": u"إرسال ملف آخر", - "errortitle": u"مشكلة", - "problem": u"حدثت مشكلة !", - "retry": u"إعادة المحاولة", - "discover": u"اكتشاف عنوان هذه الصفحة"} - -cs = {"maintitle": u"Poslat soubor", - "submit": u"Poslat", - "sending": u"Posílám", - "successtitle": u"Soubor doručen", - "received": u"Soubor doručen !", - "another": u"Poslat další soubor", - "errortitle": u"Chyba", - "problem": u"Stala se chyba !", - "retry": u"Zkusit znova.", - "discover": u"Zjistit adresu stránky"} - -da = {"maintitle": u"Send en fil", - "submit": u"Send", - "sending": u"Sender", - "successtitle": u"Fil modtaget", - "received": u"Fil modtaget!", - "another": u"Send en fil til.", - "errortitle": u"Problem", - "problem": u"Det er opstået en fejl!", - "retry": u"Forsøg igen.", - "discover": u"Find adressen til denne side"} - -de = {"maintitle": "Datei senden", - "submit": "Senden", - "sending": "Sendet", - "successtitle": "Datei empfangen", - "received": "Datei empfangen!", - "another": "Weitere Datei senden", - "errortitle": "Fehler", - "problem": "Ein Fehler ist aufgetreten!", - "retry": "Wiederholen", - "discover": "Internet-Adresse dieser Seite feststellen"} - -el = {"maintitle": u"Στείλε ένα αρχείο", - "submit": u"Αποστολή", - "sending": u"Αποστέλλεται...", - "successtitle": u"Επιτυχής λήψη αρχείου ", - "received": u"Λήψη αρχείου ολοκληρώθηκε", - "another": u"Στείλε άλλο ένα αρχείο", - "errortitle": u"Σφάλμα", - "problem": u"Παρουσιάστηκε σφάλμα", - "retry": u"Επανάληψη", - "discover": u"Βρες την διεύθυνση της σελίδας"} - -en = {"maintitle": "Send a file", - "submit": "Send", - "sending": "Sending", - "successtitle": "File received", - "received": "File received !", - "another": "Send another file.", - "errortitle": "Problem", - "problem": "There has been a problem !", - "retry": "Retry.", - "discover": "Discover the address of this page"} - -es = {"maintitle": u"Enviar un archivo", - "submit": u"Enviar", - "sending": u"Enviando", - "successtitle": u"Archivo recibido", - "received": u"¡Archivo recibido!", - "another": u"Enviar otro archivo.", - "errortitle": u"Error", - "problem": u"¡Hubo un problema!", - "retry": u"Reintentar", - "discover": u"Descubrir la dirección de esta página"} - -fi = {"maintitle": u"Lähetä tiedosto", - "submit": u"Lähetä", - "sending": u"Lähettää", - "successtitle": u"Tiedosto vastaanotettu", - "received": u"Tiedosto vastaanotettu!", - "another": u"Lähetä toinen tiedosto.", - "errortitle": u"Virhe", - "problem": u"Virhe lahetettäessä tiedostoa!", - "retry": u"Uudelleen.", - "discover": u"Näytä tämän sivun osoite"} - -fr = {"maintitle": u"Envoyer un fichier", - "submit": u"Envoyer", - "sending": u"Envoi en cours", - "successtitle": u"Fichier reçu", - "received": u"Fichier reçu !", - "another": u"Envoyer un autre fichier.", - "errortitle": u"Problème", - "problem": u"Il y a eu un problème !", - "retry": u"Réessayer.", - "discover": u"Découvrir l'adresse de cette page"} - -gl = {"maintitle": u"Enviar un ficheiro", - "submit": u"Enviar", - "sending": u"Enviando", - "successtitle": u"Ficheiro recibido", - "received": u"Ficheiro recibido!", - "another": u"Enviar outro ficheiro.", - "errortitle": u"Erro", - "problem": u"Xurdíu un problema!", - "retry": u"Reintentar", - "discover": u"Descubrir o enderezo desta páxina"} - -hu = {"maintitle": u"Állomány küldése", - "submit": u"Küldés", - "sending": u"Küldés folyamatban", - "successtitle": u"Az állomány beérkezett", - "received": u"Az állomány beérkezett!", - "another": u"További állományok küldése", - "errortitle": u"Hiba", - "problem": u"Egy hiba lépett fel!", - "retry": u"Megismételni", - "discover": u"Az oldal Internet-címének megállapítása"} - -id = {"maintitle": "Kirim sebuah berkas", - "submit": "Kirim", - "sending": "Mengirim", - "successtitle": "Berkas diterima", - "received": "Berkas diterima!", - "another": "Kirim berkas yang lain.", - "errortitle": "Permasalahan", - "problem": "Telah ditemukan sebuah kesalahan!", - "retry": "Coba kembali.", - "discover": "Kenali alamat IP dari halaman ini"} - -it = {"maintitle": u"Invia un file", - "submit": u"Invia", - "sending": u"Invio in corso", - "successtitle": u"File ricevuto", - "received": u"File ricevuto!", - "another": u"Invia un altro file.", - "errortitle": u"Errore", - "problem": u"Si è verificato un errore!", - "retry": u"Riprova.", - "discover": u"Scopri l’indirizzo di questa pagina"} - -ja = {"maintitle": u"ファイル送信", - "submit": u"送信", - "sending": u"送信中", - "successtitle": u"受信完了", - "received": u"ファイルを受信しました!", - "another": u"他のファイルを送信する", - "errortitle": u"問題発生", - "problem": u"問題が発生しました!", - "retry": u"リトライ", - "discover": u"このページのアドレスを確認する"} - -ko = {"maintitle": u"파일 보내기", - "submit": u"보내기", - "sending": u"보내는 중", - "successtitle": u"파일이 받아졌습니다", - "received": u"파일이 받아졌습니다!", - "another": u"다른 파일 보내기", - "errortitle": u"문제가 발생했습니다", - "problem": u"문제가 발생했습니다!", - "retry": u"다시 시도", - "discover": u"이 페이지 주소 알아보기"} - -nl = {"maintitle": "Verstuur een bestand", - "submit": "Verstuur", - "sending": "Bezig met versturen", - "successtitle": "Bestand ontvangen", - "received": "Bestand ontvangen!", - "another": "Verstuur nog een bestand.", - "errortitle": "Fout", - "problem": "Er is een fout opgetreden!", - "retry": "Nog eens.", - "discover": "Vind het adres van deze pagina"} - -no = {"maintitle": u"Send en fil", - "submit": u"Send", - "sending": u"Sender", - "successtitle": u"Fil mottatt", - "received": u"Fil mottatt !", - "another": u"Send en ny fil.", - "errortitle": u"Feil", - "problem": u"Det har skjedd en feil !", - "retry": u"Send på nytt.", - "discover": u"Finn addressen til denne siden"} - -pl = {"maintitle": u"Wyślij plik", - "submit": u"Wyślij", - "sending": u"Wysyłanie", - "successtitle": u"Plik wysłany", - "received": u"Plik wysłany!", - "another": u"Wyślij kolejny plik.", - "errortitle": u"Problem", - "problem": u"Wystąpił błąd!", - "retry": u"Spróbuj ponownie.", - "discover": u"Znajdź adres tej strony"} - -pt = {"maintitle": u"Enviar um ficheiro", - "submit": u"Enviar", - "sending": u"A enviar", - "successtitle": u"Ficheiro recebido", - "received": u"Ficheiro recebido !", - "another": u"Enviar outro ficheiro.", - "errortitle": u"Erro", - "problem": u"Ocorreu um erro !", - "retry": u"Tentar novamente.", - "discover": u"Descobrir o endereço desta página"} - -pt_br = { - "maintitle": u"Enviar um arquivo", - "submit": u"Enviar", - "sending": u"Enviando", - "successtitle": u"Arquivo recebido", - "received": u"Arquivo recebido!", - "another": u"Enviar outro arquivo.", - "errortitle": u"Erro", - "problem": u"Ocorreu um erro!", - "retry": u"Tentar novamente.", - "discover": u"Descobrir o endereço desta página"} - -ro = {"maintitle": u"Trimite un fişier", - "submit": u"Trimite", - "sending": u"Se trimite", - "successtitle": u"Fişier recepţionat", - "received": u"Fişier recepţionat !", - "another": u"Trimite un alt fişier.", - "errortitle": u"Problemă", - "problem": u"A intervenit o problemă !", - "retry": u"Reîncearcă.", - "discover": u"Descoperă adresa acestei pagini"} - -ru = {"maintitle": u"Отправить файл", - "submit": u"Отправить", - "sending": u"Отправляю", - "successtitle": u"Файл получен", - "received": u"Файл получен !", - "another": u"Отправить другой файл.", - "errortitle": u"Ошибка", - "problem": u"Произошла ошибка !", - "retry": u"Повторить.", - "discover": u"Посмотреть адрес этой страницы"} - -sk = {"maintitle": u"Pošli súbor", - "submit": u"Pošli", - "sending": u"Posielam", - "successtitle": u"Súbor prijatý", - "received": u"Súbor prijatý !", - "another": u"Poslať ďalší súbor.", - "errortitle": u"Chyba", - "problem": u"Vyskytla sa chyba!", - "retry": u"Skúsiť znova.", - "discover": u"Zisti adresu tejto stránky"} - -sl = {"maintitle": u"Pošlji datoteko", - "submit": u"Pošlji", - "sending": u"Pošiljam", - "successtitle": u"Datoteka prejeta", - "received": u"Datoteka prejeta !", - "another": u"Pošlji novo datoteko.", - "errortitle": u"Napaka", - "problem": u"Prišlo je do napake !", - "retry": u"Poizkusi ponovno.", - "discover": u"Poišči naslov na tej strani"} - -sr = {"maintitle": u"Pošalji fajl", - "submit": u"Pošalji", - "sending": u"Šaljem", - "successtitle": u"Fajl primljen", - "received": u"Fajl primljen !", - "another": u"Pošalji još jedan fajl.", - "errortitle": u"Problem", - "problem": u"Desio se problem !", - "retry": u"Pokušaj ponovo.", - "discover": u"Otkrij adresu ove stranice"} - -sv = {"maintitle": u"Skicka en fil", - "submit": u"Skicka", - "sending": u"Skickar...", - "successtitle": u"Fil mottagen", - "received": u"Fil mottagen !", - "another": u"Skicka en fil till.", - "errortitle": u"Fel", - "problem": u"Det har uppstått ett fel !", - "retry": u"Försök igen.", - "discover": u"Ta reda på adressen till denna sida"} - -tr = {"maintitle": u"Dosya gönder", - "submit": u"Gönder", - "sending": u"Gönderiliyor...", - "successtitle": u"Gönderildi", - "received": u"Gönderildi", - "another": u"Başka bir dosya gönder.", - "errortitle": u"Problem.", - "problem": u"Bir problem oldu !", - "retry": u"Yeniden dene.", - "discover": u"Bu sayfanın adresini bul"} - -zh_cn = { - "maintitle": u"发送文件", - "submit": u"发送", - "sending": u"发送中", - "successtitle": u"文件已收到", - "received": u"文件已收到!", - "another": u"发送另一个文件。", - "errortitle": u"问题", - "problem": u"出现问题!", - "retry": u"重试。", - "discover": u"查看本页面的地址"} - -zh_tw = { - "maintitle": u"上傳檔案", - "submit": u"上傳", - "sending": u"傳送中...", - "successtitle": u"已收到檔案", - "received": u"已收到檔案!", - "another": u"上傳另一個檔案。", - "errortitle": u"錯誤", - "problem": u"出現錯誤!", - "retry": u"重試。", - "discover": u"查閱本網頁的網址"} - -translations = {"ar": ar, "cs": cs, "da": da, "de": de, "el": el, "en": en, - "es": es, "fi": fi, "fr": fr, "gl": gl, "hu": hu, "id": id, - "it": it, "ja": ja, "ko": ko, "nl": nl, "no": no, "pl": pl, - "pt": pt, "pt-br": pt_br, "ro": ro, "ru": ru, "sk": sk, - "sl": sl, "sr": sr, "sv": sv, "tr": tr, "zh-cn": zh_cn, - "zh-tw": zh_tw} - - -class DroopyFieldStorage(cgi.FieldStorage): - """The file is created in the destination directory and its name is - stored in the tmpfilename attribute. - """ - - TMPPREFIX = 'tmpdroopy' - - def make_file(self, binary=None): - fd, name = tempfile.mkstemp(dir=directory, prefix=self.TMPPREFIX) - self.tmpfile = os.fdopen(fd, 'w+b') - self.tmpfilename = name - return self.tmpfile - - -class HTTPUploadHandler(http.server.BaseHTTPRequestHandler): - - protocol_version = 'HTTP/1.0' - form_field = 'upfile' - form_realname = 'realname' - divpicture = '
' - - - def html(self, page): - """ - page can be "main", "success", or "error" - returns an html page (in the appropriate language) as a string - """ - - # -- Parse accept-language header - if "accept-language" not in self.headers: - a = [] - else: - a = self.headers["accept-language"] - a = a.split(',') - a = [e.split(';q=') for e in a] - a = [(lambda x: len(x)==1 and (1, x[0]) or - (float(x[1]), x[0])) (e) for e in a] - a.sort() - a.reverse() - a = [x[1] for x in a] - # now a is an ordered list of preferred languages - - # -- Choose the appropriate translation dictionary (default is english) - lang = "en" - for l in a: - if l in translations: - lang = l - break - dico = copy.copy(translations[lang]) - - # -- Set message and picture - if message: - dico["message"] = ('
%s
' % - message) - else: - dico["message"] = "" - - if picture != None: - dico["divpicture"] = self.divpicture - else: - dico["divpicture"] = "" - - # -- Possibly provide download links - links = "" - names = self.published_files() - if names: - for name in names: - links += '%s
' % ( - urllib.parse.quote(name.encode('utf-8')), - name) - links = '
' + links + '
' - dico["files"] = links - - # -- Add a link to discover the url - if self.client_address[0] == "127.0.0.1": - dico["port"] = self.server.server_port - dico["linkurl"] = linkurltmpl % dico - else: - dico["linkurl"] = "" - - return templates[page] % dico - - - def do_GET(self): - name = self.path.lstrip('/') - name = urllib.parse.unquote(name) - name = name.decode('utf-8') - - if picture != None and self.path == '/__droopy/picture': - # send the picture - self.send_file(picture) - - elif name in self.published_files(): - localpath = os.path.join(directory, name) - self.send_file(localpath) - - else: - self.send_html(self.html("main")) - - - def do_POST(self): - # Do some browsers /really/ use multipart ? maybe Opera ? - try: - self.log_message("Started file transfer") - - # -- Set up environment for cgi.FieldStorage - env = {} - env['REQUEST_METHOD'] = self.command - if self.headers.typeheader is None: - env['CONTENT_TYPE'] = self.headers.type - else: - env['CONTENT_TYPE'] = self.headers.typeheader - - # -- Save file (numbered to avoid overwriting, ex: foo-3.png) - form = DroopyFieldStorage(fp = self.rfile, environ = env); - fileitem = form[self.form_field] - realname="" - if self.form_realname in list(form.keys()): - realname = form[self.form_realname].value.decode('utf-8') - if realname=="": - filename = self.basename(fileitem.filename).decode('utf-8') - else: - self.log_message("Got realname: %s", realname) - filename=self.basename(realname) - - if filename == "": - self.send_response(303) - self.send_header('Location', '/') - self.end_headers() - return - - localpath = os.path.join(directory, filename).encode('utf-8') - root, ext = os.path.splitext(localpath) - i = 1 - # race condition, but hey... - while (os.path.exists(localpath)): - localpath = "%s-%d%s" % (root, i, ext) - i = i+1 - if hasattr(fileitem, 'tmpfile'): - # DroopyFieldStorage.make_file() has been called - fileitem.tmpfile.close() - shutil.move(fileitem.tmpfilename, localpath) - else: - # no temporary file, self.file is a StringIO() - # see cgi.FieldStorage.read_lines() - fout = file(localpath, 'wb') - shutil.copyfileobj(fileitem.file, fout) - fout.close() - self.log_message("Received: %s", os.path.basename(localpath)) - - # -- Reply - if publish_files: - # The file list gives a feedback for the upload - # success - self.send_response(301) - self.send_header("Location", "/") - self.end_headers() - else: - self.send_html(self.html("success")) - - except Exception as e: - self.log_message(repr(e)) - self.send_html(self.html("error")) - - - def send_html(self, htmlstr): - self.send_response(200) - self.send_header('Content-type','text/html; charset=utf-8') - self.end_headers() - self.wfile.write(htmlstr.encode('utf-8')) - - def send_file(self, localpath): - f = open(localpath, 'rb') - self.send_response(200) - self.send_header('Content-type', - mimetypes.guess_type(localpath)[0]) - self.send_header('Content-length', os.fstat(f.fileno())[6]) - self.end_headers() - shutil.copyfileobj(f, self.wfile) - - def basename(self, path): - """Extract the file base name (some browsers send the full file path). - """ - for mod in posixpath, macpath, ntpath: - path = mod.basename(path) - return path - - def published_files(self): - """Returns the list of files that should appear as download links. - - The returned filenames are unicode strings. - """ - if publish_files: - # os.listdir() returns a list of unicode strings when the - # directory is passed as an unicode string itself. - names = [name for name in os.listdir(str(directory)) - if os.path.isfile(os.path.join(directory, name)) - and not name.startswith(DroopyFieldStorage.TMPPREFIX)] - names.sort() - else: - names = [] - return names - - def handle(self): - try: - http.server.BaseHTTPRequestHandler.handle(self) - except socket.error as e: - self.log_message(str(e)) - raise Abort() - - -class Abort(Exception): pass - - -class ThreadedHTTPServer(socketserver.ThreadingMixIn, - http.server.HTTPServer): - - def handle_error(self, request, client_address): - # Override SocketServer.handle_error - exctype = sys.exc_info()[0] - if not exctype is Abort: - http.server.HTTPServer.handle_error(self,request,client_address) - - -# -- Options - -def configfile(): - appname = 'droopy' - # os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos' - if os.name == 'posix': - filename = "%s/.%s" % (os.environ["HOME"], appname) - - elif os.name == 'mac': - filename = ("%s/Library/Application Support/%s" % - (os.environ["HOME"], appname)) - - elif os.name == 'nt': - filename = ("%s\%s" % (os.environ["APPDATA"], appname)) - - else: - filename = None - - return filename - - -def save_options(): - opt = [] - if message: - opt.append('--message=%s' % message.replace('\n', '\\n')) - if picture: - opt.append('--picture=%s' % picture) - if directory: - opt.append('--directory=%s' % directory) - if publish_files: - opt.append('--dl') - if port: - opt.append('%d' % port) - f = open(configfile(), 'w') - f.write('\n'.join(opt).encode('utf8')) - f.close() - - -def load_options(): - try: - f = open(configfile()) - cmd = [line.strip().decode('utf8').replace('\\n', '\n') - for line in f.readlines()] - parse_args(cmd) - f.close() - return True - except IOError as e: - return False - - -def parse_args(cmd=None): - """Parse command-line arguments. - - Parse sys.argv[1:] if no argument is passed. - """ - global picture, message, port, directory, must_save_options, publish_files - - if cmd == None: - cmd = sys.argv[1:] - lang, encoding = locale.getdefaultlocale() - if encoding != None: - cmd = [a.decode(encoding) for a in cmd] - - opts, args = None, None - try: - opts, args = getopt.gnu_getopt(cmd, "p:m:d:h", - ["picture=","message=", - "directory=", "help", - "save-config","delete-config", - "dl"]) - except Exception as e: - print(e) - sys.exit(1) - - for o,a in opts: - if o in ["-p", "--picture"] : - picture = os.path.expanduser(a) - - elif o in ["-m", "--message"] : - message = a - - elif o in ['-d', '--directory']: - directory = a - - elif o in ['--save-config']: - must_save_options = True - - elif o in ['--delete-config']: - try: - filename = configfile() - os.remove(filename) - print('Deleted ' + filename) - except Exception as e: - print(e) - sys.exit(0) - - elif o in ['--dl']: - publish_files = True - - elif o in ['-h', '--help']: - print(USAGE) - sys.exit(0) - - # port number - try: - if args[0:]: - port = int(args[0]) - except ValueError: - print(args[0], "is not a valid port number") - sys.exit(1) - - -# -- - -def run(): - """Run the webserver.""" - socket.setdefaulttimeout(3*60) - server_address = ('', port) - httpd = ThreadedHTTPServer(server_address, HTTPUploadHandler) - httpd.serve_forever() - - -if __name__ == '__main__': - print(LOGO) - - config_found = load_options() - parse_args() - - if config_found: - print('Configuration found in %s' % configfile()) - else: - print("No configuration file found.") - - if must_save_options: - save_options() - print("Options saved in %s" % configfile()) - - print("Files will be uploaded to %s" % directory) - try: - print() - print("HTTP server running... Check it out at http://localhost:%d"%port) - run() - except KeyboardInterrupt: - print('^C received, shutting down server') - # some threads may run until they terminate diff --git a/web/droopysend b/web/droopysend deleted file mode 100755 index 25a965d..0000000 --- a/web/droopysend +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -#droopy uploader - -IP=128.214.60.230 -PORT=8686 - -function show_error() { - echo Cannot access $IP:$PORT - exit 1 -} - - -for f in $@ -do a=$( readlink -f "$f" ) - b=$( basename "$f" ) - [[ -f "$a" ]] && { - curl -X POST -F upfile=@"$f" http://$IP:$PORT/ || show_error - } - [[ -d "$a" ]] && { - curl -X POST -F upfile=@<( tar cz "$f" ) -F realname="$b".tgz http://$IP:$PORT/ || show_error - } -done - - diff --git a/web/index.php b/web/index.php deleted file mode 100644 index 701afb5..0000000 --- a/web/index.php +++ /dev/null @@ -1,90 +0,0 @@ -'.$title.' - - - -'; - - -//////////////////////////////////////////// script starts ///////////////// - -function normal($header, $content, $linkcontent,$pre,$preurl) { -echo $header; - -$sum=0; -echo "

".basename(dirname($_SERVER['PHP_SELF']))."

"; -echo ''; -echo "
FileSizeModified\r\n"; -if (is_file("../index.php") || is_file("../index.html")) { - echo "
..[DIR]\r\n"; -} -foreach ($content as $k => $v) { - if (is_dir($pre.$v)) { - $name = htmlentities(rtrim($v)); - $linkname = $preurl.rtrim($linkcontent[$k]); - $date=date("Y-m-d H:i",filemtime($pre.$name)); - echo "
$name[DIR]$date\r\n"; - } -} -foreach ($content as $k => $v) { - if (is_file($pre.$v)) { - $name = htmlentities(rtrim($v)); - $linkname = $preurl.rtrim($linkcontent[$k]); - $size = filesize($pre.$name); - $sum = $sum + $size; - $j = 0; $ext = array("B","kB","MB","GB","TB","PB"); - while ($size >= pow(1024,$j)) ++$j; - $size = round($size / pow(1024,$j-1) * 100) / 100 . " ".$ext[$j-1]; - $date=date("Y-m-d H:i",filemtime($pre.$name)); - echo "
$name $size $date\r\n"; - } -} -echo "\r
"; -echo ""; - -// end of "normal" function -} - -/// Let's put the files in $content... -$d = dir($dirr); -$i=0; -while ($filename = $d->read()) { - if ($filename == "index.php") { continue; } - if (substr($filename,0,1) == ".") { continue; } - $content[$i] = $filename; - $linkcontent[$i] = rawurlencode($content[$i]); - $i++; -} -$d->close(); -// Rid of unwanted files.... - -array_multisort($content,$linkcontent); - -normal($header,$content, $linkcontent,$dirr,$pre); - -?> diff --git a/web/scotty b/web/scotty deleted file mode 100755 index 4f9a026..0000000 --- a/web/scotty +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -_help() { - echo '# Scotty v.5 - -Scotty is the most simple network file transfer utility. It provides -no security what so ever. - -To expose a file/folder for anyone to catch: -* scotty up [folder/file name] -* Pick the hostname from the printed list, and send it to the receiver. - -To download the exposed folder/file: -* scotty down [sender host name] -* Download happens to the current working directory. -* By default, any existing file is overwritten. - -Add tar options by modifying a variable: -* SCOTTY_TAR="pass your tar options here" scotty ... - -Scotty uses port '$PORT' to transfer files. Downloading host needs -to see the uploader directly. -' -exit -} - -PORT=60006 -[[ -z "$2" ]] && _help -[[ "$1" = "-h" ]] && _help - -PV=cat -which pv &> /dev/null && PV=pv - -[[ "$1" = up ]] && { -echo Beam me up, Scotty. Waiting for someone to beam $( hostname ) down... -printf "\n| %15s | %s\n" IP Hostname -for addr in $( hostname -I ); do - printf "| %15s | %s\n" $addr $( dig +short -x $addr ) -done -echo Scotty, beam $( hostname ) down | nc -l $PORT -echo Transporter locking to signature -tar -cv $SCOTTY_TAR "$2" | $PV | nc -l $PORT -} -[[ "$1" = down ]] && { -nc -w 10 "$2" $PORT -sleep 0.5 -nc -w 10 "$2" $PORT | $PV | tar -x $SCOTTY_TAR -} -true