first commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Block_ip_model extends CI_Model
|
||||
{
|
||||
public function __constructor()
|
||||
{
|
||||
parrent::__constructor();
|
||||
}
|
||||
|
||||
public function getBlockIpQuery($params = [])
|
||||
{
|
||||
$whereQuery = '';
|
||||
|
||||
if (!empty($params['ip_address_filter'])) {
|
||||
$whereQuery .= " AND ip = '" . pg_escape_string(trim($params['ip_address_filter'])) . "' ";
|
||||
}
|
||||
|
||||
if (!empty($params['reason_filter'])) {
|
||||
$whereQuery .= " AND reason ILIKE '%" . pg_escape_string(trim($params['reason_filter'])) . "%' ";
|
||||
}
|
||||
|
||||
if (!empty($params['blocked_date_filter'])) {
|
||||
// blocked_date_filter format: 2020-02-03 - 2020-03-01
|
||||
$fromToArray = explode(' - ', $params['blocked_date_filter']);
|
||||
$fromDate = $fromToArray[0];
|
||||
$toDate = $fromToArray[1];
|
||||
|
||||
$whereQuery .= " AND to_char(blocked, 'YYYY-MM-DD') >= '" . pg_escape_string($fromDate) . "'
|
||||
AND to_char(blocked, 'YYYY-MM-DD') <= '" . pg_escape_string($toDate) . "'
|
||||
";
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT
|
||||
id,
|
||||
ip,
|
||||
reason,
|
||||
blocked,
|
||||
"
|
||||
. " '<button style=\"padding:3px;\" type=\"button\" class=\"btn btn-info btn-xs\" onclick=\"confirmUnblockIp(''' || ip || ''');\" >Unblock</button>' "
|
||||
. " AS ACT "
|
||||
. " "
|
||||
. "
|
||||
FROM
|
||||
block_ip
|
||||
WHERE
|
||||
id > 0
|
||||
" . $whereQuery . "
|
||||
ORDER BY
|
||||
id ASC
|
||||
";
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user