Home  >  Article  >  Backend Development  >  关于ucenter通讯过程的代码的!CSDN大神多!慕名而来!请多指教!

关于ucenter通讯过程的代码的!CSDN大神多!慕名而来!请多指教!

WBOY
WBOYOriginal
2016-06-23 13:56:131005browse

调试ucenter的时候在/control/admin/app.php中遇到了这样一段代码
if($app['extra']['apppath'] && @include $app['extra']['apppath'].'./api/'.$app['apifilename'])
{
//code
}
请问 这个if 后面 include 进来的文件 是执行的结果还是文件本身,还是仅仅返回一个ture or false?
include 进来的是一个.php的文件。
分割线----------------------------------------------------------------------------------------------------------------
运行下面这个文件中的 onping函数

<?php	function onping() {		$ip = getgpc('ip');		$url = getgpc('url');		$appid = intval(getgpc('appid'));		$app = $_ENV['app']->get_app_by_appid($appid);		$status = '';		if($app['extra']['apppath'] && @include $app['extra']['apppath'].'./api/'.$app['apifilename']) {			echo 'in if='.$app['extra']['apppath'].'./api/'.$app['apifilename'];			$uc_note = new uc_note();			$status = $uc_note->test($note['getdata'], $note['postdata']);		} else {			echo 'in else';			$this->load('note');			$url = $_ENV['note']->get_url_code('test', '', $appid);			$status = $_ENV['app']->test_api($url, $ip);		}		if($status == '1') {			echo 'document.getElementById(\'status_'.$appid.'\').innerHTML = "<img  src=\'images/correct.gif\' border=\'0\' class=\'statimg\' \/ alt="关于ucenter通讯过程的代码的!CSDN大神多!慕名而来!请多指教!" ><span class=\'green\'>'.$this->lang['app_connent_ok'].'</span>";testlink();';		} else {			echo 'document.getElementById(\'status_'.$appid.'\').innerHTML = "<img  src=\'images/error.gif\' border=\'0\' class=\'statimg\' \/ alt="关于ucenter通讯过程的代码的!CSDN大神多!慕名而来!请多指教!" ><span class=\'red\'>'.$this->lang['app_connent_false'].'</span>";testlink();';		}	}?>


其中include $app['extra']['apppath'].'./api/'.$app['apifilename'] 这个文件是 其他目录里面的 uc.php文件,前部代码如下!这个文件是utf8版的HDwiki5.1自带的!

<?phperror_reporting(0);define('UC_CLIENT_VERSION', '1.5.1');define('UC_CLIENT_RELEASE', '20100501');define('API_DELETEUSER', 1);			//用户删除 APIdefine('API_RENAMEUSER', 1);            //用户改名 APIdefine('API_GETTAG', 1);                //获取标签 APIdefine('API_SYNLOGIN', 1);              //同步登录 APIdefine('API_SYNLOGOUT', 1);             //同步登出 APIdefine('API_UPDATEPW', 1);              //更改用户密码define('API_UPDATEBADWORDS', 1);        //更新关键字列表define('API_UPDATEHOSTS', 1);           //更新域名解析缓存define('API_UPDATEAPPS', 1);            //更新应用列表define('API_UPDATECLIENT', 1);          //更新客户端缓存define('API_UPDATECREDIT', 1);          //更新用户积分define('API_GETCREDITSETTINGS', 1);     //向 UCenter 提供积分设置define('API_GETCREDIT', 1);             //获取用户的某项积分define('API_UPDATECREDITSETTINGS', 1);  //积分设置define('API_RETURN_SUCCEED', '1');define('API_RETURN_FAILED', '-1');define('API_RETURN_FORBIDDEN', '-2');define('HDWIKI_ROOT', substr(dirname(__FILE__),0,-4));define('UC_CLIENT_ROOT',HDWIKI_ROOT.'/api/uc_client/');define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());require_once HDWIKI_ROOT.'/api/ucconfig.inc.php';$get = $post = array();$code = @$_GET['code'];parse_str(authcode($code, 'DECODE', UC_KEY), $get);if(MAGIC_QUOTES_GPC) {	$get = _stripslashes($get);}$timestamp = time();if(empty($get)){	exit('Invalid Request');}elseif($timestamp - $get['time'] > 3600){	exit('Authracation has expiried');}


那为什么输出了一个'Invalid Request 呢?这个输出结果对吗?


回复讨论(解决方案)

对于 @include $app['extra']['apppath'].'./api/'.$app['apifilename']
当文件 $app['extra']['apppath'].'./api/'.$app['apifilename'] 不存在时,反对 false
存在时返回 1
这种写法完全没有问题!

如果你的程序出现了问题,请在其他的地方找原因

对于 @include $app['extra']['apppath'].'./api/'.$app['apifilename']
当文件 $app['extra']['apppath'].'./api/'.$app['apifilename'] 不存在时,反对 false
存在时返回 1
这种写法完全没有问题!

如果你的程序出现了问题,请在其他的地方找原因



请问,这样的用法和file_exists的功能有什么区别呢?include进来的内容 对本地程序有影响吗?还是 单纯的判读文件是否存在?

include 进来的肯定是有内容的了,从你贴出的片段不也能看到很多定义吗?
你当然可以先判断文件存在,然后再include
但这样写不是很简洁吗?至少在编译器件要少分析一个语句吧?

问题找到了
是301跳转的问题
换了主机空间原来的独立Ip没有了!
301跳转方面可能有点问题!
多谢各位大神了!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn