/** * @return APF_MQ_Stomp */ public function load_stomp($name = "default") { $cfg = MPF::get_instance()->get_config($name, 'mq'); mpf_require_class('MPF_MQ_Stomp'); $stomp = new MPF_MQ_Stomp($cfg['uri']); return $stomp; }
/** * Returns MPF instance. * * @return MPF The instance of MPF */ public static function &get_instance() { if (!self::$instance) { self::$instance = new MPF(); } return self::$instance; }
public function execute($input_parameters = NULL) { if (MPF::get_instance()->is_debug_enabled()) { MPF::get_instance()->debug(__CLASS__ . '[' . $this->pdo->config['dsn'] . '|' . $this->pdo->get_name() . ']' . "->execute: " . $this->queryString); } $logger = MPF::get_instance()->get_logger(); $logger->debug(__CLASS__, '[' . $this->pdo->get_name() . ']->execute: ', $this->queryString); MPF::get_instance()->pf_benchmark_inc_begin('dbtime'); $start = microtime(true); $ret = parent::execute($input_parameters); $end = microtime(true); MPF::get_instance()->pf_benchmark_inc_end('dbtime'); //add by hexin for record SQL execute time MPF::get_instance()->pf_benchmark("sql_time", array($this->i => $end - $start)); // 按照惯用格式记录sql执行时间和占用内存 // added by htlv $tmp_time = $end - $start; $tmp_mem = memory_get_usage(); mpf_require_class('MPF_Performance'); MPF::get_instance()->pf_benchmark("sql_time_af", array($this->i => array('sql' => $this->_sql, MPF_Performance::MESSAGE_TIME => $tmp_time, MPF_Performance::MESSAGE_MEMORY => $tmp_mem))); if (!$ret) { $error_info = parent::errorInfo(); /** * remove duplicated error log $logger->error(__CLASS__, '['. $this->pdo->get_name() .']->execute: ', $this->queryString); $_error_info = preg_replace("#[\r\n \t]+#",' ',print_r($error_info,true)); $logger->error(__CLASS__, '['. $this->pdo->get_name() .']->execute: ', $_error_info); */ if (parent::errorCode() !== '00000') { throw new MPF_Exception_SqlException(parent::errorCode(), $this->pdo->get_name() . ' | ' . $this->pdo->config['dsn'] . ' | ' . $this->queryString . ' | ' . join(' | ', $error_info)); } } return $ret; }
/** * 处理压缩资源内容。调用父类APF_Resource_ResourcesController的handle_request方法, * 获取资源内容,在调用压缩服务实现压缩,最终给浏览器返回压缩后的资源内容。 * @see APF_Resource_ResourcesController::handle_request() */ public function handle_request() { // 开启缓冲区 ob_start(); parent::handle_request(); $uri = $_SERVER['REQUEST_URI']; // 获取资源内容 $content = ob_get_contents(); ob_end_clean(); // 读取压缩服务配置 $mpf = MPF::get_instance(); $host = @$mpf->get_config(self::CONFIG_N_YUICOMPRESSOR_HOST, parent::CONFIG_F_RESOURCE); $port = @$mpf->get_config(self::CONFIG_N_YUICOMPRESSOR_PORT, parent::CONFIG_F_RESOURCE); if (!$host || !$port) { // 为配置压缩服务则直接输出原始内容 echo $content; return; } // 调用压缩服务,输出压缩结果 $fp = @fsockopen($host, $port); if (!$fp) { // 连接失败则直接输出内容 echo $content; return; } // 发送要压缩的内容 fwrite($fp, "{$uri}\n"); fwrite($fp, $content); fwrite($fp, "\n\n"); // 读取并显示压缩后的内容 while (!feof($fp)) { echo fread($fp, 8192); } fclose($fp); }
public function query($sql) { MPF::get_instance()->benchmark_begin('MPF_DB_Mysqli::query'); parent::query($sql); MPF::get_instance()->benchmark_end('MPF_DB_Mysqli::query'); return $this; }
/** * @return AMQPChannel */ private function load_channel($name) { $config = MPF::get_instance()->get_config($name, self::CONF_F_AMQP); $con = $this->get_connection($name); $ch = $con->channel(); $ch->access_request($config['vhost'], false, false, true, true); return $ch; }
private function load_client($name) { $solrcloud = MPF::get_instance()->get_config('solrcloud', self::CONF_F_SOLR); if (!isset($solrcloud['hostname']) || !isset($solrcloud['port'])) { throw new SolrException('Sole Exception: solrcloud undefined', '7000'); } $option = array('hostname' => $solrcloud['hostname'], 'port' => $solrcloud['port'], 'path' => $name); return new SolrClient($option); }
/** * Returns the class name of matched controller * * @return class name in string */ public function mapping() { $mpf = MPF::get_instance(); if (empty($this->mappings)) { $mappings = $mpf->get_config(self::CONFIG_N_MAPPINGS, self::CONFIG_F_ROUTE); } else { $mappings = $this->mappings; } $regex_function = @$mpf->get_config(self::CONFIG_N_REGEX_FUNCTION, self::CONFIG_F_ROUTE); if (!function_exists($regex_function)) { $regex_function = self::DEFAULT_REGEX_FUNCTION; } $regex_label = @$mpf->get_config(self::CONFIG_N_REGEX_LABEL, self::CONFIG_F_ROUTE); if (!$regex_label) { $regex_label = self::DEFAULT_REGEX_LABEL; } if (BASE_URI != '' && strpos($_SERVER['REQUEST_URI'], BASE_URI) === 0) { $uri = substr($_SERVER['REQUEST_URI'], strlen(BASE_URI)); } else { $uri = $_SERVER['REQUEST_URI']; } $pos = strpos($uri, '?'); if ($pos) { $uri = substr($uri, 0, $pos); } if (empty($uri)) { $uri = '/'; } $matches = array(); foreach ($mappings as $prefix => $groups) { if ($prefix == substr($uri, 0, strlen($prefix))) { foreach ($groups as $class => $mapping) { foreach ($mapping as $k => $pattern) { if (@$regex_function($regex_label . $pattern . $regex_label, $uri, $matches) and $k != 'prefix' and $k != 'controller') { $mpf->get_request()->set_router_matches($matches); return $class; } } } } } //auto mapping $auto_mapping = $mpf->get_config('enabled_auto_router'); if ($auto_mapping) { $class = $this->auto_mapping($uri); if ($class) { return $class; } } // TODO: 404 controller? $class = $mpf->get_config(self::HTTP404_CONTROLLER, self::CONFIG_F_ROUTE); if ($class) { return $class; } $mpf->get_response()->set_header("HTTP/1.1", "404 Not Found", "404"); return false; }
public function load($filename) { #return $this->mfs->get($filename); MPF::get_instance()->pf_benchmark_begin("getpaths"); $paths = $this->mfs->getPaths($filename); MPF::get_instance()->pf_benchmark_end("getpaths"); MPF::get_instance()->pf_benchmark_begin("loadfromstorage"); return $this->mfs->new_get($paths); MPF::get_instance()->pf_benchmark_end("loadfromstorage"); }
protected function is_allow_performance() { $mpf = MPF::get_instance(); $request = $mpf->get_request(); $allow_patterns = @$mpf->get_config("performance_is_allow"); if (@$allow_patterns) { return TRUE; } return FALSE; }
public function cdn_boundable_prefix() { if (!$this->cdn_boundable_prefix) { $schema = "http://"; // TODO: check for https $host = MPF::get_instance()->get_config("cdn_boundable_host", "resource"); $path = MPF::get_instance()->get_config("cdn_boundable_path", "resource"); $this->cdn_boundable_prefix = "{$schema}{$host}{$path}"; } return $this->cdn_boundable_prefix; }
/** * 创建DFS实例. 根据name,从配置文件获取信息创建实例. * * @param string $name * @return APF_DB_PDO */ protected function create_dfs($name) { $mpf = MPF::get_instance(); $config = $mpf->get_config($name, self::CONFIG_F_DFS); if (!isset($config[self::CONFIG_N_CLASS])) { throw new Exception("class not provided for dfs::{$name}"); } $class = $config[self::CONFIG_N_CLASS]; mpf_require_class($class); $dfs = new $class(); $dfs->init($config); return $dfs; }
/** * 重载了组件的execute方法 * 载入装饰器 * @see APF_Page::execute() */ public function execute() { $view = $this->get_decorator(); MPF::get_instance()->debug("decorator: {$view}"); $file = "page/" . $view . ".phtml"; global $G_LOAD_PATH; foreach ($G_LOAD_PATH as $path) { if (file_exists($path . $file)) { $this->render($path . $file, TRUE); break; } } }
public function init($config) { if ($this->mfs) { throw new Exception("Cannot initialize twice!"); } $mfscfg = $config['mogilefs']; $domain = $mfscfg['domain']; $class = $mfscfg['class']; $trackers = $mfscfg['trackers']; $memcacheds = MPF::get_instance()->get_config('memcacheds', 'dfs'); // TODO: validate parameters? // TODO: other parameters like timeouts? $this->mfs = new MogileFSc($domain, $class, $trackers, $memcacheds); }
protected function is_allow_debug() { $mpf = MPF::get_instance(); $request = $mpf->get_request(); $client_ip = $request->get_client_ip(); $allow_patterns = @$mpf->get_config("debug_allow_patterns"); if (is_array($allow_patterns)) { foreach ($allow_patterns as $pattern) { if (preg_match($pattern, $client_ip)) { return TRUE; } } } return FALSE; }
public function delete() { if ($this->is_loaded == false) { return false; } try { $msg = $this->build_delete(); $con = MPF_AMQP_Factory::get_instance()->get_connection(); $ex = new AMQPExchange($con, self::get_exchange()); $ex->publish($msg, self::get_routing()); } catch (Exception $e) { MPF::get_instance()->get_debugger()->debug('AMPQ: Can not be published - ' . $e->getMessage()); } return true; }
/** * @return AMQPConnection */ private function load_connection($name) { if (!class_exists('AMQPConnection')) { throw new Exception('MPF_AMQP_Factory Exception: AMQPConnection not found'); } $config = MPF::get_instance()->get_config($name, self::CONF_F_AMQP); if (!isset($config['host'])) { throw new Exception('MPF_AMQP_Factory Exception: host undefined'); } $con = new AMQPConnection($config); $rst = $con->connect(); if ($rst == false) { throw new AMQPException('MPF_AMQP_Factory AMQPException: can not connect to server'); } return $con; }
public function __construct() { $disabled = @MPF::get_instance()->get_config(self::CONFIG_N_DISABLED, self::CONFIG_F_LOGGER); $this->disabled = (bool) $disabled; if ($disabled) { return; } $threhold = @intval(MPF::get_instance()->get_config(self::CONFIG_N_THREHOLD, self::CONFIG_F_LOGGER)); $this->threhold = $threhold ? $threhold : 10; $tag_prefix = @MPF::get_instance()->get_config(self::CONFIG_N_TAG_PREFIX, self::CONFIG_F_LOGGER); $this->tag_prefix = $tag_prefix ? $tag_prefix : ''; $host = @MPF::get_instance()->get_config(self::CONFIG_N_HOST, self::CONFIG_F_LOGGER); $port = @MPF::get_instance()->get_config(self::CONFIG_N_PORT, self::CONFIG_F_LOGGER); $this->logger = FluentLogger::open($host, $port); MPF::get_instance()->register_shutdown_function(array($this, 'shutdown')); }
/** * 设置返回内容的类型和字符集。默认字符集为utf-8,也可以在common.php里面指明。 * @param string $content_type 内容类型 * @param string $charset 字符集 */ public function set_content_type($content_type, $charset = NULL) { // 设置文本类型的字符集 if (!$charset && preg_match('/^text/i', $content_type)) { $charset = @MPF::get_instance()->get_config('charset'); if (!$charset) { $charset = 'utf-8'; } } // 发送内容类型头部指令 if ($charset) { $this->set_header("content-type", "{$content_type}; charset={$charset}"); } else { $this->set_header("content-type", $content_type); } }
protected function is_allow_xhprof() { return true; $mpf = MPF::get_instance(); $xhprof_allow_on = @$mpf->get_config("xhprof_allow_on"); if (!$xhprof_allow_on) { return FALSE; } $request = $mpf->get_request(); $client_ip = $request->get_client_ip(); $allow_patterns = @$mpf->get_config("xhprof_allow_patterns"); if (is_array($allow_patterns)) { foreach ($allow_patterns as $pattern) { if (preg_match($pattern, $client_ip)) { return TRUE; } } } return FALSE; }
public function handle_request() { // TODO: to handling 304 header by an interceptor? $mpf = MPF::get_instance(); $response = $mpf->get_response(); $cache_control = $this->get_cache_control(); if ($cache_control) { $response->set_header("Cache-Control", $cache_control); } $expires = @$mpf->get_config(self::CONFIG_N_EXPIRES, self::CONFIG_F_RESOURCE); $last_modified = @$mpf->get_config(self::CONFIG_N_LAST_MODIFIED, self::CONFIG_F_RESOURCE); if (isset($last_modified)) { $etag = '"' . dechex($last_modified) . '"'; } if (isset($etag)) { $none_match = @$_SERVER['HTTP_IF_NONE_MATCH']; if ($none_match && $none_match == $etag) { $response->set_header("HTTP/1.1", "304 ETag Matched", "304"); exit; } } if (isset($last_modified) && isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $tmp = explode(";", $_SERVER['HTTP_IF_MODIFIED_SINCE']); $modified_since = @strtotime($tmp[0]); if ($modified_since && $modified_since >= $last_modified) { $response->set_header("HTTP/1.1", "304 Not Modified", "304"); exit; } } if (isset($expires)) { $response->set_header("Expires", gmdate("D, d M Y H:i:s", $expires) . " GMT"); } if (isset($last_modified)) { $response->set_header("ETag", $etag); $response->set_header("Last-Modified", gmdate("D, d M Y H:i:s", $last_modified) . " GMT"); } return parent::handle_request(); }
/** * Returns new instance of pdo * * @param string $name * @return APF_DB_PDO */ public function load_pdo($name = "default") { $mpf = MPF::get_instance(); if ($mpf->is_debug_enabled()) { $mpf->benchmark_begin(__CLASS__ . ": open pdo '{$name}'"); } $dbcfg = MPF::get_instance()->get_config($name, "database"); mpf_require_class($this->pdo_class); $pdo = new $this->pdo_class($dbcfg['dsn'], @$dbcfg['username'], @$dbcfg['password'], isset($dbcfg['driver_options']) ? $dbcfg['driver_options'] : array()); $pdo->set_name($name); if (isset($dbcfg['default_fetch_mode'])) { $pdo->set_default_fetch_mode($dbcfg['default_fetch_mode']); } if (isset($dbcfg['init_statements'])) { foreach ($dbcfg['init_statements'] as $sql) { $pdo->exec($sql); } } if ($mpf->is_debug_enabled()) { $mpf->benchmark_end(__CLASS__ . ": open pdo '{$name}'"); } return $pdo; }
public function set_name($name) { $this->name = $name; $this->config = MPF::get_instance()->get_config($name, "database"); }
/** * 删除单行缓存 */ protected function cache_delete() { MPF::get_instance()->debug("delete row cache"); $cache = MPF_Cache_Factory::get_instance()->get_memcache(); $cache->delete($cache->get_obj_key(get_called_class(), $this->get_primary_key())); }
public function shutdown() { $this->benchmark_end(self::DEFAULT_BENCHMARK); $mpf = MPF::get_instance(); $mpf->component(NULL, 'MPF_Debugger_Debug'); }
private function find_response() { if (!isset($this->query)) { throw new SolrException('SolrAccessor Exception: query undefined', '7700'); } $query = new SolrQuery(); $query->setQuery($this->query); $query->addField($this->mapping['key']); if (is_array($this->fields)) { foreach ($this->fields as $field) { $query->addField($field); } } if (is_array($this->filters)) { foreach ($this->filters as $field => $value) { $query->addFilterQuery("{$field}:{$value}"); } } if (is_array($this->sorts)) { foreach ($this->sorts as $field => $type) { $query->addSortField($field, $type); } } if (is_array($this->query_field) && !empty($this->query_field)) { $arrQueryFields = array(); foreach ($this->query_field as $field => $boost) { $arrQueryFields[] = $field . '^' . $boost; } $query->setParam('qf', implode(' ', $arrQueryFields)); $query->setParam('qt', 'dismax'); } if (isset($this->start)) { $query->setStart($this->start); } if (isset($this->rows)) { $query->setRows($this->rows); } if (is_array($this->facets)) { $query->setFacet(true); $query->setFacetMinCount($this->facet_min_count); foreach ($this->facets as $facet) { $query->addFacetField($facet['filed']); if (isset($facet['limit'])) { $limit = intval($facet['limit']); $query->setFacetLimit($limit); } if (isset($facet['sort'])) { $sort = $facet['sort'] == 'index' ? $query::FACET_SORT_INDEX : $query::FACET_SORT_COUNT; $query->setFacetSort($sort, $facet['filed']); } } } if (!empty($this->facet_query_array) && is_array($this->facet_query_array)) { $query->setFacet(true); $query->setFacetMinCount($this->facet_min_count); foreach ($this->facet_query_array as $valFacetQuery) { $query->addFacetQuery($valFacetQuery); } } $client = MPF_Solr_Factory::get_instance()->get_client($this->mapping['instance']); $response = $client->query($query); $debug = explode("\n", $client->getDebug()); //TODO use getRawRequest instead of debug $raw_request = @$debug[13]; if (substr($raw_request, 0, 2) != 'q=') { $raw_request = @$debug[12]; } MPF::get_instance()->debug(__CLASS__ . '::' . __FUNCTION__ . ':' . @$response->getRequestUrl() . '&' . $raw_request); return $response->getResponse(); }
public function view_xprof($id) { $aifang_tools_domain = MPF::get_instance()->get_config("aifang_tools_domain"); echo "<a target='_brank' href='http://" . $aifang_tools_domain . "/xhprof/detail/?id=" . $id . "' >[View Xprof]</a>"; }
private function sql_rewrite($sql) { $cfg = null; if (!$this->_sql_rewrite) { $this->_sql_rewrite = MPF::get_instance()->get_config("sql_rewrite", "sql"); } foreach ($this->_sql_rewrite as $server => $pattern) { foreach ($pattern as $k => $v) { if (preg_match($v[0], $sql, $matches) && preg_last_error() == PREG_NO_ERROR) { $matches[0] = null; if (array_key_exists(1, $v) && $v[1]) { foreach ($v[1] as $vk => $vv) { if ($matches[$vk]) { $matches[$vk] = $vv; } } } $sql = implode('', $matches); $cfg = $server; break 2; } elseif (preg_last_error() != PREG_NO_ERROR) { trigger_error('Rewrite error', E_USER_ERROR); } } } if (!$cfg) { if (!defined('DB_CONFIG')) { trigger_error('Hacking attempt', E_USER_ERROR); } $cfg = DB_CONFIG; } $cfg = array_map('trim', explode("\n", $cfg)); $this->connection = null; foreach ($cfg as $c) { if (is_array($this->_links) && array_key_exists($c, $this->_links)) { $this->connection = $this->_links[$c]; break; } } if ($this->connection === null) { if (count($cfg) > 1) { $cfg = $cfg[rand(1, count($cfg)) - 1]; } else { $cfg = $cfg[0]; } $_settings = parse_url($cfg); if (empty($_settings['pass'])) { $_settings['pass'] = ''; } else { $_settings['pass'] = urldecode($_settings['pass']); } $_settings['user'] = urldecode($_settings['user']); if (empty($_settings['path'])) { trigger_error('Invalid database name.', E_USER_ERROR); } else { $_settings['path'] = str_replace('/', '', $_settings['path']); } @(list($_settings['pconnect'], $_settings['host']) = explode(':', $_settings['host'])); if (!$_settings['host']) { $_settings['host'] = $_settings['pconnect']; $_settings['pconnect'] = null; } $_settings['charset'] = defined('CHARSET') ? CHARSET : 'utf8'; $this->connection = $this->connect($_settings['host'], $_settings['user'], $_settings['pass'], $_settings['path'], $_settings['port'], $_settings['pconnect'], $_settings['charset']); $this->_links[$cfg] = $this->connection; //var_dump($this->connection);exit; } //echo $cfg;exit; return false; }
/** * 渲染页面文件phtml,也就是执行phtml。 * 即,页面phtml是作为render方法的一部分来影响最终显示结果的。 * @param string $file 文件路径 * @param boolen $send_content_type 内容类型开关 * @see APF_Component::render() */ public function render($file, $send_content_type = '') { if ($send_content_type) { // 设置返回内容类型和编码 MPF::get_instance()->get_response()->set_content_type($this->get_content_type(), $this->get_charset()); } // 执行渲染操作 parent::render($file); }
private function process_vews() { /* 0、新IP、新标识/无标识,(不限制访问 -- 不能防止有大型IP库的访问者),(限流服务 -- 1秒内访问不超过5000次,5分钟内访问不超过300000次); 1、老标识、老IP(固定设备、AJAX?、资源?),2秒钟内访问不超过5次、1分钟内访问不超过50次、1小时内访问不超过500次、1天内访问不超过1000次; 2、老标识、新IP(移动设备、AJAX?、资源?),2秒钟内访问不超过5次、1分钟内访问不超过50次、1小时内访问不超过500次、1天内访问不超过1000次; 3、老IP、新标识/无标识(NAT环境、爬虫?),2秒钟内访问不超过5次、1分钟内访问不超过50次、1小时内访问不超过500次、1天内访问不超过1000次; */ $ip = MPF::get_instance()->request->get_client_ip(); $id = $_COOKIE['ECM_ID'] ? $_COOKIE['ECM_ID'] : SID; //todo $t = time(); if ($idviews = $this->get_views($id)) { $this->set_views($id); if ($ipviews = $this->get_views($ip)) { //1、 $this->set_views($ip); if ($t - $ipviews['t'] >= 86400 && $t - $idviews['t'] >= 86400) { if ($ipviews['c'] > 300 && $idviews['c'] > 300) { //todo MPF::get_instance()->response->set_header('_pvp', '1.1'); } elseif (($t - $ipviews['t']) / 2 >= 86400) { $this->set_views($id, -300, 86400); $this->set_views($ip, -300, 86400); } } elseif ($t - $ipviews['t'] >= 3600 && $t - $idviews['t'] >= 3600) { if ($ipviews['c'] > 100 && $idviews['c'] > 100) { //todo MPF::get_instance()->response->set_header('_pvp', '1.2'); } elseif (($t - $ipviews['t']) / 2 >= 3600) { $this->set_views($id, -100, 3600); $this->set_views($ip, -100, 3600); } } elseif ($t - $ipviews['t'] >= 60 && $t - $idviews['t'] >= 60) { if ($ipviews['c'] > 10 && $idviews['c'] > 10) { //todo MPF::get_instance()->response->set_header('_pvp', '1.3'); } elseif (($t - $ipviews['t']) / 2 >= 60) { $this->set_views($id, -10, 60); $this->set_views($ip, -10, 60); } } elseif ($t - $ipviews['t'] >= 2 && $t - $idviews['t'] >= 2) { if ($ipviews['c'] > 1 && $idviews['c'] > 1) { //todo MPF::get_instance()->response->set_header('_pvp', '1.4'); } elseif (($t - $ipviews['t']) / 2 >= 2) { $this->set_views($id, -1, 2); $this->set_views($ip, -1, 2); } } } else { //2、 if ($t - $idviews['t'] >= 86400) { if ($idviews['c'] > 300) { //todo MPF::get_instance()->response->set_header('_pvp', '2.1'); } elseif (($t - $ipviews['t']) / 2 >= 86400) { $this->set_views($id, -300, 86400); $this->set_views($ip, -300, 86400); } } elseif ($t - $idviews['t'] >= 3600) { if ($idviews['c'] > 100) { //todo MPF::get_instance()->response->set_header('_pvp', '2.2'); } elseif (($t - $ipviews['t']) / 2 >= 3600) { $this->set_views($id, -100, 3600); $this->set_views($ip, -100, 3600); } } elseif ($t - $idviews['t'] >= 60) { if ($idviews['c'] > 10) { //todo MPF::get_instance()->response->set_header('_pvp', '2.3'); } elseif (($t - $ipviews['t']) / 2 >= 60) { $this->set_views($id, -10, 60); $this->set_views($ip, -10, 60); } } elseif ($t - $idviews['t'] >= 2) { if ($idviews['c'] > 1) { //todo MPF::get_instance()->response->set_header('_pvp', '2.4'); } elseif (($t - $ipviews['t']) / 2 >= 2) { $this->set_views($id, -1, 2); $this->set_views($ip, -1, 2); } } } } elseif ($ipviews = $this->get_views($ip)) { //3、 $this->set_views($ip); if ($t - $ipviews['t'] >= 86400) { if ($ipviews['c'] > 300) { //todo MPF::get_instance()->response->set_header('_pvp', '3.1'); } elseif (($t - $ipviews['t']) / 2 >= 86400) { $this->set_views($id, -300, 86400); $this->set_views($ip, -300, 86400); } } elseif ($t - $ipviews['t'] >= 3600) { if ($ipviews['c'] > 100) { //todo MPF::get_instance()->response->set_header('_pvp', '3.2'); } elseif (($t - $ipviews['t']) / 2 >= 3600) { $this->set_views($id, -100, 3600); $this->set_views($ip, -100, 3600); } } elseif ($t - $ipviews['t'] >= 60) { if ($ipviews['c'] > 10) { //todo MPF::get_instance()->response->set_header('_pvp', '3.3'); } elseif (($t - $ipviews['t']) / 2 >= 60) { $this->set_views($id, -10, 60); $this->set_views($ip, -10, 60); } } elseif ($t - $ipviews['t'] >= 2) { if ($ipviews['c'] > 1) { //todo MPF::get_instance()->response->set_header('_pvp', '3.4'); } elseif (($t - $ipviews['t']) / 2 >= 2) { $this->set_views($id, -1, 2); $this->set_views($ip, -1, 2); } } } else { //0、 $this->set_views($id); //+1 $this->set_views($ip); //+1 $this->set_views("nid_nip"); //+1 } }