Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /home/ift/52_procpy/fibu/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : //home/ift/52_procpy/fibu/acc_kto.py

#  coding:  utf8

import os,sys,re,glob,time,datetime
import codecs
import random
import sqlite3
import base64
import hashlib

#******************************************************************************

class Acc_kto (object):

    def __init__ (self,filename,db=None,rules=None):
    
        self.filename = filename
        self.db       = db
        self.rules    = rules

#********************************************************************************

    def mark (self,remark=""):
    
        t = time.clock()
        if 't0' in vars(self):
            print ("%13.9f" % (t-self.t0)) + "  " + remark
        self.t0 = t

#********************************************************************************

    def xxread (self):
    
        m = re.search(r"^(.*)[\\\/](.*)$",self.filename)
        if m:
            self.ktodir   = m.group(1)
            self.uktofile = m.group(2)
        else:
            self.ktodir   = ""
            self.uktofile = self.filename
        
        m      = re.search(r"^(.*)\.(kto|xlsx)$",self.uktofile)
        if m:
            self.uktoroot = m.group(1)
            self.uktoend  = m.group(2)
        else:
            self.error    = "ERROR 111. This is not a report file."
            return()
        
        m = re.search(r"^(.*)\_\_(.*)$",self.uktoroot)
        if m:
            self.uktoname = m.group(2)
            self.ukto1    = m.group(1)
        else:
            self.uktoname = ""
            self.ukto1    = self.uktoroot
        
        if self.uktoend == "kto":
            self.read_report_kto()
        elif self.uktoend == "xlsx":
            self.read_report_xlsx()
            
        self.error = "OK."
        
#********************************************************************************

    def read_report_kto (self):
    
        m = re.search(r"^(.*)[\\\/](.*)",self.filename)
        if m:
            self.ktodir = m.group(1)
        else:
            self.ktodir = "."

        text = open(self.filename).read()
        m = re.search(r"^(.*?\n|)(\S*) +\((.*?)\) +([0123456789,]+) +(.*?)\n +([^\n]*?)(\-?\d+\.\d\d) *\n(.*)$",text,re.DOTALL)

        if m:
            self.report_header = m.group(1)
            self.ukto          = m.group(2)
            self.dbhash        = m.group(3)[0:6]
            self.ktohash       = m.group(3)[6:]
            interval           = m.group(4)
            self.rule          = m.group(5).strip()
            self.uname         = m.group(6)
            self.sollwert      = m.group(7)
        else:
            self.error = "ERROR 112. Kto-Format not valid." 
            return()
        
        m1 = re.search(r"^(.*),(.*)$",interval)
        if m1:
            self.start = m1.group(1)
            self.ende  = m1.group(2)
        else:
            self.start = interval
            self.ende  = interval
        self.start = (self.start + "00000000")[0:8]
        self.ende  = (self.ende  + "99999999")[0:8]

        self.ukto1 = self.ukto + "-"
        if self.ukto1 == "-":
            self.ukto1 = ""        
        
        self.text = []
        text      = self.rules.__class__.__dict__[self.rule](self.rules,m.group(8))

        for zeile in text.split("\n"):
            m = re.search(r"^(\d\d\d\d\d\d\d\d) +(\-?\d+\.\d\d) +(\S*) +(\S+) +(\-?\d+\.\d\d) +(.*)$",zeile)
            if m:
                datum  = m.group(1)
                betrag = str(m.group(2))
                ktoa   = re.sub(r"^-",self.ukto+"-",m.group(3)).strip("-") + "-"
                ktob   = re.sub(r"^-",self.ukto+"-",m.group(4)).strip("-") + "-"
                if ktoa == "-":
                    ktoa = ""
                if ktob == "-":
                    ktob = ""
                remark = m.group(6)
                self.text.append(datum+"|"+betrag+"|"+ktoa+"|"+ktob+"|"+remark.strip())

        print self.text

        self.ktohash_new = self.compute_ktohash()

