/** * push job insert match predict * @param array $params * @return boolean * @author PhuongTN */ public function pushJobInsertMatchPredict($params) { try { $result = array('result' => false); $config = Thethao_Global::getApplicationIni(); //Create job client $jobClient = Thethao_Global::getJobClientInstance('sport'); //get job func name $jobFunc = $config['job']['task']['sport']['match_predict']; //default $jobParams = array(); //add job class name $jobParams['class'] = 'Job_Thethao_JobBackendCache'; //reg func delete article $jobParams['function'] = 'insertMatchPredict'; //init array args $jobParams['args'] = $params; //Register job with normal priority $pushJob = $jobClient->doBackgroundTask($jobFunc, $jobParams); $pushJob = $jobClient->doBackgroundTask($jobFunc . '_new', $jobParams); if ($pushJob != false) { $result['result'] = true; } } catch (Exception $ex) { Thethao_Global::sendlog($ex); } return $result; }
/** * @author : VinhNT * @name : ajaxsendmailAction * @copyright : FPT Online * @todo : ajaxsendmail Action * @return : array('error' => 0, 'message' => '', 'body' => '') */ public function ajaxsendmailAction() { //Disable layout $this->_helper->layout->disableLayout(true); //Set no render view $this->_helper->viewRenderer->setNoRender(true); //default return $response = array('error' => 0, 'message' => ''); /* ----------------------------------------------------------------- Get param sent to job send mail */ try { $arrParams = $this->_request->getPost(); //Trim captcha id $arrCaptcha['id'] = trim($arrParams['captchaID']); $arrCaptcha['input'] = trim($arrParams['txtCode']); // Creating a Zend_Captcha_Image instance $captcha = new Zend_Captcha_Image(); // would be key/value array: id => captcha ID, input => captcha value if ($captcha->isValid($arrCaptcha)) { // Include config send mail include APPLICATION_PATH . '/configs/mail.php'; //Check config sender if (is_array($configsender) && !empty($configsender)) { // Get Url to send $url_send = $arrParams['url']; $url_send = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($url_send)))); $url_send = str_replace('http://thethao.vnexpress.net', 'http://seagames.vnexpress.net', $url_send); // Get name of the sender $sender_name = $arrParams['sender_name']; $sender_name = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($sender_name)))); if (empty($sender_name)) { $response['error'] = 1; $response['message'] = 'Xin hãy nhập họ tên người gửi.'; echo Zend_Json::encode($response); exit; } // Get user email $email_user = $arrParams['email_user']; $email_user = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($email_user)))); //Check email user if (empty($email_user)) { $response['error'] = 1; $response['message'] = 'Xin hãy nhập email người gửi.'; echo Zend_Json::encode($response); exit; } // Get title of send mail $title_email = urldecode($arrParams['title_email']); $title_email = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($title_email)))); //Set parrams email sender $sender_email = $configsender['message']['email']; // Get email of the reciever $reciever_mail = $arrParams['receiver_mail']; $reciever_mail = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($reciever_mail)))); //Check reciever mail if (empty($reciever_mail)) { $response['error'] = 1; $response['message'] = 'Xin hãy nhập email người nhận.'; echo Zend_Json::encode($response); exit; } // Get message mail $message_mail = $arrParams['message_mail']; $message_mail = trim(strip_tags($message_mail)); //Get body message $body_message = '<strong>' . $sender_name . '(' . $email_user . ')</strong><br/>Đã gửi cho bạn bài báo tại link: <a href="' . $url_send . '" title="' . $title_email . '">' . $url_send . '</a>'; //Check message mail if (!empty($message_mail)) { $body_message .= '<br/>Với nội dung: </br>' . $message_mail; } $body_message .= '<hr><br/>Email này được gửi bằng tiện ích "Gửi cho bạn bè" của <b>SEAGames.VnExpress.net<b>'; //Get array mail $arrEmail = explode(';', $reciever_mail); $arrEmailReciever = array(); //Check array email if (!empty($arrEmail)) { foreach ($arrEmail as $email) { $email = trim($email); //If email is NOT valid if (@(!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+\$", (string) $email))) { //if (@!Fpt_Valid::isEmail($email)) continue; } //Put data to arrReciever $arrEmailReciever[] = array('email' => $email, 'alias' => $email); } if (!empty($arrEmailReciever)) { //push job call send mail $jobParams = array('class' => 'Job_Thethao_JobMessage', 'function' => 'sendMail', 'args' => array('sender' => $sender_email, 'name' => 'VNE SEA Games', 'reciever' => $arrEmailReciever, 'subject' => $title_email, 'body' => $body_message)); //get application config $config = Thethao_Global::getApplicationIni(); //To array $jobConfiguration = $config['job']['task']['sport']['send_mail']; //get job send mail instance $jobClient = Thethao_Global::getJobClientInstance('sport'); //Register job $result = $jobClient->doBackgroundTask($jobConfiguration, $jobParams); if (!$result) { $response['error'] = 1; $response['message'] = 'Không gửi được email. Xin vui lòng thử lại sau.'; echo Zend_Json::encode($response); exit; } else { $response['error'] = 0; $response['message'] = 'Gửi email thành công.'; echo Zend_Json::encode($response); exit; } } else { $response['error'] = 1; $response['message'] = 'Email gửi đến không hợp lệ'; echo Zend_Json::encode($response); exit; } } } else { $response['error'] = 1; $response['message'] = 'Empty recipient.'; echo Zend_Json::encode($response); exit; } } else { $response['error'] = 2; $response['message'] = 'Mã xác nhận không đúng.'; echo Zend_Json::encode($response); exit; } } catch (Exception $ex) { // Log error Thethao_Global::sendLog($ex); } echo Zend_Json::encode($response); exit; }