本文整理汇总了PHP中Server::getDefaultConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getDefaultConfig方法的具体用法?PHP Server::getDefaultConfig怎么用?PHP Server::getDefaultConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::getDefaultConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_index
function post_index()
{
$base = $this->getSblamBase();
$config = Server::getDefaultConfig();
$config['throttle']['enabled'] = '0';
// FIXME: this should be handled within plugins
$config['linksleeve']['enabled'] = '0';
$config['dupes']['enabled'] = '0';
$sblam = new Sblam($config, $this->services);
$num = !empty($_POST['num']) ? intval($_POST['num']) : 100;
foreach ($this->services->getDB()->query("SELECT id FROM posts_meta WHERE spamscore IS NULL and spamcert IS NULL ORDER BY rand() LIMIT\n{$num}")->fetchAll(PDO::FETCH_ASSOC) as $r) {
$score = $sblam->testPost($base->getPostById($r['id']));
$this->services->getDB()->prepareExecute("UPDATE posts_meta SET spamscore=?,spamcert=? WHERE id=?", array(round($score[0] * 100), round($score[1] * 100), $r['id']));
$this->services->getDB()->prepareExecute("UPDATE posts_data SET spamreason=? WHERE id=?", array($score[2], $r['id']));
}
}
示例2: Exception
throw new Exception("No file {$pagefile}");
}
// ob_start();
require_once $pagefile;
// ob_end_clean();
$class = ucfirst($name) . 'Page';
if (!class_exists($class)) {
throw new Exception("Class {$class} not found");
}
$page = new $class($config, $services);
if (!$page instanceof AdminPage) {
throw new Exception("Not an admin page");
}
return $page;
}
}
try {
$config = Server::getDefaultConfig();
$services = new SblamServices(sblambaseconnect($config));
Admin::process($config, $services);
} catch (Exception $e) {
header('HTTP/1.1 500 ERR');
header("Content-Type: text/plain;charset=UTF-8");
if (ini_get('display_errors')) {
echo $e;
} else {
echo "Error " . $e->getSourceLine();
}
error_log($e->getMessage() . " in " . $e->getSourceFile() . ':' . $e->getSourceLine());
warn($e, "Died");
}
示例3: getRequestIPs
/** extract all IPs from request headers
@param headers $_SERVER array
@return array
*/
static function getRequestIPs($headers = NULL, $routable = true)
{
if (NULL === $headers) {
$headers = $_SERVER;
}
if (!isset($headers['REMOTE_ADDR'])) {
$headers['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
}
$out = array($headers['REMOTE_ADDR'] => true);
// order IS important for security
$search = array('X_FORWARDED_FOR', 'FORWARDED_FOR', 'CLIENT_IP', 'X_CLIENT_IP', 'X_CLUSTER_CLIENT_IP', 'X_FORWARDED', 'PC_REMOTE_ADDR', 'FORWARDED', 'X_WAP_CLIENT_IP', 'X_COMING_FROM', 'X_REAL_IP');
foreach ($search as $h) {
$h = 'HTTP_' . $h;
if (isset($headers[$h]) && preg_match_all('!\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}!', $headers[$h], $t)) {
foreach ($t[0] as $ip) {
if (!isset($out[$ip])) {
$out[$ip] = true;
}
}
}
}
foreach ($out as $ip => $whatever) {
if (self::isPrivateOrReservedIP($ip)) {
//d($ip,'Unroutable IP - dropping');
unset($out[$ip]);
}
}
if (count($out) > 1) {
d('checking for proxies');
$db = sblambaseconnect(Server::getDefaultConfig());
$prep = $db->prepare("/*maxtime=1*/SELECT 1 FROM trustedproxies p JOIN dnscache d ON p.host = d.host WHERE d.ip = ?");
if (!$prep) {
throw new Exception("b0rked" . implode(',', $db->errorInfo()));
}
foreach ($out as $ip => $whatever) {
if (!$prep->execute(array(sprintf("%u", ip2long($ip))))) {
throw new Exception("bork" . implode($prep->errorInfo()));
}
if (count($prep->fetchAll())) {
d($ip, 'found to be a trusted proxy');
unset($out[$ip]);
} else {
d($ip, 'not a trusted proxy, bye!');
break;
}
}
}
return array_keys($out);
}