#********************************************************************************

    def compute_ktohash (self):

        addfiles  = glob.glob(self.ktodir+"/*")
        addtext   = ""
        for addfile in addfiles:
            if re.search(r"\.kto$",addfile) or "EXCLUDE" in addfile or "~" in addfile:
                continue
            addtext = addtext + base64.urlsafe_b64encode(hashlib.md5(open(self.ktodir+"/"+addfile).read()).digest())
        addfiles =  ",".join(addfiles)
        ktohash  = base64.urlsafe_b64encode(hashlib.md5(addfiles+" ".join(self.text)).digest())[0:6]
        return(ktohash)

#********************************************************************************

    def compute_dbhash (self):

        qu_string = ("select group_concat(KTOA),group_concat(KTOB),group_concat(REMARK) from " +
                     "buchungen" + " where (KTOA like '" + self.ukto1 + "%' or KTOB like '" + self.ukto1 + "%') " +
                     " and DATUM >= '" + self.start + "' and DATUM <= '" + self.ende + "' " +
                     " order by DATUM,KTOA,KTOB") 
        cursor = self.db.cursor()
        cursor.execute(qu_string)
        text1 = cursor.fetchone()
        ktohash_new = [""]
        for o in text1:
            if o:
                ktohash_new.append(re.sub(r" +"," ",o,99999999))
        if ktohash_new == [""]:
            ktohash_new = "xxxxxx"    #   wenn es gar keine Buchungen im Unterkonto gibt, dann ktohash auf "xxxxxx" setzen
        else:
            ktohash_new = base64.urlsafe_b64encode(hashlib.md5("".join(ktohash_new).encode("utf8")).digest())[0:6]
        return(ktohash_new)


#********************************************************************************

    def store_to_db (self):
    
        for zeile in self.text:
            qstr   = ("insert into buchungen (DATUM,BETRAG,KTOA,KTOB,REMARK) values " +
                    "('" + re.sub(r"\|","','",zeile,99) + "')")
            self.db.cursor().execute(qstr)

#********************************************************************************

    def get_from_db (self):

        cursor       = self.db.cursor()
        query_string =                "select DATUM,BETRAG,KTOA,KTOB,REMARK from buchungen "
        query_string = query_string + " where (KTOA like '" + self.ukto1 + "%' or KTOB like '" + self.ukto1 + "%')"
        query_string = query_string + " order by DATUM,KTOA,KTOB" 
        cursor.execute(query_string)
        print self.ukto1 , " <--- UKTO"

        gesamt = 0.00
        text   = []
        maxa   = 0
        maxb   = 0
            
        while (0 == 0):    #  Zeilen des Kontos schreiben
           
            entry  = cursor.fetchone()
            print entry
            if not entry:
                break
#            print entry
            betrag = float(entry[1])
            ktoa   = entry[2][:-1]
            ktob   = entry[3][:-1]
            ul     = len(ukto)

            anz     = 0
            if ktoa[0:ul] == ukto:
                ktoa = ktoa[ul:]
                if ktoa == "":
                    ktoa = "-"
                anz = anz + 1
            if ktob[0:ul] == ukto:
                ktob = ktob[ul:]
                if ktob == "":
                    ktob = "-"
                if anz == 0:
                    o      = ktoa
                    ktoa   = ktob
                    ktob   = o
                    betrag = -betrag
                anz = anz + 1
         
            if True or anz == 1:
                datum  = entry[0]
                remark = entry[4]
                maxa  = max(maxa,len(ktoa))
                maxb  = max(maxb,len(ktob))
                text.append("|".join([entry[0],betrag,ktoa,ktob,entry[4]]))
            

        maxa = "%-" + str(max(9,maxa)) + "s"
        maxb = "%-" + str(max(9,maxb)) + "s"
        print text
#        text.sort(key=self.sort_konten)



#        zaehler = 0
#        gesamt  = 0.00
#        while zaehler < len(text):
#            gesamt = gesamt + float(text[zaehler][1])
#            text[zaehler] = (  text[zaehler][0] +  " " + ("%13.2f" % text[zaehler][1]) + "  " +
#                                (maxa % text[zaehler][2])  + "  " +  (maxb % text[zaehler][3]) + "  " +
#                                ("%13.2f" % gesamt) + "  " + text[zaehler][4] )
#            zaehler = zaehler + 1
#            
#        text     = "\n".join(text)+"\n"
#        print text

        
        
#if __name__ == "__main__":
#    Account.__dict__[sys.argv[1]](Account(),*sys.argv[2:])

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net