emailAction.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. class emailClassAction extends Action
  3. {
  4. public function setsaveAjax()
  5. {
  6. $this->option->setval('email_sendhost@-1', $this->post('sendhost'));
  7. $this->option->setval('email_sendport@-1', $this->post('sendport'));
  8. $this->option->setval('email_recehost@-1', $this->post('recehost'));
  9. $this->option->setval('email_sendsecure@-1', $this->post('sendsecure'));
  10. $this->option->setval('email_sysname@-1', $this->post('sysname'));
  11. $this->option->setval('email_sysuser@-1', $this->post('sysuser'));
  12. $this->option->setval('email_receyumi@-1', $this->post('receyumi'));
  13. $syspass = $this->post('syspass');
  14. if(!isempt($syspass)){
  15. $this->option->setval('email_syspass@-1', $this->jm->encrypt($syspass));
  16. }
  17. $this->backmsg();
  18. }
  19. public function getsetAjax()
  20. {
  21. $arr= array();
  22. $arr['sendhost'] = $this->option->getval('email_sendhost');
  23. $arr['sendport'] = $this->option->getval('email_sendport');
  24. $arr['recehost'] = $this->option->getval('email_recehost');
  25. $arr['sendsecure'] = $this->option->getval('email_sendsecure');
  26. $arr['sysname'] = $this->option->getval('email_sysname');
  27. $arr['sysuser'] = $this->option->getval('email_sysuser');
  28. $arr['receyumi'] = $this->option->getval('email_receyumi');
  29. echo json_encode($arr);
  30. }
  31. public function savebeforecog($table, $cans)
  32. {
  33. $emailpass = $this->post('emailpass');
  34. if(!isempt($emailpass)){
  35. $cans['emailpass'] = $this->jm->encrypt($emailpass);
  36. }
  37. return array(
  38. 'rows' => $cans
  39. );
  40. }
  41. public function coguserbeforeshow($table)
  42. {
  43. $fields = '`id`,`name`,`user`,`deptallname`,`status`,`ranking`,`email`,`sort`,`face`,`emailpass`';
  44. $s = '';
  45. $key = $this->post('key');
  46. if($key!=''){
  47. $s = m('admin')->getkeywhere($key);
  48. }
  49. return array(
  50. 'fields'=> $fields,
  51. 'where' => $s,
  52. 'order' => '`sort`'
  53. );
  54. }
  55. public function coguseraftershow($table, $rows)
  56. {
  57. foreach($rows as $k=>$rs){
  58. if(!isempt($rs['emailpass']))$rows[$k]['emailpass']='******';
  59. }
  60. return array(
  61. 'rows' => $rows
  62. );
  63. }
  64. public function testsendAjax()
  65. {
  66. $msg = m('email')->sendmail_test();
  67. $txt = 'err';
  68. if($msg=='ok')$txt='ok';
  69. $this->option->setval('email_teststate@-1', $txt);
  70. echo $msg;
  71. }
  72. public function emailtotals($table, $rows)
  73. {
  74. $emrs = m('admin')->getone($this->adminid, 'email');
  75. $istxemail = $this->option->getval('txemail_corpid') ? 1 : 0;
  76. return array(
  77. 'rows' => $rows,
  78. 'email'=> $emrs,
  79. 'istxemail'=> $istxemail,
  80. 'total'=> m('emailm')->zongtotal($this->adminid)
  81. );
  82. }
  83. //收信
  84. public function recemailAjax()
  85. {
  86. $barr = m('emailm')->receemail($this->adminid);
  87. if(is_array($barr)){
  88. $this->showreturn($barr['count']);
  89. }else{
  90. $this->showreturn('', $barr, 201);
  91. }
  92. }
  93. //标已读
  94. public function biaoydAjax()
  95. {
  96. $sid = c('check')->onlynumber($this->post('sid'));
  97. m('emailm')->biaoyd($this->adminid, $sid);
  98. echo '成功标识';
  99. }
  100. /**
  101. * 删除邮件
  102. */
  103. public function delyjAjax()
  104. {
  105. $sid = c('check')->onlynumber($this->post('sid'));
  106. $atype = $this->post('atype');
  107. $uid = $this->adminid;
  108. //收件箱删除
  109. if($atype==''){
  110. m('emails')->update('isdel=1','`uid`='.$uid.' and `mid` in('.$sid.') and `type` in(0,1)');
  111. }
  112. //草稿箱删除
  113. if($atype=='cgx'){
  114. m('emailm')->delete('`id` in('.$sid.') and `sendid`='.$uid.' and `isturn`=0');
  115. }
  116. //已发送删除
  117. if($atype=='yfs'){
  118. m('emails')->update('isdel=1','`uid`='.$uid.' and `mid` in('.$sid.') and `type`=2');
  119. }
  120. //已删除删除
  121. if($atype=='ysc'){
  122. m('emails')->delete('`uid`='.$uid.' and `mid` in('.$sid.') and `isdel`=1 and `type` in(0,1)');
  123. }
  124. echo '删除成功';
  125. }
  126. //用户修改自己邮箱密码
  127. public function saveemaipassAjax()
  128. {
  129. $pass = $this->post('emailpass');
  130. if(getconfig('systype')!='demo')m('admin')->update("`emailpass`='$pass'", '`id`='.$this->adminid.'');
  131. $this->backmsg('','修改成功');
  132. }
  133. //设置自动接收邮件
  134. public function helpsetAction()
  135. {
  136. $this->display = false;
  137. $ljth = str_replace('/','\\',ROOT_PATH);
  138. echo '<title>自动接收邮件设置</title>';
  139. echo '<br>';
  140. echo '<font color="red">自动接收邮件必须使用服务器的计划任务你参考以下设置。</font><br><a target="_blank" style="color:blue" href="'.URLY.'view_email.html">查看官网上帮助</a><br>';
  141. echo '一、<b>Windows服务器</b>,可根据以下设置定时任务<br>';
  142. $str1 = '@echo off
  143. cd '.$ljth.'
  144. '.getconfig('phppath','php').' '.$ljth.'\task.php email';
  145. $this->rock->createtxt(''.UPDIR.'/cli/xinhuemailrun.bat', $str1);
  146. echo '1、打开系统配置文件webmainConfig.php加上一个配置phppath设置php环境的目录地址如:F:\php\php-5.6.22\php.exe,设置好了,刷新本页面。<br>';
  147. echo '<div style="background:#caeccb;padding:5px;border:1px #888888 solid;border-radius:5px;">';
  148. echo "return array(<br>'title' =>'信呼OA',<br>'phppath' => 'F:\php\php-5.6.22\php.exe' <font color=#aaaaaa>//加上这个你php.exe的路径</font><br>)";
  149. echo '</div>';
  150. echo '2、在您的win服务器上,开始菜单→运行 输入 cmd 回车(管理员身份运行),输入以下命令(每30分钟运行一次):<br>';
  151. echo '<div style="background:#caeccb;padding:5px;border:1px #888888 solid;border-radius:5px;">';
  152. echo 'schtasks /create /sc DAILY /mo 1 /du "24:00" /ri 30 /sd "2018/03/01" /st "00:00:05" /tn "信呼自动接收邮件" /ru System /tr '.$ljth.'\\'.UPDIR.'\cli\xinhuemailrun.bat';
  153. echo '</div>';
  154. $str1 = 'cd '.ROOT_PATH.''.chr(10).'php '.ROOT_PATH.'/task.php email';
  155. $spath= ''.UPDIR.'/cli/xinhuemailrun.sh';
  156. $this->rock->createtxt($spath, $str1);
  157. echo '<br>二、<b>Linux服务器</b>,可用根据以下设置定时任务<br>';
  158. echo '根据以下命令设置运行:<br>';
  159. echo '<div style="background:#caeccb;padding:5px;border:1px #888888 solid;border-radius:5px;"><font color=blue>chmod</font> 777 '.ROOT_PATH.'/'.$spath.'<br>';
  160. echo '<font color=blue>crontab</font> -e<br>';
  161. echo '#信呼自动接收邮件每30分钟运行一次<br>';
  162. echo '*/30 * * * * '.ROOT_PATH.'/'.$spath.'</div>';
  163. }
  164. }
粤ICP备19079148号