function sendsmsAction()
 {
     $currentTime = date("Y-m-d H:i:s");
     $this->_helper->layout->disableLayout();
     if ($this->_request->isPost() && $this->_request->getParam("login_phone") != null) {
         try {
             $login_phone = $this->_request->getParam("login_phone");
             //verify email
             $consumerModel = new Consumer();
             $consumer = $consumerModel->fetchRow("login_phone = '" . $login_phone . "'");
             if ($consumer == null) {
                 $this->view->phoneErr = $this->view->translate('The_phone_is_not_existed');
                 return;
             }
             //generate reset password link
             $codePattern = '1234567890ABCDEFGHIJKLOMNOPQRSTUVWXYZ';
             $signup_auth_code = '';
             for ($codeCount = 0; $codeCount < 12; $codeCount++) {
                 $signup_auth_code = $signup_auth_code . $codePattern[mt_rand(0, 35)];
             }
             $resetPasswordLink = $this->view->home . '/public/forgetpassword/reset/p/' . $signup_auth_code;
             //save link into DB
             $tomorrow = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 1, date("Y"));
             $expire_date = date("Y-m-d H:i:s", $tomorrow);
             $temporaryLinkModel = new TemporaryLink();
             $temporaryLink = array("link" => $resetPasswordLink, "login_phone" => $login_phone, "expire_date" => $expire_date);
             $temporaryLink_id = $temporaryLinkModel->insert($temporaryLink);
             //send sms
             $newclient = new SMS();
             $mobile = $login_phone;
             $message = $this->view->translate('Forget_Password_SMS') . $signup_auth_code;
             $time = $currentTime;
             $apitype = 2;
             // $apitype 通道选择 0:默认通道; 2:通道2; 3:即时通道;
             $msg = iconv("UTF-8", "GB2312", $message);
             $respxml = $newclient->sendSMS($mobile, $msg, $time, $apitype);
             // crypt the login_phone, added by ZHL on 2011-11-25
             $this->view->crypt_login_phone = substr($login_phone, 0, 3) . "*****" . substr($login_phone, 8, 3);
         } catch (Exception $e) {
             //roll back...
             $this->view->phoneErr = $this->view->translate('Send_fail_Try_Again');
         }
     } else {
         $this->view->phoneErr = $this->view->translate('The_phone_is_not_existed');
     }
     // sms has been sent
     // $this->_helper->redirector('reset', 'forgetpassword');
 }
Exemplo n.º 2
0
 /**
  * SMS a record.
  *
  * @return void
  * @access public
  */
 public function smsRecord()
 {
     // Load the appropriate SMS module based on the "type" parameter:
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'Record';
     include_once 'services/' . $type . '/SMS.php';
     $sms = new SMS();
     $result = $sms->sendSMS();
     if (PEAR::isError($result)) {
         return $this->output(translate($result->getMessage()), JSON::STATUS_ERROR);
     }
     return $this->output(translate('sms_success'), JSON::STATUS_OK);
 }
Exemplo n.º 3
0
 function SendSMS()
 {
     require_once ROOT_DIR . '/services/EcontentRecord/SMS.php';
     $searchObject = SearchObjectFactory::initSearchObject();
     $searchObject->init();
     $sms = new SMS();
     $result = $sms->sendSMS();
     if (PEAR_Singleton::isError($result)) {
         return '<result>Error</result>';
     } else {
         if ($result === true) {
             return '<result>Done</result>';
         } else {
             return '<result><![CDATA[' . $result . ']]></result>';
         }
     }
 }
