""" % (sys.argv[0].replace("/data/project/rightstool/public_html//cgi-bin/", "").replace("py", ""), Quser, checked1, checked2)
#Do only if the user has been specified
if Quser!="":
#Query and printing
if not who and not whom:
print """
You cannot check both boxes!
"""
else:
print """
User rights logs search for "%s"
""" % Quser
try:
db = MySQLdb.connect(db='metawiki_p', host="metawiki.labsdb", user=SQLuser, passwd=SQLpasswd)
cursor = db.cursor()
Quser_=Quser.strip(" ").replace(" ", "_")
if not whom: sqlcond="log_user in (select user_id from user where user_name like '%%%s%%')" % Quser_
elif not who: sqlcond="log_title like '%%%s%%%" % Quser_
else: sqlcond="(log_user in (select user_id from user where user_name like '%%%s%%') or log_title like '%%%s%%')" % (Quser_, Quser_)
# who, whom, parameters, comment, timestamp
sql="select user_name, log_title, log_params, log_comment, log_timestamp from logging join user on user_id=log_user where log_type='rights' and %s order by log_timestamp desc;" % sqlcond
cursor.execute(sql)
results = cursor.fetchall()
except: results=()
if results!=():
print """"""
for i in results:
if i[3]=='': comment=" "
else: comment=i[3].replace("<", "<").replace(">", ">")
t=i[4]
time="%s/%s/%s %s:%s:%s" % (t[:4], t[4:6], t[6:8], t[8:10], t[10:12], t[12:])
par=i[2].split("\n")
for p in range(len(par)):
if not par[p]: par[p]="(none)"
if len(par)!=2: params="".join(par)
else: params="from %s to %s" % tuple(par)
print """""" % (urllib.quote(i[0]), i[0].replace("_", " "), urllib.quote(i[1]), i[1].replace("_", " "), params, comment, time)
print """
User | Title | Rights | Comment | Time |
---|
%s | %s | %s | %s | %s |
"""
db.close()
print """