Example #1
0
def profile():
 # Check session
 v_user = functions.getcoockie('s_user')
 if v_user == "":
  abort(401, "Sorry, access denied.")
 else:
  # Request session
  v_password = functions.getcoockie('s_password')
  v_role = functions.getcoockie('s_role')
  # User data query
  sql_select="SELECT * FROM USERS WHERE user_user='******'" %(v_user)
  campos=functions.database_select(sql_select, v_user, v_password)
  # Gravatar function
  gravatar_url = functions.miniavatar(v_user,v_password)
  return template('views/profile.tpl',  user_user=campos[0], user_name=campos[1], user_email=campos[2], user_date=campos[3], user_role=campos[4], user_urlimage=gravatar_url, rol=v_role)
Example #2
0
def stats():
 v_user = functions.getcoockie('s_user')
 if v_user == "":
  abort(401, "Sorry, access denied.")
 else:
  v_password = functions.getcoockie('s_password')
  totalbackups="select count(backup_date) from backups;"
  sqlselectmode="select backup_mode, count(backup_host) from backups group by backup_mode;"
  sqlselecthosts="select h.host_name, count(b.backup_host) from backups b, hosts h where h.host_ip = b.backup_host group by h.host_name;"
  p_totalbackups=functions.database_select(totalbackups, v_user, v_password)
  backupsmode=functions.selectall(sqlselectmode, v_user, v_password)
  backupshost=functions.selectall(sqlselecthosts, v_user, v_password)
  total=int(p_totalbackups[0])
  gravatar_url = functions.miniavatar(v_user,v_password)
  return template('views/stats.tpl', user_user=v_user, user_urlimage=gravatar_url, total=total, modes=backupsmode, names=backupshost)
Example #3
0
def dashboard():
 # Check session
 v_user = functions.getcoockie('s_user')
 if v_user == "":
  abort(401, "Sorry, access denied.")
 else:
  # Request session
  v_password = functions.getcoockie('s_password')
  v_name = functions.getcoockie('s_name')
  v_role = functions.getcoockie('s_role')
  # Last 5 backups query
  selectbackupusers="select backup_host, host_name, backup_user, to_char(backup_date, 'DD-MM-YYYY'), to_char(backup_date,'HH24:MI') from backups join hosts on host_ip = backup_host order by backup_date desc limit 5;"
  backupsusers=functions.selectall(selectbackupusers, v_user, v_password)
  # Stats querys & functions
  totalbackups="select count(backup_date) from backups;"
  sqlselectmode="select backup_mode, count(backup_host) from backups group by backup_mode;"
  sqlselecthosts="select h.host_name, count(b.backup_host) from backups b, hosts h where h.host_ip = b.backup_host group by h.host_name;"
  p_totalbackups=functions.database_select(totalbackups, v_user, v_password)
  backupsmode=functions.selectall(sqlselectmode, v_user, v_password)
  backupshost=functions.selectall(sqlselecthosts, v_user, v_password)
  total=int(p_totalbackups[0])
  # Gravatar function
  gravatar_url = functions.miniavatar(v_user,v_password)
  return template('views/index.tpl', user_user=v_user, user_name=v_name, user_urlimage=gravatar_url, backupsusers=backupsusers, total=total, modes=backupsmode, names=backupshost, rol=v_role)