12 const TABLE_NAME =
"IpBan";
15 public $DateCreated = NULL;
16 public $DateUpdated = NULL;
18 public $IdAdminAccount = 0;
21 public $FromIpInt = 0;
28 public function __construct($src = null, $stripSlashes =
false) {
32 $this->_loadByRow($src, $stripSlashes);
33 }
else if (is_numeric($src)) {
35 $this->_loadFilter(self::GetTableName(__CLASS__), sprintf(
"Id = %d", $src));
51 public static function Load ($idApp = 0, $idAdminAccount = 0, $ip = NULL, $limit = null, $offset = null, &$count = null) {
55 $where .= ($where ?
" AND " :
"") . sprintf(
"(IdApp = 0 OR IdApp = %d)", $idApp);
57 if ($idAdminAccount > 0) {
58 $where .= ($where ?
" AND " :
"") . sprintf(
"(IdAdminAccount = %d)", $idAdminAccount);
61 $where .= ($where ?
" AND " :
"") . sprintf(
"(INET6_ATON('%s') BETWEEN FromIpInt AND ToIpInt)", $Database->Escape($ip));
63 return self::_load(self::GetTableName(__CLASS__), __CLASS__, $where, NULL, $limit, $offset, $count);
73 $this->DateUpdated = Utils::GetCurrentDateTimeFormat();
75 $query = sprintf(
"UPDATE %s SET IdApp = %d, FromIp = '%s', ToIp = '%s', FromIpInt = INET6_ATON('%s'), ToIpInt = INET6_ATON('%s'), Reason = '%s', DateUpdated = %s, IdAdminAccount = %d WHERE Id = %d",
76 self::GetTableName(__CLASS__),
78 $Database->Escape($this->FromIp),
79 $Database->Escape($this->ToIp),
80 $Database->Escape($this->FromIp),
81 $Database->Escape($this->ToIp),
82 $Database->Escape($this->Reason),
83 $Database->EscapeDate($this->DateUpdated),
84 $this->IdAdminAccount,
87 $this->DateCreated = $this->DateUpdated;
88 $query = sprintf(
"INSERT INTO %s (IdApp, IdAdminAccount, DateCreated, DateUpdated, FromIp, ToIp, FromIpInt, ToIpInt, Reason) VALUES (%d, %d, %s, %s, '%s', '%s', INET6_ATON('%s'), INET6_ATON('%s'), '%s')",
89 self::GetTableName(__CLASS__),
91 $this->IdAdminAccount,
92 $Database->EscapeDate($this->DateCreated),
93 $Database->EscapeDate($this->DateUpdated),
94 $Database->Escape($this->FromIp),
95 $Database->Escape($this->ToIp),
96 $Database->Escape($this->FromIp),
97 $Database->Escape($this->ToIp),
98 $Database->Escape($this->Reason));
100 if ($Database->Query($query)) {
102 $this->Id = $Database->InsertedId();
116 return $this->_Delete(self::GetTableName(__CLASS__), sprintf(
"Id = %d", $this->Id));
static Load($idApp=0, $idAdminAccount=0, $ip=NULL, $limit=null, $offset=null, &$count=null)
__construct($src=null, $stripSlashes=false)