viewing paste /addons/voteforpoints/modules/votef | PHP

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
<?php 
//A login is required
include ('function.php');
$this->loginRequired();
 
//This will list the sites
$vp = Flux::config('FluxTables.Sites'); 
$vp_voter = Flux::config('FluxTables.Voters'); 
$serverLogDB = $server->loginDatabase;
 
$vp_voter = Flux::config('FluxTables.Voters'); 
$vp_logs = Flux::config('FluxTables.Logs');         
$serverObj = $server->connection;
 
 
$sql = "SELECT site_id,site_name,address,points,blocking_time,banner,banner_url FROM {$server->loginDatabase}.{$vp}";
$sth = $server->connection->getStatement($sql);
$sth->execute();
 
$vp = $sth->fetchAll();
 
$account_id = $session->account->account_id;
$current_time= date("Y-m-d G:i:s",time());
$ip_address = 0;
if(Flux::config('IP_BLOCKING'))
    $ip_address = $_SERVER['REMOTE_ADDR'];
    
    
$sql = "SELECT points FROM {$server->loginDatabase}.{$vp_voter} WHERE account_id=?";
$sth = $server->connection->getStatement($sql);
$sth->execute(array($session->account->account_id));
$vp_voter = $sth->fetch();
$curr_points = $vp_voter->points;
 
function isBlock($account_id,$site_id,$current_time,$ip_address,$serverLogDB,$vp_logs,$serverObj)
{
    if($ip_address!=0)
    {
        $sql = "SELECT `rtid`,`unblock_time`,`ip_address` FROM {$serverLogDB}.{$vp_logs} WHERE f_site_id=? AND unblock_time>? AND ip_address=? ORDER BY unblock_time ASC LIMIT 1";
        $sth = $serverObj->getStatement($sql);
        $sth->execute(array($site_id,$current_time,$ip_address));
        $ip_check = $sth->fetchAll();
        
        $diff_time = strtotime($ip_check[0]->unblock_time)-strtotime(date("Y-m-d G:i:s",time()));
        if(!empty($ip_check))
            return strtotime($ip_check[0]->unblock_time);
    }
        $sql = "SELECT `unblock_time` FROM {$serverLogDB}.{$vp_logs} WHERE account_id=? AND f_site_id=?";
        $sth = $serverObj->getStatement($sql);
        $sth->execute(array($account_id,$site_id));
        $account_check = $sth->fetch();
        
        if(!empty($account_check))
            $diff_time = strtotime($account_check->unblock_time)-strtotime(date("Y-m-d G:i:s",time()));
        else
            $diff_time = 0;
            
        if($diff_time>0)
            return strtotime($account_check->unblock_time);
        else
            return 0;
 
    return strtotime($account_check->unblock_time);
}
?>
Viewed 1344 times, submitted by Snaehild.