Exemplo n.º 1
0
 public function testsmtp()
 {
     if ($this->isAjax()) {
         if ($_POST['address']) {
             if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['address'])) {
                 if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['test_email'])) {
                     $smtp = array('MAIL_ADDRESS' => $_POST['address'], 'MAIL_SMTP' => $_POST['smtp'], 'MAIL_LOGINNAME' => $_POST['loginName'], 'MAIL_PASSWORD' => $_POST['password'], 'MAIL_PORT' => $_POST['port'], 'MAIL_SECURE' => $_POST['secure'], 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                     C($smtp, 'smtp');
                     //C('','smtp');
                     import('@.ORG.Mail');
                     $content = L('EMALI_CONTENT');
                     $message = SendMail($_POST['test_email'], L('EMALI_TITLE'), $content, L('EMALI_AUTOGRAPH'));
                     if ($message === true) {
                         $message = L('SENT SUCCESSFULLY');
                     } else {
                         $message = $message ? $message : L('SENT FAILED');
                     }
                 } else {
                     $message = L('TEST YOUR INBOX MALFORMED');
                 }
             } else {
                 $message = L('EMAIL FORMAT ERROR');
             }
             $this->ajaxReturn("", $message, 1);
         } else {
             if ($_POST['uid'] && $_POST['passwd'] && $_POST['phone']) {
                 $result = sendtestSMS(trim($_POST['uid']), trim($_POST['passwd']), $_POST['phone']);
                 if ($result < 1) {
                     $message = L('ACCOUNT INFORMATION ERROR');
                 } elseif ($result == 1) {
                     $message = L('SENT SUCCESSFULLY SMS');
                 }
             } else {
                 $message = L('SENT FAILED SMS');
             }
             $this->ajaxReturn("", $message, 1);
         }
     }
 }
Exemplo n.º 2
0
 public function index()
 {
     if ($this->isAjax()) {
         if ($_POST['address']) {
             if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['address'])) {
                 if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['test_email'])) {
                     $smtp = array('MAIL_ADDRESS' => $_POST['address'], 'MAIL_SMTP' => $_POST['smtp'], 'MAIL_PORT' => $_POST['port'], 'MAIL_LOGINNAME' => $_POST['loginName'], 'MAIL_PASSWORD' => $_POST['password'], 'MAIL_SECURE' => $_POST['secure'], 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                     C($smtp, 'smtp');
                     import('@.ORG.Mail');
                     $content = '这是一封悟空CRM系统自动生成测试邮件,如果你成功收到,证明悟空smtp设置成功!请勿回复';
                     if (SendMail($_POST['test_email'], '悟空CRM邮箱测试', $content, '悟空CRM管理员')) {
                         $message = '发送成功!';
                     } else {
                         $message = '发送失败,信息错误!';
                     }
                 } else {
                     $message = '测试收件箱格式错误!';
                 }
             } else {
                 $message = '邮箱格式错误!';
             }
             $this->ajaxReturn("", $message, 1);
         } else {
             if ($_POST['uid'] && $_POST['passwd'] && $_POST['phone']) {
                 $result = sendtestSMS(trim($_POST['uid']), trim($_POST['passwd']), $_POST['phone']);
                 if (strstr(trim($_POST['uid']), 'BST') === false) {
                     $message = '账号名格式错误!';
                 } elseif ($result == 0 || $result == 1) {
                     $message = '发送成功,请先保存设置,短信如有延迟,请稍候确认!';
                 } elseif ($result == -1) {
                     $message = '账号未注册,请联系悟空CRM客服!';
                 } elseif ($result == -3) {
                     $message = '密码错误!';
                 } else {
                     $message = '发送失败,请确认短信接口信息!';
                 }
             } else {
                 $message = '发送失败,请确认短信接口信息!';
             }
             $this->ajaxReturn("", $message, 1);
         }
     } elseif ($this->isPost()) {
         $edit = false;
         $m_config = M('Config');
         if ($_POST['address']) {
             if (is_email($_POST['address'])) {
                 $value = array('MAIL_ADDRESS' => $_POST['address'], 'MAIL_SMTP' => $_POST['smtp'], 'MAIL_PORT' => $_POST['port'], 'MAIL_LOGINNAME' => $_POST['loginName'], 'MAIL_PASSWORD' => $_POST['password'], 'MAIL_SECURE' => $_POST['secure'], 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                 $smtp['name'] = 'smtp';
                 $smtp['value'] = serialize($value);
                 if ($m_config->where('name = "smtp"')->find()) {
                     if ($m_config->where('name = "smtp"')->save($smtp)) {
                         F('smtp', $smtp, __ROOT__ . '/App/Runtime/Data/');
                         $edit = true;
                     }
                 } else {
                     if ($m_config->add($smtp)) {
                         F('smtp', $smtp, __ROOT__ . '/App/Runtime/Data/');
                         $edit = true;
                     } else {
                         alert('error', '添加失败,请联系管理员!', U('setting/index'));
                     }
                 }
             } else {
                 alert('error', '邮箱格式错误!', U('setting/index'));
             }
         }
         if ($edit) {
             alert('success', '设置成功并保存!', U('setting/index'));
         } else {
             alert('error', '数据无变化', U('setting/index'));
         }
     } else {
         $smtp = M('Config')->where('name = "smtp"')->getField('value');
         $this->limit_video_size = M('Config')->where('name = "limit_video_size"')->getField('value');
         $this->smtp = unserialize($smtp);
         $this->alert = parseAlert();
         $this->display();
     }
 }
