#!/usr/bin/env python

#import os, MySQLdb
from cgitools import *
from tools import decodeStr

user_id = os.getenv('PATH_INFO')
if user_id and len(user_id)>1:
	user_id = user_id[1:]
else: exitWithInfo('Wrong user ID')

user_id = decodeStr(user_id)

#exec open('db').read()
#connection = MySQLdb.connect(host=host, db=db, port=port, user=user, passwd=passwd)
#cursor = connection.cursor()
sql_statement = 'UPDATE users SET act_state=1 WHERE user_name="%s"' % user_id 
#n = cursor.execute(sql_statement)
#cursor.close()
#connection.close()
#if n:
if inquireDB(sql_statement) or 1:
	print cgi_token
	print "Your account was activated."
	print "<p>click <a href='%s'>Here</a> to logon." % (script_path_url+'/ui')
else: exitWithInfo('Failed. Wrong user_name or database error or your account was alway in use!')


