<?php
$sumfingIncl=true;
require '../config.thing.php';

if( isset($_POST['request_ids']) && isset($_POST['uid'])) {
	
    // Get options
	$set = get_adm_opts();
	$user = is_user_fakeid($_POST['uid']);
	
	if(isset($set->use_app_requests) && ($user->req_int < time())) { 
		 
		$uid = $_POST['uid'];
		$requests = explode(',',$_POST['request_ids']);	
		
		// Get count of requests from requests table
		$reqcount = get_request_count($user->fb_id);
		
		// Check against limits if set
		if(($set->request_limit != 0) && (($reqcount+count($requests)) > $set->request_limit) )
		die(($set->request_limit - $reqcount).'_over');
		
		// Check for interval if set
		$inserted = 0;
		if(($set->request_ticket_int > 0) && ($user->req_int) < time()) {
				
			$param = "req_int = " . (time() + ($set->request_ticket_int*3600));
			
			update_user($param, $user->fake_id);
				
			$inserted = request_insert($requests,$user->fb_id);
				
			echo ($set->request_ticket_int*3600) . '_int';
		} else {
			$inserted = request_insert($requests,$user->fb_id);
			echo get_request_count($user->fb_id) . '_tot';	
		}
		
		
	}
}
?>