Exemplo n.º 4
0
 function adminreportbatchreplysendAction()
 {
     $this->_helper->layout->setLayout("layout_admin");
     ini_set('display_errors', 1);
     $frontController = Zend_Controller_Front::getInstance();
     $frontController->throwExceptions(true);
     if ($this->_request->isPost()) {
         $form = new ReplyReportForm();
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             //print_r($formData);die;
             $reportSource = $this->_request->getParam('report_source');
             // sms report:
             if ($reportSource == 'sms') {
                 $db = Zend_Registry::get('db');
                 $select = $db->select();
                 $select->from('consumer', '*');
                 $select->where('id = ?', $this->_request->getParam('consumer_id'));
                 $consumer = $db->fetchAll($select);
                 // 1.send reply
                 $msmStr = $form->getValue('message');
                 $len = strlen($msmStr);
                 for ($i = 0, $msmStrLen = 0; $i < $len; $i++, $msmStrLen++) {
                     if (ord($msmStr[$i]) >= 128) {
                         $i = $i + 2;
                     }
                 }
                 if ($msmStrLen > 70) {
                     $this->view->batchId = $formData['batch_id'];
                     $this->view->showMessage = 'Reply fail: The sms should be short then 70 characters.';
                     return;
                 }
                 include_once 'sms.inc.php';
                 $newclient = new SMS();
                 $apitype = 0;
                 $msg = iconv("UTF-8", "GB2312", $form->getValue('message'));
                 $respxml = $newclient->sendSMS($form->getValue('email'), $msg, date("Y-m-d H:i:s"), $apitype);
                 // 2.save reply
                 $replyModel = new Reply();
                 $reply = $replyModel->fetchRow('report_id = ' . $this->_request->getParam('report_id'));
                 //check reply condition!
                 if ($reply != null && $reply->status == 'SENT') {
                     $this->view->showMessage = "Reply fail: the reply has been sent!";
                     return;
                 }
                 if ($reply == null) {
                     $replyModel = new Reply();
                     $reply = $replyModel->createRow();
                 }
                 $currentTime = date("Y-m-d H:i:s");
                 $reply->date = $currentTime;
                 $reply->subject = $form->getValue('subject');
                 $reply->content = $form->getValue('message');
                 $reply->from = $config->smtp->report->mail->username;
                 $reply->campaign_id = $formData['campaign_id'];
                 $reply->report_id = $formData['report_id'];
                 $reply->to = $form->getValue('email');
                 $reply->status = 'SENT';
                 //2011-04-08 ham.bao separate the sessions with admin
                 $reply->admin_id = $this->_currentAdmin->id;
                 //$reply->usetime =$formData['usetime'];
                 $reply->save();
                 // 3.grade
                 $report_id = (int) $this->_request->getParam('report_id');
                 $this->saveReportReward($report_id, $form->getValue('grade'));
                 // 4.update notes for report
                 //$this->saveTags($report_id,$formData ['report_id']);
                 $this->saveTags($report_id, $formData['note']);
                 $this->view->batchId = $formData['batch_id'];
                 $this->updateBatchTotaltime($formData['batch_id'], $addtive);
                 $this->view->showMessage = $this->view->translate('Admin_Reply_the_report_successfully');
                 return;
             }
             // email report:
             //1. config
             $config = Zend_Registry::get('config');
             /* 
             $smtpSender = new Zend_Mail_Transport_Smtp(
             			$config->smtp->report->mail->server,
             			array(
             				'username'=> $config->smtp->report->mail->username,
             				'password'=> $config->smtp->report->mail->password,
             				'auth'=> $config->smtp->report->mail->auth,
             				'ssl' => $config->smtp->report->mail->ssl,
             			               			'port' => $config->smtp->report->mail->port));
             Zend_Mail::setDefaultTransport($smtpSender);
             $mail = new Zend_Mail('utf-8');
             */
             $db = Zend_Registry::get('db');
             $select = $db->select();
             $select->from('consumer', '*');
             $select->where('email = ?', $form->getValue('email'));
             $consumer = $db->fetchAll($select);
             if ($consumer[0] != null) {
                 /*
                 //2.get "Your story" from report
                 $reportId = $formData['report_id'];
                 				    	$reportModel = new Report();
                 				    	$report = $reportModel->find($reportId)->current();
                 				    	$config = Zend_Registry::get('config');
                 				    	$url_zh = $config->indicate2->home."/report/showAnswer/accessCode/".$report['accesscode']."/questionId/645";
                 $url_en = $config->indicate2->home."/report/showAnswer/accessCode/".$report['accesscode']."/questionId/707";
                 $contents = file_get_contents($url_zh).file_get_contents($url_en);
                 				    	$contents = trim($contents);
                 $contents = preg_replace('/\s(?=\s)/', '', $contents);
                 $contents = preg_replace('/[\n\r\t]/', ' ', $contents);
                 $contents = preg_replace('/&nbsp;/', '', $contents);	
                 preg_match_all ("|<div class.*answer_content.*>(.*)</[^>]+>|U", $contents, $out, PREG_PATTERN_ORDER);
                 
                 					    //3.create email and send
                 $emailSubject = $this->view->translate('Admin_Reply_WOM_Report_Subject');
                 if($consumer[0]['language_pref'] != null && $consumer[0]['language_pref'] == 'en'){
                 	$emailBody = $this->view->translate('Admin_Reply_WOM_Report_Body_en');
                 }else{
                 	$emailBody = $this->view->translate('Admin_Reply_WOM_Report_Body_zh');
                 }
                 
                 $stringChange = array(
                 	'?USERNAME?' => $consumer[0]['name'],
                 	'?YOURSTORY?' => $out[1][0],
                 	'?MYRESPONSE?' => $form->getValue('message'));
                 $emailBody = strtr($emailBody,$stringChange);
                 	
                 $langNamespace = new Zend_Session_Namespace('Lang');
                 	if($langNamespace->lang == 'en' || $langNamespace->lang == 'EN'){
                 		$mail->setSubject($emailSubject);
                 	}else{
                 		$mail->setSubject("=?UTF-8?B?".base64_encode($emailSubject)."?=");
                 	}
                 $mail->setBodyText($emailBody);
                 $mail->addTo($form->getValue('email'));
                 $mail->setFrom($config->smtp->report->mail->username, $this->view->translate('Wildfire'));
                 //send!
                 $mail->send();
                 */
                 //4.save reply
                 $replyModel = new Reply();
                 $reply = $replyModel->fetchRow('report_id = ' . $this->_request->getParam('report_id'));
                 //check reply condition!
                 if ($reply != null && $reply->status == 'SENT') {
                     $this->view->showMessage = "Reply fail: the reply has been sent!";
                     return;
                 }
                 if ($reply == null) {
                     $replyModel = new Reply();
                     $reply = $replyModel->createRow();
                 }
                 $currentTime = date("Y-m-d H:i:s");
                 $reply->date = $currentTime;
                 $reply->subject = $form->getValue('subject');
                 $reply->content = $form->getValue('message');
                 $reply->from = $config->smtp->report->mail->username;
                 $reply->campaign_id = $formData['campaign_id'];
                 $reply->report_id = $formData['report_id'];
                 $reply->to = $form->getValue('email');
                 $reply->status = 'SENT';
                 //2011-04-08 ham.bao separate the sessions with admin
                 $reply->admin_id = $this->_currentAdmin->id;
                 $reply->usetime = $form->getValue('usetime');
                 $reply->save();
                 // 5.grade
                 $report_id = (int) $this->_request->getParam('report_id');
                 $this->saveReportReward($report_id, $form->getValue('grade'));
                 // 6.update notes for report
                 $this->saveTags($report_id, $formData['note']);
                 // 7.update batch reply time
                 $addtive = $addtive = $formData['usetime'] - $reply->usetime;
                 $this->updateBatchTotaltime($formData['batch_id'], $addtive);
                 $this->view->showMessage = $this->view->translate('Admin_Reply_the_report_successfully');
                 //2.get "Your story" from report
                 $reportId = $formData['report_id'];
                 $reportModel = new Report();
                 $report = $reportModel->find($reportId)->current();
                 $config = Zend_Registry::get('config');
                 $url_zh = $config->indicate2->home . "/report/showAnswer/accessCode/" . $report['accesscode'] . "/questionId/2293";
                 // $url_zh = $config->indicate2->home."/report/showAnswer/accessCode/".$report['accesscode']."/questionId/645";
                 $url_en = $config->indicate2->home . "/report/showAnswer/accessCode/" . $report['accesscode'] . "/questionId/707";
                 $url_other = $config->indicate2->home . "/report/showAnswer/accessCode/" . $report['accesscode'] . "/questionId/77";
                 $contents = file_get_contents($url_zh) . file_get_contents($url_en) . file_get_contents($url_other);
                 $contents = trim($contents);
                 $contents = preg_replace('/\\s(?=\\s)/', '', $contents);
                 $contents = preg_replace('/[\\n\\r\\t]/', ' ', $contents);
                 $contents = preg_replace('/&nbsp;/', '', $contents);
                 preg_match_all("|<div class.*answer_content.*>(.*)</[^>]+>|U", $contents, $out, PREG_PATTERN_ORDER);
                 //3.create email and send
                 $smtpSender = new Zend_Mail_Transport_Smtp($config->smtp->report->mail->server, array('username' => $config->smtp->report->mail->username, 'password' => $config->smtp->report->mail->password, 'auth' => $config->smtp->report->mail->auth, 'ssl' => $config->smtp->report->mail->ssl, 'port' => $config->smtp->report->mail->port));
                 Zend_Mail::setDefaultTransport($smtpSender);
                 $mail = new Zend_Mail('utf-8');
                 $emailSubject = $this->view->translate('Admin_Reply_WOM_Report_Subject');
                 if ($consumer[0]['language_pref'] != null && $consumer[0]['language_pref'] == 'en') {
                     $emailBody = $this->view->translate('Admin_Reply_WOM_Report_Body_en');
                 } else {
                     $emailBody = $this->view->translate('Admin_Reply_WOM_Report_Body_zh');
                 }
                 $stringChange = array('?USERNAME?' => $consumer[0]['name'], '?YOURSTORY?' => $out[1][0], '?MYRESPONSE?' => $form->getValue('message'));
                 $emailBody = strtr($emailBody, $stringChange);
                 $langNamespace = new Zend_Session_Namespace('Lang');
                 if ($langNamespace->lang == 'en' || $langNamespace->lang == 'EN') {
                     $mail->setSubject($emailSubject);
                 } else {
                     $mail->setSubject("=?UTF-8?B?" . base64_encode($emailSubject) . "?=");
                 }
                 $mail->setBodyText($emailBody);
                 $mail->addTo($form->getValue('email'));
                 $mail->setFrom($config->smtp->report->mail->username, $this->view->translate('Wildfire'));
                 //send!
                 $mail->send();
                 $this->view->batchId = $formData['batch_id'];
                 $this->view->showMessage = $this->view->translate('Admin_Reply_the_report_successfully');
             } else {
                 $this->view->showMessage = "Reply fail: this email doesn't exist in DB!";
             }
         } else {
             $this->view->showMessage = 'Reply fail: please input the right data!';
         }
     } else {
         $this->view->showMessage = "err!";
     }
 }
