Exemplo n.º 1
0
def update_prv_pub(vv):
    ss = vv.split("ftr")
    uu="-1"
    if ss[1]=='true':
        uu = py_db.user_id
    py_db.executesql("update tbl_tels set t_private_user_id = '{0}' where t_id={1}".format(uu,ss[0]))
    print "ok"
Exemplo n.º 2
0
def insert(str):
    _str = str.split("__")
    uid = -1
    if _str[12].split("ffdd")[1] == "private":
        uid = py_db.user_id
        
    
    sqlstr = """
    INSERT INTO `automation`.`tbl_tels`
            (
             `t_sazman`,
             `t_name`,
             `t_semat`,
             `t_mozoo`,
             `t_tel`,
             `t_fax`,
             `t_mob`,
             `t_email`,
             `t_site`,
             `t_address`,
             `t_exp`,
             t_private_user_id)
             
VALUES (
        '{0}',
        '{1}',
        '{2}',
        '{3}',
        '{4}',
        '{5}',
        '{6}',
        '{7}',
        '{8}',
        '{9}',
        '{10}',
        '{11}'
        
        );
    
    """.format(_str[1].split("ffdd")[1],
               _str[2].split("ffdd")[1],
               _str[3].split("ffdd")[1],
               _str[4].split("ffdd")[1],
               _str[5].split("ffdd")[1],
               _str[6].split("ffdd")[1],
               _str[7].split("ffdd")[1],
               _str[8].split("ffdd")[1],
               _str[9].split("ffdd")[1],
               _str[10].split("ffdd")[1],
               _str[11].split("ffdd")[1],
               uid,
               
               
               )
   # print sqlstr
    
    py_db.executesql(sqlstr)
    ss = "select t_id from tbl_tels where t_sazman = '{0}' order by t_id desc limit 1".format(_str[1].split("ffdd")[1])
    print "ok__"+py_db.executeAndReturnRows(ss)[0][0].__str__()
def do_insert(param):
    #name:user:comname:possst:false:true:possst
    param = param.replace('false','0')
    param = param.replace('true','1')
    param = param.replace('false','0')
    param = param.replace('true','1')
    user_assistant_u_id=-1
    if param.split(":")[5]=="1":
        sqlstr='''
    select u_id from tbl_users where u_complete_name = '{0}' limit 1
        '''.format(param.split(":")[6]);
        
        db=py_db.GetDB()
        cur=db.cursor();
        cur.execute(sqlstr)
        rows = cur.fetchall()
        for row in rows:
            user_assistant_u_id = row[0]
            
        
    
    sqlstr = '''
    INSERT INTO `tbl_users` 
    (`u_name`,`u_pass`,
    `u_secretariat_group_link`,`u_complete_name`,
    `u_org_post`,`u_active`,
    `u_has_assist`,`u_link_to_user_assistant`,
    u_direct
    
    )
    VALUES
    ('{0}','{1}',{2},'{3}','{4}',{5},{6},{7},{8}
    
    )
    '''.format(
        param.split(":")[0],
        param.split(":")[1],
        param.split(":")[8],
        param.split(":")[2],
        param.split(":")[3],
        param.split(":")[4],
        param.split(":")[5],
        user_assistant_u_id.__str__(),
        param.split(":")[7]
        )
    
    
    
    print 'Content-Type: text/html; charset=utf-8'
    print ''
#    print sqlstr
    py_db.executesql(sqlstr)
    
    print "1"
def answ(name,items):
    py_db.executesql("insert into tbl_users_related_groups (urg_title) values ('{0}');".format(name))
    row = py_db.executeAndReturnRows("select urg_id from tbl_users_related_groups where urg_title='{0}'".format(name));
    f=[]
    f=items.split("gfhjdg");
    print 'Content-Type: text/html; charset=utf-8'
    print ''
    for item in f:
        py_db.executesql("insert into tbl_users_related_groups_member (urgm_link_to_users,urgm_link_to_groups) values ({0},{1})".format(item,row[0][0]))
       # print("insert into tbl_users_related_groups_member (urgm_link_to_users,urgm_link_to_groups) values ({0},{1})".format(item,row[0][0]))
    

    print "ok"
