";
if(strlen($error_msg)<1 && strlen($usr_token)>0 && $atb_token==$usr_token) {
$target=get_transient('atb_target_'.atb_cui());
if(get_transient('atb_prompt_mobile_'.atb_cui())!==false) if(strpos($target,'?')===false) $target.="?atb_mob=1"; else $target.="&atb_mob=1";
delete_transient('atb_prompt_mobile_'.atb_cui());
delete_transient('atb_target_'.atb_cui());
delete_transient("atb_flag_".atb_cui());
delete_transient('atb_token_'.atb_cui());
delete_transient('atb_sent_to_'.atb_cui());
atb_hit_page();
wp_redirect(atb_login_redirect($target)); exit;
} else {
$sent_to=get_transient('atb_sent_to_'.atb_cui());
if(function_exists('atb_sms_origin') && is_numeric(substr($sent_to,0,3)) && is_numeric(substr($sent_to,-2))) {
$origin=atb_sms_origin();
$check="If you previously opted out, you must first opt-in by texting RESUME to $origin.";
} else $check="Check your spam folder for recent emails.";
sleep(3); // Slow down brute force attempts ?>
Two Factor Authentication
";
for($x=$max_days;$x>=30;) {
$y=$x+10;
$r=atb_r("DELETE pg FROM wp_atb_pagehits pg
JOIN (
SELECT MAX(hit_id) as hit_id
FROM wp_atb_pagehits
WHERE userid<1
AND date =DATE_FORMAT(NOW(),'%Y-%m-%d')-INTERVAL $y DAY
GROUP BY LEFT(date,13),ip,userid,url,referrer
HAVING COUNT(ip)>1
ORDER BY hit_id ASC
LIMIT 2000
)mx ON mx.hit_id=pg.hit_id;");
$ct=$ct+intval($r);
if($x>30 && !get_transient('atb_compress_timeout')) {
if($max_days>30) set_transient('atb_compress_max_days',$max_days-20);
return $status."Range:$x-$max_days days".number_format($ct)." hits compressed";
}
sleep(1);
$x=$x-10;
}
if(function_exists('atb_delete_transients')) $status.=atb_delete_transients();
delete_transient('atb_compress_max_days');
if(!get_transient('atb_compress_optimized')) {
set_transient('atb_compress_optimized',1,259000); //every 3 days
atb_r("OPTIMIZE TABLE wp_atb_pagehits;");
return $status."Fully optimized.".number_format($ct)." hits compressed";
} else return $status."Max compression achieved.".number_format($ct)." hits compressed";
}
// PageHit Summary
function atb_view_summary($atb_version_type) {
$k='atb_view_summary_init';
if(get_transient($k))return;
set_transient($k,1,5*MINUTE_IN_SECONDS);
if(get_transient('limit_img_size_kb_'.atb_cui())!==false) delete_transient('limit_img_size_kb_'.atb_cui());
$current_mth=current_time('Y-m-01');
$last_gen_mth=get_option('atb_mt_max');
if(!$last_gen_mth) $last_gen_mth=get_transient('atb_mt_max');
if(!$last_gen_mth) $last_gen_mth=$current_mth;
$mth=get_option('atb_mt');
if(!$mth) $mth=get_transient('atb_mt'); // Find Historical Month Stats
function atb_month_stat($params) {
if(function_exists('atb_pro_ping')) $blocked_ips='AND ip NOT IN (SELECT blocked_ip FROM wp_aiowps_permanent_block)'; else $blocked_ips='';
$query="
SELECT DATE_FORMAT(CONCAT(month,'-01'),'%b %y') as month
,month as month_id,visitors
,ROUND(visitors/CASE WHEN month=DATE_FORMAT(NOW(),'%Y-%m') THEN DAY(NOW()) ELSE 30 END,0) as day_avg
FROM (
SELECT LEFT(date,7) as month,COUNT(DISTINCT ip) as visitors
FROM wp_atb_pagehits
WHERE date>NOW()-INTERVAL 400 DAY $params
$blocked_ips
AND url NOT LIKE '/wp-%'
GROUP BY LEFT(date,7)
)a
ORDER BY DATE_FORMAT(CONCAT(month,'-01'),'%y-%m');";
$mth=atb_r($query);
return $mth;
}
// Create Historical Month Stats
if(!$mth) {
$mth=atb_month_stat("AND date<'$current_mth'");
update_option('atb_mt',$mth,false);
update_option('atb_mt_max',$current_mth,false);
}
// Get Month Stats between last Gen Date and Month Begin
if(!$mth || $current_mth>$last_gen_mth) {
$mth_new=atb_month_stat("AND date>='$last_gen_mth' AND date<'$current_mth'");
if($mth && $mth_new) {
$mth=array_merge($mth,$mth_new); // Append Historical with Current
update_option('atb_mt',$mth,false);
update_option('atb_mt_max',$current_mth,false);
delete_transient('atb_mt');
delete_transient('atb_mt_max');
}
}
// Get Month Stats greater than Month Begin
$mth_new=atb_month_stat("AND date>='$current_mth'");
if(!$mth)$mth=$mth_new;
elseif($mth_new)$mth=array_merge($mth,$mth_new); // Append Historical with Today
$current_day=current_time('Y-m-d');
$last_gen_day=get_option('atb_dy_max');
if(!$last_gen_day) $last_gen_day=get_transient('atb_dy_max');
if(!$last_gen_day) $last_gen_day=$current_day;
$day=get_option('atb_dy');
if(!$day) $day=get_transient('atb_dy'); // Find Historical Day Stats
function atb_day_stat($params) {
if(function_exists('atb_pro_ping')) $blocked_ips='AND ip NOT IN (SELECT blocked_ip FROM wp_aiowps_permanent_block)'; else $blocked_ips='';
$query="
SELECT DATE_FORMAT(date,'%a %D') as day
,date as date_id
,DATE_FORMAT(CONCAT(date,'-01'),'%b %y') as month,visitors
,visitors
FROM (
SELECT LEFT(date,10) as date,COUNT(DISTINCT ip) as visitors
FROM wp_atb_pagehits
WHERE date>NOW()-INTERVAL 400 DAY $params
$blocked_ips
AND url NOT LIKE '/wp-%'
GROUP BY LEFT(date,10)
)a
ORDER BY date;";
$day=atb_r($query);
return $day;
}
// Create Historical Day Stats
if(!$day) {
$day=atb_day_stat("AND date<'$current_day'");
update_option('atb_dy',$day,false);
update_option('atb_dy_max',$current_day,false);
}
// Get Day Stats between last Gen Date and Today
if(!$day || $current_day>$last_gen_day) {
$day_new=atb_day_stat("AND date>='$last_gen_day' AND date<'$current_day' ");
if($day && $day_new){ // Append Historical with Current
$day=array_merge($day,$day_new);
update_option('atb_dy',$day,false);
update_option('atb_dy_max',$current_day,false);
delete_transient('atb_dy');
delete_transient('atb_dy_max');
}
}
// Get Day Stats Today
$day_new=atb_day_stat("AND date>='$current_day'");
if(!$day) $day=$day_new;
elseif($day_new)$day=array_merge($day,$day_new); // Append Historical with Today
$max_visit_avg=0;
$max_visit_tot=0;
if($mth) foreach($mth as $mth_item) if($mth_item->day_avg>$max_visit_avg) {$max_visit_avg=$mth_item->day_avg; $max_visit_tot=$mth_item->visitors;} ?>