public function get_db($sql_rewrite = null) { mpf_require_file('Mysqli_Database.php'); $db = Mysqli_Database::get_instance(); $db->_sql_rewrite = $sql_rewrite; return $db; }
/** * MPF主入口,实例化请求类、响应类,然后执行真正的框架流程 */ public function run() { //爬虫控制 if ($this->get_config('SESSION_START')) { mpf_require_file('spider.php'); if (!is_spider()) { $session_domain = $this->get_config('SESSION_DOMAIN'); if (!$session_domain) { $session_domain = $_SERVER['SERVER_NAME']; } ini_set('session.cookie_domain', $session_domain); session_start(); } } $this->prepare(); //$this->process_vews();//Interceptor... if (!$this->dispatch()) { echo "Error"; } }
<?php /** * */ mpf_require_file('Mysqli_Database.php'); class MPF_DB_Mysqli extends Mysqli_Database { private static $instance; public static function &get_instance() { if (!self::$instance) { self::$instance = new MPF_DB_Mysqli(); } return self::$instance; } 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; } }
<?php mpf_require_file('Stomp.php'); class MPF_MQ_Stomp extends Stomp { }
<?php mpf_require_class('MPF_DFS_DFS'); mpf_require_file('MogileFS.php'); class MPF_DFS_MogileFS implements MPF_DFS_DFS { 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']; // TODO: validate parameters? // TODO: other parameters like timeouts? $this->mfs = new MogileFS($domain, $class, $trackers); } public function load($filename) { return $this->mfs->get($filename); } public function save($filename, $content) { return $this->mfs->set($filename, $content); } public function delete($filename) { return $this->mfs->delete($filename); }
<?php mpf_require_file('PhpAmqpLib.php'); class MPF_AMQPLIB_Factory { const CONF_F_AMQP = 'amqp'; private function __construct() { } /** * @return APF_AMQP_Factory */ public static function &get_instance() { if (!self::$instance) { self::$instance = new MPF_AMQPLIB_Factory(); } return self::$instance; } private static $instance; /** * @return AMQPConnection */ public function get_connection($name = 'default') { if (!isset($this->connection_list[$name])) { $this->connection_list[$name] = $this->load_connection($name); } return $this->connection_list[$name]; } private $connection_list;
/** * 导入v2类 * @param string $class 类名 * @param string $prefix 父目录 * @param string $firelog * @return boolean */ function mpf_require_class($class, $prefix = "classes", $firelog = true) { if (defined('G_LOAD_AUTO') && G_LOAD_AUTO === true) { return true; } if ($prefix == "classes" && class_exists($class)) { return true; } $file = mpf_classname_to_filename($class); $flag = true; if (!mpf_require_file("{$file}.php", $prefix)) { if ($firelog) { $logger = MPF::get_instance()->get_logger(); //出错时的url $error_url = @$_SERVER['REQUEST_URI']; //屏蔽由于某些蜘蛛将url处理成小写时,引发的class not found if (preg_match('#\\.js$|\\.css$#', $error_url)) { return false; } //trigger_error("'$prefix/$class' not found", E_USER_ERROR); $http_host = @$_SERVER['HTTP_HOST']; $http_refer = @$_SERVER['HTTP_REFERER']; $logger->error("'{$prefix}/{$class}' not found error_url : {$http_host}{$error_url} refer : {$http_refer}"); //add by jackie for more error infomation ob_start(); debug_print_backtrace(); $trace = ob_get_contents(); ob_end_clean(); $logger->error($trace); } return false; } return $flag; }