def do_update(param):
    param = param.replace('false','0')
    param = param.replace('true','1')
    param = param.replace('false','0')
    param = param.replace('true','1')
    user_assistant_u_id=-1
    drf=py_db.ifIntNullThen(param.split(":")[6].__str__()).__str__()
    d=py_db.do_edit("update","tbl_users",
              [["u_name","u_pass","u_secretariat_group_link","u_complete_name",
                "u_org_post","u_active","u_has_assist","u_link_to_user_assistant","u_direct"],
              [
               param.split(":")[0],
               param.split(":")[1],
               param.split(":")[8],
               param.split(":")[2],
               param.split(":")[3],
               param.split(":")[4],
               param.split(":")[5],
               drf,
               param.split(":")[7]
               ],
              [0,0,0,0,0,0,0,1,0]],
              "yes",[
              ["tbl_users ,u_id,u_complete_name,u_id,{0},u_link_to_user_assistant".format(drf)]]
              ,"u_name",param.split(":")[0])
    i=py_db.executesql(d)
    print 'Content-Type: text/html; charset=utf-8'
    print ''
    print i
def capture_gps_to_db(uid,filecontent):
    str_arr = []
    sqlins =""
    bhr=[]
    str_arr = filecontent.split("$")
    total_date = '1998-01-01'
    speed="0"
    _tpe="0"
    x="0"
    y="0"
    z="0"
    sat_count="0"
    ic=0
    
    for i in str_arr:
        ic=ic+1
        ss=[]
        #pp=[]
        ss=i.split(",")
        if ss[0] == "GPGGA":
            _tpe = "1"
            timestamp = ss[1]
            sat_count = ss[7]
            x=conver_decimal_min_to_decimal_degree(float(find_pos(ss,"E")))
            y=conver_decimal_min_to_decimal_degree(float(find_pos(ss,"N")))
            z=float(find_pos(ss,"M"))
    
        if ss[0] == "GPRMC":
            _tpe = "2"
            timestamp = convert_timestamp(ss[1])
            validity = ss[2]
            x=conver_decimal_min_to_decimal_degree(float(find_pos(ss,"E")))
            y=conver_decimal_min_to_decimal_degree(float(find_pos(ss,"N")))
            speed=float(ss[7])
            true_course=ss[8]
            datestamp =convert_datestamp(ss[9])
            eastwest=ss[10]
            total_date = convert_stamped_to_datetime(datestamp,timestamp)
        prmmm = """insert into tbl_gps_positions (g_type,g_x,g_y,g_z,g_sat_count,g_date,g_speed,g_user_id,g_date_post,g_uploaded_user_id)  values  ('{0}','{1}','{2}','{3}','{4}',ADDTIME('{5}','3:30:00'),'{6}','{7}','{8}','{9}');""".format(_tpe,x,y,z,sat_count,total_date,speed,uid,datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),"-1")
        sqlins = prmmm
        py_db.executesql(sqlins)
        print "|"
    
    
    return  len(str_arr)
Exemplo n.º 7
0
def edit_data(_id,line):
    _str = line.split("__")
    uid = -1
    if _str[12].split("ffdd")[1] == "private":
        uid = py_db.user_id
        
    
    sqlstr = """
    update `automation`.`tbl_tels`
            set
             `t_sazman`='{0}',
             `t_name`='{1}',
             `t_semat`='{2}',
             `t_mozoo`='{3}',
             `t_tel`='{4}',
             `t_fax`='{5}',
             `t_mob`='{6}',
             `t_email`='{7}',
             `t_site`='{8}',
             `t_address`='{9}',
             `t_exp`='{10}',
             `t_private_user_id`='{12}'

             where t_id = '{11}'
             

    
    """.format(_str[1].split("ffdd")[1],
               _str[2].split("ffdd")[1],
               _str[3].split("ffdd")[1],
               _str[4].split("ffdd")[1],
               _str[5].split("ffdd")[1],
               _str[6].split("ffdd")[1],
               _str[7].split("ffdd")[1],
               _str[8].split("ffdd")[1],
               _str[9].split("ffdd")[1],
               _str[10].split("ffdd")[1],
               _str[11].split("ffdd")[1],
               _id,
               uid,
               )
    py_db.executesql(sqlstr)
    _str = send_tr(_id)
    print _str
def updateusrprm(param,uid):
    py_db.checkAccessCookie()
    py_db.checkuser(5,py_db.username)
    __form = cgi.FieldStorage()
    sel_uid = py_db.get_userID_from_uname(uid)
    
    sd=param.split("bbb")
    py_db.executesql("delete from tbl_module_premission where m_user_link = "+sel_uid)
    for row in sd:
        s="3"
        if (row.split("=~")[1].__str__())== "true":s="1"
        py_db.executesql("""
                         insert into tbl_module_premission
                         (`m_module_link`,`m_user_link`,`m_type_of_view`)
                         values
                         ({0},{1},{2}) 
                         """.format(row.split("=~")[0].__str__(),
                                    sel_uid,s))
    print 'Content-Type: text/html; charset=utf-8'
    print ''
    print "1"      
def insert_into_erja(param1,l_id):
    st=param1
    #print st
    st=st[3:len(st)]
    #print st
    st=param1.split("zzz")
    for s in st:
        sr=s.split(")))")
        if len(s)<>0:
            hidd=1
            if sr[1][0:2]=="**":
                hidd=2
            py_db.executesql("""
                             
            UPDATE tbl_inbox
            set i_position= 3
            WHERE i_active_user_link={1} and 
            i_letter_link = {0}
            
            
            
            
                             """.format(l_id,py_db.user_id)
                             )
            sqlstr = """
            
        INSERT INTO `automation`.`tbl_inbox`
            (
             `i_letter_link`,
             `i_position`,
             `i_date_of_create`,
             
             `i_active_user_link`,
             `i_order`,
        
             `i_prev_active_user_link`,
             `i_erja_type`)
VALUES (
        '{0}',
        '1',
        '{1}',

 (
 
 
SELECT 
CASE t1.u_direct
WHEN 0 THEN {2}
WHEN 1 THEN 
	CASE  (SELECT t3.`u_has_assist` FROM tbl_users t3 WHERE t3.u_id={2})
	WHEN 0 THEN {2}
	WHEN 1 THEN 
		CASE  (SELECT t5.u_link_to_user_assistant FROM tbl_users t5 WHERE t5.u_id={2})
		WHEN {5} THEN {2}
		ELSE (SELECT t2.u_id FROM tbl_users t2 WHERE t2.u_id = (SELECT t3.`u_link_to_user_assistant` FROM tbl_users t3 WHERE t3.u_id={2}) LIMIT 1)
		END
	END 
END AS ssss
 FROM tbl_users t1 WHERE t1.u_id={5}
 
        )
        
        ,
        '{3}',
        
        {5},
        '{4}'
        );
            
            
            """.format(
                l_id,
                datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                sr[0],
                sr[1],
                hidd,
                py_db.user_id
                )
            
    
            py_db.executesql(sqlstr);
    
    




    print 'Content-Type: text/html; charset=utf-8'
    print ''
    #print sqlstr
    print "1"
Exemplo n.º 10
0
def do_insert(_param):
    print "Content-Type: text/html"
    print
    sqlstr = ""
    main_rows = _param.split("[[[a")
    data_field = main_rows[0].split("91A1")
    sqlstr = "'{0}','{1}','{2}','{3}'".format(
        chk_n(data_field[0]), chk_n(data_field[1]), chk_n(data_field[2]), chk_n(data_field[3])
    )

    fs = """
    INSERT INTO `automation`.`tbl_sale_kharidha`
            (`sk_link_to_company`,
             `sk_namayande_sherkat`,
             `sk_link_faaliat`,
             `sk_tel_no`)
    VALUES (
        {0}); 
        
    """.format(
        sqlstr
    )

    py_db.executesql(fs)
    new_id = py_db.executeAndReturnRows("select sk_id from tbl_sale_kharidha  order by sk_id desc limit 1")[0][
        0
    ].__str__()

    sqlstr_details = " DELIMITER ; "
    if main_rows[1] == "":
        print "no_item"
        return
    for row in main_rows[1].split("al12c"):
        row_arr = row.split(",")
        py_db.executesql(
            """
                         insert into `automation`.`tbl_sale_kharidha_details`
            (
             `skd_link_to_kharid_ha`,
             `skd_zekhamate_varagh`,
             `skd_arz`,
             `skd_tool`,
             `skd_mizan`,
             `skd_zekhamte_ghal`,
             `skd_shekle_varagh`,
             skd_date_kharid)
values (
        '{0}',
        '{1}',
        '{2}',
        '{3}',
        '{4}',
        '{5}',
        '{6}',
        '{7}');
        """.format(
                new_id,
                chk_n(row_arr[0]),
                chk_n(row_arr[1]),
                chk_n(row_arr[2]),
                chk_n(row_arr[3]),
                chk_n(row_arr[4]),
                chk_n(row_arr[5]),
                chk_n(row_arr[6]),
            )
        )
        # al12c

    print "ok"