Exemplo n.º 3
0
 public function smtp()
 {
     if ($this->isAjax()) {
         if ($_POST['address']) {
             if (ereg('^([a-zA-Z0-9]+[-|_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[-|_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['address'])) {
                 if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['test_email'])) {
                     $smtp = array('MAIL_ADDRESS' => $_POST['address'], 'MAIL_SMTP' => $_POST['smtp'], 'MAIL_LOGINNAME' => $_POST['loginName'], 'MAIL_PASSWORD' => $_POST['password'], 'MAIL_PORT' => $_POST['port'], 'MAIL_SECURE' => $_POST['secure'], 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                     C($smtp, 'smtp');
                     //C('','smtp');
                     import('@.ORG.Mail');
                     $content = L('EMALI_CONTENT');
                     $message = SendMail($_POST['test_email'], L('EMALI_TITLE'), $content, L('EMALI_AUTOGRAPH'));
                     if ($message === true) {
                         $message = L('SENT SUCCESSFULLY');
                     } else {
                         $message = $message ? $message : L('SENT FAILED');
                     }
                 } else {
                     $message = L('TEST YOUR INBOX MALFORMED');
                 }
             } else {
                 $message = L('EMAIL FORMAT ERROR');
             }
             $this->ajaxReturn("", $message, 1);
         } else {
             if ($_POST['uid'] && $_POST['passwd'] && $_POST['phone']) {
                 $result = sendtestSMS(trim($_POST['uid']), trim($_POST['passwd']), $_POST['phone']);
                 if ($result < 1) {
                     $message = L('ACCOUNT INFORMATION ERROR');
                 } elseif ($result == 1) {
                     $message = L('SENT SUCCESSFULLY SMS');
                 }
             } else {
                 $message = L('SENT FAILED SMS');
             }
             $this->ajaxReturn("", $message, 1);
         }
     } elseif ($this->isPost()) {
         $edit = false;
         $m_config = M('Config');
         if (empty($_POST['address'])) {
             alert('error', L('NEED_ADDRESS'), U('setting/smtp'));
         }
         if (empty($_POST['smtp'])) {
             alert('error', L('NEED_SMTP'), U('setting/smtp'));
         }
         if (empty($_POST['port'])) {
             alert('error', L('NEED_PORT'), U('setting/smtp'));
         }
         if (empty($_POST['loginName'])) {
             alert('error', L('NEED_LOGINNAME'), U('setting/smtp'));
         }
         if (empty($_POST['password'])) {
             alert('error', L('NEED_PASSWORD'), U('setting/smtp'));
         }
         if ($_POST['address']) {
             if (is_email($_POST['address'])) {
                 $demosmtp = array('MAIL_ADDRESS' => $_POST['address'], 'MAIL_SMTP' => $_POST['smtp'], 'MAIL_PORT' => $_POST['port'], 'MAIL_LOGINNAME' => $_POST['loginName'], 'MAIL_PASSWORD' => $_POST['password'], 'MAIL_SECURE' => $_POST['secure'], 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                 $smtp['name'] = 'smtp';
                 $smtp['value'] = serialize($demosmtp);
                 if ($m_config->where('name = "smtp"')->find()) {
                     if ($m_config->where('name = "smtp"')->save($smtp)) {
                         F('smtp', $demosmtp);
                         $edit = true;
                     }
                 } else {
                     if ($m_config->add($smtp)) {
                         F('smtp', $demosmtp);
                         $edit = true;
                     } else {
                         alert('error', L('ADD FAILED'), U('setting/smtp'));
                     }
                 }
             } else {
                 alert('error', L('EMAIL FORMAT ERROR'), U('setting/smtp'));
             }
         }
         if ($_POST['uid']) {
             if (strstr(trim($_POST['uid']), 'BST') === false) {
                 $message = L('ACCOUNT NAME IS MALFORMED');
             }
             $sms = array('uid' => trim($_POST['uid']), 'passwd' => trim($_POST['passwd']), 'sign_name' => trim($_POST['sign_name']), 'sign_sysname' => trim($_POST['sign_sysname']));
             $sms['name'] = 'sms';
             $sms['value'] = serialize($sms);
             if ($m_config->where('name = "sms"')->find()) {
                 if ($m_config->where('name = "sms"')->save($sms)) {
                     F('sms', $sms);
                     $edit = true;
                 }
             } else {
                 if ($m_config->add($sms)) {
                     F('sms', $sms);
                     $edit = true;
                 } else {
                     alert('error', L('EMAIL FORMAT ERROR'), U('setting/smtp'));
                 }
             }
         }
         if ($edit) {
             alert('success', L('SUCCESSFULLY SET AND SAVED'), U('setting/smtp'));
         } else {
             alert('error', L('DATA UNCHANGED'), U('setting/smtp'));
         }
     } else {
         $smtp = M('Config')->where('name = "smtp"')->getField('value');
         $sms = M('Config')->where('name = "sms"')->getField('value');
         $this->smtp = unserialize($smtp);
         $this->sms = unserialize($sms);
         $this->alert = parseAlert();
         $this->display();
     }
 }
Exemplo n.º 4
0
 public function smtp()
 {
     if ($this->isAjax()) {
         if ($this->_post('address', 'trim')) {
             if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['address'])) {
                 if (ereg('^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$', $_POST['test_email'])) {
                     $smtp = array('MAIL_ADDRESS' => $this->_post('address', 'trim'), 'MAIL_SMTP' => $this->_post('smtp', 'trim'), 'MAIL_LOGINNAME' => $this->_post('loginName', 'trim'), 'MAIL_PASSWORD' => $this->_post('password', 'trim'), 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                     C($smtp, 'smtp');
                     import('@.ORG.Mail');
                     $content = '这是一封悟空HRM系统自动生成测试邮件,如果你成功收到,证明悟空HRM的SMTP设置成功!请勿回复';
                     if (SendMail($_POST['test_email'], '悟空HRM邮箱测试', $content, '悟空HRM管理员')) {
                         $message = '发送成功!';
                     } else {
                         $message = '发送失败,信息错误!';
                     }
                 } else {
                     $message = '测试收件箱格式错误!';
                 }
             } else {
                 $message = '邮箱格式错误!';
             }
             $this->ajaxReturn("", $message, 1);
         } else {
             if ($this->_post('uid', 'trim') && $this->_post('passwd', 'trim') && $this->_post('phone', 'trim')) {
                 $result = sendtestSMS($this->_post('uid', 'trim'), $this->_post('passwd', 'trim'), $this->_post('phone', 'trim'));
                 if (strstr($this->_post('uid', 'trim'), 'BST') === false) {
                     $message = '账号名格式错误!';
                 } elseif ($result == 0 || $result == 1) {
                     $message = '发送成功,请先保存设置,短信如有延迟,请稍候确认!';
                 } elseif ($result == -1) {
                     $message = '账号未注册,请联系悟空HRM客服!';
                 } elseif ($result == -3) {
                     $message = '密码错误!';
                 } else {
                     $message = '发送失败,请确认短信接口信息!';
                 }
             } else {
                 $message = '发送失败,请确认短信接口信息!';
             }
             $this->ajaxReturn("", $message, 1);
         }
     } elseif ($this->isPost()) {
         $edit = false;
         $m_config = M('Config');
         if ($_POST['address']) {
             if (is_email($_POST['address'])) {
                 $smtp = array('MAIL_ADDRESS' => $this->_post('address', 'trim'), 'MAIL_SMTP' => $this->_post('smtp', 'trim'), 'MAIL_LOGINNAME' => $this->_post('loginName', 'trim'), 'MAIL_PASSWORD' => $this->_post('password', 'trim'), 'MAIL_CHARSET' => 'UTF-8', 'MAIL_AUTH' => true, 'MAIL_HTML' => true);
                 if (D('Config')->setConfig('smtp', $smtp)) {
                     F('smtp', $smtp);
                     $edit = true;
                 } else {
                     alert('error', '添加失败,请联系管理员!', U('setting/smtp'));
                 }
             } else {
                 alert('error', '邮箱格式错误!', U('setting/smtp'));
             }
         }
         if ($_POST['uid']) {
             if (strstr(trim($_POST['uid']), 'BST') === false) {
                 $message = '账号名格式错误!';
             }
             $sms = array('uid' => $this->_post('uid', 'trim'), 'passwd' => $this->_post('passwd', 'trim'), 'sign_name' => $this->_post('sign_name', 'trim'), 'sign_sysname' => $this->_post('sign_sysname', 'trim'));
             if (D('Config')->setConfig('sms', $sms)) {
                 F('sms', $sms);
                 $edit = true;
             } else {
                 alert('error', '添加失败,请联系管理员!', U('setting/smtp'));
             }
         }
         if ($edit) {
             alert('success', '设置成功并保存!', U('setting/smtp'));
         } else {
             alert('error', '数据无变化', U('setting/smtp'));
         }
     } else {
         $this->smtp = D('Config')->getConfig('smtp');
         $this->sms = D('Config')->getConfig('sms');
         $this->alert = parseAlert();
         $this->display();
     }
 }