emailAction.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. echo $msg;
  68. }
  69. public function emailtotals($table, $rows)
  70. {
  71. $emrs = m('admin')->getone($this->adminid, 'email');
  72. $istxemail = $this->option->getval('txemail_corpid') ? 1 : 0;
  73. return array(
  74. 'rows' => $rows,
  75. 'email'=> $emrs,
  76. 'istxemail'=> $istxemail,
  77. 'total'=> m('emailm')->zongtotal($this->adminid)
  78. );
  79. }
  80. //收信
  81. public function recemailAjax()
  82. {
  83. $barr = m('emailm')->receemail($this->adminid);
  84. if(is_array($barr)){
  85. $this->showreturn($barr['count']);
  86. }else{
  87. $this->showreturn('', $barr, 201);
  88. }
  89. }
  90. //标已读
  91. public function biaoydAjax()
  92. {
  93. $sid = c('check')->onlynumber($this->post('sid'));
  94. m('emailm')->biaoyd($this->adminid, $sid);
  95. echo '成功标识';
  96. }
  97. /**
  98. * 删除邮件
  99. */
  100. public function delyjAjax()
  101. {
  102. $sid = c('check')->onlynumber($this->post('sid'));
  103. $atype = $this->post('atype');
  104. $uid = $this->adminid;
  105. //收件箱删除
  106. if($atype==''){
  107. m('emails')->update('isdel=1','`uid`='.$uid.' and `mid` in('.$sid.') and `type` in(0,1)');
  108. }
  109. //草稿箱删除
  110. if($atype=='cgx'){
  111. m('emailm')->delete('`id` in('.$sid.') and `sendid`='.$uid.' and `isturn`=0');
  112. }
  113. //已发送删除
  114. if($atype=='yfs'){
  115. m('emails')->update('isdel=1','`uid`='.$uid.' and `mid` in('.$sid.') and `type`=2');
  116. }
  117. //已删除删除
  118. if($atype=='ysc'){
  119. m('emails')->delete('`uid`='.$uid.' and `mid` in('.$sid.') and `isdel`=1 and `type` in(0,1)');
  120. }
  121. echo '删除成功';
  122. }
  123. //用户修改自己邮箱密码
  124. public function saveemaipassAjax()
  125. {
  126. $pass = $this->post('emailpass');
  127. if(getconfig('systype')!='demo')m('admin')->update("`emailpass`='$pass'", '`id`='.$this->adminid.'');
  128. $this->backmsg('','修改成功');
  129. }
  130. //设置自动接收邮件
  131. public function helpsetAction()
  132. {
  133. $this->display = false;
  134. $ljth = str_replace('/','\\',ROOT_PATH);
  135. echo '<title>自动接收邮件设置</title>';
  136. echo '<br>';
  137. echo '<font color="red">自动接收邮件必须使用服务器的计划任务你参考以下设置。</font><br><a target="_blank" style="color:blue" href="'.URLY.'view_email.html">查看官网上帮助</a><br>';
  138. echo '一、<b>Windows服务器</b>,可根据以下设置定时任务<br>';
  139. $str1 = '@echo off
  140. cd '.$ljth.'
  141. '.getconfig('phppath','php').' '.$ljth.'\task.php email';
  142. $this->rock->createtxt(''.UPDIR.'/cli/xinhuemailrun.bat', $str1);
  143. echo '1、打开系统配置文件webmainConfig.php加上一个配置phppath设置php环境的目录地址如:F:\php\php-5.6.22\php.exe,设置好了,刷新本页面。<br>';
  144. echo '<div style="background:#caeccb;padding:5px;border:1px #888888 solid;border-radius:5px;">';
  145. echo "return array(<br>'title' =>'信呼OA',<br>'phppath' => 'F:\php\php-5.6.22\php.exe' <font color=#aaaaaa>//加上这个你php.exe的路径</font><br>)";
  146. echo '</div>';
  147. echo '2、在您的win服务器上,开始菜单→运行 输入 cmd 回车(管理员身份运行),输入以下命令(每30分钟运行一次):<br>';
  148. echo '<div style="background:#caeccb;padding:5px;border:1px #888888 solid;border-radius:5px;">';
  149. 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';
  150. echo '</div>';
  151. $str1 = 'cd '.ROOT_PATH.''.chr(10).'php '.ROOT_PATH.'/task.php email';
  152. $spath= ''.UPDIR.'/cli/xinhuemailrun.sh';
  153. $this->rock->createtxt($spath, $str1);
  154. echo '<br>二、<b>Linux服务器</b>,可用根据以下设置定时任务<br>';
  155. echo '根据以下命令设置运行:<br>';
  156. echo '<div style="background:#caeccb;padding:5px;border:1px #888888 solid;border-radius:5px;"><font color=blue>chmod</font> 777 '.ROOT_PATH.'/'.$spath.'<br>';
  157. echo '<font color=blue>crontab</font> -e<br>';
  158. echo '#信呼自动接收邮件每30分钟运行一次<br>';
  159. echo '*/30 * * * * '.ROOT_PATH.'/'.$spath.'</div>';
  160. }
  161. }
粤ICP备19079148号