微擎inc.php 读不到,解读微擎之----bootstrap.inc.php

加载各种静态资源,定义大量$_W下变量的值,判断是否安装微擎,设置phpini的值,$_W[]判断http发送的方式

';

//strpos("$atr","a")查找 "a" 在字符串$atr中第一次出现的位置

echo "·如果你还没安装本程序,请运行install.php 进入安装>>

";

echo "  Power by WE7 " . IMS_VERSION . "  微擎公众平台自助开源引擎";

exit();

} else {

header('Content-Type: text/html; charset=utf-8');

exit('配置文件不存在或是不可读,请检查“data/config”文件或是重新安装!');

}

}

require $configfile;

require IA_ROOT . '/framework/version.inc.php';//定义了三个常量

require IA_ROOT . '/framework/const.inc.php';//大量常量的定义

require IA_ROOT . '/framework/class/loader.class.php';//load()机制加载文件

load()->func('global');

load()->func('compat');

load()->func('pdo');

load()->classs('account');

load()->classs('agent');

load()->model('cache');

load()->model('account');

load()->model('setting');

define('CLIENT_IP', getip());

$_W['config'] = $config;

$_W['config']['db']['tablepre'] = !empty($_W['config']['db']['master']['tablepre']) ? $_W['config']['db']['master']['tablepre'] : $_W['config']['db']['tablepre'];

$_W['timestamp'] = TIMESTAMP;//定义当前时间戳常量

$_W['charset'] = $_W['config']['setting']['charset'];

$_W['clientip'] = CLIENT_IP;

//$config在$configfile加载的config.php中定义的数组

unset($configfile, $config);//销毁常量$configfile, $config

//IA_ROOT本页第十行返回当前目录

define('ATTACHMENT_ROOT', IA_ROOT .'/attachment/');

define('DEVELOPMENT', $_W['config']['setting']['development'] == 1);

if(DEVELOPMENT) {

//PHP ini_set用来设置php.ini的值,在函数执行的时候生效,脚本结束后,设置失效。无需打开php.ini文件,就能修改配置,

ini_set('display_errors', '1');

//规定不同的错误级别报告: // 报告 E_NOTICE 之外的所有错误

error_reporting(E_ALL ^ E_NOTICE);

} else {

error_reporting(0);// 关闭错误报告

}

//in_array("Mark", $people)检测$people中会否存在Mark返回布尔值

if(!in_array($_W['config']['setting']['cache'], array('mysql', 'memcache', 'redis'))) {

$_W['config']['setting']['cache'] = 'mysql';

}

load()->func('cache');

//function_exists();检测函数是否已经定义返回布尔值

if(function_exists('date_default_timezone_set')) {

date_default_timezone_set($_W['config']['setting']['timezone']);

}

if(!empty($_W['config']['setting']['memory_limit']) && function_exists('ini_get') && function_exists('ini_set')) {

//ini_get是获取php.ini里的环境变量的值。

if(@ini_get('memory_limit') != $_W['config']['setting']['memory_limit']) {

@ini_set('memory_limit', $_W['config']['setting']['memory_limit']);

}

}

if (isset($_W['config']['setting']['https'])) {

$_W['ishttps'] = $_W['config']['setting']['https'];

} else {

//和$_SERVER有关的解释参考http://blog.csdn.net/jinxingfeng_cn/article/details/24960981

$_W['ishttps'] = $_SERVER['SERVER_PORT'] == 443 ||

//strtolower()把所有字符转换为小写

(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ||

strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ||

strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https' ? true : false;

}

//判断请求是否为ajax请求

$_W['isajax'] = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';

$_W['ispost'] = $_SERVER['REQUEST_METHOD'] == 'POST';

$_W['sitescheme'] = $_W['ishttps'] ? 'https://' : 'http://';

//htmlspecialchars($str)转化$str为输出为html

$_W['script_name'] = htmlspecialchars(scriptname());

//substr($str,6,5) 函数返回字符串第六个字符开始的五个字符

$sitepath = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));

$_W['siteroot'] = htmlspecialchars($_W['sitescheme'] . $_SERVER['HTTP_HOST'] . $sitepath);

