当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::getDefaultConfig方法代码示例

本文整理汇总了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']));
     }
 }
开发者ID:bitemyapp,项目名称:Sblam,代码行数:16,代码来源:test.php

示例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");
}
开发者ID:bitemyapp,项目名称:Sblam,代码行数:31,代码来源:index.php

示例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);
 }
开发者ID:bitemyapp,项目名称:Sblam,代码行数:54,代码来源:server.php


注:本文中的Server::getDefaultConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。