public function actionDelete() { $id = $this->_get('id'); $user_id = $this->_get('user_id'); $obj = User::model()->findByPk($user_id); if ($id && Report::model()->deleteByPk($id)) { $mobile = $obj->mobile; if (isset($mobile) && $mobile) { // $type =='register','forget', $sms = new Sms(); $result = $sms->sendSMS($mobile, '您好,你的反馈我们已近收到,我们将尽快处理,Urtime谢谢你的宝贵意见', 'true'); $result = $sms->execResult($result); if ($result[1] == 0) { // echo '发送成功'; Yii::app()->user->setFlash('send', 1); $this->redirect(array('report/index')); } else { //echo "发送失败{$result[1]}"; Yii::app()->user->setFlash('send', 0); $this->redirect(array('report/index')); } } else { Yii::app()->user->setFlash('report', 0); $this->redirect(array('report/index')); } } else { Yii::app()->user->setFlash('report', 0); $this->redirect(array('report/index')); } }
public function actionLogin() { $data = array(); $params = Yii::$app->request->getBodyParams(); if (isset($params['acc_device_token'])) { $devisetoken = $params['acc_device_token']; } else { $devisetoken = ""; } $sms = new Sms(); $vcode = $sms->checkVerifyCode($params['mobile'], $params['code'])['error']; if ($vcode == 0) { $userdata = Accounts::get_user_by_mobile($params['mobile']); if (empty($userdata)) { $access_token = Yii::$app->security->generateRandomString(); $this->userReg($params['mobile'], $devisetoken, $access_token); $userdata = Accounts::get_user_by_mobile($params['mobile']); if (!$userdata) { return Message::say(Message::E_ERROR, null, "登录错误"); } } return Message::say(Message::E_OK, $userdata, "登录成功"); } else { return Message::say(Message::E_ERROR, null, "验证码错误"); } }
public function sendSms($params = array()) { //extract($params); $type = $params['type']; $mobile = $params['mobile']; if (isset($type) && isset($mobile)) { // $type =='register','forget', $num = $this->getrandstr(); $cache = Yii::app()->cache; $cache->hset($mobile, $type, $num); $sms = new Sms(); $result = $sms->send($mobile, '【Urtime】您的注册验证码是:' . $num . '.请完成注册', true); $res = $sms->execResult($result); if ($res[1] == 0) { // echo '发送成功'; $ret = $this->notice('OK', 0, '', $result); } else { //echo "发送失败{$result[1]}"; $ret = $this->notice('ERR', 307, '', $result); } } else { $ret = $this->notice('ERR', 301, '', array('mobile' => isset($mobile) ? $mobile : 0, 'type' => isset($type) ? $type : '')); } return $ret; }
/** * 发送验证码 */ public static function send($mobile) { $code = mt_rand('100000', '999999'); $Sms = new Sms($mobile, $code); if ($Sms->send()) { M('app_sms_code')->add(['phone' => $mobile, 'code' => $code, 'ctime' => time()]); } }
public function actionSend() { $model = new Sms(); if (isset($_POST['Sms'])) { $model->attributes = $_POST['Sms']; if ($model->validate() && $model->send()) { $this->refresh(); } } $this->render('/sms/send', ['model' => $model]); }
/** * Redirect user after successful login. * * @param string $redirect_to URL to redirect to. * @param string $request URL the user is coming from. * @param object $user Logged user's data. * @return string */ function my_login_redirect($redirect_to, $request, $user) { //is there a user to check? if (!is_user_logged_in()) { $redirect_to; } $hp = get_user_meta($user->ID, 'phone', true); $sms = new Sms(); $r = $sms->send($hp, "Notifikasi Login\nYth {$user->display_name}, Anda baru saja login. Kalau itu bukan anda, harap laporkan pada admin.\nstaff.stiba.ac.id"); return $redirect_to; }
/** * 首页 * */ public function actionIndex() { parent::_acl('sms_index'); $model = new Sms(); $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->render('index', array('datalist' => $result, 'pagebar' => $pages)); }
public function statusUpdate($order_id) { $this->load->model('checkout/order'); $this->load->model('module/smsapi'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info['order_status_id'] != 0) { $message = $this->model_module_smsapi->get_status($order_info['order_status_id'])[0]['description']; $customer_msg = new Message($order_info, $message); $customer_message = $customer_msg->get_customer_message(); $options = array('special_chars' => $this->model_module_smsapi->get_settings()[0]['special_chars'], 'fast' => $this->model_module_smsapi->get_settings()[0]['fast']); $db_sender = $this->model_module_smsapi->get_settings()[0]['sender']; $username = $this->model_module_smsapi->get_settings()[0]['smsapi_username']; $password = $this->model_module_smsapi->get_settings()[0]['smsapi_password']; $admin_phone = $this->model_module_smsapi->get_settings()[0]['admin_phone']; $sms = new Sms($options, $db_sender, $username, $password); if (!$this->model_module_smsapi->get_order($order_info['order_id']) && $this->model_module_smsapi->get_settings()[0]['new_order']) { $this->model_module_smsapi->set_order($order_info); $message = $this->model_module_smsapi->get_settings()[0]['new_order_message']; $admin_msg = new Message($order_info, $message); $admin_message = $admin_msg->get_admin_message(); $result = $sms->send($admin_phone, $admin_message); if (is_string($result)) { $this->model_module_smsapi->add_history($result); } else { $this->model_module_smsapi->add_history($admin_message); } if ($this->model_module_smsapi->get_status($order_info['order_status_id'])[0]['checked']) { $result = $sms->send($order_info['telephone'], $customer_message); if (is_string($result)) { $this->model_module_smsapi->add_history($result); } else { $this->model_module_smsapi->add_history($customer_message); } } } if ($this->model_module_smsapi->get_settings()[0]['change_order_status']) { if ($this->model_module_smsapi->get_status($order_info['order_status_id'])[0]['checked']) { $this->model_module_smsapi->set_order($order_info); $result = $sms->send($order_info['telephone'], $customer_message); if (is_string($result)) { $this->model_module_smsapi->add_history($result); } else { $this->model_module_smsapi->add_history($customer_message); } } } } }
/** * 发送手机验证码 * @method POST_phoneAction * @author NewFuture */ public function POST_phoneAction() { $response['status'] = 0; if (!Input::post('phone', $phone, Config::get('regex.phone'))) { $response['info'] = '手机号格式有误或者不支持!'; } elseif (!Input::post('account', $account, Config::get('regex.account'))) { $response['info'] = '账号有误,如果账号忘记请联系云印工作人员'; } elseif (!($Printer = PrinterModel::where('account', $account)->field('id,phone')->find())) { $response['info'] = '尚未注册'; } elseif (!Safe::checkTry('pwd_phone_' . $account)) { $response['info'] = '尝试次数过多,临时封禁!'; } elseif (!$Printer['phone'] || $Printer['phone'] != $phone) { $response['info'] = '绑定手机不一致,或者手机号错误'; } elseif (!Sms::findPwd($phone, $code = Random::number(6))) { $response['info'] = '短信发送出错,请联系我们!'; } else { /*发送成功*/ $find = ['id' => $Printer['id'], 'account' => $account, 'code' => strtoupper($code)]; Session::set('find_info_p', $find); Safe::del('pwd_phone_' . $account); $response['status'] = 1; $response['info'] = '验证短信已发送'; } $this->response = $response; }
/** * 发送手机验证码 * @method POST_phoneAction * @author NewFuture */ public function POST_phoneAction() { $response['status'] = 0; if (!Input::post('phone', $phone, Config::get('regex.phone'))) { $response['info'] = '手机号格式有误或者不支持!'; } elseif (!Input::post('number', $number, 'card')) { $response['info'] = '学号格式有误!'; } elseif (!Safe::checkTry('pwd_phone_' . $number)) { $response['info'] = '尝试次数过多,临时封禁!'; } elseif (!($user = UserModel::where('number', $number)->field('id,phone')->find())) { $response['info'] = '尚未注册,或者学号错误'; } elseif (empty($user['phone'])) { $response['info'] = '未绑定手机号,或者学号错误'; } elseif (Encrypt::encryptPhone($phone, $number, $user['id']) != $user['phone']) { $response['info'] = '绑定手机不一致,或者手机号错误'; } elseif (!Sms::findPwd($phone, $code = Random::code(6))) { $response['info'] = '短信发送出错,请联系我们!'; } else { /*发送成功*/ $find = ['id' => $user['id'], 'number' => $number, 'code' => strtoupper($code)]; Session::set('find_info', $find); Safe::del('pwd_phone_' . $number); $response['status'] = 1; $response['info'] = '短信已发送'; } $this->response = $response; }
public function postInsert($event) { $company = $this->getCreator()->getGroups()->getFirst(); // notify it-admins if ($company) { $subject = Email::generateSubject($this); $text = 'Заявка от компании ' . $company->getName() . ', пользователь ' . $this->getCreator()->getUsername() . PHP_EOL . 'http://helpdesk.f1lab.ru/tickets/' . $this->getId(); // sms if (true == ($notify = $company->getNotifySms())) { $phones = []; foreach ($notify as $user) { if ($user->getPhone()) { $phones[] = $user->getPhone(); } } Sms::send($phones, $text); } // email if (true == ($notify = $company->getNotifyEmail())) { $emails = []; foreach ($notify as $user) { if ($user->getEmailAddress()) { $emails[] = $user->getEmailAddress(); } } Email::send($emails, $subject, $text); } } // send email to creator $to = $this->getRealSender() ?: $this->getCreator()->getEmailAddress(); Email::send($to, Email::generateSubject($this), EmailTemplate::newTicket($this)); }
public function smssendtest() { if (strlen($_GET['mp']) != 11) { $this->error('请输入正确的手机号'); } $this->error(Sms::sendSms('admin', 'hello,你好', $_GET['mp'])); }
public function index($orderid, $paytype, $third_id) { $product_cart_model = M('product_cart'); $out_trade_no = $orderid; $order = $product_cart_model->where(array('orderid' => $out_trade_no))->find(); if (!$this->wecha_id) { $this->wecha_id = $order['wecha_id']; } $sepOrder = 0; if (!$order) { $order = $product_cart_model->where(array('id' => $out_trade_no))->find(); $sepOrder = 1; } if ($order) { if ($order['paid'] != 1) { exit('该订单还未支付'); } /************************************************/ Sms::sendSms($this->token, '您的微信里有团购订单已经付款'); /************************************************/ header('Location:/index.php?g=Wap&m=Groupon&a=myOrders&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id']); } else { exit('订单不存在:' . $out_trade_no); } }
public function actionReplyMessage() { if (isset(Yii::app()->params['twilio']['replyMessage']) && Yii::app()->params['twilio']['replyMessage']) { file_put_contents(Yii::app()->params['logDirPath'] . '/twilio_request.log', print_r($_REQUEST, true) . "\n\n", FILE_APPEND); $phone = str_replace('+44', '', $_REQUEST['From']); $client = Client::model()->findByPhone($phone); $sms = new Sms(); $sms->clientId = $client ? $client->cli_id : 0; $sms->receive($_REQUEST); if ($client) { $latestText = Sms::model()->latestTextToClient($client); } header('content-type: text/xml'); echo '<Response><Sms><![CDATA[' . Yii::app()->params['twilio']['replyMessage'] . ']]></Sms></Response>'; } }
public function index() { $set_id = $this->_get('id', 'intval'); $formData = $this->_createForms($this->token, $set_id); if (IS_POST) { $limit_info = $this->limit_db->where(array('limit_id' => $this->thisForm['limit_id']))->find(); if ($limit_info['enddate']) { if ($limit_info['enddate'] < time()) { $this->error('抱歉,时间已过期,无法提交'); } } if (0 < $limit_info['today_total']) { $time = strtotime(date('Y-m-d')); $total = $this->info_db->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'set_id' => $this->thisForm['set_id'], 'add_time' => array('gt', $time)))->count(); if ($limit_info['today_total'] <= $total) { $this->error('抱歉,今日只能提交' . $limit_info['today_total'] . '次'); } } if (0 < $limit_info['sub_total']) { $total = $this->info_db->where(array('token' => $this->token, 'set_id' => $this->thisForm['set_id'], 'wecha_id' => $this->wecha_id))->count(); if ($limit_info['sub_total'] <= $total) { $this->error('抱歉,提交总数已经超过' . $limit_info['sub_total'] . '次'); } } $data['token'] = $this->token; $data['wecha_id'] = $this->wecha_id; $data['set_id'] = $set_id; $data['add_time'] = time(); $data['user_name'] = empty($this->fans['wechaname']) ? '匿名' : $this->fans['wechaname']; $data['phone'] = empty($this->fans['tel']) ? '匿名' : $this->fans['tel']; $array = array(); foreach ($this->_request() as $key => $value) { if ($value == '') { $array[] = array($key => '未填写'); } } $arr = array(); foreach ($array as $k => $v) { foreach ($v as $key => $value) { $arr[$key] = $value; } } $b = $this->_request(); $request = array_merge($b, $arr); $data['sub_info'] = $this->_serializeSubInfo($request, $set_id); if ($this->info_db->add($data)) { Sms::sendSms($this->token, '你的表单“' . $this->thisForm['title'] . '”中有新的信息'); $this->success($this->thisForm['succ_info']); } else { $this->error($this->thisForm['err_info']); } } else { $spoor = $this->info_db->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'set_id' => $set_id))->count(); $this->assign('spoor', $spoor); $this->assign('verify', $formData['verify']); $this->assign('formData', $formData['string']); $this->display(); } }
public function get_short_message_verification_code() { Logger::getRootLogger()->debug("Authentication::get_short_message_verification_code"); //Logger::getRootLogger()->debug(Utils::var2str(getallheaders())); Logger::getRootLogger()->debug(Utils::get_http_raw()); $response = Utils::validate_request(); if (Utils::validate_request() !== null) { echo Response::getResponseJson($response); return; } $adv_infor = $_POST['request_json']; Logger::getRootLogger()->debug("adv_infor = " . $adv_infor); $adv_infor_array = json_decode($adv_infor, true); Logger::getRootLogger()->debug("dump adv_infor_array:" . Utils::var2str($adv_infor_array)); if (!isset($adv_infor_array['DATA']['cellphone'])) { $response->status = Response::STATUS_ERROR; $response->error_code = "0003"; $response->message = "手机号不得为空"; return $response; } if (!preg_match($this->cellphone_pattern, $adv_infor_array['DATA']['cellphone'])) { $response->status = Response::STATUS_ERROR; $response->error_code = "0005"; $response->message = "无效的手机号码"; return $response; } $cellphone = $adv_infor_array['DATA']['cellphone']; $code = sprintf("%06d", rand(0, 999999)); Utils::set_sms_code($cellphone, $code); $sms = new Sms(); $ret = $sms->send($cellphone, $code); if ($ret != 0) { $response = new Response(); $response->status = Response::STATUS_ERROR; $response->message = "短信校验码获取失败"; $response->error_code = "0027"; echo Response::getResponseJson($response); return; } else { $response = new Response(); $response->status = Response::STATUS_OK; $response->message = "短信校验码获取成功"; echo Response::getResponseJson($response); return; } }
public function index($orderid, $paytype = '', $third_id = '') { $wecha_id = ''; $token = ''; if ($order = M('dish_order')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 $token = $order['token']; $wecha_id = $order['wecha_id']; //$order['paid']=1; $Dishcompany = M('Dish_company')->where(array('cid' => $order['cid']))->find(); $kconoff = $Dishcompany['kconoff']; if ($order['paid']) { $temp = unserialize($order['info']); $tmparr = array('token' => $token, 'cid' => $order['cid'], 'order_id' => $order['id'], 'paytype' => $order['paytype']); $log_db = M('Dishout_salelog'); if (!empty($temp) && is_array($temp)) { $DishDb = M('Dish'); $mDishSet = ThirdPayDishOut::getDishMainCompany($token); foreach ($temp as $kk => $vv) { $did = isset($vv['did']) ? $vv['did'] : $kk; $dishofcid = $order['cid']; if ($mDishSet['cid'] != $order['cid'] && $mDishSet['dishsame'] == 1) { $dishofcid = $mDishSet['cid']; $kconoff = $mDishSet['kconoff']; } $tmpdish = $DishDb->where(array('id' => $did, 'cid' => $dishofcid))->find(); if ($kconoff && !empty($tmpdish) && $tmpdish['instock'] > 0) { $DishDb->where(array('id' => $did, 'cid' => $dishofcid))->setDec('instock', $vv['num']); } $logarr = array('did' => isset($vv['did']) ? $vv['did'] : $kk, 'nums' => $vv['num'], 'unitprice' => $vv['price'], 'money' => $vv['num'] * $vv['price'], 'dname' => $vv['name'], 'addtime' => $order['time'], 'addtimestr' => date('Y-m-d H:i:s', $order['time']), 'comefrom' => 0); $savelogarr = array_merge($tmparr, $logarr); $log_db->add($savelogarr); } } $company = M('Company')->where(array('token' => $token, 'id' => $order['cid']))->find(); if (empty($company) || !is_array($company)) { header('Location:' . U('DishOut/index', array('token' => $token, 'wecha_id' => $wecha_id))); } Sms::sendSms($token, "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理", $company['mp']); $model = new templateNews(); $siteurl = $_SERVER['HTTP_HOST']; $siteurl = strtolower($siteurl); if (strpos($siteurl, "http:") === false && strpos($siteurl, "https:") === false) { $siteurl = 'http://' . $siteurl; } $siteurl = rtrim($siteurl, '/'); /*$model->sendTempMsg('OPENTM202521011', array('href' =>U('DishOut/myOrder', array('token' => $token, 'wecha_id' => $wecha_id, 'cid' => $order['cid']), true, false, true), 'wecha_id' => $wecha_id, 'first' => '外卖订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!'));*/ $model->sendTempMsg('OPENTM202521011', array('href' => $siteurl . '/index.php?g=Wap&m=DishOut&a=myOrder&token=' . $token . '&wecha_id=' . $wecha_id . '&cid=' . $order['cid'], 'wecha_id' => $wecha_id, 'first' => '外卖订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!')); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'des' => htmlspecialchars_decode($order['des'], ENT_QUOTES), 'companytel' => $company['tel'], 'truename' => htmlspecialchars_decode($order['name'], ENT_QUOTES), 'tel' => $order['tel'], 'address' => htmlspecialchars_decode($order['address'], ENT_QUOTES), 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => $order['reservetime'] > 0 ? $order['reservetime'] : '尽快送达', 'price' => $order['price'], 'total' => $order['total'], 'typename' => '外卖', 'ptype' => $order['paytype'], 'list' => $temp); $msg = ArrayToStr::array_to_str($msg, $order['paid']); $op->printit($token, $order['cid'], 'DishOut', $msg, $order['paid']); } header('Location:' . U('DishOut/myOrder', array('token' => $token, 'wecha_id' => $wecha_id, 'cid' => $order['cid']))); } else { exit('抱歉,订单信息出错'); } }
public function index($orderid, $paytype = '', $third_id = '') { if ($order = M('Product_cart')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); $carts = unserialize($order['info']); $tdata = self::getCat($carts, $order['token'], $order['cid'], $userInfo['getcardtime']); $list = array(); $info = ''; $pre = ''; foreach ($tdata[0] as $va) { $t = array(); $salecount = 0; if (!empty($va['detail'])) { foreach ($va['detail'] as $v) { $t = array('num' => $v['count'], 'colorName' => $v['colorName'], 'formatName' => $v['formatName'], 'price' => $v['price'], 'name' => $va['name']); $list[] = $t; $salecount += $v['count']; } } else { $t = array('num' => $va['count'], 'price' => $va['price'], 'name' => $va['name']); $list[] = $t; $salecount = $va['count']; } $info .= $pre . $va['name']; $pre = ','; D("Product")->where(array('id' => $va['id']))->setInc('salecount', $salecount); } if ($order['twid']) { if ($set = M("Twitter_set")->where(array('token' => $order['token'], 'cid' => $order['cid']))->find()) { $price = $set['percent'] * 0.01 * $order['totalprice']; $info = $info ? '购买' . $info . '等产品,订单号:' . $orderid : '购买订单号:' . $orderid; D("Twitter_log")->add(array('token' => $order['token'], 'cid' => $order['cid'], 'twid' => $order['twid'], 'type' => 3, 'dateline' => time(), 'param' => $order['totalprice'], 'price' => $price, 'wecha_id' => $order['wecha_id'], 'info' => $info)); if ($count = M("Twitter_count")->where(array('token' => $order['token'], 'cid' => $order['cid'], 'twid' => $order['twid']))->find()) { D("Twitter_count")->where(array('id' => $count['id']))->setInc('total', $price); } else { D("Twitter_count")->add(array('token' => $order['token'], 'cid' => $order['cid'], 'twid' => $order['twid'], 'total' => $price, 'remove' => 0)); } } } $company = D('Company')->where(array('token' => $order['token'], 'id' => $order['cid']))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $order['truename'], 'tel' => $order['tel'], 'address' => $order['address'], 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => '', 'price' => $order['price'], 'total' => $order['total'], 'list' => $list); $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($order['token'], $order['cid'], 'Store', $msg, 1); $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); Sms::sendSms($order['token'], "您的顾客{$userInfo['truename']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理"); $model = new templateNews(); $model->sendTempMsg('OPENTM202521011', array('href' => U('Store/my', array('token' => $order['token'], 'wecha_id' => $order['wecha_id'], 'twid' => $order['twid']), true, false, true), 'wecha_id' => $order['wecha_id'], 'first' => '购买商品提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '购买成功,感谢您的光临,欢迎下次再次光临!')); } header('Location:/index.php?g=Wap&m=Store&a=my&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id'] . '&twid=' . $order['twid']); } else { exit('订单不存在:' . $out_trade_no); exit('订单不存在'); } }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); Sms::create(['provider_id' => '1', 'name' => 'auth_key']); Sms::create(['provider_id' => '1', 'name' => 'sender_id']); Sms::create(['provider_id' => '1', 'name' => 'route']); Provider::create(array('name' => 'Msg91.com')); // $this->call("OthersTableSeeder"); }
/** * 发送短信 * @method send * @param [type] $phone [手机] * @param [type] $msg [内容参数] * @param [type] $tplName [模板名] * @author NewFuture */ private static function send($phone, $msg, $tplName) { if (null == self::$_handler) { $config = Config::getSecret('sms'); self::$_handler = new Service\Ucpaas($config['account'], $config['appid'], $config['token']); self::$_template = $config['template']; } return self::$_handler->send($phone, $msg, self::$_template[$tplName]); }
/** * * {@inheritDoc} * @see \yii\base\Object::init() */ public function init() { parent::init(); // 1. require the file require_once __DIR__ . '/yunpian/YunpianAutoload.php'; // 2. 首先在 conf/config.php 中配置自己的相关信息 $GLOBALS['YUNPIAN_CONFIG']['APIKEY'] = $this->apikey; $GLOBALS['YUNPIAN_CONFIG']['API_SECRET'] = $this->api_secret; }
public static function handle($task) { echo '<pre>'; echo date('Y-m-d H:i:s') . ' handle task: ' . $task; echo "\r\n"; switch ($task) { case 'sms': Sms::model()->send(); break; } }
public function postInsert($event) { $responsible = Doctrine_Core::getTable('sfGuardUser')->find($this->getUserId()); // send sms to responsible if ($responsible and $responsible->getPhone()) { Sms::send([$responsible->getPhone()], 'Вы были назначены ответственным за выполнение заявки ' . $this->getTicketId()); } // add comment to ticket if ($responsible) { $comment = Comment::createFromArray(['ticket_id' => $this->getTicketId(), 'created_by' => $this->getCreatedBy(), 'text' => 'Добавил в список ответственных ' . $responsible, 'skip_notification' => true]); $comment->save(); } }
public function index(){ $set_id = $this->_get('id','intval'); $formData = $this->_createForms($this->token,$set_id); if(IS_POST){ $limit_info = $this->limit_db->where(array('limit_id'=>$this->thisForm['limit_id']))->find(); if($limit_info['enddate']){ if($limit_info['enddate']<time()){ $this->error('抱歉,时间已过期,无法提交'); } } if($limit_info['today_total'] >0){ $time = strtotime(date('Y-m-d')); //凌晨时间 $total = $this->info_db->where(array('wecha_id'=>$this->token,'wecha_id'=>$this->wecha_id,'add_time'=>array('gt',$time)))->count(); if($total >= $limit_info['today_total']){ $this->error('抱歉,今日只能提交'.$limit_info['today_total'].'次'); } } if($limit_info['sub_total'] >0){ $total = $this->info_db->where(array('wecha_id'=>$this->token,'wecha_id'=>$this->wecha_id))->count(); if($total >= $limit_info['sub_total']){ $this->error('抱歉,提交总数已经超过'.$limit_info['sub_total'].'次'); } } $data['token'] = $this->token; $data['wecha_id'] = $this->wecha_id; $data['set_id'] = $set_id; $data['add_time'] = time(); $data['user_name'] = empty($this->fans['wechaname'])?'匿名':$this->fans['wechaname']; $data['phone'] = empty($this->fans['tel'])?'匿名':$this->fans['tel']; $data['sub_info'] = $this->_serializeSubInfo($this->_request(),$set_id); if($this->info_db->add($data)){ Sms::sendSms($this->token, '你的表单“'.$this->thisForm['title'].'”中有新的信息'); //发送商家短信 $this->success($this->thisForm['succ_info']); }else{ $this->error($this->thisForm['err_info']); } }else{ //提交记录 $spoor = $this->info_db->where(array('token'=>$this->token,'wecha_id'=>$this->wecha_id,'set_id'=>$set_id))->count(); $this->assign('spoor',$spoor); //dump($formData['verify']); $this->assign('verify',$formData['verify']); $this->assign('formData',$formData['string']); $this->display(); } }
public static function send($tpl, $phonenum, $smsvalue) { header('content-type:text/html;charset=utf-8'); $sendUrl = 'http://v.juhe.cn/sms/send'; //短信接口的URL $smsConf = array(); $smsConf['key'] = '##'; //您申请的APPKEY $smsConf['mobile'] = $phonenum; //接受短信的用户手机号码 switch ($tpl) { case 'code': //验证码 $smsConf['tpl_id'] = 00; //您申请的短信模板ID,根据实际情况修改 $smsConf['tpl_value'] = '#name#=' . $phonenum . '&#code#=' . $smsvalue; //您设置的模板变量,根据实际情况修改 break; case 'succ': //通过 $smsConf['tpl_id'] = 1111; $arr = explode("&&&", $smsvalue); $smsConf['tpl_value'] = '#app#=' . $arr[0] . '&#code#=' . $arr[1]; break; case 'fail': //拒绝 $smsConf['tpl_id'] = 2222; $smsConf['tpl_value'] = '#app#=' . $smsvalue; break; } $content = Sms::juhecurl($sendUrl, $smsConf, 1); //请求发送短信 if ($content) { $result = json_decode($content, true); $error_code = $result['error_code']; if ($error_code == 0) { //状态为0,说明短信发送成功 //echo "短信发送成功,短信ID:".$result['result']['sid'];exit; return 1; } else { //状态非0,说明失败 //echo "短信发送失败(".$error_code."):".$result['reason'];exit; return -2; } } else { //返回内容异常,以下可根据业务逻辑自行修改 //echo "请求发送短信失败"; return -1; } }
public function index($orderid, $paytype, $third_id) { $product_cart_model = M('product_cart'); $out_trade_no = $orderid; $order = $product_cart_model->where(array('orderid' => $out_trade_no))->find(); if (!$this->wecha_id) { $this->wecha_id = $order['wecha_id']; } $sepOrder = 0; if (!$order) { $order = $product_cart_model->where(array('id' => $out_trade_no))->find(); $sepOrder = 1; } if ($order) { if ($order['paid'] != 1) { exit('该订单还未支付'); } if (!empty($order['sn']) && empty($order['sn_content'])) { $where['sendstutas'] = 0; $where['order_id'] = 0; $where['token'] = $this->token; $where['pid'] = $order['productid']; $productSn = M('ProductSn'); $models = $productSn->where($where)->limit($order['total'])->order('id ASC')->select(); foreach ($models as $key => $model) { $model['order_id'] = $order['id']; $model['sendstutas'] = 1; $model['sendtime'] = time(); $model['wecha_id'] = $order['wecha_id']; $updateWhere['id'] = $model['id']; $updateWhere['sendstutas'] = 0; unset($model['id']); $productSn->where($updateWhere)->save($model); $models[$key] = $model; } $order['sent'] = 1; $order['handled'] = 1; $order['sn_content'] = serialize($models); $product_cart_model->save($order); } else { M('Product')->where(array('id' => $order['productid']))->setDec('groupon_num', $order['total']); } /************************************************/ Sms::sendSms($this->token, '您的微信里有团购订单已经付款'); /************************************************/ header('Location:/index.php?g=Wap&m=Groupon&a=myOrders&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id']); } else { exit('订单不存在:' . $out_trade_no); } }
public function index($orderid, $paytype = '', $third_id = ''){ if ($order = M('Hotels_order')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); $sort = M('Hotels_house_sort')->where(array('id' => $order['sid'], 'token' => $order['token']))->find(); $days = (strtotime($order['enddate']) - strtotime($order['startdate'])) / 86400; $price = $userInfo['getcardtime'] > 0 ? ($sort['vprice'] ? $sort['vprice'] : $sort['price']) : $sort['price']; $company = M('Company')->where(array('id' => $order['cid'], 'token' => $order['token']))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $order['name'], 'tel' => $order['tel'], 'address' => '', 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => '', 'price' => $order['price'], 'total' => $order['nums'], 'list' => array(array('name' => $sort['name'], 'day' => $days, 'price' => $price, 'num' => $order['nums'], 'startdate' => $order['startdate'], 'enddate' => $order['enddate']))); $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($order['token'], $order['cid'], 'Hotel', $msg, 1); Sms::sendSms($order['token'] . "_" . $order['cid'], "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理"); $model = new templateNews(); $href = C('site_url').'/index.php?g=Wap&m=Hotels&a=my&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id'] . '&cid=' . $order['cid']; $model->sendTempMsg('OPENTM202521011', array('href' => $href, 'wecha_id' => $order['wecha_id'], 'first' => '预订房间提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); } header('Location:/index.php?g=Wap&m=Hotels&a=my&token='.$order['token'].'&wecha_id='.$order['wecha_id'].'&cid='.$order['cid']); // $this->redirect(U('Hotels/my', array('token'=>$this->token, 'wecha_id' => $this->wecha_id))); }else{ exit('订单不存在'); } // $product_cart_model=M('product_cart'); // $out_trade_no=$orderid; // $order=$product_cart_model->where(array('orderid'=>$out_trade_no))->find(); // if (!$this->wecha_id){ // $this->wecha_id=$order['wecha_id']; // } // $sepOrder=0; // if (!$order){ // $order=$product_cart_model->where(array('id'=>$out_trade_no))->find(); // $sepOrder=1; // } // if($order){ // if($order['paid']!=1){exit('该订单还未支付');} // /************************************************/ // Sms::sendSms($this->token,'您的微信里有团购订单已经付款'); // /************************************************/ // header('Location:/index.php?g=Wap&m=Groupon&a=myOrders&token='.$order['token'].'&wecha_id='.$order['wecha_id']); // }else{ // exit('订单不存在:'.$out_trade_no); // } }
public function leave() { //留言信息插入处理 $leave_model = M("leave"); $message = $this->_get('message'); $name = $this->_get('name'); $msgarr = array(); $msgarr['checked'] = 1 - intval($this->needCheck); $msgarr['name'] = $name; $msgarr['message'] = $message; $msgarr['wecha_id'] = $this->wecha_id; $msgarr['token'] = $this->token; $msgarr['time'] = time(); //根据token 来确定同一用户60秒以后才能留言 $lasttime = $leave_model->where(array("token" => $this->token))->getField("max(time)"); //获得准备数据 是否与数据库中数据留言是同一人 $timeres = time() - $lasttime; if ($timeres < $this->sepTime) { $this->ajaxReturn("", "您已留言,请60秒以后再留言", 0); exit; } else { $res = $leave_model->add($msgarr); //echo $res;exit; if ($res) { Sms::sendSms($this->token, '留言板有新的留言'); $msgarr['id'] = $res; if ($msgarr['checked'] == 1) { $msgarr['time'] = date("Y-m-d H:i:s", $msgarr['time']); $data['data'] = $msgarr; $data['info'] = "留言成功"; $data['status'] = 1; $this->ajaxReturn($data); exit; } else { $data['data'] = $msgarr; $data['info'] = "留言成功,正在审核中"; $data['status'] = 2; $this->ajaxReturn($data); exit; } } else { $data['data'] = ""; $data['info'] = "留言失败"; $data['status'] = 0; $this->ajaxReturn($data); exit; } } }
function sae_send_sms($msg, $detail, $mobile = NULL) { $sms_on = C('SMS_ON'); if ($sms_on !== null && !$sms_on) { return; } // 如果关闭短信不进行操作 //判断平台 if (!IS_SAE) { //非SAE平台只记录日志 Log::record($msg . ';detail:' . $detail, 'SEND_SMS', true); } else { Sms::send($msg, $detail, Sms::USER, $mobile); } }
/** * 统一发送身份验证码 */ public function send_auth_codeOp() { if (!in_array($_GET['type'], array('email', 'mobile'))) { exit; } $model_member = Model('member'); $member_info = $model_member->getMemberInfoByID($_SESSION['member_id'], 'member_email,member_mobile'); $verify_code = rand(100, 999) . rand(100, 999); $data = array(); $data['auth_code'] = $verify_code; $data['send_acode_time'] = TIMESTAMP; $update = $model_member->editMemberCommon($data, array('member_id' => $_SESSION['member_id'])); if (!$update) { exit(json_encode(array('state' => 'false', 'msg' => '系统发生错误,如有疑问请与管理员联系'))); } $model_tpl = Model('mail_templates'); $tpl_info = $model_tpl->getTplInfo(array('code' => 'authenticate')); $param = array(); $param['send_time'] = date('Y-m-d H:i', TIMESTAMP); $param['verify_code'] = $verify_code; $param['site_name'] = C('site_name'); $subject = ncReplaceText($tpl_info['title'], $param); $message = ncReplaceText($tpl_info['content'], $param); if ($_GET['type'] == 'email') { $email = new Email(); $result = $email->send_sys_email($member_info["member_email"], $subject, $message); } elseif ($_GET['type'] == 'mobile') { $sms = new Sms(); $result = $sms->send($member_info["member_mobile"], $message); } if ($result) { exit(json_encode(array('state' => 'true', 'msg' => '验证码已发出,请注意查收'))); } else { exit(json_encode(array('state' => 'false', 'msg' => '验证码发送失败'))); } }