Exemplo n.º 11
0
## when user enters to letter the letter must change to read
#
sqls ='''
UPDATE `automation`.`tbl_inbox`
SET 
  `i_position` = '2',
  `i_date_of_seen` = '{2}'
WHERE
i_letter_link = {0} and
i_position='1' and
i_active_user_link={1}

'''.format(
           dt,
           py_db.user_id,
           py_db.get_datetime_of_now()
           
           );
#print sqls
py_db.executesql(sqls)



if dta<>"xcc":
    print "hey"




Exemplo n.º 12
0
import Cookie
import os
from pyDes import *
import cgi
import sys
import cgitb

cgitb.enable(display=0, logdir="c:\cgilog.txt")


def ord_validation_mapping(hashed_text):
    txt = ""
    for i in list(hashed_text):
        txt += " " + ord(i).__str__()
    return txt


rows = py_db.executeAndReturnRows("select * from sheet2")
for row in rows:
    if row[2] is not None:
        if len(row[2].__str__()) > 0:
            ss = row[2]
            ss = ss.replace("ي", "ی")
            ss = ss.replace("ك", "ک")
            py_db.executesql("update sheet2 set cd3='{0}' where id = '{1}'".format(ss, row[0]))
            print row[0]


# print ord_validation_mapping("ك")
# print ord_validation_mapping("ک")+"  <<< "
message = ""
i = 0
uploadedFileName = []

for fileitem in fileitemArr:
    if fileitem.filename:
        i += i + 1
        # uuid.uuid1()
        # strip leading path from file name to avoid directory traversal attacks
        s = "abs" + str(uuid.uuid1())

        fn = os.path.basename(s + "_" + fileitem.filename)
        open("files/" + fn, "wb").write(fileitem.file.read())
        uf = []
        uf.append("file" + str(i))
        uf.append(fileitem.filename)
        uf.append(s + "_" + fileitem.filename)
        uploadedFileName.append(uf)
        message += 'The file "' + fileitem.filename + '" was uploaded successfully' + "<br/>"
        # 1=richtext 2=scan 3=attachment 4=related letter id
        py_db.executesql(
            "insert into tbl_letters_papers (lp_type,lp_address,lp_link_to_letters) values (2,'{0}',{1}) ".format(
                s + "_" + fileitem.filename, id
            )
        )

print "Location: py_main.py?mid=2&id=" + id
print ""
# print message
# print uploadedFileName
Exemplo n.º 14
0


form = cgi.FieldStorage()
uname=form.getvalue("xsa","")






#print 'Content-Type: text/html; charset=utf-8'
#print ''

if uname<>"":
    de=uname.split("szzas");
    if de[2]==de[3]:
        py_db.executesql("""
            update tbl_users set `u_pass`='{0}'
            where u_name='{1}' and u_pass='******'""".format(de[2],de[0],de[1])
        )
    print 'Content-Type: text/html; charset=utf-8'
    print ''
    
    
    
    
    


#print ''
#!d:/Python27/python.exe -u
# -*- coding: UTF-8 -*-

import cgi, os
import cgitb; cgitb.enable()
import uuid
import py_db

print 'Content-Type: text/plain'
print ''

form = cgi.FieldStorage()

dt=form.getvalue("id")

py_db.executesql("delete from tbl_letters_papers where lp_id="+dt)
print "delete from tbl_secretrait_letters where lp_id="+dt
Exemplo n.º 16
0
def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        return False


rows = py_db.executeAndReturnRows("select * from sheet2")
b=0

i=0
for row in rows:
    if row[4] is not None:
        if len(row[4].__str__())>3:
            py_db.executesql("update sheet2 set cd3='{0}' , num4='1' where id = '{1}'".format(row[4],row[0]))
            i=i+1
            print "update sheet2 set cd3='{0}' where id = '{1}'".format(row[4],row[0])

#
#for row in rows:
#    dr = []
#    dr = row[1].split('_')
#    
#    for d in dr:
#        dh = d.split('-')
#        i=2
#        for dc in dh:
#            if is_number(dc):
#                i=i+1
#                py_db.executesql("update sheet set num{0}='{1}' where id = '{2}'".format(i,dc,row[11]))
Exemplo n.º 17
0
def delrow(_id):
    py_db.executesql("delete from tbl_tels where t_id='{0}'".format(_id))
    print _id