服务端
<?<span style="width: auto; height: auto; float: none;" id="5_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=php&k0=php&kdi0=0&luki=6&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="5_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">php</span></a></span>
require 'conn.php';
header('Content-Type:text/<span style="width: auto; height: auto; float: none;" id="6_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=html&k0=html&kdi0=0&luki=3&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="6_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">html</span></a></span>;<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=charset" class="bdcs-inlinelink" target="_blank">charset</a>=<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=utf-8" class="bdcs-inlinelink" target="_blank">utf-8</a>');
$action = $_GET['action'];
<span style="width: auto; height: auto; float: none;" id="7_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=switch&k0=switch&kdi0=0&luki=5&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="7_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">switch</span></a></span> ($action) {
//<span style="width: auto; height: auto; float: none;" id="8_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=%D7%A2%B2%E1&k0=%D7%A2%B2%E1&kdi0=0&luki=1&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="8_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">注册</span></a></span>会员
case"adduserinfo";
$<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=username" class="bdcs-inlinelink" target="_blank">username</a> = lib_replace_end_tag(<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=trim" class="bdcs-inlinelink" target="_blank">trim</a>($_GET['username']));
$<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=password" class="bdcs-inlinelink" target="_blank">password</a>2 = lib_replace_end_tag(trim($_GET['userpassword']));
$password = md5("$password2" . ALL_PS);
$email = lib_replace_end_tag(trim($_GET['email']));
if ($username == '' || $password2 == '' || $password == '') {
$<span style="width: auto; height: auto; float: none;" id="9_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=res&k0=res&kdi0=0&luki=8&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="9_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">res</span></a></span> = urlencode("参数有误");
exit(<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=json_encode" class="bdcs-inlinelink" target="_blank">json_encode</a>($res)); //有空信息
}
$<span style="width: auto; height: auto; float: none;" id="10_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=sql&k0=sql&kdi0=0&luki=7&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="10_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">sql</span></a></span> = "select username <span style="width: auto; height: auto; float: none;" id="11_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=from&k0=from&kdi0=0&luki=2&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="11_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">from</span></a></span> `member` where username='$username'";
$query = <a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=mysql_query" class="bdcs-inlinelink" target="_blank">mysql_query</a>($sql, $conn);
$count = <a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=mysql_num_rows" class="bdcs-inlinelink" target="_blank">mysql_num_rows</a>($query);
if ($count > 0) {
exit(json_encode(1)); //返回1表示<span style="width: auto; height: auto; float: none;" id="12_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=%D7%A2%B2%E1&k0=%D7%A2%B2%E1&kdi0=0&luki=1&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="12_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">注册</span></a></span>失败
} else {
$addsql = "insert into `member` (username,password,email) values ('$username','$password','$email')";
mysql_query($addsql);
exit(json_encode(0)); //返回0表示注册成功
}
break;
//<span style="width: auto; height: auto; float: none;" id="13_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=%B2%E9%D1%AF&k0=%B2%E9%D1%AF&kdi0=0&luki=4&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="13_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">查询</span></a></span>用户信息
case"selectuserinfo";
$username = lib_replace_end_tag($_GET['username']);
$<span style="width: auto; height: auto; float: none;" id="14_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=sql&k0=sql&kdi0=0&luki=7&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="14_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">sql</span></a></span> = "select id,username,nickname,mobile <span style="width: auto; height: auto; float: none;" id="15_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=from&k0=from&kdi0=0&luki=2&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="15_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">from</span></a></span> `member` where username='$username'";
$query = mysql_query($sql, $conn);
$row = <a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=mysql_fetch_array" class="bdcs-inlinelink" target="_blank">mysql_fetch_array</a>($query);
foreach ($row as $key => $v) {
$<span style="width: auto; height: auto; float: none;" id="16_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=res&k0=res&kdi0=0&luki=8&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="16_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">res</span></a></span>[$key] = urlencode($v);
}
exit(json_encode($res));
break;
//会员登录
case"userlogin";
$username = lib_replace_end_tag($_GET['username']);
$password2 = lib_replace_end_tag(trim($_GET['userpassword']));
$password = md5("$password2" . ALL_PS);
$<span style="width: auto; height: auto; float: none;" id="17_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=sql&k0=sql&kdi0=0&luki=7&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="17_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">sql</span></a></span>user = "select id,username,password <span style="width: auto; height: auto; float: none;" id="18_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=from&k0=from&kdi0=0&luki=2&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="18_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">from</span></a></span> `member` where username='" . $username . "' and password='" . $password . "'";
$queryuser = mysql_query($sqluser);
$rowuser = mysql_fetch_array($queryuser);
if ($rowuser && <a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=is_array" class="bdcs-inlinelink" target="_blank">is_array</a>($rowuser) && !empty($rowuser)) {
if ($rowuser['username'] == $username && $rowuser['password'] == $password) {
if ($rowuser['password'] == $password) {
$<span style="width: auto; height: auto; float: none;" id="19_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=res&k0=res&kdi0=0&luki=8&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="19_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">res</span></a></span> = urlencode("登录成功");
exit(json_encode($res));
} else {
$res = urlencode("密码错误");
exit(json_encode($res));
}
} else {
$res = urlencode("用户名不存在");
exit(json_encode($res));
}
} else {
$res = urlencode("用户名密码错误");
exit(json_encode($res));
}
/*
* 0:表示登录成功,1:表示密码错误,2:用户名不存在,3:用户名密码错误
*/
break;
default:
exit(json_encode(error));
}
?>
客户端例子:
<?<span style="width: auto; height: auto; float: none;" id="0_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=php&k0=php&kdi0=0&luki=6&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="0_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">php</span></a></span>
header('Content-Type:text/<span style="width: auto; height: auto; float: none;" id="1_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=html&k0=html&kdi0=0&luki=3&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="1_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">html</span></a></span>;charset=utf-8'); //避免输出乱码
function httpPost($url, $parms) {
$url = $url . $parms;
if (($ch = <a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=curl_init" class="bdcs-inlinelink" target="_blank">curl_init</a>($url)) == false) {
throw new Exception(<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=sprintf" class="bdcs-inlinelink" target="_blank">sprintf</a>("curl_init error for url %s.", $url));
}
<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=curl_setopt" class="bdcs-inlinelink" target="_blank">curl_setopt</a>($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if (is_array($parms)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data;'));
}
$postResult = @curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($postResult === false || $http_code != 200 || curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception("HTTP POST FAILED:$error");
} else {
// $postResult=str_replace("\xEF\xBB\xBF", '', $postResult);
<span style="width: auto; height: auto; float: none;" id="2_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=switch&k0=switch&kdi0=0&luki=5&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="2_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">switch</span></a></span> (curl_getinfo($ch, CURLINFO_CONTENT_TYPE)) {
case 'application/json':
$postResult = <a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=json_decode" class="bdcs-inlinelink" target="_blank">json_decode</a>($postResult);
break;
}
curl_close($ch);
return $postResult;
}
}
$postUrl = "http://pujia.test.com/api/server.<span style="width: auto; height: auto; float: none;" id="3_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=php&k0=php&kdi0=0&luki=6&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="3_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">php</span></a></span>";
$p=$_GET['p'];
if ($p =="selectuserinfo") {
$username = $_GET['username'];
$parms = "?action=selectuserinfo&username=" . $username . "";
} elseif ($p =="adduserinfo") {
$username = $_GET['username'];
$userpassword = $_GET['userpassword'];
$parms = "?action=adduserinfo&username=" . $username . "&userpassword=" . $userpassword . "";
} elseif ($p =="userlogin") {
$username = $_GET['username'];
$userpassword = $_GET['userpassword'];
$parms = "?action=userlogin&username=" . $username . "&userpassword=" . $userpassword . "";
}
$<span style="width: auto; height: auto; float: none;" id="4_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=20&is_app=0&jk=a3e6e49f21a074bf&k=res&k0=res&kdi0=0&luki=8&mcpm=0&n=10&p=baidu&q=14063017_cpr&rb=0&rs=1&seller_id=1&sid=bf74a0219fe4e6a3&ssp2=1&stid=9&t=tpclicked3_hc&td=1837572&tu=u1837572&u=http%3A%2F%2Fwww%2Ekuitao8%2Ecom%2F20140418%2F2293%2Eshtml&urlid=0" id="4_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">res</span></a></span> = httpPost($postUrl, $parms); //$parms
$res = json_decode($res);
<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=print_r" class="bdcs-inlinelink" target="_blank">print_r</a>(<a target=_blank href="http://zhannei.baidu.com/cse/search?s=326913546274321940&entry=1&q=urldecode" class="bdcs-inlinelink" target="_blank">urldecode</a>(json_encode($res)));
?>