%PDF- %PDF-
Direktori : /data/www_bck/varak.net_bck/epgp.varak.net/ |
Current File : //data/www_bck/varak.net_bck/epgp.varak.net/attend.php |
<?php header("Content-type: text/plain"); include "lib.php"; include "config.php"; $tzac = getmicrotime(); $spojeni = pg_connect("host=$sql port=5432 dbname=$db user=$usr password=$pass"); $limit = time() - 3600*24*30; q("update characters set attendance=0, flask=0"); $res = q("select time from public.vw_attend where cnt > 4 and \"time\" > $limit"); $raids = 0; $att = array(); foreach($res as $r) { $raids++; $min = $r[0] - 1800; $max = $r[0] + 3600*12; $ppl = q("select distinct character from log where time > $min and time < $max and \"desc\" like '%The Emerald Nightmare%' group by character"); foreach($ppl as $p) { $att[$p[0]][0]++; $att[$p[0]][1] = $p[0]; } } foreach($att as $a) { $num = floor(($a[0]/$raids)*100); q("update characters set attendance=$num where id=$a[1]"); } pg_close($spojeni); $tkon = getmicrotime(); $time = $tkon-$tzac; $time = sprintf("%01.4f", $time); header("Location: index.php"); echo "Attendance recounted in $time seconds, used $queries SQL queries"; ?>