addnews.inc.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $info=pdo_get('zhtc_news',array('id'=>$_GPC['id']));
  5. $system=pdo_get('zhtc_system',array('uniacid'=>$_W['uniacid']));
  6. if($system['many_city']==2){
  7. $city = pdo_fetchall("SELECT DISTINCT cityname FROM " . tablename('zhtc_hotcity') . " WHERE uniacid= :weid ORDER BY id DESC", array(':weid' =>$_W['uniacid']), 'id');
  8. }
  9. //var_dump($info);die;
  10. if(checksubmit('submit')){
  11. $data['title']=$_GPC['title'];
  12. $data['num']=$_GPC['num'];
  13. //$data['img']=$_GPC['img'];
  14. $data['state']=$_GPC['state'];
  15. $data['type']=$_GPC['type'];
  16. $data['cityname']=$_GPC['cityname'];
  17. if(empty($_GPC['cityname'])){
  18. $data['cityname']=$system['cityname'];
  19. }
  20. $data['details']=html_entity_decode($_GPC['details']);
  21. $data['time']=time();
  22. $data['uniacid']=$_W['uniacid'];
  23. if($_GPC['id']==''){
  24. $res=pdo_insert('zhtc_news',$data);
  25. if($res){
  26. message('添加成功!', $this->createWebUrl('news'), 'success');
  27. }else{
  28. message('添加失败!','','error');
  29. }
  30. }else{
  31. $res=pdo_update('zhtc_news',$data,array('id'=>$_GPC['id']));
  32. if($res){
  33. message('编辑成功!', $this->createWebUrl('news'), 'success');
  34. }else{
  35. message('编辑失败!','','error');
  36. }
  37. }
  38. }
  39. include $this->template('web/addnews');