我自己写的小功能出现问题,请大侠帮我找找问题所在
我仿照网站login.php写了一个myupload.php,现在需求是发送一个用户名给服务器,让他判断其权限是否是2,是的话就返回该用户信息,不是就返回错误
//myupload.php
<?php include(__DIR__ . '/common.php'); require(__DIR__ . '/language/' . ForumLanguage . '/login.php'); $Error = ''; $ErrorCode = 101000; $DoctorName = ''; $ReturnUrl = isset($_SERVER['HTTP_REFERER']) ? htmlspecialchars($_SERVER["HTTP_REFERER"]) : ''; if ($_SERVER['REQUEST_METHOD'] == 'POST' || $IsApp) { if (!ReferCheck(Request('Post', 'FormHash'))) { AlertMsg($Lang['Error_Unknown_Referer'], $Lang['Error_Unknown_Referer'], 403); } $ReturnUrl = htmlspecialchars(Request('Post', 'ReturnUrl')); $DoctorName = strtolower(Request('Post', 'DoctorName')); do{ if (!$DoctorName) { $Error = $Lang['Forms_Can_Not_Be_Empty']; $ErrorCode = 101001; break; } $DBUser = $DB->row("SELECT ID,UserName,Salt,Password,UserRoleID,UserMail,UserIntro FROM " . $Prefix . "users WHERE UserName = :UserName", array( "UserName" => $DoctorName )); if (!$DBUser) { $Error = $Lang['User_Does_Not_Exist']; $ErrorCode = 101003; break; } if ($DBUser['UserRoleID']!=2) { $Error = $Lang['User_IsNot_DOCTOR']; $ErrorCode = 101004; break; } }while(false); } $DB->CloseConnection(); // 页面变量 $ContentFile = $TemplatePath . 'myupload.php'; include($TemplatePath . 'layout.php');
//---------------------------------------------------------------------------
//api----myupload.php
<?php if (!defined('InternalAccess')) exit('{"Status": 0, "ErrorCode": "403", "ErrorMessage": "403"}'); if($Error){ ?>{ "Status": 0, "ErrorCode": <?php echo $ErrorCode;?>, "ErrorMessage": "<?php echo $Error;?>" } <?php }else{ ?> { "Status": 1, "DoctorID": <?php echo $DBUser['ID']; ?>, "DoctorInfo" : <?php unset($DBUser['Password']); unset($DBUser['Salt']); unset($DBUser['PasswordQuestion']); unset($DBUser['PasswordAnswer']); echo json_encode($DBUser); ?> } <?php } ?>
//android
MyUploadTask AsyncTask<VoidVoidJSONObject> { Map<StringString> = HashMap<>()MyUploadTask(String doctorusername) { .put(doctorusername)} JSONObject (Void... params) { HttpUtil.(RecordActivity.APIAddress.)}
然后现在报错
08-04 04:32:58.542 2618-2656/com.myproject.carbonforum D/POST URL :: http://api.woe.pub/myupload.php 08-04 04:32:58.543 2618-2656/com.myproject.carbonforum D/POST parameter: SKey=12450&STime=1470285178&SValue=172a79722ec5fc2c0b5b3520630b4c82&DoctorName=admin 08-04 04:32:58.712 2618-2656/com.myproject.carbonforum D/Configuration error: API_KEY or API_SECRET or system time error.
请问这是什么原因呢,我是不是有什么细节没有加上
<?php
include(__DIR__ . '/common.php');
require(__DIR__ . '/language/' . ForumLanguage . '/login.php');
$Error = '';
$ErrorCode = 101000;
$DoctorName = '';
$ReturnUrl = isset($_SERVER['HTTP_REFERER']) ? htmlspecialchars($_SERVER["HTTP_REFERER"]) : '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' || $IsApp) {
if (!ReferCheck(Request('Post', 'FormHash'))) {
AlertMsg($Lang['Error_Unknown_Referer'], $Lang['Error_Unknown_Referer'], 403);
}
$ReturnUrl = htmlspecialchars(Request('Post', 'ReturnUrl'));
$DoctorName = strtolower(Request('Post', 'DoctorName'));
do{
if (!$DoctorName) {
$Error = $Lang['Forms_Can_Not_Be_Empty'];
$ErrorCode = 101001;
break;
}
$DBUser = $DB->row("SELECT ID,UserName,Salt,Password,UserRoleID,UserMail,UserIntro FROM " . $Prefix . "users WHERE UserName = :UserName", array(
"UserName" => $DoctorName
));
if (!$DBUser) {
$Error = $Lang['User_Does_Not_Exist'];
$ErrorCode = 101003;
break;
}
if ($DBUser['UserRoleID']!=2) {
$Error = $Lang['User_IsNot_DOCTOR'];
$ErrorCode = 101004;
break;
}
}while(false);
}
$DB->CloseConnection();
// 页面变量
$ContentFile = $TemplatePath . 'myupload.php';
include($TemplatePath . 'layout.php');
回复#12 @lincanbin :
这是根目录的index.php
<?php
require(__DIR__ . '/common.php');
require(__DIR__ . '/language/' . ForumLanguage . '/home.php');
$Page = intval(Request('Get', 'page'));
$TotalPage = ceil($Config['NumTopics'] / $Config['TopicsPerPage']);
if (($Page < 0 || $Page == 1) && !$IsApp) { //页数小于0或者第一页跳转到首页
header('location: ' . $Config['WebsitePath'] . '/');
exit;
}
if ($Page > $TotalPage) { //页数大于总页跳转到最后一页
header('location: ' . $Config['WebsitePath'] . '/page/' . $TotalPage);
exit;
}
if ($Page == 0)
$Page = 1;
$TopicsArray = array();
if ($MCache && $Page == 1) {
$TopicsArray = $MCache->get(MemCachePrefix . 'Homepage');
}
if (!$TopicsArray) {
if ($Page <= 10) {
$TopicsArray = $DB->query('SELECT `ID`, `Topic`, `Tags`, `UserID`, `UserName`, `LastName`, `LastTime`, `Replies`
FROM ' . $Prefix . 'topics force index(LastTime)
WHERE IsDel=0
ORDER BY LastTime DESC
LIMIT ' . ($Page - 1) * $Config['TopicsPerPage'] . ',' . $Config['TopicsPerPage']);
if ($MCache && $Page == 1) {
$MCache->set(MemCachePrefix . 'Homepage', $TopicsArray, 600);
}
} else {
$TopicsArray = $DB->query('SELECT `ID`, `Topic`, `Tags`, `UserID`, `UserName`, `LastName`, `LastTime`, `Replies`
FROM ' . $Prefix . 'topics force index(LastTime)
WHERE LastTime<=(SELECT LastTime
FROM ' . $Prefix . 'topics force index(LastTime)
WHERE IsDel=0
ORDER BY LastTime DESC
LIMIT ' . ($Page - 1) * $Config['TopicsPerPage'] . ',1)
and IsDel=0
ORDER BY LastTime DESC
LIMIT ' . $Config['TopicsPerPage']);
}
}
$DB->CloseConnection();
$PageTitle = $Page > 1 ? ' Page' . $Page . '-' : '';
$PageTitle .= $Config['SiteName'];
$PageMetaDesc = htmlspecialchars(mb_substr($Config['SiteDesc'], 0, 150, 'utf-8'));
$ContentFile = $TemplatePath . 'home.php';
include($TemplatePath . 'layout.php');
登录后方可回帖
android那里显示不全,这里加上