本文整理汇总了PHP中MatchaModel::save方法的典型用法代码示例。如果您正苦于以下问题:PHP MatchaModel::save方法的具体用法?PHP MatchaModel::save怎么用?PHP MatchaModel::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatchaModel
的用法示例。
在下文中一共展示了MatchaModel::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isBlocked
/**
* @return bool
*/
public function isBlocked()
{
include_once ROOT . '/dataProvider/GeoIpLocation.php';
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip == '::1' || $ip == '127.0.0.1') {
return false;
}
$geo_data = GeoIpLocation::getGeoLocation($ip);
if ($geo_data === false) {
$sql = 'SELECT * FROM `ip_access_rules` WHERE active = 1 AND ip = :ip1 OR ip = :ip2 ORDER BY weight DESC LIMIT 1';
$where = [];
$where[':ip1'] = '*';
$where[':ip2'] = $ip;
} else {
$sql = 'SELECT * FROM `ip_access_rules` WHERE active = 1 AND ip = :ip1 OR ip = :ip2 OR country_code = :country_code ORDER BY weight DESC LIMIT 1';
$where = [];
$where[':ip1'] = '*';
$where[':ip2'] = $ip;
$where[':country_code'] = $geo_data['country_code'];
}
$conn = Matcha::getConn();
$sth = $conn->prepare($sql);
$sth->execute($where);
$result = $sth->fetch(PDO::FETCH_ASSOC);
if ($result !== false) {
$blocked = $result['rule'] == 'BLK';
} else {
// if no rule found blocked the IP if not inside local network
$blocked = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) !== false;
}
if ($blocked) {
$record = new stdClass();
$record->ip = $ip;
$record->country_code = $geo_data !== false ? $geo_data['country_code'] : '';
$record->event = 'Blocked';
$record->create_date = date('Y-m-d H:i:s');
$this->l->save($record);
}
return $blocked;
}