if(substr($_W['siteroot'], -1) != '/') {

$_W['siteroot'] .= '/';

}

//parse_url($url);解析url返回数组

$urls = parse_url($_W['siteroot']);

$urls['path'] = str_replace(array('/web', '/app', '/payment/wechat', '/payment/alipay', '/api'), '', $urls['path']);

$_W['siteroot'] = $urls['scheme'].'://'.$urls['host'].((!empty($urls['port']) && $urls['port']!='80') ? ':'.$urls['port'] : '').$urls['path'];

$_W['siteurl'] = $urls['scheme'].'://'.$urls['host'].((!empty($urls['port']) && $urls['port']!='80') ? ':'.$urls['port'] : '') . $_W['script_name'] . (empty($_SERVER['QUERY_STRING'])?'':'?') . $_SERVER['QUERY_STRING'];

//MAGIC_QUOTES_GPC本页13行

if(MAGIC_QUOTES_GPC) {

//istripslashes()删除反斜杠

$_GET = istripslashes($_GET);

$_POST = istripslashes($_POST);

$_COOKIE = istripslashes($_COOKIE);

}

$cplen = strlen($_W['config']['cookie']['pre']);

foreach($_COOKIE as $key => $value) {

if(substr($key, 0, $cplen) == $_W['config']['cookie']['pre']) {

$_GPC[substr($key, $cplen)] = $value;

}

}

unset($cplen, $key, $value);

//array_merge合并数组

$_GPC = array_merge($_GET, $_POST, $_GPC);

$_GPC = ihtmlspecialchars($_GPC);//没有查到ihtmlspecialchars

if(!$_W['isajax']) {

//file_get_contents() 函数把整个文件读入一个字符串中。

$input = file_get_contents("php://input");

if (!empty($input)) {

$__input = @json_decode($input, true);

if (!empty($__input)) {

$_GPC['__input'] = $__input;

$_W['isajax'] = true;

}

}

unset($input, $__input);//销毁变量

}

setting_load();//见model/seting.mod.php 31行

if (empty($_W['setting']['upload'])) {

$_W['setting']['upload'] = array_merge($_W['config']['upload']);

}

$_W['attachurl'] = $_W['attachurl_local'] = $_W['siteroot'] . $_W['config']['upload']['attachdir'] . '/';

if (!empty($_W['setting']['remote']['type'])) {

//ATTACH_FTP见framework/version.inc.php47行

if ($_W['setting']['remote']['type'] == ATTACH_FTP) {

$_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['ftp']['url'] . '/';

} elseif ($_W['setting']['remote']['type'] == ATTACH_OSS) {

$_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['alioss']['url'].'/';

} elseif ($_W['setting']['remote']['type'] == ATTACH_QINIU) {

$_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['qiniu']['url'].'/';

} elseif ($_W['setting']['remote']['type'] == ATTACH_COS) {

$_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['cos']['url'].'/';

}

}

$_W['os'] = Agent::deviceType();//framework/agent.class.php36行

if($_W['os'] == Agent::DEVICE_MOBILE) {

$_W['os'] = 'mobile';

} elseif($_W['os'] == Agent::DEVICE_DESKTOP) {

$_W['os'] = 'windows';

} else {

$_W['os'] = 'unknown';

}

$_W['container'] = Agent::browserType();

if(Agent::isMicroMessage() == Agent::MICRO_MESSAGE_YES) {

$_W['container'] = 'wechat';

} elseif ($_W['container'] == Agent::BROWSER_TYPE_ANDROID) {

$_W['container'] = 'android';

} elseif ($_W['container'] == Agent::BROWSER_TYPE_IPAD) {

$_W['container'] = 'ipad';

} elseif ($_W['container'] == Agent::BROWSER_TYPE_IPHONE) {

$_W['container'] = 'iphone';

} elseif ($_W['container'] == Agent::BROWSER_TYPE_IPOD) {

$_W['container'] = 'ipod';

} else {

$_W['container'] = 'unknown';

}

$controller = $_GPC['c'];

$action = $_GPC['a'];

$do = $_GPC['do'];

header('Content-Type: text/html; charset=' . $_W['charset']);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值