def change_customer_details(field,value,user): column_value=['postal_add','username','contact',"passcode","password"] conn,cursor=config.connect_to_database() if field=="username" or field=="contact": sql="select email from customers where %s='%s'"%(field,value) try: cursor.execute(sql) if cursor.rowcount!=0: row=cursor.fetchone() if user!=row[0]: return -11 except: return -99 if field=="passcode": cid=customer_details.get_any_value(user,"cid") table_name="accounts" condition="c_id='%s'"%cid else: table_name="customers" condition="email='%s'"%user sql="update %s SET %s='%s' where %s"%(table_name,field,value,condition) try: cursor.execute(sql) conn.commit() return 1 except: conn.rollback() return -99 finally: conn.close()
def reload_chats(user_id, email_id): conn, cursor = config.connect_to_database() sql = "select * from chats where from_id='%s' or to_id='%s' ORDER BY created_time ASC" % ( user_id, user_id) reload_mess = "" try: cursor.execute(sql) results = cursor.fetchall() for row in results: chat_id = "chat_%s" % row[0] from_id = row[1] to_id = row[2] text = row[3] datetime = row[4] time = datetime.strftime('%H : %M') name = customer_details.get_any_value(email_id, "username") profile_pic = customer_details.get_any_document( name, "profile_pic") if int(to_id) != 0 or from_id == 0: reload_mess += """<li id='%s' class="mess"><div><img src="images/jon-cart.jpg" alt="You" style="width:100%%;"><p class="text-left">%s</p><br/><span class="time-right">%s</span></div></li><br/>""" % ( chat_id, text, time) else: reload_mess += """<li id='%s' class='mess'><div><img src="%s" alt="Jon" class="right" style="height:50px;"><p class="text-right">%s</p><br/><span class="time-left">%s</span></div></li><br/>""" % ( chat_id, profile_pic, text, time) return reload_mess except: return "error"
#!/usr/bin/python import cgi, cgitb import sys import security import customer_details import feedback_modules import jon_snow_brain print("Content-type:text/html;Content-type: image/jpeg\r\n\r\n") cgitb.enable(display=0, logdir="/path/to/logdir") form = cgi.FieldStorage() if form.getvalue('get_data'): user = security.protect_data(form.getvalue('user')) get_data = security.protect_data(form.getvalue('get_data')) got_it = customer_details.get_any_value(user, get_data) print("%s" % got_it) if form.getvalue('get_data_id') and form.getvalue('userid'): userid = security.protect_data(form.getvalue('userid')) get_data_id = security.protect_data(form.getvalue('get_data_id')) got_it = customer_details.get_any_value_by_id(userid, get_data_id) print("%s" % got_it) if form.getvalue('get_document') and form.getvalue('userid'): userid = security.protect_data(form.getvalue('userid')) username = customer_details.get_any_value_by_id(userid, "username") get_document = security.protect_data(form.getvalue('get_document')) got_it = customer_details.get_any_document(username, get_document) print("%s" % got_it) if form.getvalue('get_acc_details') and form.getvalue('user'): user = security.protect_data(form.getvalue('user')) get_acc_details = security.protect_data(form.getvalue('get_acc_details')) got_it = customer_details.get_account_details_by_user(
if form.getvalue('s_middlename'): middle_name = form.getvalue('s_middlename') if form.getvalue('s_gender'): gender = form.getvalue('s_gender') if form.getvalue('s_dob'): dob = form.getvalue('s_dob') if form.getvalue('s_postaladd'): postal_add = form.getvalue('s_postaladd') if form.getvalue('s_permadd'): perm_add = form.getvalue('s_permadd') if form.getvalue('s_pincode'): pincode = form.getvalue('s_pincode') if form.getvalue('s_city'): city = form.getvalue('s_city') if form.getvalue('s_state'): state = form.getvalue('s_state') if form.getvalue('s_country'): country = form.getvalue('s_country') sql="""INSERT INTO customers (username,fname,lname,middle_name,email,contact,password,gender,dob,postal_add,perm_add,pincode,city,state,country) values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')""" %(username,fname,lname,middle_name,email,phone,password,gender,dob,postal_add,perm_add,pincode,city,state,country) try: cursor.execute(sql) conn.commit() cid=customer_details.get_any_value(email,"cid") m.send_mail(email,phone,username) print("%d"%cid) except: conn.rollback() print("-99") conn.close()
info = no_found.no_found("No new requests") if flag == "approved_customers": info = admin_show_customers.show_customers(1) elif flag == "rejected_customers": info = admin_show_customers.show_customers(-1) elif flag == "new_customers": info = admin_show_customers.show_customers(0) elif flag == "new_requests": info = admin_control.provides_requests() elif flag == "new_feedbacks": info = admin_control.provides_feedbacks() print("%s" % info) if form.getvalue('get_data'): user = security.protect_data(form.getvalue('user')) get_data = security.protect_data(form.getvalue('get_data')) got_it = customer_details.get_any_value(user, get_data) print("%s" % got_it) if form.getvalue('get_data_id') and form.getvalue('userid'): userid = security.protect_data(form.getvalue('userid')) get_data_id = security.protect_data(form.getvalue('get_data_id')) got_it = customer_details.get_any_value_by_id(userid, get_data_id) print("%s" % got_it) if form.getvalue('get_document') and form.getvalue('userid'): userid = security.protect_data(form.getvalue('userid')) username = customer_details.get_any_value_by_id(userid, "username") get_document = security.protect_data(form.getvalue('get_document')) got_it = customer_details.get_any_document(username, get_document) print("%s" % got_it) if form.getvalue("verify_customer") and form.getvalue("status"): userid = security.protect_data(form.getvalue('verify_customer')) status = security.protect_data(form.getvalue('status'))