PHP微商城开源代码实例
本文实例为大家分享了PHP微商城的具体代码,供大家参考,具体内容如下
0) {
$C_webtitle = $row["C_title"];
$C_wtoken = $row["C_wtoken"];
$C_logo = $row["C_logo"];
$C_ico = $row["C_ico"];
$C_wx_appidz = $row["C_wx_appid"];
$C_wx_appsecretz = $row["C_wx_appsecret"];
}
$signature = $_REQUEST["signature"];
$nonce = $_REQUEST["nonce"];
$timestamp = $_REQUEST["timestamp"];
$echostr = $_REQUEST["echostr"];
if ($echostr != "") {
$array = array();
$array = array($C_wtoken, $timestamp, $nonce);
sort($array);
$str = sha1(implode($array));
if ($str == $signature && $echostr) {
echo $echostr;
exit;
}
}
if ($signature != "" && $echostr == "") {
$postArr = file_get_contents("php://input");
$postObj = simplexml_load_string($postArr);
$ToUserName = $postObj->FromUserName;
$FromUserName = $postObj->ToUserName;
$MsgType = $postObj->MsgType;
$strEvent = $postObj->Event;
$EventKey = $postObj->EventKey;
file_put_contents("test.txt", $postArr);
if ($MsgType == "event") {
if ($strEvent == "subscribe") {
$strsend = events( $ToUserName,$FromUserName, "key_" . getrs("select * from SL_reply where R_key like '新用户关注'", "R_reply"));
$sqlx = "Select * from SL_member where M_qqid like '" . $ToUserName . "'";
$resultx = mysqli_query($conn, $sqlx);
if (mysqli_num_rows($resultx) > 0) {
mysqli_query($conn, "update SL_member set M_subscribe=1 where M_qqid like '" . $ToUserName . "'");
} else {
$access_token = json_decode(GetBody("http://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $C_wx_appidz . "&secret=" . $C_wx_appsecretz, ""))->access_token;
$M_info = json_decode(GetBody("http://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $ToUserName . "&lang=zh_CN", ""));
$M_login = $M_info->nickname;
$M_pic = $M_info->headimgurl;
$M_city = $M_info->city;
$M_province = $M_info->province;
$M_country = $M_info->country;
mysqli_query($conn, "insert into SL_member(M_login,M_pwd,M_qqid,M_pic,M_fen,M_regtime,M_add,M_name,M_subscribe) values('" . $M_login . "','" . $ToUserName . "','" . $ToUserName . "','" . $M_pic . "',0,'" . date('Y-m-d H:i:s') . "','" . $M_country . $M_province . $M_city . "','" . $M_login . "',1)");
$sql = "select * from SL_member order by M_id desc limit 1";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
if (mysqli_num_rows($result) > 0) {
$M_id = $row["M_id"];
}
uplevel($M_id);
}
}
if ($strEvent == "unsubscribe") {
mysqli_query($conn, "update SL_member set M_subscribe=0 where M_qqid like '" . $ToUserName . "'");
}
if ($strEvent == "CLICK") {;
$strsend = events( $ToUserName,$FromUserName, $EventKey);
}
}
if ($MsgType == "text") {
$E_content = $postObj->Content;
$strsend = text( $ToUserName, $FromUserName,$E_content);
file_put_contents("test3.txt", $strsend);
}
echo $strsend;
}
function events($FromUserName, $ToUserName, $key) {
global $conn, $D_domain, $C_ico;
$E_type = getrs("select * from SL_event where E_id=" . splitx($key, "_", 1), "E_type");
$E_content = getrs("select * from SL_event where E_id=" . splitx($key, "_", 1), "E_content");
switch ($E_type) {
case "text":
$events = "