Exemplo n.º 5
0
<?php

require_once "./includes/initialize.php";
$bmlist = man_power::BMlist2('BETWEEN 1 AND 25');
foreach ($bmlist as $BM) {
    $message = "Dear " . $BM->BM_Name . "," . PHP_EOL;
    $message .= "The Mebapp reporting system will be active only for today.Login now to share your team's performance for Go-Make A Difference." . PHP_EOL . "Regards" . PHP_EOL . "Cipla Respiratory";
    $sendSMS = new SMS();
    $sendSMS->sendSMS($BM->BM_Mobile, $message);
}
Exemplo n.º 6
0
 function sendcouponAction()
 {
     $this->_helper->layout->setLayout("layout_coupon");
     $currentTime = date("Y-m-d H:i:s");
     $endTime = date("Y年m月d日", strtotime("+7 day"));
     $couponId = (int) $this->_request->getParam('uid');
     //$message = $this->getCouponById($couponId);
     //var_dump($_SERVER['HTTP_REFERER']);die;
     $lou = 0;
     if (isset($_SERVER['HTTP_REFERER']) && preg_match('/19lou/', $_SERVER['HTTP_REFERER'])) {
         $lou = 1;
         $_SESSION['19lou'] = 1;
     }
     if (isset($_SESSION['19lou'])) {
         $lou = 1;
     }
     //var_dump($_SESSION);die;
     $this->view->message = array();
     $this->view->coupon = $couponId;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if (trim($formData['username']) == '') {
             $this->view->message['username'] = '******';
         }
         if (trim($formData['telephone']) == '') {
             $this->view->message['telephone'] = '手机号码不能为空。';
         }
         if (trim($couponId) == '') {
             $this->view->message['coupon'] = '没有对应的优惠券。';
         }
         $this->view->postData = $formData;
         if (trim($formData['telephone']) != '' && $this->validateSend($formData['telephone'], $couponId, $lou)) {
             $this->view->message['got'] = '已经领取优惠券或同一天固定IP只能领取一份。';
         }
         //print_r($formData);die;
         if (!count($this->view->message)) {
             $newclient = new SMS();
             if ($newclient->ConfNull == "1") {
                 $mobile = $formData['telephone'];
                 $message = $this->getCouponById($couponId);
                 $time = $currentTime;
                 //echo str_replace('{date}',$endTime,$message['content']);die;
                 $apitype = 3;
                 // $apitype 通道选择 0:默认通道; 2:通道2; 3:即时通道;
                 $msg = iconv("UTF-8", "GB2312", str_replace('{date}', $endTime, $message['content']));
                 //				Zend_Debug::dump($msg);
                 $respxml = $newclient->sendSMS($mobile, $msg, $time, $apitype);
                 //print_r($newclient->sendXML);die();
                 $smsSpace = new Zend_Session_Namespace('SMS');
                 $smsSpace->xml = $newclient->sendXML;
                 $smsSpace->respxml = $respxml;
                 $this->view->code = $newclient->getCode();
                 if ($this->view->code == 2000) {
                     $this->view->message['susess'] = "成功领取优惠券.";
                     //add the coupon history
                     $db = Zend_Registry::get('db');
                     $insetSql = $db->prepare("insert into coupon_history(telephone,ip,crdate,cuid) values ('{$formData['telephone']}','{$_SERVER['REMOTE_ADDR']}','{$currentTime}',{$couponId})");
                     $insetSql->execute();
                 } else {
                     $this->view->message['telephone'] = '手机号码可能不正确。';
                 }
             } else {
                 $this->view->message['fail'] = "失败";
                 $this->view->message['noconfig'] = "你还没有配置文件";
             }
         }
     }
 }
Exemplo n.º 7
0
<?php

require_once "./includes/initialize.php";
$date = date('Y-m-d');
$sql = "SELECT \n  GROUP_CONCAT(DISTINCT(BM_Name)) AS BM_Name,\n  `SM_Emp_Id`,\n  `SM_Name`,\n  `SM_Mobile` \nFROM\n  `respi2_manpower` \nWHERE BM_Emp_Id NOT IN \n  (\n  SELECT DISTINCT \n    (BM_Emp_ID) \n  FROM\n    `respi2_activity` \n  WHERE DATE_FORMAT(created, '%Y-%m-%d') = '{$date}') GROUP BY `SM_Emp_Id` ";
$result = Query::executeQuery($sql);
foreach ($result as $value) {
    $message = "Dear " . $value->SM_Name . "," . PHP_EOL;
    $message .= "Following BMs have not reported today : " . $value->BM_Name;
    $sendSMS = new SMS();
    //echo $message.'<br/>';
    $sendSMS->sendSMS($value->SM_Mobile, $message);
}