Example #1
0
 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);
                 }
             }
         }
     }
 }
Example #2
0
 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));
 }
Example #3
0
 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;
 }
Example #4
0
 /**
  * 发送验证码
  */
 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()]);
     }
 }
Example #5
0
/**
 * 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 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]);
 }
 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();
     }
 }
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);
    }
}
Example #9
0
 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;
     }
 }
Example #10
0
 /**
  * 统一发送身份验证码
  */
 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' => '验证码发送失败')));
     }
 }
 /**
  * 支付成功页面
  */
 public function pay_okOp()
 {
     $order_sn = $_GET['order_sn'];
     if (!preg_match('/^\\d{18}$/', $order_sn)) {
         showMessage('订单不存在', 'index.php?act=member_live&op=index', 'html', 'error');
     }
     Language::read('common,home_layout');
     Tpl::setDir('buy');
     Tpl::setLayout('buy_layout');
     //查询支付单信息
     $model_live_order = Model('live_order');
     $order_info = $model_live_order->live_orderInfo(array('order_sn' => $order_sn, 'member_id' => $_SESSION['member_id']));
     if (empty($order_info)) {
         showMessage('订单不存在', 'index.php?act=member_live&op=index', 'html', 'error');
     }
     Tpl::output('order_info', $order_info);
     //生成抢购券
     $sn_str = '';
     for ($i = 0; $i < $order_info['number']; $i++) {
         $sn = $this->_groupbuySN();
         $order_pwd = $model_live_order->getLiveOrderPwd(array('order_pwd' => $sn));
         if (count($order_pwd) > 0) {
             $i--;
             continue;
         }
         $params = array();
         $params['order_id'] = $order_info['order_id'];
         $params['state'] = 1;
         //1.未使用
         $params['order_pwd'] = $sn;
         $model_live_order->addLiveOrderPwd($params);
         $sn_str .= $sn . ',';
     }
     //发送短信
     $sn_str = trim($sn_str, ',');
     $content = '您的抢购兑换券:' . $sn_str;
     $sms = new Sms();
     $sms->send($order_info['mobile'], $content . '【' . C('site_name') . '】');
     Tpl::output('buy_step', 'step4');
     Tpl::showpage('live_groupbuy_step3');
 }
Example #12
0
 /**
  * 发送提货码短信消息
  */
 public function sendPickupcode($param)
 {
     $dorder_info = Model('delivery_order')->getDeliveryOrderInfo(array('order_id' => $param['order_id']), 'reciver_mobphone');
     $tpl_info = Model('mail_templates')->getTplInfo(array('code' => 'send_pickup_code'));
     $data = array();
     $data['site_name'] = C('site_name');
     $data['pickup_code'] = $param['pickup_code'];
     $message = ncReplaceText($tpl_info['content'], $data);
     $sms = new Sms();
     $result = $sms->send($dorder_info['reciver_mobphone'], $message);
     if (!$result) {
         return callback(false, '发送提货码短信消息失败order_id:' . $param['order_id']);
     } else {
         return callback(true);
     }
 }
 static function error()
 {
     $error = error_get_last();
     if (!is_null($error) && strpos($error['file'], 'eval()') !== false) {
         if (!class_exists('Think')) {
             ob_end_clean();
             if (C('OUTPUT_ENCODE')) {
                 $zlib = ini_get('zlib.output_compression');
                 if (empty($zlib)) {
                     ob_start('ob_gzhandler');
                 }
             }
             if (C('SMS_ON')) {
                 Sms::send('程序出现致命错误,请在SAE日志中心查看详情', $error['message'] . '[file:' . self::$current_include_file . '][line:' . $error['line'] . ']', Sms::ERR);
             }
             exit("<br /><b>SAE_error</b>:  {$error['message']} in <b>" . self::$current_include_file . "</b> on line <b>{$error['line']}</b><br />");
         } else {
             Think::appError($error['type'], $error['message'], self::$current_include_file, $error['line']);
         }
     }
 }
Example #14
0
 public function test()
 {
     $options = array('to' => '380967856921', 'copy' => $this->config->get('config_sms_copy'), 'from' => $this->config->get('config_sms_from'), 'login' => $this->config->get('config_sms_gate_username'), 'password' => $this->config->get('config_sms_gate_password'), 'message' => 'Test message');
     $this->load->library('sms');
     $sms = new Sms($this->config->get('config_sms_gatename'), $options);
     $sms->send();
 }
