49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
require_once('mt/AttrHelper.php');
|
|
require_once('mt/StrHelper.php');
|
|
|
|
use phpcommon;
|
|
|
|
class WhiteList {
|
|
|
|
public static function get($id)
|
|
{
|
|
return getXVal(self::getMetaList(), $id);
|
|
}
|
|
|
|
public static function inWhiteList($account)
|
|
{
|
|
self::mustBeAccountHash();
|
|
$account = strtolower($account);
|
|
return getXVal(self::$accountHash, $account, null) != null;
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('whitelist@whitelist.php');
|
|
foreach (self::$metaList as &$item) {
|
|
$item['white_list'] = strtolower($item['white_list']);
|
|
}
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static function mustBeAccountHash()
|
|
{
|
|
if (!self::$accountHash) {
|
|
self::$accountHash = array();
|
|
foreach (self::getMetaList() as $meta) {
|
|
self::$accountHash[$meta['white_list']] = $meta;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected static $metaList;
|
|
protected static $accountHash;
|
|
|
|
}
|