check_token(); $utype = intval($_POST['utype']); $content = trim($_POST['content']) == '' ? adminmsg("请输入消息内容!", 1) : trim($_POST['content']); if ($utype == 0) { $users = $db->getall("select * from " . table('members') . " where `weixin_openid`!=''"); } else { $users = $db->getall("select * from " . table('members') . " where `weixin_openid`!='' and `utype`=" . $utype); } $access_token = get_access_token(); if (empty($access_token)) { adminmsg("access_token获取失败!", 1); } $setsqlarr['content'] = $content; $setsqlarr['sendtime'] = time(); foreach ($users as $key => $value) { send_weixin_msg($value['weixin_openid'], $content, $access_token); $setsqlarr['uid'] = $value['uid']; $setsqlarr['utype'] = $value['utype']; $setsqlarr['username'] = addslashes($value['username']); $setsqlarr['weixin_openid'] = $value['weixin_openid']; $db->inserttable(table("weixin_msg_list"), $setsqlarr, 1); } adminmsg("发送成功!", 2); } elseif ($act == 'del_weixin_msg') { check_token(); $id = $_REQUEST['id']; if ($num = del_weixin_msg($id)) { write_log("删除消息,共删除" . $num . "条记录", $_SESSION['admin_name'], 3); adminmsg("删除成功!共删除" . $num . "条记录", 2); } else { adminmsg("删除失败!", 1);
/** * 进行抽奖 * * @param string * @return array */ public function rand_lucky() { $lucky = rand_lucky_man(); if (is_array($lucky)) { //获取中奖者信息 $user = get_weixin_user_info($lucky["openId"]); //标示中奖者 $bResult = update_luck_man($lucky["openId"], $user["nickname"]); //推送中奖信息 $msg = c("weixin_lucky_msg"); if (c("wxPush")) { $bResult = send_weixin_msg($lucky["openId"], $msg); } if ($bResult) { return self::send_result($user["nickname"]); } else { return self::send_error(LR_API_SYSTEM_EXCEPTION, '抱歉,系统发生未知故障!'); } } else { return self::send_error(LR_API_SYSTEM_EXCEPTION, '抱歉,系统发生未知故障!'); } }