public function getRightToken() { $customer_config = new Model_CustomerConfig(); $sql = "select customer_id,c_value,create_date from customer_config where customer_id='" . $this->customer_id . "' and c_type='token'"; $configinfo = $customer_config->fetchRow($sql); //token 有记录 if ($configinfo) { //token 未过期 if (strtotime($configinfo['create_date']) > time()) { $token = $configinfo['c_value']; //token 已经过期 } else { $token = $this->gettoken($customer_config); if ($token) { $configdata['c_value'] = $token; $configdata['create_date'] = date('Y-m-d H:i:s', time() + 1800); $customer_config->row_update($configdata, "customer_id='{$configinfo[customer_id]}' and c_type='token'"); } } } else { //没有记录 $token = $this->gettoken($customer_config); if ($token) { $configdata['customer_id'] = $this->customer_id; $configdata['c_type'] = "token"; $configdata['c_value'] = $token; $configdata['create_date'] = date('Y-m-d H:i:s', time() + 1800); $customer_config->insert($configdata); } } return $token; }
<?php include_once "../includes/config.inc.php"; //send_phone_msg('18789251158','您的验证码是:568972'); $configModel = new Model_CustomerConfig(); $ss = $configModel->sendCustomerMsg("【云客生活部落】:【★】天气预报:【今天】8月1日,多云,27°到36°,南风3-4级转西南风3-4级。\n\n【★】【心灵鸡汤】:一齐走的兄弟姐妹是一种安慰,一齐走的兄弟姐妹忠告是一种激励,一齐走的兄弟姐妹鼓励是一种力量,一齐走的兄弟姐妹想念是一种愉悦。祝福你兄弟姐妹!\n<a href='http://mp.weixin.qq.com/s?__biz=MzA5ODQwMzI4Ng==&mid=208574136&idx=2&sn=f978823cb2c33499635362154118e724#rd'>【★】【★】【★】“值得学习的思维模式”(←点击我哦^_^)</a>", array('ow6AGuAOUkUcUrjCyT2isDn9rRJc')); var_dump($ss);
} elseif ($_POST['act'] == "dele") { $c_id = (int) $_SESSION['customer_id']; $id = (int) $_POST['m_id']; $where = "customer_id={$c_id} and id={$id}"; $BottomMenu->delete($where); } elseif ($_POST['act'] == "select") { $id = (int) $_POST['m_id']; $row = $BottomMenu->fetchRow("select * from bottom_menu where customer_id='{$c_id}' and id='{$id}'"); $res = json_encode($row); header('Content-Type: application/json'); echo $res; } elseif ($_POST['act'] == "update") { $result = $BottomMenu->query("update bottom_menu set parent_id={$data[parent_id]},menu_name='{$data[menu_name]}',menu_type='{$data[menu_type]}',menu_key='{$data['menu_key']}',menu_order='{$data['menu_order']}' where id={$_POST['m_id']} and customer_id={$data[customer_id]}"); } elseif ($_POST['act'] == "pub_menu") { //向微信提交菜单信息 $db_obj = new Model_CustomerConfig(); $sql = "select c_value from customer_config where customer_id='{$c_id}' and c_type='appid' limit 1"; $db_obj->query($sql); if ($db_obj->next_record()) { $c_value = $db_obj->f('c_value'); $appid_info = explode(',', $c_value); $appid = $appid_info['0']; $secret = $appid_info['1']; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}"; $get_token = post_http($url, 'GET', ''); //$get_token = file_get_contents($url); if (strstr($get_token, 'errmsg')) { die('无效的Appld'); } else { if (strstr($get_token, 'access_token')) { $token_array = json_decode($get_token, true);
<?php include_once "../../includes/config.inc.php"; function post($url, $postType, $jsonData) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $postType); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); curl_close($ch); return $result; } $Customer_Config = new Model_CustomerConfig(); $data = array(); $data['customer_id'] = (int) $_SESSION['customer_id']; $data['c_type'] = str_inmysql('appid'); $data['c_value'] = str_inmysql($_POST['app_id']) . ',' . str_inmysql($_POST['app_Secret']); $data['create_date'] = str_inmysql(date("Y-m-d H:i:s")); $appid = $_POST['app_id']; $secret = $_POST['app_Secret']; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}"; //获取 token $get_token = post($url, $postType = 'GET', ''); if (strstr($get_token, 'errmsg')) { die('无效的AppId'); //如果有获取token成功 } else { if (strstr($get_token, 'access_token')) {
<?php include_once "../../includes/config.inc.php"; $configModel = new Model_CustomerConfig(); $userModel = new Model_Subtable('sub_user'); //微信通道 if (method_is('post')) { $dailyModel = new Model_Subtable('sub_daily'); $id = $_POST['content']; $row = $dailyModel->find($id); $content = $row['title'] . $row['content'] . "<a href='" . $row['a_link'] . "'>" . $row['a_title'] . "</a>"; $configModel->sendCustomerMsg($content, $_POST['fromuser']); } else { $dailyModel = new Model_Subtable('sub_daily'); $id = $_GET['id']; $row = $dailyModel->find($id); $content = $row['title'] . $row['content'] . "<a href='" . $row['a_link'] . "'>" . $row['a_title'] . "</a>"; $smarty->assign('content', $content); $smarty->assign('id', $id); $listArr = $userModel->field('fromuser')->where("username in ('15631183141','18013085978','13814812590','18351519983')")->dataArr(); $smarty->assign('list', $listArr); $smarty->assign('listcount', count($listArr)); $smarty->setTpl('msg/templates/send_kf.html')->display(); die; }
foreach ($listArr as $key => $value) { $uRow = $userModel->field('id,nickname,fromuser')->where("id='{$value['uid']}'")->dataRow(); if ($uRow['fromuser']) { //$post_data="您好".$uRow['nickname'].",您已成功报名".$taskRow['title'].",请于".$taskRow['jihe_time']."到".$taskRow['jihe_address']."集合!"; $post_data = "您好" . $uRow['nickname'] . ",您报名的" . $taskRow['title'] . ",因得到客户临时通知,此兼职取消!"; //$post_data="您好".$uRow['nickname'].",您报名的".$taskRow['title'].",因得到客户通知,明天照常派单哦!"; $configModel->sendCustomerMsg($post_data, $uRow['fromuser']); usleep(100000); } } } die; } if ($_REQUEST['a'] == 'send_msg_new') { set_time_limit(0); $configModel = new Model_CustomerConfig(); $tid = $_POST['tid']; $content = $_POST['msg']; //职位信息 /* $taskModel=D('sub_task'); $taskRow=$taskModel->find($tid); */ //确认过的报名人员 $listArr = D('sub_sign')->where("tid='{$tid}' and is_valid=1")->dataArr(); if ($listArr) { foreach ($listArr as $key => $value) { $uRow = $userModel->field('id,nickname,fromuser')->where("id='{$value['uid']}'")->dataRow(); if ($uRow['fromuser']) { $configModel->sendCustomerMsg($content, $uRow['fromuser']); usleep(100000); } }
} } //非追加非指定的人员 $limit_str = (int) $out_num . ',' . ($aRow['num'] - $zd_sign_row_my['count_num']); $listArr = $signModel->where("is_valid=1 and is_zj=0 and dudao_uid=0 and tid='" . $aRow['tid'] . "'")->order('id asc')->limit($limit_str)->dataArr(); if (!$listArr) { $listArr = array(); } //已追加给该督导和指定给该督导的报名人员 $zj_list = $signModel->where("is_valid=1 and tid='" . $aRow['tid'] . "' and dudao_uid='" . $userRow['id'] . "'")->order('id asc')->dataArr(); if (!$zj_list) { $zj_list = array(); } $listArr = array_merge($listArr, $zj_list); if ($listArr) { $configModel = new Model_CustomerConfig(); foreach ($listArr as $key => $value) { //从快照中获取用户信息 $value['user_json'] ? $uRow = unserialize($value['user_json']) : ($uRow = $userModel->find($value['uid'])); $configModel->sendCustomerMsg($_POST['content'], array($uRow['fromuser'])); usleep(100000); } } die; } //追加报名 if ($_REQUEST['a'] == 'sign_zj') { $phone = $_GET['phone']; //判断手机账号是否存在 $uRow = $userModel->where("type=1 and pid!=0 and username='******'")->dataRow(); if (!$uRow) {
public function getLocation() { $i = 0; $push_num = 1; $infolbsModel = new Model_InfoLbs(); $filter['where'] = " customer_id='{$this->customer_id}' and state='1' and x_dian!='' "; $sql = $infolbsModel->select($filter); $inforesult = $infolbsModel->fetchAll($sql); $infocount = count($inforesult); for ($i = 0; $i < $infocount; $i++) { $inforesult[$i]['location_desc'] = strip_tags($inforesult[$i]['location_desc']); $short_intro = cut_str(strip_tags($inforesult[$i]['location_intro']), 120, $start = 0, $code = 'UTF-8'); $inforesult[$i]['location_desc'] = $inforesult[$i]['location_desc'] != '' ? $inforesult[$i]['location_desc'] : $short_intro; $inforesult[$i]['faraway'] = $this->get_distance($this->location_x, $this->location_y, $inforesult[$i]['x_dian'], $inforesult[$i]['y_dian']); } $newlocallist = multi_array_sort($inforesult, 'faraway', $sort = SORT_ASC); $customerconfigModel = new Model_CustomerConfig(); $filter['where'] = " customer_id='{$this->customer_id}' and c_type='lbs_push' "; $sql = $customerconfigModel->select($filter); $inforesult = $customerconfigModel->fetchRow($sql); if ($inforesult['c_value']) { $push_num = $inforesult['c_value']; } else { if ($i >= 2) { $push_num = 2; } } $push_num = $push_num <= $i ? $push_num : $i; for ($j = 0; $j < $push_num; $j++) { if ($j >= 10) { $push_num = 10; break; } $sql = "update info_lbs set push_num=push_num+1 where id='" . $newlocallist[$j]['id'] . "' limit 1"; $customerconfigModel->query($sql); $infolbsrecordModel = new Model_InfoLbsRecord(); $row['lbs_id'] = $newlocallist[$j]['id']; $row['customer_id'] = $this->customer_id; $row['fromuser'] = $this->fromuser; $row['fromwhere'] = $this->fromwhere; $row['ip'] = $_WGT['IP']; $row['create_date'] = date("Y-m-d H:i:s"); $infolbsrecordModel->insert($row); $url = 'http://' . $_SERVER['HTTP_HOST'] . "/mobile/info.php?t=location&id=" . $newlocallist[$j]['id']; $itemlist .= "<item>\n\t\t <Title><![CDATA[[" . $newlocallist[$j]['faraway'] . "公里]" . $newlocallist[$j]['location_name'] . "]]></Title>\n\t\t <Description><![CDATA[" . $newlocallist[$j]['location_desc'] . "]]></Description>\n\t\t <PicUrl><![CDATA[http://" . $_SERVER['HTTP_HOST'] . "/data/image_c/" . $newlocallist[$j]['location_pic'] . "]]></PicUrl>\n\t\t <Url><![CDATA[{$url}]]></Url>\n\t\t </item>"; } if ($i > 0) { $Bodystr = "\n\t\t\t <ArticleCount>{$push_num}</ArticleCount>\n\t\t\t <Articles>\n\t\t\t {$itemlist}\n\t\t\t </Articles>"; $data['msgtype'] = 'news'; $data['bodystr'] = $Bodystr; return $data; } }
$jobsignModel = new Model_Subtable('sub_jobsign'); $data = array(); $data['info']['jid'] = (int) $_REQUEST['jid']; $data['info']['uid'] = $_SESSION['tyuser']['id']; $jobRow = $model->find($data['info']['jid']); $row = $jobsignModel->where("jid='" . $data['info']['jid'] . "' and uid='" . $data['info']['uid'] . "'")->dataRow(); //已领取 if ($row) { die('err'); } else { $res = $jobsignModel->add($data); //领取数+1 $jobsignModel->query("update sub_job set num=num+1 where id='" . $data['info']['jid'] . "'"); //发消息 if ($res) { $configModel = new Model_CustomerConfig(); $configModel->sendCustomerMsg('您领取了新任务:' . $jobRow['title'] . ",<a href='" . $jobRow['msg'] . "'>点击这里</a>,查看详细任务密函", $userRow['fromuser']); die('suc'); } else { die('err'); } } } //推送消息页 if ($_REQUEST['a'] == 'msg') { $id = (int) $_GET['id']; $smarty->assign('vo', $model->find($id)); $smarty->setLayout('')->setTpl('mobile/templates/job_msg.html')->display(); die; } //取消任务
} else { $id = (int) $_GET['id']; if ($id) { $smarty->assign('vo', $model->find($id)); } $smarty->setTpl('user/templates/cz.html')->display(); die; } } //向单个用户发消息 if ($_REQUEST['a'] == 'send_msg') { if (method_is('post')) { $id = $_POST['id']; $userModel = new Model_Subtable('sub_user'); $userRow = $userModel->find($id); $configModel = new Model_CustomerConfig(); $configModel->sendCustomerMsg($_POST['content'], $userRow['fromuser']); } die; } //生成大礼包优惠码 if ($_REQUEST['a'] == 'produce_code') { if (method_is('post')) { $data = array(); $id = $_POST['id']; $userModel = new Model_Subtable('sub_user'); $userRow = $userModel->find($id); $data['info']['id'] = $id; $data['info']['code'] = substr(md5($userRow['username']), -6); $userModel->add($data); }
<?php include_once "../../includes/config.inc.php"; include_once "../../includes/login_check.php"; $customer_id = (int) $_SESSION['customer_id']; $customerconfigModel = new Model_CustomerConfig(); $filter['where'] = " customer_id='{$customer_id}' and c_type='appid' "; $sql = $customerconfigModel->select($filter, 'c_value'); $value_str = $customerconfigModel->fetchRow($sql); $value_array = explode(',', $value_str['c_value']); $smarty->assign('value_array', $value_array); $smarty->setTpl('info/templates/auth.html')->display();
public function getMeminfo($fromuser) { $customer_config = new Model_CustomerConfig(); $sql = "select customer_id,c_value,create_date from customer_config where customer_id='" . $this->customer_id . "' and c_type='token'"; $configinfo = $customer_config->fetchRow($sql); //获取access_token if ($configinfo) { if (strtotime($configinfo['create_date']) > time()) { //token未过期 $token = $configinfo['c_value']; } else { //token已经过期 $token = $this->gettoken($customer_config); if ($token) { $configdata['c_value'] = $token; $configdata['create_date'] = date('Y-m-d H:i:s', time() + 3600); $customer_config->row_update($configdata, "customer_id='{$configinfo[customer_id]}' and c_type='token'"); } } } else { //没有记录 $token = $this->gettoken($customer_config); if ($token) { $configdata['customer_id'] = $this->customer_id; $configdata['c_type'] = "token"; $configdata['c_value'] = $token; $configdata['create_date'] = date('Y-m-d H:i:s', time() + 3600); $customer_config->insert($configdata); } } //获取详细信息 $rowMem2 = array(); if ($token) { $memberjson = file_get_contents("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $token . "&openid=" . $fromuser . "&lang=zh_CN"); $meminfo = json_decode($memberjson); if ($meminfo->nickname) { $rowMem2['nickname'] = $meminfo->nickname; $rowMem2['sex'] = $meminfo->sex; $rowMem2['language'] = $meminfo->language; $rowMem2['city'] = $meminfo->city; $rowMem2['province'] = $meminfo->province; $rowMem2['country'] = $meminfo->country; $rowMem2['headimgurl'] = $meminfo->headimgurl; return $rowMem2; } } return $rowMem2; }