gerenAction.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <?php
  2. class gerenClassAction extends Action
  3. {
  4. public function getinitAjax()
  5. {
  6. $uid = $this->adminid;
  7. $carr= m('admin')->getcompanyinfo($uid);
  8. return array(
  9. 'gerentodo' => $this->option->getval('gerennotodo_'.$uid.''),
  10. 'qmimgstr' => $this->option->getval('qmimgstr_'.$uid.''),
  11. 'carr' => $carr,
  12. );
  13. }
  14. public function cogsaveAjax()
  15. {
  16. $uid = $this->adminid;
  17. $this->option->setval('gerennotodo_'.$uid.'', $this->get('gerentodo','0'));
  18. }
  19. //保存图片
  20. public function qmimgsaveAjax()
  21. {
  22. $uid = $this->adminid;
  23. $str = '';
  24. $qmimgstr = $this->post('qmimgstr');
  25. if(!isempt($qmimgstr)){
  26. if(contain($qmimgstr,'.')){
  27. $str = $qmimgstr;
  28. }else{
  29. $qma = explode(',', $qmimgstr);
  30. $str = ''.UPDIR.'/'.date('Y-m').'/'.$uid.'qming_'.rand(1000,9999).'.png';
  31. $this->rock->createtxt($str, base64_decode($qma[1]));
  32. }
  33. }
  34. $this->option->setval('qmimgstr_'.$uid.'', $str);
  35. }
  36. public function filebefore($table)
  37. {
  38. $key = $this->post('key');
  39. $atype = $this->post('atype');
  40. $dt1 = $this->post('dt1');
  41. $dt2 = $this->post('dt2');
  42. $where = 'and optid='.$this->adminid.'';
  43. if($atype=='all' && $this->adminid == 1){
  44. $where='';
  45. if($this->adminid>1)$where=m('admin')->getcompanywhere(3);
  46. }
  47. if($key!=''){
  48. $where.=" and (`optname` like '%$key%' or `filename` like '%$key%' or `mtype`='$key')";
  49. }
  50. if($dt1!='')$where.=" and `adddt`>='".$dt1." 00:00:00'";
  51. if($dt2!='')$where.=" and `adddt`<='".$dt2." 23:59:59'";
  52. return array(
  53. 'where' => $where,
  54. );
  55. }
  56. public function fileafter($table, $rows)
  57. {
  58. $fobj = m('file');
  59. foreach($rows as $k=>&$rs){
  60. $rs['thumbpath'] = $fobj->getthumbpath($rs);
  61. $fpath = $rs['filepath'];
  62. $status= 1;
  63. if(substr($fpath,0,4)=='http'){
  64. $status = 2;
  65. }else{
  66. if(isempt($rs['filenum']) && !file_exists($fpath))$status=0;
  67. $filepathout = arrvalue($rs, 'filepathout');
  68. if(!file_exists($fpath) && !isempt($filepathout)){
  69. if($fobj->isimg($rs['fileext']))$rs['filepath'] = $filepathout;
  70. $status=2;
  71. }
  72. }
  73. $rs['status'] = $status;
  74. }
  75. return array(
  76. 'rows' => $rows
  77. );
  78. }
  79. public function delfileAjax()
  80. {
  81. $id = c('check')->onlynumber($this->post('id','0'));
  82. m('file')->delfile($id);
  83. backmsg();
  84. }
  85. public function defaultAction()
  86. {
  87. $this->title = '修改头像';
  88. $face = $this->db->getmou($this->T('admin'),'face',"`id`='$this->adminid'");
  89. $imgurl = '';
  90. if(!$this->rock->isempt($face)){
  91. $imgurl='../../'.preg_replace("/_crop\d{4}/",'',$face);
  92. }
  93. //$face = $this->rock->repempt($face,'images/white.gif');
  94. $this->smartydata['face'] = $face;
  95. $this->smartydata['imgurl'] = $imgurl;
  96. }
  97. public function changestyleAjax()
  98. {
  99. $style = (int)$this->post('style','0');
  100. m('admin')->update('`style`='.$style.'', 'id='.$this->adminid.'');
  101. }
  102. public function editpassAjax()
  103. {
  104. $id = $this->adminid;
  105. if(getconfig('systype')=='demo')exit('演示上不要修改');
  106. $oldpass = $this->rock->post('passoldPost');
  107. $pasword = $this->rock->post('passwordPost');
  108. $msg = '';
  109. if($this->rock->isempt($pasword))$msg ='新密码不能为空';
  110. if($msg == ''){
  111. $oldpassa = $this->db->getmou($this->T('admin'),"`pass`","`id`='$id'");
  112. if($oldpassa != md5($oldpass))$msg ='旧密码不正确';
  113. if($msg==''){
  114. if($oldpassa == md5($pasword))$msg ='新密码不能和旧密码相同';
  115. }
  116. }
  117. if($msg == ''){
  118. if(!$this->db->record($this->T('admin'), "`pass`='".md5($pasword)."',`editpass`=`editpass`+1", "`id`='$id'"))$msg = $this->db->error();
  119. }
  120. if($msg=='')$msg='success';
  121. echo $msg;
  122. }
  123. /**
  124. 保存头像
  125. */
  126. public function savefaceAjax()
  127. {
  128. $id = $this->adminid;
  129. $arr = array('face'=>$this->rock->post('facePost'));
  130. $msg = '';
  131. if(!$this->db->record($this->T('admin'),$arr, "`id`='$id'"))$msg= $this->db->error();
  132. if($msg=='')$msg='success';
  133. echo $msg;
  134. }
  135. public function todoydAjax()
  136. {
  137. m('todo')->update("status=1,`readdt`='$this->now'", "`id` in(".$this->post('s').") and `status`=0");
  138. }
  139. public function totaldaetods($table, $rows)
  140. {
  141. $wdtotal = m('todo')->rows("`uid`='$this->adminid' and `status`=0 and `tododt`<='$this->now'");
  142. return array('wdtotal'=>$wdtotal);
  143. }
  144. public function beforetotaldaetods($table)
  145. {
  146. $s = " and `uid`='$this->adminid' and `tododt`<='$this->now'";
  147. $key = $this->post('key');
  148. if($key)$s.=" and (`title` like '%$key%' or `mess` like '%$key%')";
  149. return $s;
  150. }
  151. public function getlinksAjax()
  152. {
  153. $rows = m('links')->getrows('1=1','*','`type`,`sort`');
  154. echo json_encode($rows);
  155. }
  156. //导入个人通讯录
  157. public function piliangaddAjax()
  158. {
  159. $rows = c('html')->importdata('name,unitname,tel,mobile,email,gname,address','name');
  160. $oi = 0;
  161. $db = m('vcard');
  162. foreach($rows as $k=>$rs){
  163. $rs['optdt'] = $this->now;
  164. $rs['uid'] = $this->adminid;
  165. $rs['optname'] = $this->adminname;
  166. $db->insert($rs);
  167. $oi++;
  168. }
  169. backmsg('','成功导入'.$oi.'条数据');
  170. }
  171. public function filelogs_before($table)
  172. {
  173. $where = '';
  174. $fileid = (int)$this->post('fileid','0');
  175. $where = "and `fileid`='$fileid'";
  176. return $where;
  177. }
  178. public function delfilelogsAjax()
  179. {
  180. $id = (int)$this->post('id','0');
  181. m('files')->delete($id);
  182. backmsg();
  183. }
  184. //获取背景图片
  185. public function getbeijingAjax()
  186. {
  187. $dev = $this->option->getval('beijing_'.$this->adminid.'','images/beijing/bj0.jpg');
  188. $path = ''.ROOT_PATH.'/images/beijing';
  189. if(!is_dir($path))return returnsuccess(array(
  190. 'dev' => $dev,
  191. 'rows'=> array()
  192. ));
  193. $barr = array();
  194. $bar = glob(''.$path.'/*.jpg');
  195. $isno = false;
  196. if($bar)foreach($bar as $k=>$fil1){
  197. $faiar = explode('images', $fil1);
  198. $lujg = 'images'.$faiar[1].'';
  199. if($lujg==$dev)$isno = true;
  200. $barr[] = $lujg;
  201. }
  202. if(!$isno)$barr[] = $dev;
  203. return returnsuccess(array(
  204. 'dev'=> $dev,
  205. 'rows'=>$barr
  206. ));
  207. }
  208. public function savebeijingAjax()
  209. {
  210. $val = $this->post('value');
  211. $this->option->setval('beijing_'.$this->adminid.'',$val);
  212. }
  213. }
粤ICP备19079148号