function recover($mail) { $dao = new UserDAO(); $id = $dao->getUserIdByMail($mail); if ($id != -1) { $user = $dao->selectUserById($id); $name = $user->name; $pass = $user->password; $message = "Dear " . $name . ", Your account password is " . $pass; $subject = "Password Recovery Mail"; $mailSender = new MailSender(); $mailSender->sendMail("*****@*****.**", $mail, $message, $subject); } return $id; }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new self(); } return self::$instance; }
/** * Initializes the PHPMailer. * @return true */ private static function initPHPMailer() { self::$_mailer = new PHPMailer(); self::$_mailer->IsSMTP(); self::$_mailer->Host = Yii::app()->params['mailHost']; self::$_mailer->SMTPAuth = true; self::$_mailer->Username = Yii::app()->params['adminEmail']; self::$_mailer->Password = Yii::app()->params['mailPassword']; self::$_mailer->WordWrap = 70; return true; }
/** * Creates a new instance of the default mail sender. */ private static function createDefault() { switch (MAIL_SEND_METHOD) { case 'php': require_once WCF_DIR . 'lib/data/mail/PHPMailSender.class.php'; self::$defaultMailSender = new PHPMailSender(); break; case 'smtp': require_once WCF_DIR . 'lib/data/mail/SMTPMailSender.class.php'; self::$defaultMailSender = new SMTPMailSender(); break; case 'debug': require_once WCF_DIR . 'lib/data/mail/DebugMailSender.class.php'; self::$defaultMailSender = new DebugMailSender(); break; } }
function sendMail($info) { foreach ($info as $user) { $emailAddr = $user["email"]; if (isset($emailAddr) && !empty($emailAddr)) { date_default_timezone_set('UTC'); $date = date('F j, Y'); $textResources = new TextResources('en'); $serverContext = str_replace('/statusreport.php', '', $_SERVER['SCRIPT_NAME']); $pageContext = new PageContext("mail", $textResources, "en", $serverContext); $twigVars = array('host' => "http://" . $_SERVER['HTTP_HOST'], 'pageContext' => $pageContext, 'user' => $user, 'date' => $date, 'textResources' => $textResources); $message = $this->twig->render('mails/statusreport.twig', $twigVars); if (isset($_GET["testMail"])) { MailSender::sendMail($_GET["testMail"], "zSticker Status Update", $message); } else { if (isset($_GET["realMail"])) { MailSender::sendMail($emailAddr, "zSticker Status Update", $message); } } echo "<br/>Sending to: " . $emailAddr . "<br/>" . $message; } } }
<?php $user = new User(); $_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); $res = $user->selectByEmail($_POST['email']); if ($res !== false) { echo ReturnCode::$userPresent; } else { $_POST['password'] = Database::encryptString($_POST['password']); $user->fillByAssoc($_POST); $res = $user->insert(); if ($res !== false) { $body = 'Dear ' . $user->getName() . ',' . PHP_EOL . PHP_EOL . 'Thanks for registering to our service, we wish you a happy user experience.'; MailSender::sendMail($_POST['email'], 'Welcome to Trizor', $body); echo ReturnCode::$success; } else { echo ReturnCode::$error; } }
// # Build chart $CB->buildChartByCustomer($RSByoID); $CB->buildChartByTechnician($RSByTechnician); $CB->buildChartByMonth($RSByMonth); // # OK $SR->status = ServiceResponse::STATUS_OK; echo json_encode($SR); } catch (Exception $e) { // # No way $log->addError($e->getMessage()); } }); // # Mail sender route $router->map('GET', 'sender', function () use($PM, $log) { // # Mail sender instance $MS = new MailSender(); $SR = $MS->send(); // # Response echo json_encode($SR); }); // # CONFIG Page ajax ROUTES // # Get recipients API $router->map('GET', 'recipients', function () { echo json_encode(file_get_contents("config/mail/recipients")); }); // # Get technicians list $router->map('GET', 'technicians', function () use($DAOConn, $log) { try { // # Connect to db $DAO = new DAO($DAOConn, $log, array()); echo json_encode($DAO->getTechnicians());
/** * Sends mail using SMTP. * @param string $from User's email address * @param string $subject Subject of the email * @param string $body Body of the email * @param boolean $html true indicates that the body format is html; false means the body is plain text * @return true|false */ private function sendMailSmtp($from, $fromName, $subject, $body, $html = false) { $mailParams = array('from' => $from, 'fromName' => $fromName, 'to' => Yii::app()->params['adminEmail'], 'subject' => $subject, 'body' => $body); return MailSender::sendSMTP($mailParams, '', 'text/plain'); }
public static function sendRegisterVerification($email, $username) { if (empty($email)) { return false; } $key = sha1(uniqid(rand())); $data = array('verification_key' => $key); $model = EmailVerification::model()->get($email); if ($model === null) { /*$model = new EmailVerification(); $model->email = $email; $model->verification_key = $key;*/ $mailParams = array('from' => Yii::app()->params['adminEmail'], 'fromName' => 'LintinZone', 'to' => $email, 'subject' => 'LintinZone ' . UserModule::t('Xác nhận đăng ký thành viên'), 'body' => array('{receiver}' => empty($username) ? UserModule::t('my friend') : $username, '{confirm_link}' => Yii::app()->createAbsoluteUrl('user/registration/confirm', array('key' => $key, 'email' => $email)), '{support_link}' => Yii::app()->createAbsoluteUrl('site/contact', array('email' => $email)), '{home_link}' => Yii::app()->createAbsoluteUrl(''))); if (MailSender::sendSMTP($mailParams, 'register', 'text/html')) { /*$model->sent_date = new CDbExpression('NOW()'); $model->save();*/ $data['sent'] = true; $data['active'] = true; $data['verified'] = false; EmailVerification::model()->insert($email, $data); return true; } //$model->save(); $data['sent'] = false; $data['active'] = true; $data['verified'] = false; EmailVerification::model()->insert($email, $data); return false; } else { if (!$model->verified) { //$model->verification_key = $key; $mailParams = array('from' => Yii::app()->params['adminEmail'], 'fromName' => 'LintinZone', 'to' => $email, 'subject' => 'LintinZone ' . UserModule::t('Xác nhận đăng ký thành viên'), 'body' => array('{receiver}' => empty($username) ? UserModule::t('my friend') : $username, '{confirm_link}' => Yii::app()->createAbsoluteUrl('user/registration/confirm', array('key' => $key, 'email' => $email)), '{support_link}' => Yii::app()->createAbsoluteUrl('site/contact', array('email' => $email)), '{home_link}' => Yii::app()->createAbsoluteUrl(''))); if (MailSender::sendSMTP($mailParams, 'register', 'text/html')) { $data['sent'] = true; $data['active'] = true; $data['verified'] = false; EmailVerification::model()->insert($email, $data); return true; } $data['sent'] = false; $data['active'] = true; $data['verified'] = false; EmailVerification::model()->insert($email, $data); return false; } else { return true; } } }
public static function sendByPhpMail($from, $recipients, $subject, $body) { $mailSender = new MailSender(); return $mailSender->sendHtml($from, $recipients, $subject, $body); }
<link rel='stylesheet' href='/style/basket-style.css' type='text/css' media='screen, projection' /> <div id="content"> <?php if ($payOk == 1) { $userInfo = $_SESSION['basketStuff']->getUserInfo(); $orderInfo = $_SESSION['basketStuff']->getOrderInfo(); $productStuff = new ProductsStuff(); $productStuff->addRelatedProducts($orderInfo->orderedProductsInfo); if ($userInfo == NULL) { header("Location: /index.php/"); } if (!($userInfo->email == '')) { $mSender = new MailSender(); $mSender->sendMail($orderInfo); } echo "<div id='empty'> Заказ успешно оплачен! </div>"; $_SESSION['basketStuff']->clear(); } else { echo "<div id='empty'> Заказ не был оплачен =( </div>"; } ?> </div>
} array_push($_SESSION['messages'], $message); // Redirect user to home page header("Location: index.php"); ob_end_flush(); die; } if ($result === -1) { $dbconn->disconnect(); $message = array('content' => 'Yêu cầu không hợp lệ!', 'type' => 'error'); if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); } array_push($_SESSION['messages'], $message); // Redirect user to home page header("Location: index.php"); ob_end_flush(); die; } // Send mail $mailParams = array('to' => $email, 'subject' => 'LintinZone: Ngừng đăng ký tin tức :-(', 'message' => array('{receiver}' => $dbconn->getContactName($email), '{home_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/index.php', '{support_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/contact.php')); $sender = new MailSender($dbconn); $sender->send($mailParams, 'unsubscribe-vi', 'html'); $dbconn->disconnect(); $message = array('content' => 'Bạn đã ngừng nhận tin từ LintinZone :-(.', 'type' => 'success'); if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); } array_push($_SESSION['messages'], $message); header("Location: index.php"); ob_end_flush();
static function send($recip) { $ms = new MailSender($recip, true); $ms->run(); }
function sendPassRestoreEmail($email, $hash) { $body = '<h2>Вы запросили восстановление пароля на сайте</h2>'; $body .= 'Пожалуйста, пройдите по ссылке <a href="http://balbum.ru/f/' . $hash . '">http://balbum.ru/f/' . $hash . '</a> чтобы задать новый пароль.'; $body = '<!DOCTYPE html PUBLIC "html"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body>' . $body . '</body> </html>'; $mailer = new MailSender(); $r = $mailer->mail(Config::GLOBAL_EMAIL, $email, 'Восстановление пароля на balbum.ru', $body); if (!$r) { throw new Exception('mailing error ' . Config::GLOBAL_EMAIL . '-' . $email); } return $r; }
<?php $_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); $user = new User(); if ($user->selectByEmail($_POST['email'])) { $newPassword = uniqid(); $user->setPassword(Database::encryptString($newPassword)); if ($user->update()) { $body = "Dear " . $user->getName() . ",\r\n\r\n" . "Your password has been reset.\r\n" . "Your new password is: {$newPassword}.\r\n" . "We suggest you to change your password to a more familiar one as soon as possible.\r\n\r\n" . "Have a nice day.\r\n" . "Tripzor Team"; $res = MailSender::sendMail($user->getEmail(), 'Tripzor Password Reset', $body); if (!$res) { echo ReturnCode::$mailError; } else { echo ReturnCode::$success; } echo $mail->ErrorInfo; } else { echo ReturnCode::$error; } } else { echo ReturnCode::$userNotFound; }
public function upd_resa() { global $wpdb; if (isset($_POST["pl_adulte_upd"]) && isset($_POST["pl_enfant_upd"])) { if (!is_numeric($_POST["post_id_upd"])) { $upd = z; } else { if ($_POST["pl_adulte_upd"] == 0 && $_POST["pl_enfant_upd"] == 0) { $upd = 2; } else { $post_id = $_POST["post_id_upd"]; $current_user = wp_get_current_user(); $id_user = $current_user->ID; $user_rank = $user->roles[0]; $nb_place_dispo = get_post_meta($post_id, '_nb_place', true); $query2 = $wpdb->get_results("SELECT * FROM cjm_reservation WHERE id_evenement = {$post_id} AND id_participant = {$id_user}"); $ancien_nb_place = $query2[0]->nbplace + $query2[0]->nbplace_enf; $prix_total = getPrixTotal($post_id, intval($_POST["pl_adulte_upd"]), intval($_POST["pl_enfant_upd"]), $user_rank); if ($nb_place_dispo + $ancien_nb_place < $_POST["pl_adulte_upd"] + $_POST["pl_enfant_upd"]) { $upd = 3; } else { if (get_post_meta($post_id, '_etat_resa', true) == 'file_attente') { $bool = 1; } else { $bool = 0; } $query = $wpdb->update(cjm_reservation, array('nbplace' => esc_attr($_POST["pl_adulte_upd"]), 'nbplace_enf' => esc_attr($_POST["pl_enfant_upd"]), 'paiement' => 0, 'prix_total' => $prix_total, 'liste_attente' => $bool, 'date_resa' => date("d-m-Y H:i:s")), array('id_participant' => $id_user, 'id_evenement' => $_POST["post_id_upd"])); if ($query == 1) { $nb_place_maj = $nb_place_dispo + $ancien_nb_place - intval(esc_attr($_POST["pl_adulte_upd"])) - intval(esc_attr($_POST["pl_enfant_upd"])); $query = update_post_meta($post_id, '_nb_place', $nb_place_maj); } if ($query == 1) { $isSent = MailSender::send_email_ins_modif($current_user->user_login, true, $post_id); } $upd = 1; } } } echo json_encode($upd); } wp_die(); }
foreach ($_POST as $k => $v) { $str .= "{$k}: " . mb($v) ."\n"; } $str .= "\n-- _SERVER -- \n"; foreach ($_SERVER as $k => $v) { $str .= "{$k}: $v\n"; } //-------------------------------------- // メール送信 //-------------------------------------- $smtp['host'] = MAIL_SMTP; $smtp['port'] = 25; $smtp['auth'] = false; $mail = new MailSender($smtp); $mail->setFrom(MAIL_FROM); $mail->setTo(MAIL_TO); // 話題ID、コメントIDがブランクの場合は別アドレスへ if (empty($_POST['t']) == true && empty($_POST['m']) == true) { $mail->setTo(MAIL_TO_PARAMS_NG); } $hostname = @exec('hostname'); $today = date('Y/m/d H:i:s'); $mail->setSubject("[{$hostname}] CGM違反報告 ({$today})"); $mail->send($str); // urlが取得出来ない場合はリダイレクトしない //↓↓===========nm00142 start================================ //↓↓if (empty($_POST['url']) == false) { //↓↓ $url = base64_decode(urldecode($_POST['url'])); //↓↓ header("Location: {$url}#cgm-01");
$message = array('content' => 'This email address has subscribed.', 'type' => 'warning'); if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); } array_push($_SESSION['messages'], $message); // Redirect user to home page header("Location: index.php"); ob_end_flush(); } // Generate an unique key for email confirmation. $key = sha1(uniqid(rand())); // 40 characters $result = $dbconn->sendVerification($email, $key); // Send mail $mailParams = array('to' => $email, 'subject' => 'LintinZone: Comfirm email subscription', 'message' => array('{receiver}' => !empty($name) ? $name : 'my friend', '{confirm_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/en/confirm.php?key=' . $key . '&email=' . $email . '&lang=en', '{support_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/en/contact.php', '{home_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/en/index.php')); $sender = new MailSender($dbconn); $sender->send($mailParams, 'confirm-en', 'html'); // If verification key is stored... if ($result) { $_SESSION['email'] = $email; $message = array('content' => 'An email confirmation has been sent to your email address.', 'type' => 'success'); } else { $dbconn->rollback(); $message = array('content' => 'Oops, an error has occurred! Please try again.', 'type' => 'error'); } // Disconnect after executing query. $dbconn->disconnect(); // Push message to message holder. if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); }
array_push($_SESSION['messages'], $message); // Redirect user to home page header("Location: index.php"); ob_end_flush(); die; } $unsubscribe = sha1(uniqid(rand())); if (!$dbconn->confirmEmail($email, $key, $unsubscribe)) { $dbconn->disconnect(); $message = array('content' => 'Quá trình xử lý xảy ra lỗi! Xin vui lòng thử lại.', 'type' => 'error'); if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); } array_push($_SESSION['messages'], $message); // Redirect user to home page header("Location: index.php"); ob_end_flush(); die; } // Send mail $mailParams = array('to' => $email, 'subject' => 'LintinZone: Chào mừng bạn đến với LintinZone', 'message' => array('{receiver}' => $dbconn->getContactName($email), '{unsubscribe_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/unsubscribe.php?key=' . $key . '|' . $unsubscribe . '&email=' . $email . '&lang=vi', '{support_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/contact.php', '{home_link}' => 'http://' . $_SERVER['SERVER_NAME'] . '/index.php')); $sender = new MailSender($dbconn); $sender->send($mailParams, 'greeting-vi', 'html'); $dbconn->disconnect(); $message = array('content' => 'Chào mừng bạn đến với LintinZone.', 'type' => 'success'); if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); } array_push($_SESSION['messages'], $message); header("Location: index.php"); ob_end_flush();
function update_user($username, $changes) { if (!is_array($changes) or empty($changes)) { throw new Exception('-'); } $assignments = array(); $arguments = array(); $err = array(); if (isset($changes['full_name'])) { if (!Validator::validate_full_name($changes['full_name'])) { $err['full_name'] = $this->msg->_('/signup/errors/full-name.two-words', [255]); } else { $assignments[] = 'full_name = ?'; $arguments[] = $changes['full_name']; } } if (isset($changes['birth_date'])) { if (!Validator::validate_birth_date($changes['birth_date'])) { $err['birth_date'] = $this->msg->_('/signup/errors/b-date.invalid'); } else { $assignments[] = 'birth_date = ?'; $arguments[] = $changes['birth_date']; } } if (isset($changes['gender'])) { if (!Validator::validate_gender($changes['gender'])) { $err['gender'] = $this->msg->_('/signup/errors/gender.invalid'); } else { $assignments[] = 'gender = ?'; $arguments[] = $changes['gender']; } } if (isset($changes['status'])) { if (!Validator::validate_status($changes['status'])) { $err['status'] = $this->msg->_('/update-user/errors/status.invalid'); } else { $assignments[] = 'status = ?'; $arguments[] = $changes['status']; if ($changes['status'] === 'active') { $user = $this->get_users(array('fields' => 'email', 'username' => $username))['items'][0]; MailSender::tell_approved($this->msg, $user['email']); } } } if (isset($changes['password'])) { if (!Validator::validate_password($changes['password'])) { $err['password'] = $this->msg->_('/signup/errors/password.invalid'); } else { $assignments[] = 'password = ?'; $arguments[] = password_hash($changes['password'], PASSWORD_BCRYPT); } } if (!empty($err)) { throw new Exception(my_json_encode($err)); } $sql = 'UPDATE `user` SET '; $sql .= implode(', ', $assignments); $sql .= ' WHERE username = ?;'; $arguments[] = $username; $s = $this->conn->prepare($sql); if (!$s) { throw new DatabaseException($this->conn->errorInfo()[2]); } if (!$s->execute($arguments)) { throw new DatabaseException($s->errorInfo()[2]); } return $s->rowCount(); }
public function testReportMailSender() { $sender = new MailSender; $sender->addRecipient('domainezz.com Admin <*****@*****.**>'); $sender->send('toto','titi'); $mailData = Stato_StaticTransport::getMailQ(); $this->assertEquals('Rapport d\'exploitation : titi',$mailData[0]['subject']); $this->assertEquals("domainezz.com Admin <*****@*****.**>", $mailData[0]['to']); $this->assertContains("Rapport d'exploitation du traitement \"titi\" :\n" ."\n" ."toto",$mailData[0]['content']); }
public function executeSendPassword(sfWebRequest $request) { // try to find the user by the given E-Mail-Address $user = Doctrine::getTable('User')->findOneByEmail($request->getParameter('email')); if ($user) { // delete all previous recovery tokens Doctrine_Query::create()->delete('Token t')->where('t.user_id=? AND action=?', array($user->getId(), Token::$ACTION_RECOVER))->execute(); // generate recover token $token = new Token(); $token->setUserId($user->getId()); $token->setAction(Token::$ACTION_RECOVER); $token->save(); // sending user email $html = $this->getPartial('recoverEmail', array('user' => $user, 'token' => $token)); $subject = sfContext::getInstance()->getI18N()->__('Your TimeHive password'); MailSender::createInstance()->send($user['email'], $subject, $html); $this->getUser()->setFlash('send_pwd_failure', $this->getContext()->getI18N()->__('An email with instructions to choose a new password has been sent to you.')); $this->redirect('login/index'); } else { $this->getUser()->setFlash('send_pwd_failure', $this->getContext()->getI18N()->__('There is no such e-mail address in the our database!')); $this->redirect('login/index'); } }
/** * Sends this mail. */ public function send() { MailSender::getDefault()->sendMail($this); }
// generate new id $sqlr = "SELECT max(idmessage) as newid from message "; $resultr = mysql_query($sqlr); if (mysql_num_rows($resultr) < 1) { $kode = 1; } else { $rowr = mysql_fetch_array($resultr); $kode = $rowr['newid'] + 1; } $query = "INSERT INTO messages "; $query .= "VALUES('{$kode}','1111111111','{$idmember}','{$message}','inputdate','1')"; $result = mysql_query($query); // sending email to customer related about the action $emailsender = "*****@*****.**"; $emailreceiver = $email; $namapengirim = "Roripon.com"; $namapenerima = $namamember; $subject = "Confirmation about your roricoins\tin roripon.com"; echo $isiemail = "\n\t<table width=\"625\" border=\"0\" align=\"center\" style=\"border:1px solid green\">\n\t <tr>\n\t\t<td colspan='2'> </td>\n\t </tr>\n\t <tr>\n\t\t<td align=\"right\">\n\t\t\t<img width=\"187\" height=\"88\" src=\"http://www.roripon.com/config/images/newtoplogo.png\" align=\"right\" />\n\t\t</td>\n\t\t<td width=\"605\"><p align=\"center\">\n\t\t\t<strong>PT. RORI PON</strong><br />\n\t\t\tJalan Dharmahusada Indah Utara Blok U/VI no. 319 Surabaya<br />\n\t\t\tTlp. 031 83222289/99, 031 71998877.<br/> \n\t\t\tEmail cs@roripon.com</p>\n\t\t</td>\n\t </tr>\t \n\t <tr>\n\t\t<td colspan='2'><hr color='green'></td>\n\t </tr>\n\t <tr>\n\t\t<td colspan='2'><i>You got this message via Roripon.com</i></td>\n\t </tr>\n\t <tr>\n\t\t<td align='left' colspan='2'>From : {$namapengirim}" . "(" . $emailsender . ")</td>\n\t </tr> \n\t <tr>\n\t\t<td align='left' colspan='2'>Subject : {$subject}</td>\n\t </tr> \n\t <tr>\n\t\t<td colspan='2'> </td>\n\t </tr> \n\t <tr>\n\t\t<td colspan='2'>" . $greet1 . "\n\t\t</td>\n\t </tr>\n\t</table>"; $sender = new MailSender(); $sender->set_from($emailsender); $sender->set_from_name($namapengirim); $sender->set_message($isiemail); $sender->set_subject($subject); $sender->set_to($emailreceiver); $sender->set_to_name($namapenerima); $sender->send(); if ($sender) { $pesan = "An email has been sent to member's email address. Update " . $prod . " success."; } echo "<script>alert(\"{$pesan}\");window.location='javascript:javascript:history.go(-2)';</script>";
$ownname = DBA::getInstance()->getOneGeneral("fool_author"); $ownhdr = DBA::getInstance()->getOneGeneral("fool_header"); $ownmail = DBA::getInstance()->getOneGeneral("fool_email"); $nrmail = "*****@*****.**"; $encoding = "UTF-8"; $res = array(); $m_val = new \MailValidator($email); if ($m_val->isValid() === true) { $res['q_id'] = DBA::getInstance()->saveNewMsg($in); $subject .= " - from {$ownhdr}"; // отправляем сообщение себе $mailres = \MailSender::getInstance()->send($name, $email, $ownname, $ownmail, $encoding, $encoding, $subject, $message); // отправляем уведомление посетителю $subject = "Сообщение на сайте {$ownhdr}"; $message = "Вы создали сообщение № " . $res['q_id'] . " на сайте {$ownhdr}"; $mailres = \MailSender::getInstance()->send($ownhdr, $nrmail, $name, $email, $encoding, $encoding, $subject, $message); } else { $mailres = false; } if ($res['q_id'] > -1 && $mailres !== false) { $res['status'] = 'Ok'; } else { $res['status'] = 'Fail'; } if ($res) { echo json_encode($res); } break; default: break; }