我自己写的小功能出现问题,请大侠帮我找找问题所在
By q191045643
at 2016-08-04
0人收藏 • 7974人看过
我仿照网站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.
请问这是什么原因呢,我是不是有什么细节没有加上
- 登录后方可回帖
android那里显示不全,这里加上
MyUploadTask(String doctorusername) { .put(doctorusername)}
JSONObject (Void... params) { HttpUtil.(RecordActivity.APIAddress.)}
回复#1 @q191045643 :
怎么老是吞,
MyUploadTask(String doctorusername) { parameter.put("DoctorName", doctorusername); } protected JSONObject doInBackground(Void... params) { return HttpUtil.postRequest(RecordActivity.this, APIAddress.MY_UPLOAD_URL,parameter, true, false); }
回复#5 @lincanbin :
什么意思,要我再发一次吗,还是截图给你看
回复#6 @q191045643 :
再发一次。
<?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');
回复#7 @lincanbin :
我发了
回复#7 @lincanbin :
是不是要把自己的页面在哪注册一下呢
回复#10 @q191045643 :
5.6.1吗?
回复#10 @q191045643 :
你下载的版本里,index.php有没有route?
回复#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');
回复#12 @lincanbin :
好像没有
回复#13 @q191045643 :
旧版本的,那么你的.htaccess里需要添加对应的route。
回复#15 @lincanbin :
我想问,如果不在.htaccess中重写路由规则,像验证码那个php页面一样,app能不能访问获取json数据
回复#16 @q191045643 :
不能。
回复#17 @lincanbin :
我直接访问mypage.php不行吗,为啥你android里的apiaddress里可以直接通过
public static final String VERIFICATION_CODE = BASIC_API_URL + "seccode.php";
获取,这个我在.htaccess没有找到