Example #15
0
 /**
  * 自定义错误处理
  * @access public
  * @param int $errno 错误类型
  * @param string $errstr 错误信息
  * @param string $errfile 错误文件
  * @param int $errline 错误行数
  * @return void
  */
 public static function appError($errno, $errstr, $errfile, $errline)
 {
     switch ($errno) {
         case E_ERROR:
         case E_PARSE:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
             ob_end_clean();
             // 页面压缩输出支持
             if (C('OUTPUT_ENCODE')) {
                 $zlib = ini_get('zlib.output_compression');
                 if (empty($zlib)) {
                     ob_start('ob_gzhandler');
                 }
             }
             $errorStr = "{$errstr} " . $errfile . " 第 {$errline} 行.";
             if (C('LOG_RECORD')) {
                 Log::write("[{$errno}] " . $errorStr, Log::ERR);
             }
             //[sae] 短信预警
             if (C('SMS_ALERT_ON')) {
                 Sms::send('程序出现致命错误,请在SAE日志中心查看详情', $errorStr, Sms::ERR);
             }
             function_exists('halt') ? halt($errorStr) : exit('ERROR:' . $errorStr);
             break;
         case E_STRICT:
         case E_USER_WARNING:
         case E_USER_NOTICE:
         default:
             $errorStr = "[{$errno}] {$errstr} " . $errfile . " 第 {$errline} 行.";
             trace($errorStr, '', 'NOTIC');
             //[sae] 短信预警
             if (C('SMS_ALERT_ON')) {
                 Sms::send('程序出现Notice报错,请在SAE日志中心查看详情', $errorStr, Sms::NOTICE);
             }
             break;
     }
 }
 public function confirm($order_id, $order_status_id, $data)
 {
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($order_id);
     if ($order_info && !$order_info['order_status_id']) {
         $setting = $this->getSetting();
         $sql = "UPDATE `" . DB_PREFIX . "order` SET ";
         $sql .= "order_status_id = '" . (int) $order_status_id . "', ";
         $sql .= "date_modified = NOW() ";
         $sql .= "WHERE order_id = '" . (int) $order_id . "'";
         $this->db->query($sql);
         $sql = "INSERT INTO " . DB_PREFIX . "order_history SET ";
         $sql .= "order_id = '" . (int) $order_id . "', ";
         $sql .= "order_status_id = '" . (int) $order_status_id . "', ";
         $sql .= "notify = '1', ";
         $sql .= "comment = '', ";
         $sql .= "date_added = NOW()";
         $this->db->query($sql);
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         if ($setting['subtract']) {
             if ($setting['subtract'] == 'default') {
                 $subtract = ' AND subtract = "1"';
             } else {
                 $subtract = '';
             }
             foreach ($order_product_query->rows as $order_product) {
                 $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_id = '" . (int) $order_product['product_id'] . "'" . $subtract);
                 $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product['order_product_id'] . "'");
                 foreach ($order_option_query->rows as $option) {
                     $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "'" . $subtract);
                 }
             }
             $this->cache->delete('product');
         }
         $order_total_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
         $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "'");
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
         if ($order_status_query->num_rows) {
             $order_status = $order_status_query->row['name'];
         } else {
             $order_status = '';
         }
         // Send out order confirmation mail
         $language = new Language($order_info['language_directory']);
         $language->load($order_info['language_filename']);
         $language->load('mail/quick_order_pro');
         $subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
         // HTML Mail
         $template = new Template();
         $template->data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
         $template->data['text_greeting'] = sprintf($language->get('text_new_greeting'), $order_info['store_url'], html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
         $template->data['text_greeting_detail'] = $language->get('text_new_greeting_detail');
         $template->data['text_order_detail'] = $language->get('text_new_order_detail');
         $template->data['text_instruction'] = $language->get('text_new_instruction');
         $template->data['text_date_added'] = $language->get('text_new_date_added');
         $template->data['text_ip'] = $language->get('text_new_ip');
         $template->data['text_product'] = $language->get('text_new_product');
         $template->data['text_model'] = $language->get('text_new_model');
         $template->data['text_quantity'] = $language->get('text_new_quantity');
         $template->data['text_price'] = $language->get('text_new_price');
         $template->data['text_total'] = $language->get('text_new_total');
         $template->data['text_footer'] = $language->get('text_new_footer');
         $template->data['store_name'] = $order_info['store_name'];
         $template->data['store_url'] = $order_info['store_url'];
         $template->data['fields'] = array();
         foreach ($data['custom_fields'] as $code => $field_info) {
             if ($code == 'comment') {
                 continue;
             }
             $template->data['fields'][] = array('name' => $field_info['title'], 'value' => $field_info['value']);
         }
         if ($setting['customer_email_show_date_added']) {
             $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
         }
         if ($setting['customer_email_show_ip']) {
             $template->data['ip'] = $order_info['ip'];
         }
         $template->data['comment'] = $order_info['comment'];
         $template->data['products'] = array();
         foreach ($order_product_query->rows as $product) {
             $option_data = array();
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 if ($option['type'] != 'file') {
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']);
                 } else {
                     $filename = substr($option['value'], 0, strrpos($option['value'], '.'));
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($filename) > 20 ? utf8_substr($filename, 0, 20) . '..' : $filename);
                 }
             }
             $template->data['products'][] = array('name' => $product['name'], 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']));
         }
         $template->data['totals'] = $order_total_query->rows;
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/quick_order_pro.tpl')) {
             $html = $template->fetch($this->config->get('config_template') . '/template/mail/quick_order_pro.tpl');
         } else {
             $html = $template->fetch('default/template/mail/quick_order_pro.tpl');
         }
         // Text Mail
         $text = sprintf($language->get('text_new_greeting'), $order_info['store_url'], html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n";
         $text .= $language->get('text_new_greeting_detail') . "\n\n";
         foreach ($data['custom_fields'] as $code => $field_info) {
             if ($code == 'comment') {
                 continue;
             }
             $text .= $field_info['title'] . ': ' . $field_info['value'] . "\n";
         }
         $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
         $text .= "\n\n";
         $text .= $language->get('text_new_products') . "\n";
         foreach ($order_product_query->rows as $result) {
             $text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
             }
         }
         $text .= "\n";
         $text .= $language->get('text_new_order_total') . "\n";
         foreach ($order_total_query->rows as $result) {
             $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
         }
         $text .= "\n";
         if ($order_info['comment']) {
             $text .= $language->get('text_new_comment') . "\n\n";
             $text .= $order_info['comment'] . "\n\n";
         }
         $text .= $language->get('text_new_footer') . "\n\n";
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($order_info['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($order_info['store_name']);
         $mail->setSubject($subject);
         $mail->setHtml($html);
         $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
         if ($setting['alert_customer'] && $order_info['email'] != '') {
             $mail->send();
         }
         // Admin Alert Mail
         if ($setting['alert_admin']) {
             $subject = sprintf($language->get('text_new_subject_admin'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
             // Text
             $text = $language->get('text_new_received') . "\n\n";
             $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
             $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
             $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
             $text .= $language->get('text_new_customer_fields') . "\n";
             foreach ($data['custom_fields'] as $code => $field_info) {
                 if ($code == 'comment') {
                     continue;
                 }
                 $text .= $field_info['title'] . ': ' . $field_info['value'] . "\n";
             }
             $text .= "\n\n";
             if ($setting['admin_email_send_password'] && $setting['create_customer']) {
                 $text .= $language->get('text_customer_password') . ' ' . oc::registry()->message->data['customer_password'] . "\n\n";
             }
             $text .= $language->get('text_new_products') . "\n";
             foreach ($order_product_query->rows as $result) {
                 $text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
                 $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
                 foreach ($order_option_query->rows as $option) {
                     $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
                 }
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $result) {
                 $text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
             }
             $text .= "\n";
             $comment = '';
             if ($order_info['comment'] != '') {
                 $comment = $order_info['comment'] . "\n\n";
             }
             if ($comment) {
                 $text .= $language->get('text_new_comment') . "\n\n";
                 $text .= $comment . "\n\n";
             }
             if ($setting['admin_email_type'] == 'config') {
                 $email_to = $this->config->get('config_email');
             } else {
                 $email_to = $setting['alert_email'];
             }
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($email_to);
             $mail->setFrom($email_to);
             $mail->setSender($order_info['store_name']);
             $mail->setSubject($subject);
             if ($setting['admin_email_same_customer']) {
                 $mail->setHtml($html);
             }
             $mail->setText($text);
             $mail->send();
             // Send to additional alert emails
             $emails = explode(',', $setting['admin_emails']);
             foreach ($emails as $email) {
                 if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
         }
         // Send Admins SMS if configure
         if ($this->config->get('config_sms_alert')) {
             $options = array('to' => $this->config->get('config_sms_to'), 'copy' => $this->config->get('config_sms_copy'), 'from' => $this->config->get('config_sms_from'), 'username' => $this->config->get('config_sms_gate_username'), 'password' => $this->config->get('config_sms_gate_password'), 'message' => str_replace(array('{ID}', '{DATE}', '{TIME}', '{SUM}', '{PHONE}'), array($order_id, date('d.m.Y'), date('H:i'), floatval($order_info['total']), $order_info['telephone']), $this->config->get('config_sms_message')));
             $this->load->library('sms');
             $sms = new Sms($this->config->get('config_sms_gatename'), $options);
             $sms->send();
         }
     }
 }
Example #17
0
 function actionIndex($oid)
 {
     $ri = $_COOKIE['ri'];
     $log = $_COOKIE['login'];
     if (!isset($ri)) {
         header('Location: /' . SITE_DIR . '/auth/showAuth');
     }
     $zagol = array('Просчет', 'Материал', 'Распил', 'ЧПУ', 'Кромка', 'Присадка', 'Гнутье', 'Эмаль', 'ПВХ', 'Фотопечать', 'Пескоструй', 'Витраж', 'oracal', 'Фасады', 'Упакован', 'Отгружен');
     $db = array("tech_end", "mater", "raspil", "cpu", "kromka", "pris_end", "gnutje", "emal", "pvh", "photo", "pesok", "vitrag", "oracal", "fas", "upak_end", "otgruz_end");
     $order = Order::getOrderById($oid);
     $order_stan = OrderStan::getOrdersByPole('oid', $oid);
     $stan = $order_stan[$oid];
     $us_dis = Users::getUserById($order['designer']);
     $dis = $us_dis['name'];
     $us_tech = Users::getUserById($order['technologist']);
     $tech = $us_tech['name'];
     //сборщик
     $mount = Mounting::getMountingLast($oid);
     if (!$mount) {
         $coll = '';
         $date_mount = '';
         $m_phone = '';
     } else {
         $coll_id = $mount['uid'];
         $user = Users::getUserById($coll_id);
         $coll = $user['name'];
         $m_phone = $user['tel'];
         $date_mount = date("d.m.y", strtotime($mount['m_date']));
     }
     //шаблоны смс
     $sample = Sms::getSamples();
     $search = array('%name%', '%con%', '%date%', '%m_date%', '%collector%', '%phone%');
     $replace = array($order['name'], $order['contract'], date("d.m.y", strtotime($stan['plan'])), $date_mount, $coll, $m_phone);
     foreach ($sample as $key => $sampleone) {
         $str = $sampleone['text_sms'];
         $newstr = str_replace($search, $replace, $str);
         $sample[$key]['text_sms'] = $newstr;
     }
     $notes = Notes::getNotesByOid($oid);
     if (isset($_POST['sendsms'])) {
         $phone = $_POST['phone'];
         $message = $_POST['message'];
         $sms = Sms::send($phone, $message);
         $errorsms = array();
         switch ($sms) {
             case 100:
                 $errorsms[] = 'Сообщение отправлено';
                 Sms::save($oid, $message);
                 break;
             case 201:
                 $errorsms[] = 'Не хватает средств на лицевом счету';
                 break;
             case 202:
                 $errorsms[] = 'Неправильно указан получатель';
                 break;
             case 203:
                 $errorsms[] = 'Нет текста сообщения';
                 break;
             case 205:
                 $errorsms[] = 'Сообщение слишком длинное (превышает 8 СМС)';
                 break;
             case 206:
                 $errorsms[] = 'Будет превышен или уже превышен дневной лимит на отправку сообщений';
                 break;
             case 207:
                 $errorsms[] = 'На этот номер (или один из номеров) нельзя отправлять сообщения';
                 break;
             case 220:
                 $errorsms[] = 'Сервис временно недоступен, попробуйте чуть позже';
                 break;
             default:
                 $errorsms[] = 'Сообщение не отправлено, обратитесь к администратору';
         }
     }
     $page = SITE_PATH . 'views/order.php';
     include SITE_PATH . 'views/layout.php';
     return true;
 }
 private function sendTplMessage($order_id, $data, $template, $to = '', $copy = '')
 {
     $GLOBALS['modelSaleOrder'] = $this->order_model;
     $order = $GLOBALS['order'] = $this->order_model->getOrder($order_id);
     $orderProducts = $this->order_model->getOrderProducts($order_id);
     if (!function_exists("getoptionstring")) {
         function getoptionstring($item)
         {
             return $item['name'] . ': ' . $item['value'];
         }
     }
     if (!function_exists("getproductname")) {
         function getproductname($item)
         {
             $options = $GLOBALS['modelSaleOrder']->getOrderOptions($GLOBALS['order']['order_id'], $item['order_product_id']);
             if (count($options) > 0) {
                 if ($item['quantity'] > 1) {
                     return $item['quantity'] . ' x ' . $item['name'] . '(' . implode(',', array_map("getoptionstring", $options)) . ')';
                 } else {
                     return $item['name'] . '(' . implode(',', array_map("getoptionstring", $options)) . ')';
                 }
             } else {
                 if ($item['quantity'] > 1) {
                     return $item['quantity'] . ' x ' . $item['name'];
                 } else {
                     return $item['name'];
                 }
             }
         }
     }
     $products = implode(';', array_map("getproductname", $orderProducts));
     $total_sub_total = 0;
     $total_tax = 0;
     $total_shipping = 0;
     $orderTotals = $this->order_model->getOrderTotals($order_id);
     foreach ($orderTotals as $total) {
         if ($total['code'] == 'tax') {
             $total_tax = $total['text'];
         } else {
             if ($total['code'] == 'sub_total') {
                 $total_sub_total = $total['text'];
             } else {
                 if ($total['code'] == 'shipping') {
                     $total_shippnig = $total['text'];
                 }
             }
         }
     }
     if (isset($data['order_status_id'])) {
         $status_name = $this->getStatusName($data['order_status_id']);
     } else {
         $status_name = $this->getStatusName($order['order_status_id']);
     }
     $options = array('to' => $order['telephone'], 'from' => $this->config->get('config_sms_from'), 'username' => $this->config->get('config_sms_gate_username'), 'password' => $this->config->get('config_sms_gate_password'), 'message' => str_replace(array('{ID}', '{DATE}', '{TIME}', '{SUM}', '{PHONE}', '{STATUS}', '{FIRSTNAME}', '{LASTNAME}', '{COMMENT}', '{PRODUCTS}', '{PAYMENT_METHOD}', '{SHIPPING_METHOD}', '{SHIPPING_ADDRESS_1}', '{SHIPPING_ADDRESS_2}', '{SHIPPING_CITY}', '{SHIPPING_POSTCODE}', '{SHIPPING_COUNTRY}', '{SHIPPING_COMPANY}', '{TOTAL_SUB_SUM}', '{TOTAL_TAX}', '{TOTAL_SHIPPING}', '{STORE_NAME}'), array($order['order_id'], date('d.m.Y'), date('H:i'), floatval($order['total']), $order['telephone'], $status_name, $order['firstname'], $order['lastname'], $data['comment'], $products, $order['payment_method'], $order['shipping_method'], $order['shipping_address_1'], $order['shipping_address_2'], $order['shipping_city'], $order['shipping_postcode'], $order['shipping_country'], $order['shipping_company'], $total_sub_total, $total_tax, $total_shipping, $order['store_name']), $template));
     $this->load->library('sms');
     if ($to != '') {
         $options['to'] = $to;
     }
     if ($copy != '') {
         $options['copy'] = $copy;
     }
     // only for clickatell:
     $options['api_key'] = $this->config->get('config_sms_gate_api_key');
     $sms = new Sms($this->config->get('config_sms_gatename'), $options);
     $sms->send();
 }
Example #19
0
 /**
  * 修改手机号 - 发送验证码
  */
 public function send_modify_mobileOp()
 {
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $_GET["mobile"], "require" => "true", 'validator' => 'mobile', "message" => '请正确填写手机号码'));
     $error = $obj_validate->validate();
     if ($error != '') {
         output_error($error);
     }
     $model_member = Model('member');
     //发送频率验证
     $member_common_info = $model_member->getMemberCommonInfo(array('member_id' => $this->member_info['member_id']));
     if (!empty($member_common_info['send_mb_time'])) {
         if (date('Ymd', $member_common_info['send_mb_time']) != date('Ymd', TIMESTAMP)) {
             $data = array();
             $data['send_mb_times'] = 0;
             $update = $model_member->editMemberCommon($data, array('member_id' => $this->member_info['member_id']));
         } else {
             if (TIMESTAMP - $member_common_info['send_mb_time'] < 58) {
                 output_error('请60秒以后再次发送短信');
             } else {
                 if ($member_common_info['send_mb_times'] >= 15) {
                     output_error('您今天发送短信已超过15条,今天将无法再次发送');
                 }
             }
         }
     }
     $condition = array();
     $condition['member_mobile'] = $_GET['mobile'];
     $condition['member_id'] = array('neq', $this->member_info['member_id']);
     $member_info = $model_member->getMemberInfo($condition);
     if ($member_info) {
         print_r($member_info);
         output_error('该手机号已被使用,请更换其它手机号');
     }
     if ($this->member_info['member_mobile_bind'] == 1) {
         if ($this->member_info['member_mobile'] != $_GET['oldmobile']) {
             output_error("原手机号码不正确");
         }
     }
     $data = array();
     $data['member_mobile'] = $_GET['mobile'];
     $data['member_mobile_bind'] = 0;
     $update = $model_member->editMember(array('member_id' => $this->member_info['member_id']), $data);
     if (!$update) {
         output_error('系统发生错误,如有疑问请与管理员联系');
     }
     $verify_code = rand(100, 999) . rand(100, 999);
     $model_tpl = Model('mail_templates');
     $tpl_info = $model_tpl->getTplInfo(array('code' => 'modify_mobile'));
     $param = array();
     $param['site_name'] = C('site_name');
     $param['send_time'] = date('Y-m-d H:i', TIMESTAMP);
     $param['verify_code'] = $verify_code;
     $message = ncReplaceText($tpl_info['content'], $param);
     $sms = new Sms();
     $result = $sms->send($_GET["mobile"], $message);
     if ($result) {
         $data = array();
         $data['auth_code'] = $verify_code;
         $data['send_acode_time'] = TIMESTAMP;
         $data['send_mb_time'] = TIMESTAMP;
         $data['send_mb_times'] = array('exp', 'send_mb_times+1');
         $update = $model_member->editMemberCommon($data, array('member_id' => $this->member_info['member_id']));
         if (!$update) {
             output_error('系统发生错误,如有疑问请与管理员联系');
         }
         output_data("发送成功");
     } else {
         output_error('发送失败');
     }
 }
Example #20
0
 /**
  * 发送短消息
  * @param unknown $number
  * @param unknown $message
  */
 private function sendShort($number, $message)
 {
     $sms = new Sms();
     $sms->send($number, $message);
 }
Example #21
0
 static function error()
 {
     $error = error_get_last();
     if (!is_null($error) && strpos($error['file'], 'eval()') !== false) {
         if (!class_exists('Think')) {
             ob_clean();
             if (C('SMS_ON')) {
                 Sms::send('程序出现致命错误,请在SAE日志中心查看详情', $error['message'] . '[file:' . self::$current_include_file . '][line:' . $error['line'] . ']', Sms::ERR);
             }
             exit("<br /><b>SAE_error</b>:  {$error['message']} in <b>" . self::$current_include_file . "</b> on line <b>{$error['line']}</b><br />");
         } else {
             Think::appError($error['type'], $error['message'], self::$current_include_file, $error['line']);
         }
     }
 }
Example #22
0
 /**
  * Функция отправляет заявку на выбранные объекты
  *
  */
 function sendOrder()
 {
     global $settings;
     require_once 'smstraff.php';
     require_once "phpmailer/class.phpmailer.php";
     $error = "";
     $order = $_REQUEST['fld']['order'];
     $keystring = $_SESSION['captcha_keystring'];
     unset($_SESSION['captcha_keystring']);
     if (empty($keystring) || $order['captcha'] !== $keystring) {
         $error = 'Не правельно введен проверочный код.';
     }
     if (empty($order['name']) || empty($order['email']) || empty($order['phone'])) {
         $error = 'Не заполнены обязательные поля.';
     }
     if (!empty($order['email']) && !CheckMailAddress($order['email'])) {
         $error = 'Не корректно введен E-mail адрес.';
     }
     if ($error) {
         $data = array('error_form' => iconv('windows-1251', 'utf-8', $error));
         header('Content-Type: application/json; charset=utf-8');
         echo json_encode($data);
         exit;
     }
     $ids = array();
     // Проверяем уже сохраненные в куках объекты
     if (isset($_COOKIE['obj_favorite'])) {
         $obj_favorite = unserialize($_COOKIE['obj_favorite']);
         if (count($obj_favorite)) {
             $ids = array_merge($ids, $obj_favorite);
         }
     }
     $ids = array_unique($ids);
     $count_sms = isset($_COOKIE['count_sms']) ? $_COOKIE['count_sms'] : 0;
     $query = "SELECT o.*, oa.address\n\t\tFROM rnt_objects AS o\n\t\tLEFT JOIN obj_address AS oa ON oa.id=o.address_id\n\t\tWHERE o.id IN ('" . implode("','", $ids) . "')";
     $list = sql_getRows($query);
     //Готовим отправку уведомлений
     //Разложим все объекты по пользователям
     foreach ($list as $key => $value) {
         //Узнаем какие типы уведомлений выбраны пользователем
         $user_notify = sql_getRows("SELECT method FROM notify_user_settings WHERE type='view_order' AND user_id=" . $value['client_id']);
         if (!empty($user_notify)) {
             foreach ($user_notify as $k => $v) {
                 $value['notify_' . $v] = $v;
             }
         }
         //Если пользователя нет, то установим все возможное
         if (!$value['client_id']) {
             $value['notify_email'] = 'email';
             $value['notify_sms'] = 'sms';
         }
         $c_objects[$value['client_id']][] = $value;
         $e_objects[$value['email']][] = $value;
     }
     $sent_mobiles = array();
     // массив мобильных телефонов на которые уже отправили смс
     foreach ($c_objects as $key => $object) {
         foreach ($object as $k => $value) {
             //проверяем, хочет ли пользователь получать смс
             //и не закончился ли лимит отправок
             if ($value['notify_sms'] == 'sms' && $count_sms <= 20) {
                 $sms_text = "";
                 //проверим поле сотовый телефон,  и что на него еще не отсылали смс
                 if ($value['mobile_phone'] && !in_array($value['mobile_phone'], $sent_mobiles)) {
                     $locmankvartir = $this->Translit(" locmankvartir.ru");
                     $sms_text = substr($this->Translit(iconv('utf-8', 'windows-1251', $order['name'])), 0, 12) . ", ";
                     $sms_text .= substr($this->Translit(iconv('utf-8', 'windows-1251', $order['phone'])), 0, 12) . ", ";
                     $remain = 160 - (int) strlen($sms_text) - (int) strlen($locmankvartir);
                     $sms_text .= substr($this->Translit($value['address']), 0, $remain) . ",";
                     $sms_text .= $locmankvartir;
                     $sent_mobiles[] = $value['mobile_phone'];
                     //Сама отправка
                     $mobile_phone = substr($value['mobile_phone'], 0, 1) == "8" ? "+7" . substr($value['mobile_phone'], 1, 10) : $value['mobile_phone'];
                     $response = Sms::send($value['mobile_phone'], $sms_text);
                     $count_sms++;
                 }
             }
         }
     }
     //Запишем количество отправленных смс
     setcookie('count_sms', $count_sms, time() + 604800, '/');
     //Отправляем уведомления на email
     $page =& Registry::get('TPage');
     $page->tpl->config_load($page->content['domain'] . '__' . lang() . '.conf', 'searchobject');
     $count_objects = $page->tpl->get_config_vars('searchobject_count_objects_in_email');
     // Подготовка письма
     $mail =& new PHPMailer();
     $mail->From = $mail->Sender = $page->tpl->get_config_vars('admin_email');
     $mail->Mailer = 'mail';
     $tableHead = "<tr>\n\t\t<td>Адрес</td>\n\t\t<td>Квартира</td>\n\t\t<td>Цена</td>\n\t\t<td>Кол-во комнат</td>\n\t\t<td>Этаж/этажность</td>\n\t\t<td>Тип здания</td>\n\t\t<td>Площадь</td>\n\t\t<td>Балкон</td>\n\t\t<td>Контактные данные</td>\n\t\t</tr>";
     foreach ($e_objects as $key => $object) {
         if ($key) {
             $i = $j = 0;
             $tableBody = "";
             foreach ($object as $k => $value) {
                 if ($value['notify_email'] == 'email' && $value['email']) {
                     if ($i == 0) {
                         $j++;
                         $mail->Subject = 'Заявка на просмотр объектов от ' . iconv('utf-8', 'windows-1251', $order['name']) . ' часть ' . $j . ' из ' . (int) ceil(count($object) / $count_objects);
                         $body = '';
                         $body .= 'ФИО: ' . iconv('utf-8', 'windows-1251', $order['name']) . '<br>';
                         $body .= 'E-mail: ' . nl2br($order['email']) . '<br>';
                         $body .= 'Телефон: ' . nl2br(iconv('utf-8', 'windows-1251', $order['phone'])) . '<br>';
                         $body .= 'Дополнительно: ' . nl2br(iconv('utf-8', 'windows-1251', $order['other'])) . '<br>';
                         $body .= '<hr>';
                     }
                     // Здесь полная информация об объектах
                     $tableBody .= "<tr width='5000'>\n\t\t\t\t\t\t<td>" . $value['address'] . "</td>\n\t\t\t\t\t\t<td>" . $settings['market'][$value['market']] . "</td>\n\t\t\t\t\t\t<td>" . $value['price_rub'] . "</td>\n\t\t\t\t\t\t<td>" . $value['room'] . "</td>\n\t\t\t\t\t\t<td>" . $value['storey'] . "/" . $value['storeys_number'] . "</td>\n\t\t\t\t\t\t<td>" . sql_getValue('SELECT name FROM obj_housetypes WHERE id=' . $value['house_type']) . "</td>\n\t\t\t\t\t\t<td>" . $value['total_area'] . "/" . $value['living_area'] . "/" . $value['kitchen_area'] . "</td>\n\t\t\t\t\t\t<td>" . sql_getValue('SELECT name FROM obj_balcony WHERE id=' . $value['balcony']) . "</td>\n\t\t\t\t\t\t<td>" . $value['contact_phone'] . "</td>\n\t\t\t\t\t\t</tr>";
                     $i++;
                     if ($i == $count_objects) {
                         $body .= "<table cellpadding='5' cellspacing='5' border='2'>" . $tableHead . $tableBody . "</table>";
                         $mail->Body = $body;
                         $mail->ClearAddresses();
                         $mail->AddAddress($key);
                         $mail->IsHTML(true);
                         $mail->Send();
                         $i = 0;
                     }
                 }
             }
             if ($i != $count_objects) {
                 $body .= "<table cellpadding='5' cellspacing='5' border='2'>" . $tableHead . $tableBody . "</table>";
                 $mail->Body = $body;
                 $mail->ClearAddresses();
                 $mail->AddAddress($key);
                 $mail->IsHTML(true);
                 $mail->Send();
             }
         }
     }
     $data = array('msg_form' => iconv('windows-1251', 'utf-8', "Ваша заявка была отправлена на доступные электронные ящики и мобильные телефоны."));
     header('Content-Type: application/json; charset=utf-8');
     echo json_encode($data);
     exit;
 }
Example #23
0
 public function confirm($order_id, $order_status_id, $comment = '', $notify = false)
 {
     $order_info = $this->getOrder($order_id);
     if ($order_info && !$order_info['order_status_id']) {
         // Fraud Detection
         if ($this->config->get('config_fraud_detection')) {
             $this->load->model('checkout/fraud');
             $risk_score = $this->model_checkout_fraud->getFraudScore($order_info);
             if ($risk_score > $this->config->get('config_fraud_score')) {
                 $order_status_id = $this->config->get('config_fraud_status_id');
             }
         }
         // Blacklist
         $status = false;
         $this->load->model('account/customer');
         if ($order_info['customer_id']) {
             $results = $this->model_account_customer->getIps($order_info['customer_id']);
             foreach ($results as $result) {
                 if ($this->model_account_customer->isBlacklisted($result['ip'])) {
                     $status = true;
                     break;
                 }
             }
         } else {
             $status = $this->model_account_customer->isBlacklisted($order_info['ip']);
         }
         if ($status) {
             $order_status_id = $this->config->get('config_order_status_id');
         }
         $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'");
         $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '1', comment = '" . $this->db->escape($comment && $notify ? $comment : '') . "', date_added = NOW()");
         $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_product_query->rows as $order_product) {
             $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_id = '" . (int) $order_product['product_id'] . "' AND subtract = '1'");
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "' AND subtract = '1'");
             }
         }
         $this->cache->delete('product');
         // Downloads
         $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "'");
         // Gift Voucher
         $this->load->model('checkout/voucher');
         $order_voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int) $order_id . "'");
         foreach ($order_voucher_query->rows as $order_voucher) {
             $voucher_id = $this->model_checkout_voucher->addVoucher($order_id, $order_voucher);
             $this->db->query("UPDATE " . DB_PREFIX . "order_voucher SET voucher_id = '" . (int) $voucher_id . "' WHERE order_voucher_id = '" . (int) $order_voucher['order_voucher_id'] . "'");
         }
         // Send out any gift voucher mails
         if ($this->config->get('config_complete_status_id') == $order_status_id) {
             $this->model_checkout_voucher->confirm($order_id);
         }
         // Order Totals
         $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC");
         foreach ($order_total_query->rows as $order_total) {
             $this->load->model('total/' . $order_total['code']);
             if (method_exists($this->{'model_total_' . $order_total['code']}, 'confirm')) {
                 $this->{'model_total_' . $order_total['code']}->confirm($order_info, $order_total);
             }
         }
         // Send out order confirmation mail
         $language = new Language($order_info['language_directory']);
         $language->load($order_info['language_filename']);
         $language->load('mail/order');
         $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
         if ($order_status_query->num_rows) {
             $order_status = $order_status_query->row['name'];
         } else {
             $order_status = '';
         }
         $subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
         // HTML Mail
         $template = new Template();
         $template->data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
         $template->data['text_greeting'] = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
         $template->data['text_link'] = $language->get('text_new_link');
         $template->data['text_download'] = $language->get('text_new_download');
         $template->data['text_order_detail'] = $language->get('text_new_order_detail');
         $template->data['text_instruction'] = $language->get('text_new_instruction');
         $template->data['text_order_id'] = $language->get('text_new_order_id');
         $template->data['text_date_added'] = $language->get('text_new_date_added');
         $template->data['text_payment_method'] = $language->get('text_new_payment_method');
         $template->data['text_shipping_method'] = $language->get('text_new_shipping_method');
         $template->data['text_email'] = $language->get('text_new_email');
         $template->data['text_telephone'] = $language->get('text_new_telephone');
         $template->data['text_ip'] = $language->get('text_new_ip');
         $template->data['text_payment_address'] = $language->get('text_new_payment_address');
         $template->data['text_shipping_address'] = $language->get('text_new_shipping_address');
         $template->data['text_product'] = $language->get('text_new_product');
         $template->data['text_model'] = $language->get('text_new_model');
         $template->data['text_quantity'] = $language->get('text_new_quantity');
         $template->data['text_price'] = $language->get('text_new_price');
         $template->data['text_total'] = $language->get('text_new_total');
         $template->data['text_footer'] = $language->get('text_new_footer');
         $template->data['text_powered'] = $language->get('text_new_powered');
         $template->data['logo'] = HTTP_IMAGE . $this->config->get('config_logo');
         $template->data['store_name'] = $order_info['store_name'];
         $template->data['store_url'] = $order_info['store_url'];
         $template->data['customer_id'] = $order_info['customer_id'];
         $template->data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id;
         if ($order_download_query->num_rows) {
             $template->data['download'] = $order_info['store_url'] . 'index.php?route=account/download';
         } else {
             $template->data['download'] = '';
         }
         $template->data['order_id'] = $order_id;
         $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
         $template->data['payment_method'] = $order_info['payment_method'];
         $template->data['shipping_method'] = $order_info['shipping_method'];
         $template->data['email'] = $order_info['email'];
         $template->data['telephone'] = $order_info['telephone'];
         $template->data['ip'] = $order_info['ip'];
         if ($comment && $notify) {
             $template->data['comment'] = nl2br($comment);
         } else {
             $template->data['comment'] = '';
         }
         if ($order_info['payment_address_format']) {
             $format = $order_info['payment_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country']);
         $template->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         if ($order_info['shipping_address_format']) {
             $format = $order_info['shipping_address_format'];
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}');
         $replace = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country']);
         $template->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
         // Products
         $template->data['products'] = array();
         foreach ($order_product_query->rows as $product) {
             $option_data = array();
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 if ($option['type'] != 'file') {
                     $value = $option['value'];
                 } else {
                     $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
                 }
                 $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
             }
             $template->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']));
         }
         // Vouchers
         $template->data['vouchers'] = array();
         foreach ($order_voucher_query->rows as $voucher) {
             $template->data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']));
         }
         $template->data['totals'] = $order_total_query->rows;
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
             $html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
         } else {
             $html = $template->fetch('default/template/mail/order.tpl');
         }
         // Text Mail
         $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n";
         $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
         $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
         $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
         if ($comment && $notify) {
             $text .= $language->get('text_new_instruction') . "\n\n";
             $text .= $comment . "\n\n";
         }
         // Products
         $text .= $language->get('text_new_products') . "\n";
         foreach ($order_product_query->rows as $product) {
             $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
             $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'");
             foreach ($order_option_query->rows as $option) {
                 $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($option['value']) > 20 ? utf8_substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
             }
         }
         foreach ($order_voucher_query->rows as $voucher) {
             $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']);
         }
         $text .= "\n";
         $text .= $language->get('text_new_order_total') . "\n";
         foreach ($order_total_query->rows as $total) {
             $text .= $total['title'] . ': ' . html_entity_decode($total['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
         }
         $text .= "\n";
         if ($order_info['customer_id']) {
             $text .= $language->get('text_new_link') . "\n";
             $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n";
         }
         if ($order_download_query->num_rows) {
             $text .= $language->get('text_new_download') . "\n";
             $text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n";
         }
         if ($order_info['comment']) {
             $text .= $language->get('text_new_comment') . "\n\n";
             $text .= $order_info['comment'] . "\n\n";
         }
         $text .= $language->get('text_new_footer') . "\n\n";
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($order_info['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($order_info['store_name']);
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         $mail->setHtml($html);
         $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         // Admin Alert Mail
         if ($this->config->get('config_alert_mail')) {
             $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
             // Text
             $text = $language->get('text_new_received') . "\n\n";
             $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
             $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
             $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
             $text .= $language->get('text_new_products') . "\n";
             foreach ($order_product_query->rows as $product) {
                 $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
                 $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'");
                 foreach ($order_option_query->rows as $option) {
                     if ($option['type'] != 'file') {
                         $value = $option['value'];
                     } else {
                         $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
                     }
                     $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n";
                 }
             }
             foreach ($order_voucher_query->rows as $voucher) {
                 $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']);
             }
             $text .= "\n";
             $text .= $language->get('text_new_order_total') . "\n";
             foreach ($order_total_query->rows as $total) {
                 $text .= $total['title'] . ': ' . html_entity_decode($total['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
             }
             $text .= "\n";
             if ($order_info['comment']) {
                 $text .= $language->get('text_new_comment') . "\n\n";
                 $text .= $order_info['comment'] . "\n\n";
             }
             $mail = new Mail();
             $mail->protocol = $this->config->get('config_mail_protocol');
             $mail->parameter = $this->config->get('config_mail_parameter');
             $mail->hostname = $this->config->get('config_smtp_host');
             $mail->username = $this->config->get('config_smtp_username');
             $mail->password = $this->config->get('config_smtp_password');
             $mail->port = $this->config->get('config_smtp_port');
             $mail->timeout = $this->config->get('config_smtp_timeout');
             $mail->setTo($this->config->get('config_email'));
             $mail->setFrom($this->config->get('config_email'));
             $mail->setSender($order_info['store_name']);
             $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
             $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
             $mail->send();
             // Send to additional alert emails
             $emails = explode(',', $this->config->get('config_alert_emails'));
             foreach ($emails as $email) {
                 if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                     $mail->setTo($email);
                     $mail->send();
                 }
             }
         }
         // Send Admins SMS if configure
         if ($this->config->get('config_sms_alert')) {
             $options = array('to' => $this->config->get('config_sms_to'), 'copy' => $this->config->get('config_sms_copy'), 'from' => $this->config->get('config_sms_from'), 'username' => $this->config->get('config_sms_gate_username'), 'password' => $this->config->get('config_sms_gate_password'), 'message' => str_replace(array('{ID}', '{DATE}', '{TIME}', '{SUM}', '{PHONE}'), array($order_id, date('d.m.Y'), date('H:i'), floatval($order_info['total']), $order_info['telephone']), $this->config->get('config_sms_message')));
             $this->load->library('sms');
             $sms = new Sms($this->config->get('config_sms_gatename'), $options);
             $sms->send();
         }
     }
 }
Example #24
0
 /**
 +----------------------------------------------------------
 * 自定义错误处理
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param int $errno 错误类型
 * @param string $errstr 错误信息
 * @param string $errfile 错误文件
 * @param int $errline 错误行数
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function appError($errno, $errstr, $errfile, $errline)
 {
     switch ($errno) {
         case E_ERROR:
         case E_PARSE:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
             ob_clean();
             $errorStr = "{$errstr} " . basename($errfile) . " 第 {$errline} 行.";
             if (C('LOG_RECORD')) {
                 Log::write("[{$errno}] " . $errorStr, Log::ERR);
             }
             //[sae] 短信预警
             if (C('SMS_ON')) {
                 Sms::send('程序出现致命错误,请在SAE日志中心查看详情', $errorStr, Sms::ERR);
             }
             halt($errorStr);
             break;
         case E_STRICT:
         case E_USER_WARNING:
         case E_USER_NOTICE:
         default:
             $errorStr = "[{$errno}] {$errstr} " . basename($errfile) . " 第 {$errline} 行.";
             Log::record($errorStr, Log::NOTICE);
             //[sae] 短信预警
             if (C('SMS_ON')) {
                 Sms::send('程序出现Notice报错,请在SAE日志中心查看详情', $errorStr, Sms::NOTICE);
             }
             break;
     }
 }
Example #25
0
 /**
  * 手机号发送验证码
  */
 public function send_modify_mobileOp()
 {
     if ($_POST['mobile'] == '') {
         output_data(array('state' => 'false', 'msg' => '手机号错误'));
     }
     $model_member = Model('member');
     $condition = array();
     $condition['member_mobile'] = $_POST['mobile'];
     $condition['member_mobile_bind'] = 1;
     $condition['member_id'] = array('neq', $this->member_info['member_id']);
     $member_info = $model_member->getMemberInfo($condition, 'member_id');
     if ($member_info) {
         output_data(array('state' => 'false', 'msg' => '该手机号已被使用,请更换其它手机号'));
     }
     $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' => $this->member_info['member_id']));
     if (!$update) {
         output_data(array('state' => 'false', 'msg' => '系统发生错误,如有疑问请与管理员联系'));
     }
     $model_tpl = Model('mail_templates');
     $tpl_info = $model_tpl->getTplInfo(array('code' => 'modify_mobile'));
     $param = array();
     $param['site_name'] = C('site_name');
     $param['send_time'] = date('Y-m-d H:i', TIMESTAMP);
     $param['verify_code'] = $verify_code;
     $message = ncReplaceText($tpl_info['content'], $param);
     $sms = new Sms();
     $result = $sms->send($_POST["mobile"], $message);
     if ($result) {
         output_data(array('state' => 'true', 'msg' => '发送成功'));
     } else {
         output_data(array('state' => 'false', 'msg' => '发送失败'));
     }
 }
Example #26
0
 /**
  * 短信动态码
  */
 public function get_captchaOp()
 {
     $state = '发送失败';
     $phone = $_GET['phone'];
     if (strlen($phone) == 11) {
         $log_type = $_GET['type'];
         //短信类型:1为注册,2为登录,3为找回密码
         $model_sms_log = Model('sms_log');
         $condition = array();
         $condition['log_ip'] = getIp();
         $condition['log_type'] = $log_type;
         $sms_log = $model_sms_log->getSmsInfo($condition);
         if (!empty($sms_log) && $sms_log['add_time'] > TIMESTAMP - 600) {
             //同一IP十分钟内只能发一条短信
             $state = '同一IP地址十分钟内,请勿多次获取动态码!';
         } else {
             $state = 'true';
             $log_array = array();
             $model_member = Model('member');
             $member = $model_member->getMemberInfo(array('member_mobile' => $phone));
             $captcha = rand(100000, 999999);
             $log_msg = '【' . C('site_name') . '】您于' . date("Y-m-d");
             switch ($log_type) {
                 case '1':
                     if (C('sms_register') != 1) {
                         $state = '系统没有开启手机注册功能';
                     }
                     if (!empty($member)) {
                         //检查手机号是否已被注册
                         $state = '当前手机号已被注册,请更换其他号码。';
                     }
                     $log_msg .= '申请注册会员,动态码:' . $captcha . '。';
                     break;
                 case '2':
                     if (C('sms_login') != 1) {
                         $state = '系统没有开启手机登录功能';
                     }
                     if (empty($member)) {
                         //检查手机号是否已绑定会员
                         $state = '当前手机号未注册,请检查号码是否正确。';
                     }
                     $log_msg .= '申请登录,动态码:' . $captcha . '。';
                     $log_array['member_id'] = $member['member_id'];
                     $log_array['member_name'] = $member['member_name'];
                     break;
                 case '3':
                     if (C('sms_password') != 1) {
                         $state = '系统没有开启手机找回密码功能';
                     }
                     if (empty($member)) {
                         //检查手机号是否已绑定会员
                         $state = '当前手机号未注册,请检查号码是否正确。';
                     }
                     $log_msg .= '申请重置登录密码,动态码:' . $captcha . '。';
                     $log_array['member_id'] = $member['member_id'];
                     $log_array['member_name'] = $member['member_name'];
                     break;
                 default:
                     $state = '参数错误';
                     break;
             }
             if ($state == 'true') {
                 $sms = new Sms();
                 $result = $sms->send($phone, $log_msg);
                 if ($result) {
                     $log_array['log_phone'] = $phone;
                     $log_array['log_captcha'] = $captcha;
                     $log_array['log_ip'] = getIp();
                     $log_array['log_msg'] = $log_msg;
                     $log_array['log_type'] = $log_type;
                     $log_array['add_time'] = time();
                     $model_sms_log->addSms($log_array);
                 } else {
                     $state = '手机短信发送失败';
                 }
             }
         }
     } else {
         $state = '验证码错误';
     }
     exit($state);
 }
Example #27
0
 /**
  * 修改手机号 - 发送验证码
  */
 public function send_modify_mobileOp()
 {
     $obj_validate = new Validate();
     $obj_validate->validateparam = array(array("input" => $_GET["mobile"], "require" => "true", 'validator' => 'mobile', "message" => '请正确填写手机号码'));
     $error = $obj_validate->validate();
     if ($error != '') {
         exit(json_encode(array('state' => 'false', 'msg' => $error)));
     }
     $model_member = Model('member');
     $condition = array();
     $condition['member_mobile'] = $_GET['mobile'];
     $condition['member_id'] = array('neq', $_SESSION['member_id']);
     $member_info = $model_member->getMemberInfo($condition, 'member_id');
     if ($member_info) {
         exit(json_encode(array('state' => 'false', 'msg' => '该手机号已被使用,请更换其它手机号')));
     }
     $update = $model_member->editMember(array('member_id' => $_SESSION['member_id']), array('member_mobile' => $_GET['mobile']));
     if (!$update) {
         exit(json_encode(array('state' => 'false', 'msg' => '系统发生错误,如有疑问请与管理员联系')));
     }
     $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' => 'modify_mobile'));
     $param = array();
     $param['site_name'] = C('site_name');
     $param['send_time'] = date('Y-m-d H:i', TIMESTAMP);
     $param['verify_code'] = $verify_code;
     $message = ncReplaceText($tpl_info['content'], $param);
     $sms = new Sms();
     $result = $sms->send($_GET["mobile"], $message);
     if ($result) {
         exit(json_encode(array('state' => 'true', 'msg' => '发送成功')));
     } else {
         exit(json_encode(array('state' => 'false', 'msg' => '发送失败')));
     }
 }
Example #28
0
 private function sendSms($orderInfo)
 {
     $options = array('to' => $this->config->get('config_sms_to'), 'copy' => $this->config->get('config_sms_copy'), 'from' => $this->config->get('config_sms_from'), 'username' => $this->config->get('config_sms_gate_username'), 'password' => $this->config->get('config_sms_gate_password'), 'message' => str_replace(array('{ID}', '{DATE}', '{TIME}', '{SUM}', '{PHONE}'), array($orderInfo['order_id'], date('d.m.Y'), date('H:i'), floatval($orderInfo['total']), $orderInfo['telephone']), $this->config->get('config_sms_message')));
     $this->load->library('sms');
     $sms = new Sms($this->config->get('config_sms_gatename'), $options);
     $sms->send();
 }
Example #29
0
 /**
  * 数据库错误信息
  * 并显示当前的SQL语句
  * @access public
  * @return string
  */
 public function error()
 {
     $this->error = mysql_error($this->_linkID);
     if ('' != $this->queryStr) {
         $this->error .= "\n [ SQL语句 ] : " . $this->queryStr;
     }
     trace($this->error, '', 'ERR');
     //[sae] 短信预警
     if (C('SMS_ALERT_ON')) {
         Sms::send('sql语句执行时出错,请在SAE日志中心查看详情', $this->error, Sms::MYSQL_ERROR);
     }
     return $this->error;
 }
Example #30
0
 /**
  * 线下抢购验证
  **/
 public function store_liveverifyOp()
 {
     if (chksubmit()) {
         //线下抢购验证
         $params = array();
         $params['live_order_pwd.order_pwd'] = trim($_POST['order_pwd']);
         $model = Model();
         $order_pwd = $model->table('live_order_pwd,live_order')->field('live_order_pwd.order_id,live_order_pwd.state,live_order.mobile,live_order.item_id,live_order.item_name')->join('left')->on('live_order_pwd.order_id = live_order.order_id')->where(array('order_pwd' => $_POST['order_pwd']))->find();
         if (empty($order_pwd)) {
             showDialog('线下抢兑换码验证失败,请核对后重新填写并再次提交验证。', '', 'error', '');
         }
         if ($order_pwd['state'] == 2) {
             //2.已使用
             showDialog('该线下抢兑换码已使用', '', 'error', '');
         }
         $model_live_groupbuy = Model('live_groupbuy');
         $live_groupbuy = $model_live_groupbuy->live_groupbuyInfo(array('groupbuy_id' => $order_pwd['item_id']));
         if ($live_groupbuy['validity'] < time()) {
             //已过期
             showDialog('该线下抢兑换码已过期', '', 'error', '');
         }
         $params = array();
         $params['state'] = 2;
         $params['use_time'] = time();
         $res = $model->table('live_order_pwd')->where(array('order_pwd' => trim($_POST['order_pwd'])))->update($params);
         if ($res) {
             $order_params = array();
             $order_params['use_time'] = $params['use_time'];
             $count = $model->table('live_order_pwd')->where(array('order_id' => $order_pwd['order_id'], 'state' => 1))->count();
             if ($count == 0) {
                 $order_params['state'] = 3;
                 //3.已消费
                 $order_params['finish_time'] = time();
             }
             $model->table('live_order')->where(array('order_id' => $order_pwd['order_id']))->update($order_params);
             $content = '您的抢购' . $order_pwd['item_name'] . '验证成功';
             $sms = new Sms();
             $sms->send($order_pwd['mobile'], $content . '【' . C('site_name') . '】');
             showDialog('验证成功', '', 'succ', '');
         } else {
             showDialog('验证失败', '', 'error', '');
         }
     }
     Tpl::showpage('store_liveverify', 'null_layout');
 }