Browse Source

第二次推送项目3

master
wanghongjun 2 years ago
parent
commit
f31a570789
  1. 58
      app/admin/behavior/Cron.php
  2. 624
      app/admin/controller/Activitys.php
  3. 177
      app/admin/controller/Addons.php
  4. 315
      app/admin/controller/Admin.php
  5. 230
      app/admin/controller/Agencys.php
  6. 50
      app/admin/controller/Ajax.php
  7. 135
      app/admin/controller/Ask.php
  8. 204
      app/admin/controller/Auth.php
  9. 212
      app/admin/controller/Base.php
  10. 462
      app/admin/controller/Bbs.php
  11. 681
      app/admin/controller/Bigdata.php
  12. 71
      app/admin/controller/Bjjg.php
  13. 68
      app/admin/controller/Bsgg.php
  14. 71
      app/admin/controller/Bsjs.php
  15. 71
      app/admin/controller/Bsry.php
  16. 68
      app/admin/controller/Bsyw.php
  17. 68
      app/admin/controller/Bszc.php
  18. 68
      app/admin/controller/Bszc2.php
  19. 145
      app/admin/controller/Culture.php
  20. 209
      app/admin/controller/Download.php
  21. 71
      app/admin/controller/Dsffwjg.php
  22. 17
      app/admin/controller/Error.php
  23. 253
      app/admin/controller/Feedback.php
  24. 72
      app/admin/controller/Ggnew.php
  25. 3073
      app/admin/controller/Gpgl.php
  26. 70
      app/admin/controller/Gyzc.php
  27. 17
      app/admin/controller/Help.php
  28. 168
      app/admin/controller/Hyzq.php
  29. 52
      app/admin/controller/Index.php
  30. 100
      app/admin/controller/Join.php
  31. 164
      app/admin/controller/Lcgyxm.php
  32. 976
      app/admin/controller/Lcmanager.php
  33. 244
      app/admin/controller/Lcwhcyb.php
  34. 100
      app/admin/controller/License.php
  35. 250
      app/admin/controller/Link.php
  36. 82
      app/admin/controller/Login.php
  37. 70
      app/admin/controller/Lxwm.php
  38. 341
      app/admin/controller/Member.php
  39. 331
      app/admin/controller/Menu.php
  40. 713
      app/admin/controller/News.php
  41. 72
      app/admin/controller/Nwwd.php
  42. 62
      app/admin/controller/Page.php
  43. 460
      app/admin/controller/Plug.php
  44. 881
      app/admin/controller/Product.php
  45. 71
      app/admin/controller/Rczp.php
  46. 162
      app/admin/controller/Region.php
  47. 308
      app/admin/controller/Roadshow.php
  48. 72
      app/admin/controller/Scnew.php
  49. 168
      app/admin/controller/Scsj.php
  50. 71
      app/admin/controller/Sczcxy.php
  51. 263
      app/admin/controller/Sms.php
  52. 71
      app/admin/controller/Ssyyzx.php
  53. 1636
      app/admin/controller/Sys.php
  54. 71
      app/admin/controller/Tjjg.php
  55. 425
      app/admin/controller/Type.php
  56. 511
      app/admin/controller/Ueditor.php
  57. 345
      app/admin/controller/Video.php
  58. 213
      app/admin/controller/WebLog.php
  59. 71
      app/admin/controller/Whjrfwzx.php
  60. 71
      app/admin/controller/Whsb.php
  61. 71
      app/admin/controller/Whsbhd.php
  62. 72
      app/admin/controller/Ypnew.php
  63. 72
      app/admin/controller/Ysjyhnew.php
  64. 71
      app/admin/controller/Zbxstgzx.php
  65. 71
      app/admin/controller/Zbzq.php
  66. 68
      app/admin/controller/Zcfg.php
  67. 71
      app/admin/controller/Zcfwjg.php
  68. 71
      app/admin/controller/Zjtd.php
  69. 70
      app/admin/controller/Zzjg.php
  70. 210
      app/admin/model/Admin.php
  71. 21
      app/admin/model/Asklog.php
  72. 270
      app/admin/model/AuthRule.php
  73. 21
      app/admin/model/Bigdata.php
  74. 21
      app/admin/model/Finance.php
  75. 52
      app/admin/model/MemberList.php
  76. 24
      app/admin/model/Menu.php
  77. 29
      app/admin/model/News.php
  78. 224
      app/admin/model/Options.php
  79. 218
      app/admin/model/Options1218.php
  80. 21
      app/admin/model/Procategory.php
  81. 21
      app/admin/model/Product.php
  82. 21
      app/admin/model/Proquarter.php

58
app/admin/behavior/Cron.php

@ -0,0 +1,58 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\behavior;
use think\Log;
class Cron
{
protected $options = array(
'cron_max_time' => 60,
);
public function run(&$params)
{
$this->options['cron_max_time']=config('cron_max_time')?:60;
$lockfile = RUNTIME_PATH.'cron.lock';
if(is_writable($lockfile) && filemtime($lockfile) > $_SERVER['REQUEST_TIME'] - $this->options['cron_max_time']) {
return ;
} else {
touch($lockfile);
}
@set_time_limit(1000);
@ignore_user_abort(true);
if(is_file(RUNTIME_PATH.'~crons.php')) {
$crons = include RUNTIME_PATH.'~crons.php';
}elseif(is_file(ROOT_PATH.'app/crons.php')){
$crons = include ROOT_PATH.'app/crons.php';
}
if(isset($crons) && is_array($crons)) {
$update = false;
$log = array();
foreach ($crons as $key=>$cron){
if(empty($cron[2]) || $_SERVER['REQUEST_TIME']>=$cron[2]) {
debug('cronStart');
include ROOT_PATH.'app/cron/'.$cron[0].'.php';
debug('cronEnd');
$_useTime = debug('cronStart','cronEnd', 6);
$cron[2] = $_SERVER['REQUEST_TIME']+$cron[1];
$crons[$key] = $cron;
$log[] = "Cron:$key Runat ".date('Y-m-d H:i:s')." Use $_useTime s\n";
$update = true;
}
}
if($update) {
Log::write(implode('',$log));
$content = "<?php\nreturn ".var_export($crons,true).";\n?>";
file_put_contents(RUNTIME_PATH.'~crons.php',$content);
}
}
file_exists($lockfile) && unlink($lockfile);
return ;
}
}

624
app/admin/controller/Activitys.php

@ -0,0 +1,624 @@
<?php
namespace app\admin\controller;
use think\Db;
use app\admin\model\Agency;
use think\Controller;
use think\db\Query;
class Activitys extends Base
{
protected $groupid='';
public function __construct(){
parent::__construct();
$groupid=session('admin_auth.role');
$this->groupid=$groupid;
}
/**
* 列表
*/
public function index()
{
$kind=input("kind");
$this->assign('kind',$kind);
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['kind']=$kind;
if($search_name){
$map['title']= array('like',"%".$search_name."%");
}
$gid=$this->groupid;
if(!in_array($gid,[1,2])&&$gid)$map['groups']=[['like',"%,".$gid.",%"],['like',$gid.",%"],['like',"%".$gid."%"],'OR'];
$admin_list=Db::name('activity')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 添加
*/
public function add()
{
$kind=input("kind");
$this->assign('kind',$kind);
$auth_group=Db::name('auth_group')->where('status','1')->select();
$this->assign('groups',$auth_group);
$list=Db::name('smstpl')->where('status','1')->select();
$this->assign('tpls',$list);
$apply=[];
array_push($apply,['fname'=>'姓名','ftag'=>'uname','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>1]);
array_push($apply,['fname'=>'性别','ftag'=>'usex','ftype'=>'radio','frequire'=>1,'foptions'=>'男||女','fnotice'=>'','del'=>1,'fsort'=>2]);
array_push($apply,['fname'=>'年龄','ftag'=>'uage','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>3]);
array_push($apply,['fname'=>'工作','ftag'=>'ujob','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>4]);
array_push($apply,['fname'=>'电话','ftag'=>'utel','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>5]);
array_push($apply,['fname'=>'邮箱','ftag'=>'uemail','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>6]);
$this->assign("apply",$apply);
$this->assign('role',$this->groupid);
return $this->fetch();
}
/**
* 添加操作
*/
public function runadd()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['title']=input('title');
$data['kind']=$kind;
$data['status']=input('status');
$data['login']=input('login');
$data['contact']=input('contact');
$data['notice']=input('notice');
$data['poster']=input('poster');
$data['banner']=input('banner');
$data['pic']=input('pic');
$data['infor']=input('infor');
$data['smsid']=input('smsid');
$start=input('start_date');
if($start)$start=strtotime($start);
$data['start_date']=$start;
$end=input('end_date');
if($end)$end=strtotime($end);
$data['end_date']=$end;
$data['create_date']=time();
$groups=isset($_POST['groups'])?$_POST['groups']:'';
$data['groups']=is_array($groups)?implode(',', $groups):'';
$apply=input('apply')?htmlspecialchars_decode(input('apply')):'';
if($apply){
$applylist=json_decode($apply,true);
array_multisort(array_column($applylist,'fsort'),SORT_ASC,$applylist);
$apply=$applylist;
$apply=json_encode($apply);
$fileds=array_column($applylist,'ftag');
$cfileds=Db::name('activityapply')->getTableFields(['table'=>'wjs_activityapply']);
$update=true;
foreach ($fileds as $k=>$row){
if(!in_array($row, $cfileds)){
$current=$applylist[$k];
$curtext='varchar(255)';
if($current['ftype']=='checkbox'||$current['ftype']=='select'||$current['ftype']=='date') $curtext='int(11)';
if($current['ftype']=='textarea') $curtext='text';
if($current['frequire']==1)$curtext.=" not null ";
$sql="alter table wjs_activityapply add column ".$current['ftag']." ".$curtext." comment '".$current['fname'].' '.$current['foptions']."'";
$query=db()->execute($sql);
if(!$query){
$update=false;
break;
}
}
}
if(!$update){
$this->error('修改失败',url('admin/Activitys/index',['kind'=>$kind]));
}
}
$data['apply']=$apply;
$admin_id=Db::name('activity')->insert($data);
if($admin_id){
$this->success('添加成功',url('admin/Activitys/index',['kind'=>$kind]));
}else{
$this->error('添加失败',url('admin/Activitys/index',['kind'=>$kind]));
}
}
/**
* 修改
*/
public function edit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('activity')->find(input('admin_id'));
$list['groups']=$list['groups']?explode(',',$list['groups']):[];
$apply=$list['apply']?json_decode(htmlspecialchars_decode($list['apply']),true):[];
if(!count($apply)){
array_push($apply,['fname'=>'姓名','ftag'=>'uname','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>1]);
array_push($apply,['fname'=>'性别','ftag'=>'usex','ftype'=>'radio','frequire'=>1,'foptions'=>'男||女','fnotice'=>'','del'=>1,'fsort'=>2]);
array_push($apply,['fname'=>'年龄','ftag'=>'uage','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>3]);
array_push($apply,['fname'=>'工作','ftag'=>'ujob','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>4]);
array_push($apply,['fname'=>'电话','ftag'=>'utel','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>5]);
array_push($apply,['fname'=>'邮箱','ftag'=>'uemail','ftype'=>'input','frequire'=>1,'foptions'=>'','fnotice'=>'','del'=>1,'fsort'=>6]);
}
$this->assign("apply",$apply);
$this->assign('list',$list);
$auth_group=Db::name('auth_group')->where('status','1')->select();
$this->assign('groups',$auth_group);
$list=Db::name('smstpl')->where('status','1')->select();
$this->assign('tpls',$list);
$this->assign('role',$this->groupid);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['title']=input('title');
$data['kind']=$kind;
$data['status']=input('status');
$data['login']=input('login');
$data['contact']=input('contact');
$data['notice']=input('notice');
$data['poster']=input('poster');
$data['banner']=input('banner');
$data['pic']=input('pic');
$data['infor']=input('infor');
$data['smsid']=input('smsid');
$start=input('start_date');
if($start)$start=strtotime($start);
$data['start_date']=$start;
$end=input('end_date');
if($end)$end=strtotime($end);
$data['end_date']=$end;
$data['create_date']=time();
$groups=isset($_POST['groups'])?$_POST['groups']:'';
$data['groups']=is_array($groups)?implode(',', $groups):'';
$apply=input('apply')?htmlspecialchars_decode(input('apply')):'';
if($apply){
$applylist=json_decode($apply,true);
array_multisort(array_column($applylist,'fsort'),SORT_ASC,$applylist);
$apply=$applylist;
$apply=json_encode($apply);
$fileds=array_column($applylist,'ftag');
$cfileds=Db::name('activityapply')->getTableFields(['table'=>'wjs_activityapply']);
$update=true;
foreach ($fileds as $k=>$row){
if(!in_array($row, $cfileds)){
$current=$applylist[$k];
$curtext='varchar(255)';
if($current['ftype']=='checkbox'||$current['ftype']=='select'||$current['ftype']=='date') $curtext='int(11)';
if($current['ftype']=='textarea') $curtext='text';
if($current['frequire']==1)$curtext.=" not null ";
$sql="alter table wjs_activityapply add column ".$current['ftag']." ".$curtext." comment '".$current['fname'].' '.$current['foptions']."'";
$query=db()->execute($sql);
if(!$query){
$update=false;
break;
}
}
}
if(!$update){
$this->error('修改失败',url('admin/Activitys/index',['kind'=>$kind]));
}
}
$data['apply']=$apply;
$id=input('id');
$rst=Db::name('activity')->where(['id'=>$id])->update($data);
if($rst!==false){
$this->success('修改成功',url('admin/Activitys/index',['kind'=>$kind]));
}else{
$this->error('修改失败',url('admin/Activitys/index',['kind'=>$kind]));
}
}
/**
* 删除
*/
public function del()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('admin/Activitys/index',['kind'=>$kind]));
}
$rst=Db::name('activity')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('admin/Activitys/index',['kind'=>$kind]));
}else{
$this->error('删除失败',url('admin/Activitys/index',['kind'=>$kind]));
}
}
public function export(){
$id=input('admin_id');
$map=['id'=>$id];
$activity=Db::name('activity')->where($map)->find();
if(!$activity)$this->error("活动不存在");
$applys=Db::name('activityapply')->where(['aid'=>$id])->select();
$apply=json_decode($activity['apply'],true);
$expTitle=$activity['title'];
$expCellName=[];
foreach ($apply as $jow){
if($jow['ftag']&&$jow['fname']&&$jow['ftype']!='file'&&$jow['ftype']!='notice')array_push($expCellName,[$jow['ftag'],$jow['fname'],$jow['foptions'],$jow['ftype']]);
}
array_push($expCellName,['create_time','报名时间','','date']);
$apply=$activity['apply']?json_decode($activity['apply'],true):[];
foreach ($applys as &$row){
$row['usex']=$row['usex']==1?'男':'女';
if(count($apply)){
foreach ($apply as $j=>$jow){
$key=$jow['ftag'];
$val=$row[$key];
if($jow['ftype']=='select'||$jow['ftype']=='radio'){
$opts=$jow['foptions'];
if($opts){
$opts=explode("||", $opts);
$val=intval($val);
$val=isset($opts[$val-1])?$opts[$val-1]:'';
if($jow['ftype']=='radio'&&$val=='其他'){
$val.=$row['uother'];
}
}
}
if($jow['ftype']=='checkbox'){
$opts=$jow['foptions'];
if($opts){
$opts=explode("||", $opts);
$shtml='';
$vals=explode(",", $val);
foreach ($vals as $tmp){
$tmp=intval($tmp);
$shtml.=isset($opts[$tmp-1])?$opts[$tmp-1].';':'';
}
$val=$shtml;
}
}
$row[$key]=$val;
}
}
}
$expTableData=$applys;
$res=exportExcel($expTitle,$expCellName,$expTableData);
}
/**
* 列表
*/
public function tpl()
{
$kind=input("kind");
$this->assign('kind',$kind);
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['kind']=$kind;
if($search_name){
$map['title']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('smstpl')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 添加
*/
public function addtpl()
{
$kind=input("kind");
$this->assign('kind',$kind);
return $this->fetch();
}
/**
* 添加操作
*/
public function runaddtpl()
{
$data=[];
$data['title']=input('title');
$data['status']=input('status');
$data['infor']=input('infor');
$data['create_date']=time();
$admin_id=Db::name('smstpl')->insert($data);
$url=url('admin/Activitys/tpl');
if($admin_id){
$this->success('添加成功',$url);
}else{
$this->error('添加失败',$url);
}
}
/**
* 修改
*/
public function edittpl()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('smstpl')->find(input('admin_id'));
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedittpl()
{
$data=[];
$data['title']=input('title');
$data['status']=input('status');
$data['infor']=input('infor');
$data['create_date']=time();
$id=input('id');
$rst=Db::name('smstpl')->where(['id'=>$id])->update($data);
$url=url('admin/Activitys/tpl');
if($rst!==false){
$this->success('修改成功',$url);
}else{
$this->error('修改失败',$url);
}
}
/**
* 删除
*/
public function deltpl()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
$url=url('admin/Activitys/tpl');
if (empty($admin_id)){
$this->error('ID不存在',$url);
}
$rst=Db::name('smstpl')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',$url);
}else{
$this->error('删除失败',$url);
}
}
/**
* 列表
*/
public function sms()
{
$kind=input("kind",'activitys');
$this->assign('kind',$kind);
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['sms_type']=$kind;
if($search_name){
$map['sms_txt|sms_tel']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('smslog')->where($map)->order('sms_id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 删除
*/
public function delsms()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
$url=url('admin/Activitys/sms');
if (empty($admin_id)){
$this->error('ID不存在',$url);
}
$rst=Db::name('smslog')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',$url);
}else{
$this->error('删除失败',$url);
}
}
/**
* 列表
*/
public function apply()
{
$kind=input("kind");
$this->assign('kind',$kind);
$aid=input('aid');
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['kind']=$kind;
if($search_name){
$map['uname|ucard']= array('like',"%".$search_name."%");
}
if($aid)$map['aid']=$aid;
$admin_list=Db::name('activityapply')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
$this->assign('aid',$aid);
return $this->fetch();
}
/**
* 修改
*/
public function editapply()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('activityapply')->find(input('admin_id'));
$aid=isset($list['aid'])?$list['aid']:'';
$showlist=[];
if($aid&&$list){
$activity=Db::name('activity')->where(['id'=>$aid])->find();
$apply=$activity['apply']?json_decode($activity['apply'],true):[];
if(count($apply)){
foreach ($apply as $j=>$jow){
$key=$jow['ftag'];
$val=$list[$key];
if($jow['ftype']=='date'){
$val=date("Y-m-d",$val);
}
if($jow['ftype']=='select'||$jow['ftype']=='radio'){
$opts=$jow['foptions'];
if($opts){
$opts=explode("||", $opts);
$val=intval($val);
$val=isset($opts[$val-1])?$opts[$val-1]:'';
if($jow['ftype']=='radio'&&$val=='其他'){
$val.=$list['uother'];
}
}
}
if($jow['ftype']=='checkbox'){
$opts=$jow['foptions'];
if($opts){
$opts=explode("||", $opts);
$shtml='';
$vals=explode(",", $val);
foreach ($vals as $tmp){
$tmp=intval($tmp);
$shtml.=isset($opts[$tmp-1])?$opts[$tmp-1].';':'';
}
$val=$shtml;
}
}
if($jow['ftype']=='file'){
$files=explode(";", $val);
$shtml='';
foreach ($files as $k=>$tmp){
$file=pathinfo($tmp);
if(isset($file['extension'])){
if(in_array($file['extension'],['jpg','jpeg','png','gif'])){
$shtml.='<img src="'.SITE_PATH.$tmp.'" style="max-width:100px;margin-right:5px;"/>';
}else{
$shtml.='<a href="'.SITE_PATH.$tmp.'" target="__blank">附件'.$k.'</a>';
}
}
}
$val=$shtml;
}
if($jow['ftype']!='notice')array_push($showlist,['key'=>$jow['fname'],'val'=>$val]);
}
}
}
$this->assign('showlist',$showlist);
$this->assign('list',$list);
return $this->fetch();
}
/**
* 删除
*/
public function delapply()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
$url=url('admin/Activitys/apply');
if (empty($admin_id)){
$this->error('ID不存在',$url);
}
$rst=Db::name('activityapply')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',$url);
}else{
$this->error('删除失败',$url);
}
}
/**
* 审核/取消审核
*/
public function editstate(){
if(request()->isAjax()){
$exptime=input('exptime');
$data=[];
$data['express']=input('express');
$data['expname']=input('expname');
$data['exptime']=$exptime?strtotime($exptime):'';
$data['state']=input('state');
$data['advice']=input('advice');
$data['passtime']=(input('state')==1)?time():'';
$id=input('id');
$aid=input('aid');
$rst=Db::name('activityapply')->where(['id'=>$id])->update($data);
$url=url("apply",['aid'=>$aid]);
if($rst!==false){
$this->success('审核成功',$url);
}else{
$this->error('审核失败',$url);
}
}
$id=input('id');
$aid=input('aid');
$find=Db::name('activityapply')->where(array('id'=>$id))->find();
$this->assign('list',$find);
$this->assign('aid',$aid);
return $this->fetch();
}
/**
* 审核/取消审核
*/
public function state()
{
$id=input('x');
$find=Db::name('activityapply')->where(array('id'=>$id))->find();
$msg='未审';
if($find){
$status=$find['state'];
if($status==1){
$statedata = array('state'=>0);
}else{
$statedata = array('state'=>1);
$msg='已审';
}
$send=$find['send'];
if($send==0){
$statedata['send']=1;
}
$query=Db::name('activityapply')->where(array('id'=>$id))->setField($statedata);
if($send==0&&$query){
$aid=$find['aid'];
$act=Db::name('activity')->where(array('id'=>$aid))->find();
if($act){
$notice_title='您好,您的活动报名('.$act['title'].')已审核成功 ';
$notice='';
$sl_data=[
'notice_title'=>$notice_title,
'notice'=>$notice_title,
'user_id'=>$find['uid'],
'apply_id'=>$aid,
'create_id'=>session('admin_auth.aid'),
'create_type'=>1,
'create_time'=>time()
];
Db::name('activitynotice')->insert($sl_data);
}
}
}
$this->success($msg);
}
}

177
app/admin/controller/Addons.php

@ -0,0 +1,177 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use app\common\model\Addon as AddonModel;
use app\common\model\HookAddon as HookAddonModel;
/**
* 插件后台管理页面
*/
class Addons extends Base
{
/**
* 插件列表
*/
public function addons_list()
{
$addons_model=new AddonModel;
$addons=$addons_model->getAll();
$this->assign('addons',$addons);
return $this->fetch();
}
/**
* 安装插件
*/
public function install()
{
$addon_name = input('name','');
if ($addon_name == '') $this->error('插件不存在!');
$addon_class = get_addon_class($addon_name);
if (!class_exists($addon_class)) $this->error('插件不存在!');
// 实例化插件
$addon = new $addon_class;
// 插件预安装
if(!$addon->install()) $this->error('插件预安装失败!'. $addon->getError());
// 添加钩子
if (isset($addon->hooks) && $addon->hooks) {
if (!HookAddonModel::addHooks($addon->hooks, $addon_name)) {
$this->error('安装插件钩子时出现错误');
}
cache('hook_addons', null);
}
// 执行安装插件sql文件
$sql_file = realpath(ADDON_PATH.$addon_name.'/install.sql');
if (file_exists($sql_file)) {
if (isset($addon->database_prefix) && $addon->database_prefix != '') {
db_restore_file($sql_file,$addon->database_prefix);
} else {
db_restore_file($sql_file);
}
}
// 插件配置信息
$addon_info = $addon->info;
if(!$addon->checkInfo()) $this->error('插件信息不完整');
// 并入插件配置值
$addon_info['config'] = $addon->getConfig();
//插件管理操作
if(property_exists($addon,'admin_actions')){
$addon_info['admin_actions']=$addon->admin_actions;
}
// 将插件信息写入数据库
if (AddonModel::create($addon_info)) {
cache('addon_all',null);
$this->success('插件安装成功');
} else {
$this->error('插件安装失败');
}
}
/**
* 卸载插件
*/
public function uninstall()
{
$addon_name = input('name','');
if ($addon_name == '') $this->error('插件不存在!');
$class = get_addon_class($addon_name);
if (!class_exists($class)) $this->error('插件不存在!');
// 实例化插件
$addon = new $class;
// 插件预卸
if(!$addon->uninstall()) {
$this->error('插件预卸载失败!原因:'. $addon->getError());
}
// 卸载插件自带钩子
if (isset($addon->hooks) && $addon->hooks) {
if (false === HookAddonModel::deleteHooks($addon_name)) {
$this->error('卸载插件钩子时出现错误');
}
cache('hook_addons', null);
}
// 执行卸载插件sql文件
$sql_file = realpath(config('plugin_path').$addon_name.'/uninstall.sql');
if (file_exists($sql_file)) {
if (isset($addon->database_prefix) && $addon->database_prefix != '') {
db_restore_file($sql_file,$addon->database_prefix);
} else {
db_restore_file($sql_file);
}
}
$addon_model=new AddonModel;
// 删除插件信息
if ($addon_model->where('name', $addon_name)->delete()) {
cache('addon_all', null);
$this->success('插件卸载成功');
} else {
$this->error('插件卸载失败');
}
}
/**
* 禁用插件
*/
public function disable()
{
$id=input('id');
if (empty($id)){
$this->error('插件不存在',url('admin/Addons/addons_list'));
}
$rst=Db::name('addon')->where('id',$id)->setField('status',0);
if($rst!==false){
cache('addon_all',null);
cache('hook_addons',null);
$this->success('禁用成功',url('admin/Addons/addons_list'));
}else{
$this->error('禁用失败',url('admin/Addons/addons_list'));
}
}
/**
* 启用插件
*/
public function enable()
{
$id=input('id');
if (empty($id)){
$this->error('插件不存在',url('admin/Addons/addons_list'));
}
$rst=Db::name('addon')->where('id',$id)->setField('status',1);
if($rst!==false){
cache('addon_all',null);
cache('hook_addons',null);
$this->success('启用成功',url('admin/Addons/addons_list'));
}else{
$this->error('启用失败',url('admin/Addons/addons_list'));
}
}
/**
* 插件排序
*/
public function addons_order()
{
$list=[];
foreach (input('post.') as $id => $sort){
$list[]=['id'=>$id,'sort'=>$sort];
}
$model=new AddonModel;
$model->saveAll($list);
cache('addon_all',null);
$this->success('排序成功',url('admin/Addons/addons_list'));
}
}

315
app/admin/controller/Admin.php

@ -0,0 +1,315 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\model\Admin as AdminModel;
use app\admin\model\AuthRule;
use think\Db;
use think\Cache;
class Admin extends Base
{
/**
* 管理员列表
*/
public function admin_list()
{
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($search_name){
$map['admin_username']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('admin')->where($map)->order('admin_open desc,admin_id')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('admin_list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 管理员添加
*/
public function admin_add()
{
$auth_group=Db::name('auth_group')->where('status','1')->select();
$this->assign('auth_group',$auth_group);
return $this->fetch();
}
/**
* 管理员添加操作
*/
public function admin_runadd()
{
$admin_id=AdminModel::add(input('admin_username'),'',input('admin_pwd'),input('admin_email',''),input('admin_tel',''),input('admin_open',0),input('admin_realname',''),input('group_id'));
if($admin_id){
$this->success('管理员添加成功',url('admin/Admin/admin_list'));
}else{
$this->error('管理员添加失败',url('admin/Admin/admin_list'));
}
}
/**
* 管理员修改
*/
public function admin_edit()
{
$auth_group=Db::name('auth_group')->select();
$admin_list=Db::name('admin')->find(input('admin_id'));
$auth_group_access=Db::name('auth_group_access')->where(array('uid'=>$admin_list['admin_id']))->value('group_id');
$this->assign('admin_list',$admin_list);
$this->assign('auth_group',$auth_group);
$this->assign('auth_group_access',$auth_group_access);
return $this->fetch();
}
/**
* 管理员修改操作
*/
public function admin_runedit()
{
$data=input('post.');
$rst=AdminModel::edit($data);
if($rst!==false){
$this->success('管理员修改成功',url('admin/Admin/admin_list'));
}else{
$this->error('管理员修改失败',url('admin/Admin/admin_list'));
}
}
/**
* 管理员删除
*/
public function admin_del()
{
$admin_id=input('admin_id');
if (empty($admin_id)){
$this->error('用户ID不存在',url('admin/Admin/admin_list'));
}
Db::name('admin')->delete($admin_id);
$rst=Db::name('auth_group_access')->where('uid',$admin_id)->delete();
if($rst!==false){
$this->success('管理员删除成功',url('admin/Admin/admin_list'));
}else{
$this->error('管理员删除失败',url('admin/Admin/admin_list'));
}
}
/**
* 管理员开启/禁止
*/
public function admin_state()
{
$id=input('x');
if (empty($id)){
$this->error('用户ID不存在',url('admin/Admin/admin_list'));
}
$status=Db::name('admin')->where('admin_id',$id)->value('admin_open');//判断当前状态情况
if($status==1){
$statedata = array('admin_open'=>0);
Db::name('admin')->where('admin_id',$id)->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('admin_open'=>1);
Db::name('admin')->where('admin_id',$id)->setField($statedata);
$this->success('状态开启');
}
}
/**
* 用户组列表
*/
public function admin_group_list()
{
$auth_group=Db::name('auth_group')->select();
$this->assign('auth_group',$auth_group);
return $this->fetch();
}
/**
* 用户组添加
*/
public function admin_group_add()
{
return $this->fetch();
}
/**
* 用户组添加操作
*/
public function admin_group_runadd()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Admin/admin_group_list'));
}else{
$sldata=array(
'title'=>input('title'),
'status'=>input('status',0),
'addtime'=>time(),
);
$rst=Db::name('auth_group')->insert($sldata);
if($rst!==false){
$this->success('用户组添加成功',url('admin/Admin/admin_group_list'));
}else{
$this->error('用户组添加失败',url('admin/Admin/admin_group_list'));
}
}
}
/**
* 用户组删除操作
*/
public function admin_group_del()
{
$rst=Db::name('auth_group')->delete(input('id'));
if($rst!==false){
$this->success('用户组删除成功',url('admin/Admin/admin_group_list'));
}else{
$this->error('用户组删除失败',url('admin/Admin/admin_group_list'));
}
}
/**
* 用户组编辑
*/
public function admin_group_edit()
{
$group=Db::name('auth_group')->find(input('id'));
$this->assign('group',$group);
return $this->fetch();
}
/**
* 用户组编辑操作
*/
public function admin_group_runedit()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Admin/admin_group_list'));
}else{
$sldata=array(
'id'=>input('id'),
'title'=>input('title'),
'status'=>input('status'),
);
Db::name('auth_group')->update($sldata);
$this->success('用户组修改成功',url('admin/Admin/admin_group_list'));
}
}
/**
* 用户组开启/禁用
*/
public function admin_group_state()
{
$id=input('x');
$status=Db::name('auth_group')->where('id',$id)->value('status');//判断当前状态情况
if($status==1){
$statedata = array('status'=>0);
Db::name('auth_group')->where('id',$id)->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('status'=>1);
Db::name('auth_group')->where('id',$id)->setField($statedata);
$this->success('状态开启');
}
}
/**
* 权限配置
*/
public function admin_group_access()
{
$admin_group=Db::name('auth_group')->where(array('id'=>input('id')))->find();
$data=AuthRule::get_ruels_tree();
$this->assign('admin_group',$admin_group);
$this->assign('datab',$data);
return $this->fetch();
}
/**
* 权限配置保存
*/
public function admin_group_runaccess()
{
$new_rules = input('new_rules/a');
$imp_rules = implode(',', $new_rules);
$sldata=array(
'id'=>input('id'),
'rules'=>$imp_rules,
);
if(Db::name('auth_group')->update($sldata)!==false){
Cache::clear();
$this->success('权限配置成功',url('admin/Admin/admin_group_list'));
}else{
$this->error('权限配置失败',url('admin/Admin/admin_group_list'));
}
}
/*
* 管理员信息
*/
public function profile()
{
$admin=array();
if(session('admin_auth.aid')){
$admin=Db::name('admin')->alias("a")->join(config('database.prefix').'auth_group_access b','a.admin_id =b.uid')
->join(config('database.prefix').'auth_group c','b.group_id = c.id')
->where(array('a.admin_id'=>session('admin_auth.aid')))->find();
}
$this->assign('admin', $admin);
return $this->fetch();
}
/**
* 管理员修改
*/
public function avatar_edit()
{
$admin_list=Db::name('admin')->find(session('admin_auth.aid'));
$this->assign('admin_list',$admin_list);
return $this->fetch();
}
/**
* 管理员修改操作
*/
public function avatar_runedit()
{
$data=input('post.');
$data['admin_id']=session('admin_auth.aid');
$rst=AdminModel::avatar_edit($data);
if($rst!==false){
$this->success('个人信息修改成功',url('admin/Admin/profile'));
}else{
$this->error('个人信息修改失败',url('admin/Admin/profile'));
}
}
/*
* 管理员头像
*/
public function avatar()
{
$imgurl=input('imgurl');
//去'/'
$imgurl=str_replace('/','',$imgurl);
$url='/data/upload/avatar/'.$imgurl;
$state=false;
if(config('storage.storage_open')){
//七牛
$upload = \Qiniu::instance();
$info = $upload->uploadOne('.'.$url,"image/");
if ($info) {
$state=true;
$imgurl= config('storage.domain').$info['key'];
@unlink('.'.$url);
}
}
if($state !=true){
//本地
//写入数据库
$data['uptime']=time();
$data['filesize']=filesize('.'.$url);
$data['path']=$url;
Db::name('plug_files')->insert($data);
}
$admin=Db::name('admin')->where(array('admin_id'=>session('admin_auth.aid')))->find();
$admin['admin_avatar']=$imgurl;
$rst=Db::name('admin')->where(array('admin_id'=>session('admin_auth.aid')))->update($admin);
if($rst!==false){
session('admin_avatar',$imgurl);
$this->success ('头像更新成功',url('admin/Admin/profile'));
}else{
$this->error ('头像更新失败',url('admin/Admin/profile'));
}
}
}

230
app/admin/controller/Agencys.php

@ -0,0 +1,230 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use app\admin\model\Agency;
class Agencys extends Base
{
/**
* 列表
*/
public function index()
{
$kind=input("kind");
$this->assign('kind',$kind);
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['kind']=$kind;
if($search_name){
$map['title']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('agency')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 添加
*/
public function add()
{
$kind=input("kind");
$this->assign('kind',$kind);
return $this->fetch();
}
/**
* 添加操作
*/
public function runadd()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['title']=input('title');
$data['kind']=$kind;
$data['status']=1;
//$data['members']=input('members');
$data['contact']=input('contact');
$data['href']=input('href');
$data['infor']=input('infor');
$data['create_date']=time();
$admin_id=Db::name('agency')->insert($data);
if($admin_id){
$this->success('添加成功',url('admin/Agencys/index',['kind'=>$kind]));
}else{
$this->error('添加失败',url('admin/Agencys/index',['kind'=>$kind]));
}
}
/**
* 修改
*/
public function edit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('agency')->find(input('admin_id'));
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=input('post.');
$data=[];
$data['id']=input('id');
$data['title']=input('title');
$data['kind']=$kind;
$data['status']=input('status',0);
//$data['members']=input('members');
$data['contact']=input('contact');
$data['href']=input('href');
$data['infor']=input('infor');
$rst=Db::name('agency')->update($data);
if($rst!==false){
$this->success('修改成功',url('admin/Agencys/index',['kind'=>$kind]));
}else{
$this->error('修改失败',url('admin/Agencys/index',['kind'=>$kind]));
}
}
/**
* 删除
*/
public function del()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('admin/Agencys/index',['kind'=>$kind]));
}
$rst=Db::name('agency')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('admin/Agencys/index',['kind'=>$kind]));
}else{
$this->error('删除失败',url('admin/Agencys/index',['kind'=>$kind]));
}
}
/**
* 列表
*/
public function user()
{
$kind=input("kind");
$this->assign('kind',$kind);
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['kind']=$kind;
if($search_name){
$map['username']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('agency_user')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 添加
*/
public function adduser()
{
$kind=input("kind");
$this->assign('kind',$kind);
return $this->fetch();
}
/**
* 添加操作
*/
public function runadduser()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['username']=input('username');
$data['avatar']=input('avatar');
$data['kind']=$kind;
$data['status']=1;
$data['infor']=input('infor');
$data['create_date']=time();
$admin_id=Db::name('agency_user')->insert($data);
if($admin_id){
$this->success('添加成功',url('admin/Agencys/user',['kind'=>$kind]));
}else{
$this->error('添加失败',url('admin/Agencys/user',['kind'=>$kind]));
}
}
/**
* 修改
*/
public function edituser()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('agency_user')->find(input('id'));
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedituser()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=input('post.');
$data=[];
$data['id']=input('id');
$data['username']=input('username');
$data['avatar']=input('avatar');
$data['kind']=$kind;
$data['status']=input('status',0);
$data['infor']=input('infor');
$rst=Db::name('agency_user')->update($data);
if($rst!==false){
$this->success('修改成功',url('admin/Agencys/user',['kind'=>$kind]));
}else{
$this->error('修改失败',url('admin/Agencys/user',['kind'=>$kind]));
}
}
/**
* 删除
*/
public function deluser()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('admin/Agencys/user',['kind'=>$kind]));
}
$rst=Db::name('agency_user')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('admin/Agencys/user',['kind'=>$kind]));
}else{
$this->error('删除失败',url('admin/Agencys/user',['kind'=>$kind]));
}
}
}

50
app/admin/controller/Ajax.php

@ -0,0 +1,50 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Ajax
{
/*
* 返回行政区域json字符串
*/
public function getRegion()
{
$map['pid']=input('pid');
$map['type']=input('type');
$list=Db::name("region")->where($map)->select();
return json($list);
}
/*
* 返回模块下控制器json字符串
*/
public function getController()
{
$module=input('request_module','admin');
$list=\ReadClass::readDir(APP_PATH . $module. DS .'controller');
return json($list);
}
/*
* 返回角色列表json字符串
*/
public function getRole()
{
$map['type']=input('pid');
if($map['type']==1){
$map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2
$list=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select();
}elseif($map['type']==2){
$map2['id']=array('gt',0);
$list=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select();
}
return json($list);
}
}

135
app/admin/controller/Ask.php

@ -0,0 +1,135 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Request;
use app\admin\model\Asklog;
class Ask extends Base{
protected $table='asklog';
/**
* 首页数据展示
* @return mixed|string
*/
public function index(Request $request){
$search_name=input('search_name','');
$this->assign('search_name',$search_name);
$kind=$request->param('kind');
$page=$request->param('page');
$this->assign('kind',$kind);
$db=Db::name($this->table)->alias("a")->field("a.*,m.member_list_username as name")->join(config('database.prefix').'member_list m','a.uid =m.member_list_id')->where('kind',$kind);
if($search_name){
$db->where('name|code','like','%'.$search_name.'%');
}
$gp_list=$db->order('create_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $gp_list->render();
$this->assign('page',$page);
$this->assign('pageshow',$show);
$this->assign('showlist',$gp_list);
if(request()->isAjax()){
return $this->fetch('ajax_list');
}else{
return $this->fetch();
}
}
public function content(Request $request){
$kind=input('kind');
$page=input('page');
$this->assign('page',$page);
$this->assign('kind',$kind);
$id = input('id', 0, 'intval');
if (!$id) $this->error('参数错误', url('Ask/index',array('kind'=>$kind)));
$gp_list = Db::name($this->table)->alias("a")->field("a.*,m.member_list_username as name")->join(config('database.prefix').'member_list m','a.uid =m.member_list_id')->where('id', $id)->find();
$content =unserialize($gp_list['content']);
$this->assign('content', $content);
$this->assign('list', $gp_list);
return $this->fetch();
}
public function edit(Request $request)
{
$kind=input('kind');
$page=input('page');
$this->assign('page',$page);
$this->assign('kind',$kind);
if(!request()->isAjax()) {
$id = input('id', 0, 'intval');
$this->assign('id', $id);
$tpl='edit';
return $this->fetch($tpl);
}else{
$jump=url('Ask/index',array('kind'=>$kind,'page'=>$page));
$sl_data=[];
$id = input('id', 0, 'intval');
$replay=input('replay');
$gp_list = Db::name($this->table)->where('id', $id)->find();
$content =unserialize($gp_list['content']);
array_push($content,['ques'=>'','ans'=>$replay,'type'=>1,'time'=>time()]);
$sl_data['id']=$id;
$sl_data['flag']=2;
$sl_data['update_time']=time();
$sl_data['content']=serialize($content);
$item=new Asklog();
$rst=$item->allowField(true)->update($sl_data);
if($rst!==false){
$this->success('回复成功',$jump);
}else{
$this->error('回复失败',$jump);
}
}
}
/**
* 非文化资产挂牌删除(单个)
*/
public function del(){
$p=input('p');
$kind=input('kind');
$this->assign('kind',$kind);
$rst=Db::name($this->table)->delete(input('id'));
if($rst!==false){
$this->success('删除成功',url('Ask/index',array('p' => $p,'kind'=>$kind)));
}else{
$this -> error("删除失败!",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
}
}
/**
* 非文化资产删除挂牌(全选)
*/
public function alldel(){
$p = input('p');
$kind=input('kind');
$this->assign('kind',$kind);
$ids = input('id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name($this->table)->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
}else{
$this -> error("删除失败!",url('Ask/index',array('p'=>$p,'kind'=>$kind)));
}
}
}

204
app/admin/controller/Auth.php

@ -0,0 +1,204 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: luofei614 <weibo.com/luofei614> 
// +----------------------------------------------------------------------
namespace app\admin\controller;
/**
* 权限认证类
* 功能特性:
* 1,是对规则进行认证,不是对节点进行认证。用户可以把节点当作规则名称实现对节点进行认证。
* $auth=new Auth(); $auth->check('规则名称','用户id')
* 2,可以同时对多条规则进行认证,并设置多条规则的关系(or或者and)
* $auth=new Auth(); $auth->check('规则1,规则2','用户id','and')
* 第三个参数为and时表示,用户需要同时具有规则1和规则2的权限。 当第三个参数为or时,表示用户值需要具备其中一个条件即可。默认为or
* 3,一个用户可以属于多个用户组(think_auth_group_access表 定义了用户所属用户组)。我们需要设置每个用户组拥有哪些规则(think_auth_group 定义了用户组权限)
*
* 4,支持规则表达式。
* 在think_auth_rule 表中定义一条规则时,如果type为1, condition字段就可以定义规则表达式。 如定义{score}>5 and {score}<100 表示用户的分数在5-100之间时这条规则才会通过
*/
class Auth
{
//默认配置
protected $_config = array(
'auth_on' => true, // 认证开关
'auth_type' => 1, // 认证方式,1为实时认证;2为登录认证。
'auth_group' => 'auth_group', // 用户组数据表名
'auth_group_access' => 'auth_group_access', // 用户-用户组关系表
'auth_rule' => 'menu', // 权限规则表
'auth_user' => 'auth_user' // 用户信息表
);
public function __construct()
{
if (config('auth_config')) {
//可设置配置项 auth_config, 此配置项为数组。
$this->_config = array_merge($this->_config, config('auth_config'));
}
}
/**
* 检查权限
* @param string|array $name 需要验证的规则列表,支持逗号分隔的权限规则或索引数组
* @param int $uid 认证用户的id
* @param int $type 执行check的模式
* @param string $mode 执行check的模式,'url'模式或'id'
* @param string $relation 如果为 'or' 表示满足任一条规则即通过验证;如果为 'and'则表示需满足所有规则才能通过验证
* @return boolean 通过验证返回true;失败返回false
*/
public function check($name, $uid, $type=1, $mode='url', $relation='or')
{
if (!$this->_config['auth_on'])
return true;
$authList = $this->getAuthList($uid,$type,$mode); //获取用户需要验证的所有有效规则列表
if (is_string($name)) {
$name = strtolower($name);
if (strpos($name, ',') !== false) {
$name = explode(',', $name);
} else {
$name = array($name);
}
}
$list = array(); //保存验证通过的规则名
if ($mode=='url') {
$REQUEST = unserialize( strtolower(serialize($_REQUEST)) );
}
foreach ( $authList as $auth ) {
$query = preg_replace('/^.+\?/U','',$auth);
if ($mode=='url' && $query!=$auth ) {
parse_str($query,$param); //解析规则中的param
$intersect = array_intersect_assoc($REQUEST,$param);
$auth = preg_replace('/\?.*$/U','',$auth);
if ( in_array($auth,$name) && $intersect==$param ) { //如果节点相符且url参数满足
$list[] = $auth ;
}
}else if (in_array($auth , $name)){
$list[] = $auth ;
}
}
if ($relation == 'or' && !empty($list)) {
return true;
}
$diff = array_diff($name, $list);
if ($relation == 'and' && empty($diff)) {
return true;
}
return false;
}
/**
* 根据用户id获取用户组,返回值为数组
* @param int $uid 用户id
* @return array 用户所属的用户组 array(
* array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
* ...)
*/
public function getGroups($uid)
{
static $groups = array();
if (isset($groups[$uid]))
return $groups[$uid];
$user_groups = db()->name($this->_config['auth_group_access'] . ' a')
->where("a.uid='$uid' and g.status='1'")
->join(config('database.prefix')."{$this->_config['auth_group']} g"," a.group_id = g.id")
->field('uid,group_id,title,rules')->select();
$groups[$uid]=$user_groups?:array();
return $groups[$uid];
}
/**
* 根据用户id获取用户组ids
* @param int $uid 用户id
* @return array 用户所属的用户组id array(1,2,3)
*/
public function getGroupIds($uid)
{
static $groups = array();
if (isset($groups[$uid]))
return $groups[$uid];
$user_groups = db()->name($this->_config['auth_group_access'] . ' a')
->where("a.uid='$uid' and g.status='1'")
->join(config('database.prefix')."{$this->_config['auth_group']} g"," a.group_id = g.id")
->column('group_id');
$groups[$uid]=$user_groups?:array();
return $groups[$uid];
}
/**
* 获得权限列表
* @param integer $uid 用户id
* @param integer $type
* @param string $mode 'url'或'id'
* @return array
*/
public function getAuthList($uid,$type,$mode='url')
{
static $_authList = array(); //保存用户验证通过的权限列表
$mode=$mode?:'url';
$t = implode(',',(array)$type);
if (isset($_authList[$uid.'_'.$t.'_'.$mode])) {
return $_authList[$uid.'_'.$t.'_'.$mode];
}
//登录验证时,返回保存在session的列表
if( $this->_config['auth_type']==2 && isset($_SESSION['_AUTH_LIST_'.$uid.'_'.$t.'_'.$mode])){
return $_SESSION['_AUTH_LIST_'.$uid.'_'.$t.'_'.$mode];
}
//读取用户所属用户组
$groups = $this->getGroups($uid);
$ids = array();//保存用户所属用户组设置的所有权限规则id
foreach ($groups as $g) {
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
}
$ids = array_unique($ids);
if (empty($ids)) {
$_authList[$uid.$t] = array();
return array();
}
//rules的ids
$map = array(
'id' => array('in', $ids),
'type' => $type,
'notcheck'=>0,
);
//读取用户组所有权限规则
$rules = db()->name($this->_config['auth_rule'])->where($map)->whereOr('notcheck',1)->field('id,condition,name,notcheck')->select();
//循环规则,判断结果。
$authList = array();
foreach ($rules as $rule) {
if($rule['notcheck'] || empty($rule['condition'])){
$authList[] = ($mode=='url')?strtolower($rule['name']):$rule['id'];
}else{
$user = $this->getUserInfo($uid);//获取用户信息,一维数组
$command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $rule['condition']);
@(eval('$condition=(' . $command . ');'));
if ($condition) {
$authList[] = ($mode=='url')?strtolower($rule['name']):$rule['id'];
}
}
}
$_authList[$uid.'_'.$t.'_'.$mode] = $authList;
if($this->_config['auth_type']==2){
//规则列表结果保存到session
session('_AUTH_LIST_'.$uid.'_'.$t.'_'.$mode,$authList);
}
return array_unique($authList);
}
/**
* 获得用户资料,根据自己的情况读取数据库
*/
protected function getUserInfo($uid)
{
static $userinfo=array();
if(!isset($userinfo[$uid])){
$userinfo[$uid] = db()->where(array('admin_id'=>$uid))
->name($this->_config['auth_user'])->find();
}
return $userinfo[$uid];
}
}

212
app/admin/controller/Base.php

@ -0,0 +1,212 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Common;
use app\admin\model\AuthRule;
use OSS\OssClient;
use OSS\Core\OssException;
use think\Request;
use think\Db;
use think\Image;
class Base extends Common
{
public function _initialize()
{
parent::_initialize();
if(!$this->check_admin_login()) $this->redirect('admin/Login/login');//未登录
$auth=new AuthRule;
$id_curr=$auth->get_url_id();
//echo "<div style='display:none'>".$id_curr."</div>";
if(!$auth->check_auth($id_curr)){
$this->error('没有权限',url('admin/Index/index'));
}
//获取有权限的菜单tree
$menus=$auth->get_admin_menus();
$this->assign('menus',$menus);
//当前方法倒推到顶级菜单ids数组
$menus_curr=$auth->get_admin_parents($id_curr);
$this->assign('menus_curr',$menus_curr);
//取当前操作菜单父节点下菜单 当前菜单id(仅显示状态)
$menus_child=$auth->get_admin_parent_menus($id_curr);
$this->assign('menus_child',$menus_child);
$this->assign('id_curr',$id_curr);
$this->assign('admin_avatar',session('admin_auth.admin_avatar'));
}
public function uploadAliYun($filename='',$filepath=''){
$bucket = \aliyunoss\Common::getBucketName();
$ossClient = \aliyunoss\Common::getOssClient();
try {
$result = $ossClient->uploadFile($bucket,$filename,$filepath);
$path=$result['info']['url'];
return ['action'=>true,'path'=>$path,'filename'=>$filename];
}catch (OssException $e){
return ['action'=>false,'path'=>'','filename'=>'','msg'=>$e->getErrorMessage()];
}
}
protected function gmt_iso8601($time) {
$dtStr = date("c", $time);
$mydatetime = new \DateTime($dtStr);
$expiration = $mydatetime->format(\DateTime::ISO8601);
$pos = strpos($expiration, '+');
$expiration = substr($expiration, 0, $pos);
return $expiration."Z";
}
function aliinfo(Request $request){
$id=\aliyunoss\Common::accessKeyId; // 请填写您的AccessKeyId。
$key=\aliyunoss\Common::accessKeySecret; // 请填写您的AccessKeySecret。
// $host的格式为 bucketname.endpoint,请替换为您的真实信息。
$host =\aliyunoss\Common::bucketHost;
$endpoint=\aliyunoss\Common::endpoint;
// $callbackUrl为上传回调服务器的URL,请将下面的IP和Port配置为您自己的真实URL信息。
$callbackUrl = 'http://www.szcaee.cn/extend/aliyunoss/callback.php';
$dir =$request->param('dir'); // 用户上传文件时指定的前缀。
$dir.='/';
$callback_param = array('callbackUrl'=>$callbackUrl,
'callbackBody'=>'filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}&endpoint='.$host,
'callbackBodyType'=>"application/x-www-form-urlencoded");
$callback_string = json_encode($callback_param);
$base64_callback_body = base64_encode($callback_string);
$now = time();
$expire = 30; //设置该policy超时时间是10s. 即这个policy过了这个有效时间,将不能访问。
$end = $now + $expire;
$expiration = $this->gmt_iso8601($end);
//最大文件大小.用户可以自己设置
$condition = array(0=>'content-length-range', 1=>0, 2=>1048576000);
$conditions[] = $condition;
// 表示用户上传的数据,必须是以$dir开始,不然上传会失败,这一步不是必须项,只是为了安全起见,防止用户通过policy上传到别人的目录。
$start = array(0=>'starts-with', 1=>'$key', 2=>$dir);
$conditions[] = $start;
$arr = array('expiration'=>$expiration,'conditions'=>$conditions);
$policy = json_encode($arr);
$base64_policy = base64_encode($policy);
$string_to_sign = $base64_policy;
$signature = base64_encode(hash_hmac('sha1', $string_to_sign, $key, true));
$response = array();
$response['accessid'] = $id;
$response['host'] = $host;
$response['policy'] = $base64_policy;
$response['signature'] = $signature;
$response['expire'] = $end;
$response['callback'] = $base64_callback_body;
$response['dir'] = $dir; // 这个参数是设置用户上传文件时指定的前缀。
echo json_encode($response);exit;
}
/**
* 上传方法
*/
public function upload(Request $request){
// 获取表单上传文件
$key=$request->param('key');
if(!$key)return $this->error('參數錯誤');
$file = request()->file($key);
// 移动到框架应用根目录/uploads/ 目录下
$uploadpath=config('upload_path');
$path=ROOT_PATH . config('upload_path');
$validate = config('upload_validate');
$info = $file->validate($validate)->move($path);
if($info){
$data=array();
$data['ext']=$info->getExtension();
$data['path']=$uploadpath.DS.$info->getSaveName();
$data['filename']=$info->getFilename();
return $this->success('上傳成功','',$data);
}else{
return $this->error($file->getError());
}
}
/**
* 处理上传图片
* @param string $file
* @param string $files
* @return NULL[]|string[]
*/
protected function dealFile($file='',$files=''){
$validate = config('upload_validate');
$img_one='';
$picall_url='';
$upload_path=config('upload_path'). DS . date('Y-m-d');
//单图
if (!empty($file)) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH .$upload_path);
if ($info) {
$img_url = $upload_path.'/'. $info->getFilename();
$ext=strtolower(pathinfo($img_url,PATHINFO_EXTENSION));
$imgfile='.'.$img_url;
//等比例宿放
if(file_exists($imgfile)&&in_array($ext,['jpg','gif','png','jpeg'])){
$image=Image::open($imgfile);
$width=$image->width();
$height=$image->height();
if($width>1000){
$nhei=(1000/$width)*$height;
$image->thumb(1000,$nhei);
$image->save($imgfile);
}
}
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
return ['error'=>$file[0]->getError()];
}
}
//多图
if (!empty($files)) {
foreach ($files as $file) {
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH .$upload_path);
if ($info) {
$img_url = $upload_path.DS. $info->getFilename();
$ext=strtolower(pathinfo($img_url,PATHINFO_EXTENSION));
$imgfile='.'.$img_url;
//等比例宿放
if(file_exists($imgfile)&&in_array($ext,['jpg','gif','png','jpeg'])){
$image=Image::open($imgfile);
$width=$image->width();
$height=$image->height();
if($width>1000){
$nhei=(1000/$width)*$height;
$image->thumb(1000,$nhei);
$image->save($imgfile);
}
}
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$picall_url = $img_url . ',' . $picall_url;
} else {
return ['error'=>$file[0]->getError()];
}
}
}
return ['img_one'=>$img_one,'picall_url'=>$picall_url];
}
}

462
app/admin/controller/Bbs.php

@ -0,0 +1,462 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Request;
use app\admin\model\Asklog;
class Bbs extends Base{
protected $table='bbslist';
protected $tablelog='bbslog';
protected $tablecate='bbstype';
protected function getWeekMyActionAndEnd($time = '', $first = 1){
//当前日期
if (!$time) $time = time();
$sdefaultDate = date("Y-m-d", $time);
//$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
//获取当前周的第几天 周日是 0 周一到周六是 1 - 6
$w = date('w', strtotime($sdefaultDate));
//获取本周开始日期,如果$w是0,则表示周日,减去 6 天
$week_start = date('Y-m-d', strtotime("$sdefaultDate -" . ($w ? $w - $first : 6) . ' days'));
//本周结束日期
$week_end = date('Y-m-d', strtotime("$week_start +6 days"));
return array("week_start" => $week_start, "week_end" => $week_end);
}
/**
* 首页数据展示
* @return mixed|string
*/
public function index(Request $request){
$search_name=input('search_name','');
$this->assign('search_name',$search_name);
$page=$request->param('page');
$db=Db::name($this->table)->alias("a")->field("a.*,m.member_list_username as uname,m.member_list_nickname as nickname")->join(config('database.prefix').'member_list m','a.mid =m.member_list_id','left');
if($search_name){
$db->where('name','like','%'.$search_name.'%');
}
$gp_list=$db->order('create_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$total=$gp_list->total();
$this->assign('total',$total);
$show = $gp_list->render();
$this->assign('page',$page);
$this->assign('pageshow',$show);
$this->assign('showlist',$gp_list);
$count=Db::name($this->table)->sum('comment');
$this->assign("comment",$count);
$count=Db::name($this->table)->sum('viewnum');
$this->assign("viewnum",$count);
$count=Db::name($this->table)->where(['from_unixtime(update_time,"%Y%m")'=>date("Ym")])->sum('comment');
$this->assign("mcomment",$count);
$count=Db::name($this->table)->where(['from_unixtime(update_time,"%Y%m")'=>date("Ym")])->sum('viewnum');
$this->assign("mviewnum",$count);
$dates=$this->getWeekMyActionAndEnd();
$start=$dates['week_start'];
$end=$dates['week_end'];
$count=Db::name($this->table)->where(['from_unixtime(update_time,"%Y-%m-%d")'=>['between',[$start,$end]]])->sum('comment');
$this->assign("wcomment",$count);
$count=Db::name($this->table)->where(['from_unixtime(update_time,"%Y-%m-%d")'=>['between',[$start,$end]]])->sum('viewnum');
$this->assign("wviewnum",$count);
$count=Db::name($this->table)->where(['from_unixtime(update_time,"%Y-%m-%d")'=>date("%Y-%m-%d")])->sum('comment');
$this->assign("dcomment",$count);
$count=Db::name($this->table)->where(['from_unixtime(update_time,"%Y-%m-%d")'=>date("%Y-%m-%d")])->sum('viewnum');
$this->assign("dviewnum",$count);
if(request()->isAjax()){
return $this->fetch('ajax_show_list');
}else{
return $this->fetch();
}
}
/**
* 首页数据展示
* @return mixed|string
*/
public function log(Request $request){
$search_name=input('search_name','');
$this->assign('search_name',$search_name);
$page=$request->param('page');
$db=Db::name($this->tablelog)->alias("a")->field("a.*,m.member_list_username as uname,l.name")->join(config('database.prefix').'member_list m','a.mid =m.member_list_id','left')->join(config('database.prefix').'bbslist l','a.list_id =l.id','left');
if($search_name){
$db->where('a.content','like','%'.$search_name.'%');
}
$gp_list=$db->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $gp_list->render();
$this->assign('page',$page);
$this->assign('pageshow',$show);
$this->assign('showlist',$gp_list);
if(request()->isAjax()){
return $this->fetch('ajax_log_list');
}else{
return $this->fetch();
}
}
public function category(Request $request){
$search_name=input('search_name','');
$this->assign('search_name',$search_name);
$db=Db::name($this->tablecate);
if($search_name){
$db->where('name','like','%'.$search_name.'%');
}
$data=$db->order('id desc,create_time desc')->select();
$tree=new \Tree();
$tree->init($data,['child'=>'sub','parentid'=>'parentid']);
$rst=$tree->get_arraylist($data);
$this->assign('showlist',$rst);
if(request()->isAjax()){
return $this->fetch('ajax_cate_list');
}else{
return $this->fetch();
}
}
public function add(){
$page=input('page');
$this->assign('page',$page);
if(request()->isPost()){
$jump=url('index');
$data=[];
$data['name']=input('name');
$data['content']=input('content');
$data['parent_id']=input('parent_id');
$data['child_id']=input('child_id');
$data['mid']=input('mid');
$data['top']=input('top');
$data['marrow']=input('marrow');
$data['link']=input('link');
$data['open']=input('open');
$data['status']=input('status');
$data['update_time']=time();
$data['create_time']=time();
$rst=Db::name($this->table)->insert($data);
if($rst!==false){
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
$cates=Db::name($this->tablecate)->where('status',1)->select();
$tree=new \Tree();
$tree->init($cates,['child'=>'sub','parentid'=>'parentid']);
$rst=$tree->get_arraylist($cates);
$this->assign("cates",$rst);
$mems=Db::name("member_list")->field('member_list_id,member_list_username,member_list_nickname')->where(['member_list_groupid'=>['in',[7,10]],'user_status'=>1,'member_list_open'=>1])->select();
$this->assign("mems",$mems);
return $this->fetch();
}
public function edit(){
$page=input('page');
$this->assign('page',$page);
$id=input('id');
if(request()->isPost()){
$jump=url('index');
$data=[];
$data['name']=input('name');
$data['content']=input('content');
$data['parent_id']=input('parent_id');
$data['child_id']=input('child_id');
$data['mid']=input('mid');
$data['top']=input('top');
$data['marrow']=input('marrow');
$data['open']=input('open');
$data['link']=input('link');
$data['status']=input('status');
$data['update_time']=time();
$rst=Db::name($this->table)->where('id',$id)->update($data);
if($rst!==false){
$this->success('编辑成功',$jump);
}else{
$this->error('编辑失败',$jump);
}
}
$cates=Db::name($this->tablecate)->where('status',1)->select();
$tree=new \Tree();
$tree->init($cates,['child'=>'sub','parentid'=>'parentid']);
$rst=$tree->get_arraylist($cates);
$this->assign("cates",$rst);
$list=Db::name($this->table)->where('id',$id)->find();
$this->assign("list",$list);
$mems=Db::name("member_list")->field('member_list_id,member_list_username,member_list_nickname')->where(['member_list_groupid'=>['in',[7,10]],'user_status'=>1,'member_list_open'=>1])->select();
$this->assign("mems",$mems);
return $this->fetch();
}
public function addcate(){
$page=input('page');
$this->assign('page',$page);
$pid=input('pid');
$this->assign('pid',$pid);
if(request()->isPost()){
$jump=url('category');
$data=[];
$data['name']=input('name');
$data['infor']=input('infor');
$data['parentid']=input('parentid');
$data['status']=input('status');
$data['update_time']=time();
$data['create_time']=time();
$data['open']=input('open');
$rst=Db::name($this->tablecate)->insert($data);
if($rst!==false){
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
$cates=Db::name($this->tablecate)->where('parentid',0)->select();
$this->assign("cates",$cates);
return $this->fetch();
}
public function editcate(){
$page=input('page');
$this->assign('page',$page);
$id=input('id');
$this->assign('id',$id);
if(request()->isPost()){
$jump=url('category');
$data=[];
$data['name']=input('name');
$data['infor']=input('infor');
$data['parentid']=input('parentid');
$data['status']=input('status');
$data['open']=input('open');
$data['update_time']=time();
$rst=Db::name($this->tablecate)->where('id',$id)->update($data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
$cates=Db::name($this->tablecate)->where('parentid',0)->select();
$this->assign("cates",$cates);
$cate=Db::name($this->tablecate)->where('id',$id)->find();
$this->assign("list",$cate);
return $this->fetch();
}
public function editlog(){
$page=input('page');
$this->assign('page',$page);
$id=input('id');
$this->assign('id',$id);
if(request()->isPost()){
$jump=url('log');
$data=[];
$data['content']=input('content');
$data['status']=input('status');
$data['top']=input('top');
$data['open']=input('open');
$data['update_time']=time();
$rst=Db::name($this->tablelog)->where('id',$id)->update($data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
$mems=Db::name("member_list")->field('member_list_id,member_list_username,member_list_nickname')->where(['member_list_groupid'=>7,'user_status'=>1,'member_list_open'=>1])->select();
$this->assign("mems",$mems);
$cates=Db::name($this->tablecate)->where('status',1)->select();
$tree=new \Tree();
$tree->init($cates,['child'=>'sub','parentid'=>'parentid']);
$rst=$tree->get_arraylist($cates);
$this->assign("cates",$rst);
$list=Db::name($this->tablelog)->alias("a")->field("a.*,l.name")->join(config('database.prefix').'bbslist l','a.list_id =l.id','left')->where('a.id',$id)->find();
$this->assign("list",$list);
return $this->fetch();
}
/**
* 非文化资产挂牌删除(单个)
*/
public function del(){
$p=input('p');
$id=input('id');
$rst=Db::name($this->table)->where(['id'=>$id])->delete();
if($rst!==false){
Db::name($this->tablelog)->where(['list_id'=>$id])->delete();
$this->success('删除成功',url('index',array('p' => $p)));
}else{
$this -> error("删除失败!",url('index',array('p'=>$p)));
}
}
public function delcate(){
$p=input('p');
$rst=Db::name($this->tablecate)->delete(input('id'));
if($rst!==false){
$this->success('删除成功',url('category',array('p' => $p)));
}else{
$this -> error("删除失败!",url('category',array('p'=>$p)));
}
}
public function dellog(){
$p=input('p');
$rst=Db::name($this->tablelog)->delete(input('id'));
if($rst!==false){
$this->success('删除成功',url('log',array('p' => $p)));
}else{
$this -> error("删除失败!",url('log',array('p'=>$p)));
}
}
/**
* 非文化资产删除挂牌(全选)
*/
public function alldel(){
$p = input('p');
$ids = input('id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('Ask/index',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name($this->table)->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('Ask/index',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('Ask/index',array('p'=>$p)));
}
}
public function marrow(){
$id=input('x');
$find=Db::name($this->table)->where(array('id'=>$id))->find();
$msg='否';
$state=0;
if($find){
$status=$find['marrow'];
$state=$status==1?0:1;
if($status==0){
$msg='是';
}
$statedata = array('marrow'=>$state);
$query=Db::name($this->table)->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg,'',$state);
}
public function state(){
$id=input('x');
$find=Db::name($this->table)->where(array('id'=>$id))->find();
$msg='关闭';
$state=0;
if($find){
$status=$find['status'];
$state=$status==1?0:1;
if($status==0){
$msg='开启';
}
$statedata = array('status'=>$state);
$query=Db::name($this->table)->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg,'',$state);
}
public function open(){
$id=input('x');
$find=Db::name($this->table)->where(array('id'=>$id))->find();
$msg='禁止';
$state=0;
if($find){
$status=$find['open'];
$state=$status==1?0:1;
if($status==0){
$msg='开启';
}
$statedata = array('open'=>$state);
$query=Db::name($this->table)->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg,'',$state);
}
public function top(){
$id=input('x');
$find=Db::name($this->table)->where(array('id'=>$id))->find();
$msg='否';
$state=0;
if($find){
$status=$find['top'];
$state=$status==1?0:1;
if($status==0){
$msg='是';
}
$statedata=array('top'=>$state);
$query=Db::name($this->table)->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg,'',$state);
}
public function statelog(){
$id=input('x');
$find=Db::name($this->tablelog)->where(array('id'=>$id))->find();
$msg='关闭';
$state=0;
if($find){
$status=$find['status'];
$state=$status==1?0:1;
if($status==0){
$msg='开启';
}
$statedata = array('status'=>$state);
$query=Db::name($this->tablelog)->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg,'',$state);
}
public function toplog(){
$id=input('x');
$find=Db::name($this->tablelog)->where(array('id'=>$id))->find();
$msg='否';
$state=0;
if($find){
$status=$find['top'];
$state=$status==1?0:1;
if($status==0){
$msg='是';
}
$statedata=array('top'=>$state);
$query=Db::name($this->tablelog)->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg,'',$state);
}
}

681
app/admin/controller/Bigdata.php

@ -0,0 +1,681 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Request;
use app\admin\model\Bigdata as Bigdatadb;
use think\Image;
class Bigdata extends Base{
public function __construct(){
parent::__construct();
}
//获取表格图片
protected function getImg($sheet){
/*取图片*/
$imgData = array();
$subpath=config('upload_path').'/bigdata/'.date('Y-m-d').'/';
$imageFilePath =ROOT_PATH.$subpath;//图片保存目录
if (!file_exists( $imageFilePath )) {
mkdir("$imageFilePath", 0777, true);
}
//遍历表格图片
try{
foreach ($sheet->getDrawingCollection() as $img) {
list($startColumn,$startRow)= \PHPExcel_Cell::coordinateFromString($img->getCoordinates());//获取图片所在行和列
$imageFileName =md5(uniqid());
$quality=80;
switch($img->getMimeType()) {
case 'image/jpg':
$imageFileName.='.jpg';
$imgtype='jpg';
imagejpeg($img->getImageResource(),$imageFilePath.$imageFileName,40);
break;
case 'image/gif':
$imageFileName.='.gif';
$imgtype='gif';
imagegif($img->getImageResource(),$imageFilePath.$imageFileName);
break;
case 'image/png':
$imageFileName.='.png';
$imgtype='png';
imagepng($img->getImageResource(),$imageFilePath.$imageFileName,4);
break;
default:
$imageFileName.='.jpg';
$imgtype='jpg';
imagejpeg($img->getImageResource(),$imageFilePath.$imageFileName,40);
}
$startColumn = $this->ABC2decimal($startColumn);//由于图片所在位置的列号为字母,转化为数字
$imgData[$startRow][$startColumn][] =$subpath.$imageFileName;//把图片插入到数组中
}
} catch(\Exception $e) {
}
return $imgData;
}
protected function ABC2decimal($abc){
$ten = 0;
$len = strlen($abc);
for($i=1;$i<=$len;$i++){
$char = substr($abc,0-$i,1);//反向获取单个字符
$int = ord($char);
$ten += ($int-65)*pow(26,$i-1);
}
return $ten;
}
public function importxls(){
$kind=input('post.ckind','','intval');
$file = request()->file('xlsfile');
if(empty($kind)){
$this->error("请选择产品类型");
}
if(!count($file)){
$this->error("请上传xls");
}
$uploadpath=config('upload_path');
$path=ROOT_PATH . config('upload_path').'/'.'excel';
$info = $file->move($path);
$inputFileName='';
if($info){
$inputFileName=$path.'/'.$info->getSaveName();
}else{
$this->error($file->getError());
}
include ROOT_PATH.'extend'.DS.'PHPExcel'.DS.'PHPExcel.php';
$imgs=array();
// 读取excel文件
try {
$inputFileType = \PHPExcel_IOFactory::identify($inputFileName);
if($inputFileType=='Excel2007'){
$objReader = new \PHPExcel_Reader_Excel2007();
}else{
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
}
$objPHPExcel = $objReader->load($inputFileName);
// 确定要读取的sheet,什么是sheet,看excel的右下角,真的不懂去百度吧
$sheet = $objPHPExcel->getSheet(0);
$imgs=$this->getImg($sheet);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$cindex=3;
$cates=array(1=>'图片','音频','视频','电子文档','三维全景','其他');
// 获取一行的数据
for ($index =$cindex; $index <= $highestRow; $index++){
// Read a row of data into an array
$rowData = $sheet->rangeToArray('A'. $index .':'. $highestColumn . $index, NULL, TRUE, FALSE);
//这里得到的rowData都是一行的数据,得到数据后自行处理,我们这里只打出来看看效果
if(isset($rowData[0])){
switch ($kind){
case 2:
$row=$rowData[0];
if(count($row)){
if($row[1]){
$data=[];
$data['c_name']=$row[1];
$data['c_logo']='';
$data['c_kind']=2;
$data['c_infostime']=time();
$data['c_time']=time();
$query=Db::name('bigdata')->insert($data);
}
}
break;
case 1:
$row=$rowData[0];
if(count($row)){
if($row[1]){
$data=[];
$data['c_kind']=1;
$data['c_name']=$row[1];
$icode=$row[2];
$find=Db::name('bigdata')->where(['c_icode'=>$icode])->count();
if(!$find){
$data['c_icode']=$icode;
$data['c_logo']=isset($imgs[$index][3][0])?$imgs[$index][3][0]:'';
$data['c_price']=$row[6];
$data['c_seller']=$row[11];
$data['c_scode']=isset($row[12])?$row[12]:'';
$data['c_url']=$row[4];
$gptime=trim($row[5],'/');
if($gptime){
$gptime=\PHPExcel_Shared_Date::ExcelToPHP($gptime);
}
$data['c_gptime']=$gptime;
$data['c_pay']=$row[7]=='授权'?1:2;
$data['c_type']=$row[13]=='文化资源数据'?1:2;
$ccate=$row[9];
$data['c_cate']=in_array($ccate,$cates)?array_search($ccate,$cates):'';
$cdate=date("ymd");
$last=Db::name('bigdata')->count();
$prev='';
//一级代码:标的类型
$prev=$data['c_type']==1?'A':'B';
//二级代码:展示类别
$prev.=$data['c_cate'];
//四级代码:日期
$prev.=$cdate;
//五级代码:X13X14为标的数据包序号,从01起依次编码,如标的为单个数据文件,默认序号为00
$code=$prev.'00';
$code.=sprintf('%03s',($last+1));
$data['c_code']=$code;
$data['c_time']=time();
$query=Db::name('bigdata')->insert($data);
}
}
}
break;
}
}
}
} catch(\Exception $e) {
$this->error("加载文件发生错误:".pathinfo($inputFileName,PATHINFO_BASENAME).":".$e->getMessage());
}
$this->success('提交成功',url('bigdata/showlist'));
}
/**
* 首页数据展示
* @return mixed|string
*/
public function showlist(Request $request)
{
$search_name=input('search_name','');
$this->assign('search_name',$search_name);
$kind=$request->param('kind');
$ckind=$request->param('ckind');
$this->assign('ckind',$ckind);
$page=$request->param('page');
$this->assign('c_kind',$kind);
$db=Db::name('bigdata');
$where=array();
if($search_name){
$where['c_name|c_code|c_seller|c_icode'] = array('like', "%{$search_name}%", 'or');
}
$total=$db->where($where)->count();
$gp_list=$db->where($where)->order('c_order desc,c_id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $gp_list->render();
$this->assign('page',$page);
$this->assign('pageshow',$show);
$this->assign('fwhzc_list',$gp_list);
$this->assign('total',$total);
$where['c_status']=0;
$ftotal=Db::name('bigdata')->where($where)->count();
$this->assign('ftotal',$ftotal);
if(request()->isAjax()){
return $this->fetch('ajax_show_list');
}else{
return $this->fetch();
}
}
public function showexport(){
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('PRC');
$kind=input('kind');
if(in_array($kind,[17])){
$where=['n_status'=>1];
if($kind)$where['n_kind']=$kind;
$list=Db::name('news')->where($where)->order('n_id desc')->select();
}else{
$where=['c_status'=>1];
if($kind)$where['c_kind']=$kind;
$list=Db::name('bigdata')->where($where)->order('c_id desc')->select();
}
if(count($list)){
$title="";
switch ($kind){
case 1:
$title="招拍挂平台";
break;
}
$expTitle=$title."_".date("Y-m-d");
$expCellNames=[];
$expCellNames[1]=[['c_code','挂牌代码'],['c_name','企业名称'],['c_gptime','挂牌有效期']];
$expCellName=isset($expCellNames[$kind])?$expCellNames[$kind]:'';
if($expCellName){
$expTableData=[];
foreach ($list as $row){
array_push($expTableData,$row);
}
exportExcel($expTitle, $expCellName, $expTableData);
}
}
}
/**
* 非文化四版挂牌状态修改
*/
public function show_state()
{
$id=input('x');
$kind=input('kind');
$this->assign('c_kind',$kind);
$status=Db::name('bigdata')->where(array('c_id'=>$id))->value('c_status');
if($status==1){
$statedata = array('c_status'=>0);
Db::name('bigdata')->where(array('c_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('c_status'=>1);
Db::name('bigdata')->where(array('c_id'=>$id))->setField($statedata);
$this->success('状态启用');
}
}
public function show_edit(Request $request)
{
$kind=input('kind');
$page=input('page');
$this->assign('page',$page);
$this->assign('c_kind',$kind);
$types=[];
if(!request()->isAjax()) {
$c_id = input('c_id', 0, 'intval');
if (!$c_id) $this->error('参数错误', url('admin/Bigdata/showlist',array('kind'=>$kind)));
$gp_list = Db::name('bigdata')->where('c_id', $c_id)->find();
try {
$childs=json_decode($gp_list['c_childs'],true);
if(is_string($childs)||empty($childs)){
$childs=json_decode(urldecode($gp_list['c_childs']),true);
}
$gp_list['c_childs']=$childs;
} catch (\Exception $e) {
$gp_list['c_childs']=array();
}
//多图字符串转换成数组
$tpl='show_edit1';
$this->assign('list', $gp_list);
$this->assign('kind',$kind);
$this->assign('types',$types);
return $this->fetch($tpl);
}else{
$jump=url('admin/Bigdata/showlist',array('kind'=>$kind,'page'=>$page));
$img_one='';
$file = request()->file('pic_one');
$ret=$this->dealFile($file);
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one']){
$img_one=$ret['img_one'];
$quality=40;
$imgname=pathinfo($img_one,PATHINFO_FILENAME);
$imgtype=pathinfo($img_one,PATHINFO_EXTENSION);
$imgpath=pathinfo($img_one,PATHINFO_DIRNAME);
$imgname=str_replace($imgtype,'', $imgname);
$img=Image::open('.'.$img_one);
$newimg='.'.$imgpath.DIRECTORY_SEPARATOR.$imgname.'_new'.$imgtype;
$img->save($newimg,$imgtype,$quality);
$img_one=$newimg;
}
}
$sl_data=array();
$post=request()->post();
$c_id = input('c_id', 0, 'intval');
$code=input('c_code','');
if($code){
$check=$this->_checkCode($code,$c_id);
if($check){
$this->error('托管代码不能重复');
}
}
$cstype=isset($_POST["c_stype"])?$_POST["c_stype"]:array();
$ctype=input('c_type','');
$ccate=input('c_cate','');
$cdate=date("ymd");
$last=$prev='';
if(empty($code)){
$last=Db::name('bigdata')->where(array('c_id'=>array('neq',$c_id)))->count();
//一级代码:用户代码
$prev=$ctype==1?'A':'B';
//二级代码:展示类别
$prev.=$ccate;
//四级代码:日期
$prev.=$cdate;
//五级代码:X13X14为标的数据包序号,从01起依次编码,如标的为单个数据文件,默认序号为00
$code.=$prev.'00';
$code.=sprintf('%03s',($last+1));
}else{
$prev=substr($code, 0,8);
$last=substr($code,-3);
$last=intval($last)-1;
}
$cchilds=array();
$childs=htmlspecialchars_decode(input('c_childs'));
$childs=json_decode($childs,true);
if(count($childs)){
$index=1;
foreach ($childs as $key=>$child){
$child=json_decode($child,true);
if(count($child)){
$it=array();
$clen=count($child);
foreach ($child as $k=>$c){
$ch=explode("=", $c);
if($ch[0]=='ccode'&&empty($ch[1])){
$ch[1]=$prev.sprintf('%02s',$index).''.sprintf('%03s',($last+1));
}
if($ch[0]=='ccode'){
$index++;
}
$it[$k]=$ch[0].'='.$ch[1];
}
$childs[$key]=json_encode($it,JSON_UNESCAPED_UNICODE);
}
}
$row=array_filter($childs);
$row=array_values($row);
array_walk($row,"walkparse");
$cchilds=$row;
}
$sl_data['c_childs']=json_encode($cchilds,JSON_UNESCAPED_UNICODE);
//图片字段处理
if(!empty($img_one)){
$sl_data['c_logo']=$img_one;
}
$sl_data['c_infostime']=isset($post['c_infostime'])?strtotime($post['c_infostime']):time();
$sl_data['c_infoetime']=isset($post['c_infoetime'])?strtotime($post['c_infoetime']):time();
if(isset($post['c_gptime']))$sl_data['c_gptime']=strtotime($post['c_gptime']);
$sl_data['c_status']=input('c_status',0);
if(isset($post['c_pass']))$sl_data['c_pass']=input('c_pass',0);
if(isset($post['c_cate']))$sl_data['c_cate']=input('c_cate','');
if(isset($post['c_name']))$sl_data['c_name']=input('c_name');
if(isset($post['c_seller']))$sl_data['c_seller']=input('c_seller');
if(isset($post['c_scode']))$sl_data['c_scode']=input('c_scode');
if(isset($post['c_icode']))$sl_data['c_icode']=input('c_icode');
if(isset($post['c_sauth']))$sl_data['c_sauth']=input('c_sauth');
if(isset($post['c_code']))$sl_data['c_code']=input('c_code');
if(isset($post['c_ower']))$sl_data['c_ower']=input('c_ower');
if(isset($post['c_type']))$sl_data['c_type']=input('c_type');
if(isset($post['c_num']))$sl_data['c_num']=input('c_num');
if(isset($post['c_url']))$sl_data['c_url']=input('c_url');
if(isset($post['c_hot']))$sl_data['c_hot']=input('c_hot');
$sl_data['c_tag']=input('c_tag',0);
$sl_data['c_cate']=input('c_cate');
if($sl_data['c_cate']==6){
$sl_data['c_cother']=input('c_cother','');
}
if(isset($post['c_pay']))$sl_data['c_pay']=input('c_pay');
if(isset($post['c_ptype']))$sl_data['c_ptype']=input('c_ptype');
if(isset($post['c_pscope']))$sl_data['c_pscope']=input('c_pscope');
if(isset($post['c_price']))$sl_data['c_price']=input('c_price');
if(isset($post['c_proxy']))$sl_data['c_proxy']=input('c_proxy');
if(isset($post['c_year']))$sl_data['c_year']=input('c_year');
if(isset($post['c_source']))$sl_data['c_source']=input('c_source');
if(isset($post['c_charge']))$sl_data['c_charge']=input('c_charge');
$cright=isset($_POST["c_right"])?$_POST["c_right"]:[];
if(count($cright))$sl_data['c_right']=implode(',', $cright);
$cscene=isset($_POST["c_scene"])?$_POST["c_scene"]:[];
if(count($cscene))$sl_data['c_scene']=implode(',', $cscene);
if(isset($post['c_sother']))$sl_data['c_sother']=input('c_sother');
if(count($cstype))$sl_data['c_stype']=is_array($cstype)?implode(',', $cstype):'';
$sl_data['c_content']=htmlspecialchars_decode(input('c_content'));
$sl_data['c_code']=$code;
$sl_data['c_kind']=input('c_kind','');
$sl_data['c_infostime']=isset($post['c_infostime'])?strtotime($post['c_infostime']):time();
$sl_data['c_infoetime']=isset($post['c_infoetime'])?strtotime($post['c_infoetime']):time();
if(isset($sl_data['c_gptime']))$post['c_gptime']=strtotime($post['c_gptime']);
$sl_data['c_status']=input('c_status',0);
if(isset($sl_data['c_state']))$sl_data['c_state']=input('c_state',1);
$sl_data['c_uid']=session('admin_auth.aid');
$item=new Bigdatadb();
$sl_data['c_id']=$c_id;
$rst=$item->allowField(true)->update($sl_data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
}
protected function _checkCode($code='',$id='',$kind=''){
$find=Db::name('bigdata')->where(['c_code'=>$code]);
if($id){
$find->where('c_id','neq',$id);
}
if($kind){
$find->where(['c_kind'=>$kind]);
}
$res=$find->count();
return $res;
}
/**
* 非文化资产挂牌增加
*/
public function show_add(Request $request)
{
$types=[];
if(!request()->isAjax()) {
$tpl='show_add1';
$this->assign('types',$types);
$kind=input('kind');
$this->assign('c_kind',$kind);
return $this->fetch($tpl);
}else{
$jump=url('admin/Bigdata/showlist');
$img_one='';
$img_one2='';
$picall_url='';
$file = request()->file('pic_one');
$ret=$this->dealFile($file);
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
}
$post=request()->post();
$item=new Bigdatadb();
$sl_data=array();
$curl=input('c_url');
$ckind=input('c_kind');
$cstype=isset($_POST["c_stype"])?$_POST["c_stype"]:array();
$ctype=input('c_type','');
$ccate=input('c_cate','');
$cdate=date("ymd");
$code=input('c_code','');
if($code){
$check=$this->_checkCode($code);
if($check){
$this->error('标的ISLI标志码不能重复');
}
}
$last=Db::name('bigdata')->count();
$prev='';
//一级代码:标的类型
$prev=$ctype==1?'A':'B';
//二级代码:展示类别
$prev.=$ccate;
//四级代码:日期
$prev.=$cdate;
//五级代码:X13X14为标的数据包序号,从01起依次编码,如标的为单个数据文件,默认序号为00
$code.=$prev.'00';
$code.=sprintf('%03s',($last+1));
$cchilds=array();
$childs=htmlspecialchars_decode(input('c_childs'));
$childs=json_decode($childs,true);
if(count($childs)){
$index=1;
foreach ($childs as $key=>$child){
$child=json_decode($child,true);
if(count($child)){
$it=array();
$clen=count($child);
foreach ($child as $k=>$c){
$ch=explode("=", $c);
if($ch[0]=='ccode'&&empty($ch[1])){
$ch[1]=$prev.sprintf('%02s',$index).''.sprintf('%03s',($last+1));
}
if($ch[0]=='ccode'){
$index++;
}
$it[$k]=$ch[0].'='.$ch[1];
}
$childs[$key]=json_encode($it,JSON_UNESCAPED_UNICODE);
}
}
$row=array_filter($childs);
$row=array_values($row);
array_walk($row,"walkparse");
$cchilds=$row;
}
$sl_data['c_code']=$code;
$sl_data['c_kind']=$ckind;
$sl_data['c_infostime']=isset($post['c_infostime'])?strtotime($post['c_infostime']):time();
$sl_data['c_infoetime']=isset($post['c_infoetime'])?strtotime($post['c_infoetime']):time();
if(isset($post['c_gptime']))$sl_data['c_gptime']=strtotime($post['c_gptime']);
$sl_data['c_status']=input('c_status',0);
if(isset($sl_data['c_cate']))$sl_data['c_cate']=input('c_cate','');
if(isset($sl_data['c_state']))$sl_data['c_state']=input('c_state',1);
$sl_data['c_content']=htmlspecialchars_decode(input('c_content'));
$sl_data['c_childs']=json_encode($cchilds,JSON_UNESCAPED_UNICODE);
//图片字段处理
if(!empty($img_one)){
$sl_data['c_logo']=$img_one;
}
$sl_data['c_time']=time();
$sl_data['c_name']=input('c_name','');
$sl_data['c_tag']=input('c_tag',0);
$sl_data['c_seller']=input('c_seller','');
$sl_data['c_icode']=input('c_icode','');
$sl_data['c_scode']=input('c_scode','');
$sl_data['c_sauth']=input('c_sauth','');
$sl_data['c_ower']=input('c_ower','');
$sl_data['c_hot']=input('c_hot');
$sl_data['c_type']=$ctype;
$sl_data['c_num']=input('c_num','');
$sl_data['c_url']=$curl;
$sl_data['c_cate']=$ccate;
if($sl_data['c_cate']==6){
$sl_data['c_cother']=input('c_cother','');
}
$cscene=isset($_POST["c_scene"])?$_POST["c_scene"]:array();
if(count($cscene))$sl_data['c_scene']=is_array($cscene)?implode(',', $cscene):'';
if(count($cstype))$sl_data['c_stype']=is_array($cstype)?implode(',', $cstype):'';
$sl_data['c_sother']=input('c_sother','');
$sl_data['c_pay']=input('c_pay','');
$sl_data['c_ptype']=input('c_ptype');
$sl_data['c_pscope']=input('c_pscope');
$sl_data['c_price']=input('c_price','');
$sl_data['c_proxy']=input('c_proxy','');
$sl_data['c_year']=input('c_year','');
$sl_data['c_source']=input('c_source','');
$sl_data['c_charge']=input('c_charge','');
$cright=isset($_POST["c_right"])?$_POST["c_right"]:array();
if(count($cright))$sl_data['c_right']=is_array($cright)?implode(',', $cright):'';
$sl_data['c_uid']=session('admin_auth.aid');
$rst=$item->allowField(true)->insert($sl_data);
if($rst){
$this->success('增加成功',$jump);
}else{
$this->error('增加失败',$jump);
}
}
}
/**
* 非文化资产挂牌排序
*/
public function show_order()
{
$kind=input('kind');
$this->assign('c_kind',$kind);
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Bigdata/showlist',array('kind'=>$kind)));
}else{
foreach (input('post.') as $c_id => $c_order){
Db::name('bigdata')->update(['c_id'=>$c_id,'c_order'=>$c_order]);
}
$this->success('排序更新成功',url('admin/Bigdata/showlist',array('kind'=>$kind)));
}
}
/**
* 非文化资产挂牌删除(单个)
*/
public function show_del()
{
$p=input('p');
$kind=input('kind');
$this->assign('c_kind',$kind);
$rst=Db::name('bigdata')->delete(input('c_id'));
if($rst!==false){
$this->success('删除成功',url('admin/Bigdata/showlist',array('p' => $p,'kind'=>$kind)));
}else{
$this -> error("删除失败!",url('admin/Bigdata/showlist',array('p'=>$p,'kind'=>$kind)));
}
}
/**
* 非文化资产删除挂牌(全选)
*/
public function show_alldel()
{
$p = input('p');
$kind=input('kind');
$this->assign('c_kind',$kind);
$ids = input('c_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Bigdata/showlist',array('p'=>$p,'kind'=>$kind)));
}
if(is_array($ids)){
$where = 'c_id in('.implode(',',$ids).')';
}else{
$where = 'c_id='.$ids;
}
$rst=Db::name('bigdata')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Bigdata/showlist',array('p'=>$p,'kind'=>$kind)));
}else{
$this -> error("删除失败!",url('admin/Bigdata/showlist',array('p'=>$p,'kind'=>$kind)));
}
}
}

71
app/admin/controller/Bjjg.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bjjg extends News
{
public function _initialize()
{
$this->table_name='bjjg';
$this->controller_name='Bjjg';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function bjjg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bjjg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bjjg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bjjg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bjjg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bjjg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bjjg_state()
{
return $this->news_state();
}
}

68
app/admin/controller/Bsgg.php

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bsgg extends News
{
public function _initialize()
{
$this->table_name='bsgg';
$this->controller_name='Bsgg';
parent::_initialize();
}
/**
* 公告列表
*/
public function bsgg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bsgg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bsgg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bsgg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bsgg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bsgg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bsgg_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Bsjs.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bsjs extends News
{
public function _initialize()
{
$this->table_name='bsjs';
$this->controller_name='Bsjs';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 公告列表
*/
public function bsjs_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bsjs_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bsjs_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bsjs_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bsjs_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bsjs_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bsjs_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Bsry.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bsry extends News
{
public function _initialize()
{
$this->table_name='bsry';
$this->controller_name='Bsry';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 本所荣誉列表
*/
public function bsry_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bsry_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bsry_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bsry_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bsry_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bsry_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bsry_state()
{
return $this->news_state();
}
}

68
app/admin/controller/Bsyw.php

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bsyw extends News
{
public function _initialize()
{
$this->table_name='bsyw';
$this->controller_name='Bsyw';
parent::_initialize();
}
/**
* 公告列表
*/
public function bsyw_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bsyw_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bsyw_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bsyw_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bsyw_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bsyw_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bsyw_state()
{
return $this->news_state();
}
}

68
app/admin/controller/Bszc.php

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bszc extends News
{
public function _initialize()
{
$this->table_name='bszc';
$this->controller_name='Bszc';
parent::_initialize();
}
/**
* 公告列表
*/
public function bszc_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bszc_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bszc_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bszc_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bszc_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bszc_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bszc_state()
{
return $this->news_state();
}
}

68
app/admin/controller/Bszc2.php

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Bszc2 extends News
{
public function _initialize()
{
$this->table_name='bszc2';
$this->controller_name='Bszc2';
parent::_initialize();
}
/**
* 公告列表
*/
public function bszc2_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bszc2_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bszc2_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bszc2_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bszc2_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bszc2_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bszc2_state()
{
return $this->news_state();
}
}

145
app/admin/controller/Culture.php

@ -0,0 +1,145 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Culture extends Base
{
/**
* 栏目列表
*/
public function culture_list()
{
$cu_cid=input('cid',0,'intval');
$cultures=Db::name('culture')->where('cu_cid',$cu_cid)->order('cu_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $cultures->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('cu_cid',$cu_cid);
$this->assign('cultures',$cultures);
$this->assign('page',$show);
if(request()->isAjax()){
return $this->fetch('ajax_culture_list');
}else{
return $this->fetch();
}
}
/**
* 添加显示
*/
public function culture_add()
{
$cu_cid=input('cid',0,'intval');
if (!request()->isAjax()){
$this->assign('cu_cid',$cu_cid);
return $this->fetch();
}else{
$sl_data=array(
'cu_dw'=>htmlspecialchars_decode(input('cu_dw')),
'cu_status'=>input('cu_status',0),
'cu_uid'=>session('admin_auth.aid'),
'cu_time'=>time(),
'cu_dy'=>htmlspecialchars_decode(input('cu_dy')),
'cu_fw'=>htmlspecialchars_decode(input('cu_fw')),
'cu_cid'=>$cu_cid
);
$rst=Db::name('culture')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
}else{
$this->error('添加失败',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
}
}
}
/**
* 编辑显示
*/
public function culture_edit()
{
$cu_cid=input('cid',0,'intval');
if (!request()->isAjax()) {
$d_id = input('cu_id');
if (empty($d_id)) {
$this->error('参数错误', url('admin/Culture/culture_list',['cid'=>$cu_cid]));
}
$culture_list = Db::name('culture')->find($d_id);
$this->assign('culture_list', $culture_list);
$this->assign('cu_cid',$cu_cid);
return $this->fetch();
}else{
$sl_data=array(
'cu_id'=>input('cu_id'),
'cu_dw'=>htmlspecialchars_decode(input('cu_dw')),
'cu_status'=>input('cu_status',0),
'cu_dy'=>htmlspecialchars_decode(input('cu_dy')),
'cu_fw'=>htmlspecialchars_decode(input('cu_fw'))
);
$rst=Db::name('culture')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
}else{
$this->error('修改失败',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
}
}
}
/**
* 删除(单个)
*/
public function culture_del()
{
$cu_cid=input('cid',0,'intval');
$p=input('p');
$rst=Db::name('culture')->delete(input('cu_id'));
if($rst!==false){
$this->success('删除成功',url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
}else{
$this -> error("删除失败!",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
}
}
/**
* 删除(全选)
*/
public function culture_alldel()
{
$p = input('p');
$ids = input('cu_id/a');
$cu_cid=input('cid',0,'intval');
if(empty($ids)){
$this -> error("请选择待删除数据",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
}
if(is_array($ids)){
$where = 'cu_id in('.implode(',',$ids).')';
}else{
$where = 'cu_id='.$ids;
}
$rst=Db::name('culture')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
}else{
$this -> error("删除失败!",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
}
}
/**
* 审核/取消审核
*/
public function culture_state()
{
$id=input('x');
$status=Db::name('culture')->where(array('cu_id'=>$id))->value('cu_status');
if($status==1){
$statedata = array('cu_status'=>0);
Db::name('culture')->where(array('cu_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('cu_status'=>1);
Db::name('culture')->where(array('cu_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

209
app/admin/controller/Download.php

@ -0,0 +1,209 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Download extends Base
{
/**
* 资料下载列表
*/
public function download_list()
{
$d_catid=input('catid',0,'intval');
$d_cid=input('cid',0,'intval');
$downloads=Db::name('download')->where('d_catlogid',$d_catid)->where('d_cid',$d_cid)->order('d_order,d_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $downloads->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('d_catid',$d_catid);
$this->assign('d_cid',$d_cid);
$this->assign('downloads',$downloads);
$this->assign('page',$show);
if(request()->isAjax()){
return $this->fetch('ajax_download_list');
}else{
return $this->fetch();
}
}
/**
* 添加显示
*/
public function download_add()
{
$d_catid=input('catid',0,'intval');
$d_cid=input('cid',0,'intval');
if (!request()->isAjax()){
$this->assign('d_catid',$d_catid);
$this->assign('d_cid',$d_cid);
return $this->fetch();
}else{
$files = request()->file('file_all');
$fileall_url='';
if($files){
foreach ($files as $file) {
$info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
} else {
$this->error($file->getError(), url('admin/Download/download_list',['cid'=>$d_cid]));//否则就是上传错误,显示错误原因
}
}
}
$sl_data=array(
'd_name'=>input('d_name'),
'd_status'=>input('d_status',0),
'd_uid'=>session('admin_auth.aid'),
'd_time'=>time(),
'd_order'=>input('d_order',50,'intval'),
'd_url'=>$fileall_url,
'd_cid'=>$d_cid,
'd_catlogid'=>$d_catid
);
$rst=Db::name('download')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Download/download_list',['cid'=>$d_cid,'catid'=>$d_catid]));
}else{
$this->error('添加失败',url('admin/Download/download_list',['cid'=>$d_cid,'catid'=>$d_catid]));
}
}
}
/**
* 编辑显示
*/
public function download_edit()
{
$d_catid=input('catid',0,'intval');
$d_cid=input('cid',0,'intval');
if (!request()->isAjax()) {
$d_id = input('d_id');
if (empty($d_id)) {
$this->error('参数错误', url('admin/Download/download_list',['cid'=>$d_cid]));
}
$download_list = Db::name('download')->find($d_id);
$this->assign('download_list', $download_list);
$this->assign('d_catid',$d_catid);
$this->assign('d_cid',$d_cid);
return $this->fetch();
}else{
//文件
$files = request()->file('file_all');
$fileall_url='';
if($files){
foreach ($files as $file) {
$info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
} else {
$this->error($file->getError(), url('admin/Download/download_list',['cid'=>$d_cid]));//否则就是上传错误,显示错误原因
}
}
}
$sl_data=array(
'd_id'=>input('d_id'),
'd_name'=>input('d_name'),
'd_status'=>input('d_status',0),
'd_order'=>input('d_order',50,'intval'),
);
if(!empty($fileall_url)){
$sl_data['d_url']=$fileall_url;
}
$rst=Db::name('download')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Download/download_list',['cid'=>$d_cid,'catid'=>$d_catid]));
}else{
$this->error('修改失败',url('admin/Download/download_list',['cid'=>$d_cid,'catid'=>$d_catid]));
}
}
}
/**
* 排序
*/
public function download_order()
{
$d_catid=input('catid',0,'intval');
$d_cid=input('cid',0,'intval');
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Download/download_list',['cid'=>$d_cid,'catid'=>$d_catid]));
}else{
foreach (input('post.') as $d_id => $d_order){
Db::name('download')->update(['d_id'=>$d_id,'d_order'=>$d_order]);
}
$this->success('排序更新成功',url('admin/Download/download_list',['cid'=>$d_cid,'catid'=>$d_catid]));
}
}
/**
* 删除(单个)
*/
public function download_del()
{
$d_catid=input('catid',0,'intval');
$d_cid=input('cid',0,'intval');
$p=input('p');
$rst=Db::name('download')->delete(input('d_id'));
if($rst!==false){
$this->success('删除成功',url('admin/Download/download_list',array('p'=>$p,'cid'=>$d_cid,'catid'=>$d_catid)));
}else{
$this -> error("删除失败!",url('admin/Download/download_list',array('p'=>$p,'cid'=>$d_cid,'catid'=>$d_catid)));
}
}
/**
* 删除(全选)
*/
public function download_alldel()
{
$p = input('p');
$ids = input('d_id/a');
$d_catid=input('catid',0,'intval');
$d_cid=input('cid',0,'intval');
if(empty($ids)){
$this -> error("请选择待删除数据",url('admin/Download/download_list',array('p'=>$p,'cid'=>$d_cid,'catid'=>$d_catid)));
}
if(is_array($ids)){
$where = 'd_id in('.implode(',',$ids).')';
}else{
$where = 'd_id='.$ids;
}
$rst=Db::name('download')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Download/download_list',array('p'=>$p,'cid'=>$d_cid,'catid'=>$d_catid)));
}else{
$this -> error("删除失败!",url('admin/Download/download_list',array('p'=>$p,'cid'=>$d_cid,'catid'=>$d_catid)));
}
}
/**
* 审核/取消审核
*/
public function download_state()
{
$id=input('x');
$status=Db::name('download')->where(array('d_id'=>$id))->value('d_status');
if($status==1){
$statedata = array('d_status'=>0);
Db::name('download')->where(array('d_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('d_status'=>1);
Db::name('download')->where(array('d_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

71
app/admin/controller/Dsffwjg.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Dsffwjg extends News
{
public function _initialize()
{
$this->table_name='dsffwjg';
$this->controller_name='Dsffwjg';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function dsffwjg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function dsffwjg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function dsffwjg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function dsffwjg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function dsffwjg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function dsffwjg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function dsffwjg_state()
{
return $this->news_state();
}
}

17
app/admin/controller/Error.php

@ -0,0 +1,17 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Error extends Base
{
public function index()
{
$this->error('此操作无效');
}
}

253
app/admin/controller/Feedback.php

@ -0,0 +1,253 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Validate;
use think\Request;
use think\captcha\Captcha;
class Feedback extends Base
{
public function fdlist() {
$where=[];
$db=Db::name('feedback');
$account=input('account');
$org=input('org');
$tel=input('tel');
$platform=input('platform');
$startdate=input('startdate');
$enddate=input('enddate');
$target=input('target');
$this->assign('account',$account);
$this->assign('org',$org);
$this->assign('tel',$tel);
$this->assign('platform',$platform);
$this->assign('startdate',$startdate);
$this->assign('enddate',$enddate);
$this->assign('target',$target);
if($account){
$db->where('account','like',['%'.$account.'%',$account.'%']);
}
if($tel){
$db->where('tel','like',['%'.$tel.'%',$tel.'%']);
}
if($org){
$db->where('org','like',['%'.$org.'%',$org.'%']);
}
if($target){
$db->where('target','like',['%'.$target.'%',$target.'%']);
}
if($platform){
$db->where('platform','like',['%'.$platform.'%',$platform.'%']);
}
if($startdate&&empty($enddate)){
$db->where('create_time','>=',strtotime($startdate));
}else if($enddate&&empty($startdate)){
$db->where('create_time','<=',strtotime($enddate." 11:59:59"));
}else if($enddate&&$startdate){
$db->where('create_time',['>=',strtotime($startdate)],['<=',strtotime($enddate." 11:59:59")],'and');
}
$docs =$db->order("id desc")->select();
//echo $db->getLastSql();exit;
foreach ($docs as &$doc){
$doc['color']='text-primary';
if($doc['state']==1){
$cur=time();
$create=$doc['create_time'];
$time=$cur-$create;
if($time>3600*3&&$time<3600*6){
$doc['color']='text-warning';
}else if($time>=3600*6){
$doc['color']='text-danger';
}
}
if($doc['state']==1)$doc['state']='未处理客诉';
if($doc['state']==2)$doc['state']='处理中客诉';
if($doc['state']==3)$doc['state']=' 已处理客诉';
if($doc['score']==1)$doc['score']='非常满意';
if($doc['score']==3)$doc['score']='基本满意';
if($doc['score']==2)$doc['score']='满意';
}
$this->assign('fdlist', $docs);
return $this->view->fetch();
}
public function edit(){
$id = input('id','');
$remark = input('remark','');
$state=input('state','','intval');
$doc = Db::name('feedback')->where('id', $id)->find();
$remarks=$doc['remarks'];
try {
$remarks=json_decode($remarks,true);
} catch (Exception $e) {
}
if(!is_array($remarks))$remarks=[];
$remarks[$state]=$remark;
/* if($state==3){
$tels=array('complaint');
if(count($tels)){
foreach ($tels as $tel){
$token=md5('szwjs_'.$id);
$href=url('home/feedback/review',['token'=>$token,'id'=>$id],false,true);
send_sms($tel,'深圳文化产权交易所有限公司:这次处理的满意度:非常满意、基本满意、不满意!谢谢!<a href="'.$href.'">回复网址</a>');
}
}
} */
$query = Db::name('feedback')->where('id', $id)->update(['state'=>$state,'remarks'=>json_encode($remarks)]);
if($query){
$this->success('提交成功',url('fdlist'));
}else{
$this->error('提交失败');
}
}
public function detail() {
$id = input('get.id','');
if(empty($id)) {
return $this->view->fetch();
}
$doc = Db::name('feedback')->where('id', $id)->find();
if($doc['attach']){
$doc['attach']=htmlspecialchars_decode($doc['attach'],true);
try {
$doc['attach']=json_decode($doc['attach'],true);
} catch (Exception $e) {
$doc['attach']=[];
}
}
$remarks=$doc['remarks'];
try {
$remarks=json_decode($remarks,true);
} catch (Exception $e) {
}
if(!is_array($remarks))$remarks=[];
$doc['remarks']=$remarks;
$this->assign('detail',$doc);
return $this->view->fetch();
}
public function culist() {
$cid=input('cid','1','intval');
$where=[];
$db=Db::name('cultureapply');
$docs =$db->where(['cid'=>$cid])->order("id desc")->select();
//echo $db->getLastSql();exit;
foreach ($docs as &$doc){
$doc['create_time']=date("Y-m-d",$doc['create_time']);
if($doc['cid']==1){
if($doc['company']==1)$doc['company']='中央政府部门所属机构';
if($doc['company']==2)$doc['company']='国有独资企业';
if($doc['company']==3)$doc['company']='国有控股企业';
if($doc['company']==4)$doc['company']='股份有限公司';
if($doc['company']==5)$doc['company']='有限责任公司';
if($doc['company']==6)$doc['company']='其他';
}else{
if($doc['company']==1)$doc['company']='股份有限公司';
if($doc['company']==2)$doc['company']='有限责任公司';
if($doc['company']==3)$doc['company']='其他企业';
}
}
$this->assign('fdlist', $docs);
return $this->view->fetch();
}
public function cudetail() {
$id = input('get.id','');
if(empty($id)) {
return $this->view->fetch();
}
$doc = Db::name('cultureapply')->where('id', $id)->find();
$doc['create_time']=date("Y-m-d",$doc['create_time']);
if($doc['cid']==1){
if($doc['company']==1)$doc['company']='中央政府部门所属机构';
if($doc['company']==2)$doc['company']='国有独资企业';
if($doc['company']==3)$doc['company']='国有控股企业';
if($doc['company']==4)$doc['company']='股份有限公司';
if($doc['company']==5)$doc['company']='有限责任公司';
if($doc['company']==6)$doc['company']='其他';
}else{
if($doc['company']==1)$doc['company']='股份有限公司';
if($doc['company']==2)$doc['company']='有限责任公司';
if($doc['company']==3)$doc['company']='其他企业';
}
$legal=$doc['legal'];
try {
$legal=json_decode($legal,true);
} catch (Exception $e) {
}
if(!is_array($legal))$legal=[];
$doc['legal']=$legal;
$this->assign('legal',$legal);
$org=$doc['org'];
try {
$org=json_decode($org,true);
} catch (Exception $e) {
}
if(!is_array($org))$org=[];
$doc['org']=$org;
$this->assign('org',$org);
$cont=$doc['cont'];
try {
$cont=json_decode($cont,true);
} catch (Exception $e) {
}
if(!is_array($cont))$cont=[];
$doc['cont']=$cont;
$this->assign('cont',$cont);
$parter=$doc['parter'];
try {
$parter=json_decode($parter,true);
} catch (Exception $e) {
}
if(!is_array($parter))$parter=[];
$this->assign('parter',$parter);
$base=$doc['base'];
try {
$base=json_decode($base,true);
} catch (Exception $e) {
}
if(!is_array($base))$base=[];
$this->assign('base',$base);
$pro=$doc['pro'];
try {
$pro=json_decode($pro,true);
} catch (Exception $e) {
}
if(!is_array($pro))$pro=[];
$this->assign('pro',$pro);
$doc['financefile']=$doc['financefile']?explode(';', $doc['financefile']):[];
$doc['relatedfile']=$doc['relatedfile']?explode(';', $doc['relatedfile']):[];
$this->assign('detail',$doc);
return $this->view->fetch();
}
}

72
app/admin/controller/Ggnew.php

@ -0,0 +1,72 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/23
* Time: 15:32
*/
namespace app\admin\controller;
class Ggnew extends News
{
public function _initialize()
{
$this->table_name='zgwhjf_ggnew';
$this->controller_name='Ggnew';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zgwhjf_ggnew_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zgwhjf_ggnew_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zgwhjf_ggnew_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zgwhjf_ggnew_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zgwhjf_ggnew_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zgwhjf_ggnew_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zgwhjf_ggnew_state()
{
return $this->news_state();
}
}

3073
app/admin/controller/Gpgl.php

File diff suppressed because it is too large

70
app/admin/controller/Gyzc.php

@ -0,0 +1,70 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Gyzc extends News
{
public function _initialize()
{
$this->table_name='gyzc';
$this->controller_name='Gyzc';
$this->has_source=false;
$this->has_imgs=false;
parent::_initialize();
}
/**
* 公告列表
*/
public function gyzc_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function gyzc_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function gyzc_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function gyzc_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function gyzc_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function gyzc_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function gyzc_state()
{
return $this->news_state();
}
}

17
app/admin/controller/Help.php

@ -0,0 +1,17 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Help extends Base
{
public function soft()
{
return $this->fetch();
}
}

168
app/admin/controller/Hyzq.php

@ -0,0 +1,168 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Hyzq extends Base
{
/**
* 栏目列表
*/
public function hyzq_list()
{
$cu_cid=input('cid',0,'intval');
$hyzqs=Db::name('hyzq')->where('cu_cid',$cu_cid)->order('cu_order,cu_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $hyzqs->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('cu_cid',$cu_cid);
$this->assign('hyzqs',$hyzqs);
$this->assign('page',$show);
if(request()->isAjax()){
return $this->fetch('ajax_hyzq_list');
}else{
return $this->fetch();
}
}
/**
* 添加显示
*/
public function hyzq_add()
{
$cu_cid=input('cid',0,'intval');
if (!request()->isAjax()){
$this->assign('cu_cid',$cu_cid);
return $this->fetch();
}else{
$sl_data=array(
'cu_order'=>input('cu_order',50,'intval'),
'cu_status'=>input('cu_status',0),
'cu_uid'=>session('admin_auth.aid'),
'cu_time'=>time(),
'cu_content'=>htmlspecialchars_decode(input('cu_content')),
'cu_title'=>input('cu_title'),
'cu_cid'=>$cu_cid
);
$rst=Db::name('hyzq')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}else{
$this->error('添加失败',url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}
}
}
/**
* 编辑显示
*/
public function hyzq_edit()
{
$cu_cid=input('cid',0,'intval');
if (!request()->isAjax()) {
$d_id = input('cu_id');
if (empty($d_id)) {
$this->error('参数错误', url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}
$hyzq_list = Db::name('hyzq')->find($d_id);
$this->assign('hyzq_list', $hyzq_list);
$this->assign('cu_cid',$cu_cid);
return $this->fetch();
}else{
$sl_data=array(
'cu_id'=>input('cu_id'),
'cu_order'=>input('cu_order',50,'intval'),
'cu_status'=>input('cu_status',0),
'cu_content'=>htmlspecialchars_decode(input('cu_content')),
'cu_title'=>input('cu_title')
);
$rst=Db::name('hyzq')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}else{
$this->error('修改失败',url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}
}
}
/**
* 删除(单个)
*/
public function hyzq_del()
{
$cu_cid=input('cid',0,'intval');
$p=input('p');
$rst=Db::name('hyzq')->delete(input('cu_id'));
if($rst!==false){
$this->success('删除成功',url('admin/hyzq/hyzq_list',array('p'=>$p,'cid'=>$cu_cid)));
}else{
$this -> error("删除失败!",url('admin/hyzq/hyzq_list',array('p'=>$p,'cid'=>$cu_cid)));
}
}
/**
* 删除(全选)
*/
public function hyzq_alldel()
{
$p = input('p');
$ids = input('cu_id/a');
$cu_cid=input('cid',0,'intval');
if(empty($ids)){
$this -> error("请选择待删除数据",url('admin/hyzq/hyzq_list',array('p'=>$p,'cid'=>$cu_cid)));
}
if(is_array($ids)){
$where = 'cu_id in('.implode(',',$ids).')';
}else{
$where = 'cu_id='.$ids;
}
$rst=Db::name('hyzq')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/hyzq/hyzq_list',array('p'=>$p,'cid'=>$cu_cid)));
}else{
$this -> error("删除失败!",url('admin/hyzq/hyzq_list',array('p'=>$p,'cid'=>$cu_cid)));
}
}
/**
* 审核/取消审核
*/
public function hyzq_state()
{
$id=input('x');
$status=Db::name('hyzq')->where(array('cu_id'=>$id))->value('cu_status');
if($status==1){
$statedata = array('cu_status'=>0);
Db::name('hyzq')->where(array('cu_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('cu_status'=>1);
Db::name('hyzq')->where(array('cu_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
/**
* 排序
*/
public function hyzq_order()
{
$cu_cid=input('cid',0,'intval');
if (!request()->isAjax()){
if($cu_cid){
$this->error('提交方式不正确', url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}else{
$this->error('提交方式不正确', url('admin/hyzq/hyzq_list'));
}
}else{
foreach (input('post.') as $cu_id => $cu_order){
Db::name('hyzq')->update(['cu_id'=>$cu_id,'cu_order'=>$cu_order]);
}
if($cu_cid){
$this->success('排序更新成功',url('admin/hyzq/hyzq_list',['cid'=>$cu_cid]));
}else{
$this->success('排序更新成功',url('admin/hyzq/hyzq_list'));
}
}
}
}

52
app/admin/controller/Index.php

@ -0,0 +1,52 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Cache;
use think\helper\Time;
use app\admin\model\News as NewsModel;
use app\admin\model\MemberList;
class Index extends Base
{
/**
* 后台首页
*/
public function index()
{
//渲染模板
return $this->fetch();
}
/**
* 后台多语言切换
*/
public function lang()
{
if (!request()->isAjax()){
$this->error('提交方式不正确');
}else{
$lang=input('lang_s');
session('login_http_referer',$_SERVER["HTTP_REFERER"]);
switch ($lang) {
case 'cn':
cookie('think_var', 'zh-cn');
break;
case 'en':
cookie('think_var', 'en-us');
break;
//其它语言
default:
cookie('think_var', 'zh-cn');
}
Cache::clear();
$this->success('切换成功',session('login_http_referer'));
}
}
}

100
app/admin/controller/Join.php

@ -0,0 +1,100 @@
<?php
namespace app\admin\controller;
use think\Db;
use app\admin\model\Agency;
use think\Controller;
use think\db\Query;
class Join extends Base
{
public function __construct(){
parent::__construct();
}
/**
* 列表
*/
public function index()
{
$map=array();
$admin_list=Db::name('joinus')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 修改
*/
public function edit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('joinus')->find(input('admin_id'));
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['state']=input('state');
$id=input('id');
$rst=Db::name('joinus')->where(['id'=>$id])->update($data);
if($rst!==false){
$this->success('修改成功',url('Join/index',['kind'=>$kind]));
}else{
$this->error('修改失败',url('Join/index',['kind'=>$kind]));
}
}
/**
* 删除
*/
public function del()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('Join/index',['kind'=>$kind]));
}
$rst=Db::name('joinus')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('Join/index',['kind'=>$kind]));
}else{
$this->error('删除失败',url('Join/index',['kind'=>$kind]));
}
}
/**
* 审核/取消审核
*/
public function state()
{
$id=input('x');
$find=Db::name('joinus')->where(array('id'=>$id))->find();
$msg='未审';
if($find){
$status=$find['state'];
if($status==1){
$statedata = array('state'=>0);
}else{
$statedata = array('state'=>1);
$msg='已审';
}
$query=Db::name('joinus')->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg);
}
}

164
app/admin/controller/Lcgyxm.php

@ -0,0 +1,164 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/28
* Time: 9:08
*/
namespace app\admin\controller;
use think\Db;
class Lcgyxm extends Base
{
/**
* 楼层国有业务列表
*/
public function gyxm_list()
{
$gyxm_list=Db::name('lc_gyxm')->order('gyxm_sort,gyxm_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $gyxm_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('gyxm_list',$gyxm_list);
if(request()->isAjax()){
return $this->fetch('lcgyxm/ajax_lc_gyxm_list');
}else{
return $this->fetch('lcgyxm/lc_gyxm_list');
}
}
/**
* 增加
*/
public function gyxm_add()
{
if(!request()->isAjax()) {
return $this->fetch('lcgyxm/lc_gyxm_add');
}else{
$sl_data=array(
'gyxm_name'=>input('gyxm_name'),
'gyxm_price'=>input('gyxm_price'),
'gyxm_pstatus'=>input('gyxm_pstatus'),
'gyxm_uptime'=>input('gyxm_uptime','')?strtotime(input('gyxm_uptime','')):time(),
'gyxm_status'=>input('gyxm_status',0),
'gyxm_sort'=>input('gyxm_sort'),
'gyxm_content'=>htmlspecialchars_decode(input('gyxm_content')),
'gyxm_time'=>time(),
'gyxm_uid'=>session('admin_auth.aid'),
);
$rst=Db::name('lc_gyxm')->insert($sl_data);
if($rst){
$this->success('增加成功',url('admin/Lcgyxm/gyxm_list'));
}else{
$this->error('增加失败',url('admin/Lcgyxm/gyxm_list'));
}
}
}
/**
* 修改
*/
public function gyxm_edit()
{
if(!request()->isAjax()) {
$gyxm_id = input('gyxm_id', 0, 'intval');
if (!$gyxm_id) $this->error('参数错误', url('admin/Lcgyxm/gyxm_list'));
$gyxm_list = Db::name('lc_gyxm')->where('gyxm_id', $gyxm_id)->find();
$this->assign('gyxm_list',$gyxm_list);
return $this->fetch('lcgyxm/lc_gyxm_edit');
}else{
$sl_data=array(
'gyxm_id'=>input('gyxm_id'),
'gyxm_name'=>input('gyxm_name'),
'gyxm_price'=>input('gyxm_price'),
'gyxm_pstatus'=>input('gyxm_pstatus'),
'gyxm_uptime'=>input('gyxm_uptime','')?strtotime(input('gyxm_uptime','')):time(),
'gyxm_status'=>input('gyxm_status',0),
'gyxm_sort'=>input('gyxm_sort'),
'gyxm_content'=>htmlspecialchars_decode(input('gyxm_content')),
'gyxm_time'=>time(),
'gyxm_uid'=>session('admin_auth.aid'),
);
$rst=Db::name('lc_gyxm')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Lcgyxm/gyxm_list'));
}else{
$this->error('修改失败',url('admin/Lcgyxm/gyxm_list'));
}
}
}
/**
* 排序
*/
public function gyxm_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Lcgyxm/gyxm_list'));
}else{
foreach (input('post.') as $gyxm_id => $gyxm_sort){
Db::name('lc_gyxm')->update(['gyxm_id'=>$gyxm_id,'gyxm_sort'=>$gyxm_sort]);
}
$this->success('排序更新成功',url('admin/Lcgyxm/gyxm_list'));
}
}
/**
* 删除(单个)
*/
public function gyxm_del()
{
$p=input('p');
$rst=Db::name('lc_gyxm')->delete(input('gyxm_id'));
if($rst!==false){
$this->success('删除成功',url('admin/Lcgyxm/gyxm_list',array('p' => $p)));
}else{
$this -> error("删除失败!",url('admin/Lcgyxm/gyxm_list',array('p'=>$p)));
}
}
/**
* 删除(全选)
*/
public function gyxm_alldel()
{
$p = input('p');
$ids = input('gyxm_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Lcgyxm/gyxm_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'gyxm_id in('.implode(',',$ids).')';
}else{
$where = 'gyxm_id='.$ids;
}
$rst=Db::name('lc_gyxm')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Lcgyxm/gyxm_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Lcgyxm/gyxm_list',array('p'=>$p)));
}
}
/**
* 状态修改
*/
public function gyxm_state()
{
$id=input('x');
$status=Db::name('lc_gyxm')->where(array('gyxm_id'=>$id))->value('gyxm_status');
if($status==1){
$statedata = array('gyxm_status'=>0);
Db::name('lc_gyxm')->where(array('gyxm_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('gyxm_status'=>1);
Db::name('lc_gyxm')->where(array('gyxm_id'=>$id))->setField($statedata);
$this->success('状态启用');
}
}
}

976
app/admin/controller/Lcmanager.php

@ -0,0 +1,976 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/28
* Time: 13:39
*/
namespace app\admin\controller;
use think\Db;
class Lcmanager extends Base
{
/**
* 楼层公馆列表
*/
public function mansion_list()
{
$mansion_list=Db::name('lc_gg')->order('p_sort,p_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $mansion_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('mansion_list',$mansion_list);
if(request()->isAjax()){
return $this->fetch('lcmanager/ajax_lc_mansion_list');
}else{
return $this->fetch('lcmanager/lc_mansion_list');
}
}
/**
* 公馆增加
*/
public function mansion_add()
{
if(!request()->isAjax()) {
return $this->fetch('lcmanager/lc_mansion_add');
}else{
$img_one='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
$count=Db::name('lc_gg')->where(array('p_status'=>1))->count();
if($count<4){
$status =input('p_status',0);
}else{
$status =0;
}
$sl_data=array(
'p_name'=>input('p_name'),
'p_ysj'=>input('p_ysj'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_logo'=>$img_one,
'p_uid'=>session('admin_auth.aid')
);
$rst=Db::name('lc_gg')->insert($sl_data);
if($rst){
$this->success('增加成功',url('admin/Lcmanager/mansion_list'));
}else{
$this->error('增加失败',url('admin/Lcmanager/mansion_list'));
}
}
}
/**
* 公馆修改
*/
public function mansion_edit()
{
if(!request()->isAjax()) {
$p_id = input('p_id', 0, 'intval');
if (!$p_id) $this->error('参数错误', url('admin/Lcmanager/mansion_list'));
$mansion_list = Db::name('lc_gg')->where('p_id', $p_id)->find();
$this->assign('mansion_list',$mansion_list);
return $this->fetch('lcmanager/lc_mansion_edit');
}else{
$img_one='';
$picall_url='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
$count=Db::name('lc_gg')->where(array('p_status'=>1))->count();
if($count<=4){
$status =input('p_status',0);
}else{
$status =0;
}
$sl_data=array(
'p_id'=>input('p_id'),
'p_name'=>input('p_name'),
'p_ysj'=>input('p_ysj'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_uid'=>session('admin_auth.aid')
);
if(!empty($img_one)){
$sl_data['p_logo']=$img_one;
}
$rst=Db::name('lc_gg')->update($sl_data);
$countTow=Db::name('lc_gg')->where(array('p_status'=>1))->count();
if($countTow>4){
$rst=Db::name('lc_gg')->where(array('p_id'=>input('p_id')))->update(array('p_status'=>0));
}
if($rst!==false){
$this->success('修改成功',url('admin/Lcmanager/mansion_list'));
}else{
$this->error('修改失败',url('admin/Lcmanager/mansion_list'));
}
}
}
/**
* 公馆排序
*/
public function mansion_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Lcmanager/mansion_list'));
}else{
foreach (input('post.') as $p_id => $p_sort){
Db::name('lc_gg')->update(['p_id'=>$p_id,'p_sort'=>$p_sort]);
}
$this->success('排序更新成功',url('admin/Lcmanager/mansion_list'));
}
}
/**
* 公馆删除(单个)
*/
public function mansion_del()
{
$p=input('p');
$rst=Db::name('lc_gg')->delete(input('p_id'));
if($rst!==false){
$this->success('删除成功',url('admin/Lcmanager/mansion_list',array('p' => $p)));
}else{
$this -> error("删除失败!",url('admin/Lcmanager/mansion_list',array('p'=>$p)));
}
}
/**
* 公馆删除(全选)
*/
public function mansion_alldel()
{
$p = input('p');
$ids = input('p_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Lcmanager/mansion_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'p_id in('.implode(',',$ids).')';
}else{
$where = 'p_id='.$ids;
}
$rst=Db::name('lc_gg')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Lcmanager/mansion_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Lcmanager/mansion_list',array('p'=>$p)));
}
}
/**
* 公馆状态修改
*/
public function mamsion_state()
{
$id=input('x');
$status=Db::name('lc_gg')->where(array('p_id'=>$id))->value('p_status');
$count=Db::name('lc_gg')->where(array('p_status'=>1))->count();
if($status==1){
$statedata = array('p_status'=>0);
Db::name('lc_gg')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
if($count<4){
$statedata = array('p_status'=>1);
Db::name('lc_gg')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态启用');
}else{
$this -> error("状态个数已达到!",url('admin/Lcmanager/mansion_list'));
}
}
}
/**
* 楼层艺拍列表
*/
public function making_list()
{
$making_list=Db::name('lc_yp')->order('p_sort,p_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $making_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('making_list',$making_list);
if(request()->isAjax()){
return $this->fetch('lcmanager/ajax_lc_making_list');
}else{
return $this->fetch('lcmanager/lc_making_list');
}
}
/**
* 艺拍增加
*/
public function making_add()
{
if(!request()->isAjax()) {
//艺拍分类
$yplb=Db::name('type')->where('type_type',57)->select();
$this->assign('yplb', $yplb);
return $this->fetch('lcmanager/lc_making_add');
}else{
$img_one='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
//根据选择类别修改
/*$p_type=Db::name('lc_gg')->where(array('p_id'=>$p_id))->value('p_type');*/
$countp=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>80))->count();//艺品拍
$countx=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>81))->count();//艺享拍
$countb=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>82))->count();//艺版拍
$p_type=input('p_type');
if($p_type==80){
if($countp<4){
$status =input('p_status',0);
}else{
$status =0;
}
}else if($p_type==81){
if($countx<4){
$status =input('p_status',0);
}else{
$status =0;
}
}else if($p_type==82){
if($countb<4){
$status =input('p_status',0);
}else{
$status =0;
}
}
$sl_data=array(
'p_name'=>input('p_name'),
'p_sprice'=>input('p_sprice'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_endtime'=>input('p_endtime','')?strtotime(input('p_endtime','')):time(),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_type'=>input('p_type'),
'p_count'=>input('p_count'),
'p_time'=>time(),
'p_logo'=>$img_one,
'p_uid'=>session('admin_auth.aid')
);
$rst=Db::name('lc_yp')->insert($sl_data);
if($rst){
$this->success('增加成功',url('admin/Lcmanager/making_list'));
}else{
$this->error('增加失败',url('admin/Lcmanager/making_list'));
}
}
}
/**
* 艺拍修改
*/
public function making_edit()
{
if(!request()->isAjax()) {
$p_id = input('p_id', 0, 'intval');
if (!$p_id) $this->error('参数错误', url('admin/Lcmanager/making_list'));
$making_list = Db::name('lc_yp')->where('p_id', $p_id)->find();
$this->assign('making_list',$making_list);
//艺拍分类
$yplb=Db::name('type')->where('type_type',57)->select();
$this->assign('yplb', $yplb);
return $this->fetch('lcmanager/lc_making_edit');
}else{
$img_one='';
$picall_url='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
//根据选择类别修改
/*$p_type=Db::name('lc_gg')->where(array('p_id'=>$p_id))->value('p_type');*/
$countp=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>80))->count();//艺品拍
$countx=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>81))->count();//艺享拍
$countb=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>82))->count();//艺版拍
$p_type=input('p_type');
if($p_type==80){
if($countp<=4){
$status =input('p_status',0);
}else{
$status =0;
}
}else if($p_type==81){
if($countx<=4){
$status =input('p_status',0);
}else{
$status =0;
}
}else if($p_type==82){
if($countb<=4){
$status =input('p_status',0);
}else{
$status =0;
}
}
$sl_data=array(
'p_id'=>input('p_id'),
'p_name'=>input('p_name'),
'p_sprice'=>input('p_sprice'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_type'=>input('p_type'),
'p_count'=>input('p_count'),
'p_endtime'=>input('p_endtime','')?strtotime(input('p_endtime','')):time(),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_uid'=>session('admin_auth.aid')
);
if(!empty($img_one)){
$sl_data['p_logo']=$img_one;
}
$rst=Db::name('lc_yp')->update($sl_data);
$countp=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>80))->count();//艺品拍
$countx=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>81))->count();//艺享拍
$countb=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>82))->count();//艺版拍
if($p_type==80){
if($countp>4){
$rst=Db::name('lc_yp')->where(array('p_id'=>input('p_id')))->update(array('p_status'=>0));
}
}else if($p_type==81){
if($countx>4){
$rst=Db::name('lc_yp')->where(array('p_id'=>input('p_id')))->update(array('p_status'=>0));
}
}else if($p_type==82){
if($countb>4){
$rst=Db::name('lc_yp')->where(array('p_id'=>input('p_id')))->update(array('p_status'=>0));
}
}
if($rst!==false){
$this->success('修改成功',url('admin/Lcmanager/making_list'));
}else{
$this->error('修改失败',url('admin/Lcmanager/making_list'));
}
}
}
/**
* 艺拍排序
*/
public function making_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Lcmanager/making_list'));
}else{
foreach (input('post.') as $p_id => $p_sort){
Db::name('lc_yp')->update(['p_id'=>$p_id,'p_sort'=>$p_sort]);
}
$this->success('排序更新成功',url('admin/Lcmanager/making_list'));
}
}
/**
* 艺拍删除(单个)
*/
public function making_del()
{
$p = input('p');
$rst = Db::name('lc_yp')->delete(input('p_id'));
if ($rst !== false) {
$this->success('删除成功', url('admin/Lcmanager/making_list', array('p' => $p)));
} else {
$this->error("删除失败!", url('admin/Lcmanager/making_list', array('p' => $p)));
}
}
/**
* 艺拍删除(全选)
*/
public function making_alldel()
{
$p = input('p');
$ids = input('p_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Lcmanager/making_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'p_id in('.implode(',',$ids).')';
}else{
$where = 'p_id='.$ids;
}
$rst=Db::name('lc_yp')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Lcmanager/making_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Lcmanager/making_list',array('p'=>$p)));
}
}
/**
* 艺拍状态修改
*/
public function making_state()
{
$id=input('x');
$status=Db::name('lc_yp')->where(array('p_id'=>$id))->value('p_status');
//根据选择类别修改
$p_type=Db::name('lc_yp')->where(array('p_id'=>$id))->value('p_type');
$countp=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>80))->count();//艺品拍
$countx=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>81))->count();//艺享拍
$countb=Db::name('lc_yp')->where(array('p_status'=>1,'p_type'=>82))->count();//艺版拍
if($p_type==80){
if($status==1){
$statedata = array('p_status'=>0);
Db::name('lc_yp')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
if($countp<4){
$statedata = array('p_status'=>1);
Db::name('lc_yp')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态启用');
}else{
$this -> error("状态个数已达到!",url('admin/Lcmanager/mansion_list'));
}
}
}else if($p_type==81){
if($status==1){
$statedata = array('p_status'=>0);
Db::name('lc_yp')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
if($countx<4){
$statedata = array('p_status'=>1);
Db::name('lc_yp')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态启用');
}else{
$this -> error("状态个数已达到!",url('admin/Lcmanager/mansion_list'));
}
}
}else if($p_type==82){
if($status==1){
$statedata = array('p_status'=>0);
Db::name('lc_yp')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
if($countb<4){
$statedata = array('p_status'=>1);
Db::name('lc_yp')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态启用');
}else{
$this -> error("状态个数已达到!",url('admin/Lcmanager/mansion_list'));
}
}
}
}
/**
* 楼层商城列表
*/
public function shopping_list()
{
$shopping_list=Db::name('lc_sc')->order('p_sort,p_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $shopping_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('shopping_list',$shopping_list);
if(request()->isAjax()){
return $this->fetch('lcmanager/ajax_lc_shopping_list');
}else{
return $this->fetch('lcmanager/lc_shopping_list');
}
}
/**
* 商城增加
*/
public function shopping_add()
{
if(!request()->isAjax()) {
return $this->fetch('lcmanager/lc_shopping_add');
}else{
$img_one='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
$count=Db::name('lc_sc')->where(array('p_status'=>1))->count();
if($count<4){
$status =input('p_status',0);
}else{
$status =0;
}
$sl_data=array(
'p_name'=>input('p_name'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_logo'=>$img_one,
'p_uid'=>session('admin_auth.aid')
);
$rst=Db::name('lc_sc')->insert($sl_data);
if($rst){
$this->success('增加成功',url('admin/Lcmanager/shopping_list'));
}else{
$this->error('增加失败',url('admin/Lcmanager/shopping_list'));
}
}
}
/**
* 商城修改
*/
public function shopping_edit()
{
if(!request()->isAjax()) {
$p_id = input('p_id', 0, 'intval');
if (!$p_id) $this->error('参数错误', url('admin/Lcmanager/shopping_list'));
$shopping_list = Db::name('lc_sc')->where('p_id', $p_id)->find();
$this->assign('shopping_list',$shopping_list);
return $this->fetch('lcmanager/lc_shopping_edit');
}else{
$img_one='';
$picall_url='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
$count=Db::name('lc_sc')->where(array('p_status'=>1))->count();
if($count<=4){
$status =input('p_status',0);
}else{
$status =0;
}
$sl_data=array(
'p_id'=>input('p_id'),
'p_name'=>input('p_name'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_uid'=>session('admin_auth.aid')
);
if(!empty($img_one)){
$sl_data['p_logo']=$img_one;
}
$rst=Db::name('lc_sc')->update($sl_data);
$countTow=Db::name('lc_sc')->where(array('p_status'=>1))->count();
if($countTow>4){
$rst=Db::name('lc_sc')->where(array('p_id'=>input('p_id')))->update(array('p_status'=>0));
}
if($rst!==false){
$this->success('修改成功',url('admin/Lcmanager/shopping_list'));
}else{
$this->error('修改失败',url('admin/Lcmanager/shopping_list'));
}
}
}
/**
* 商城排序
*/
public function shopping_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Lcmanager/shopping_list'));
}else{
foreach (input('post.') as $p_id => $p_sort){
Db::name('lc_sc')->update(['p_id'=>$p_id,'p_sort'=>$p_sort]);
}
$this->success('排序更新成功',url('admin/Lcmanager/shopping_list'));
}
}
/**
* 商城删除(单个)
*/
public function shopping_del()
{
$p = input('p');
$rst = Db::name('lc_sc')->delete(input('p_id'));
if ($rst !== false) {
$this->success('删除成功', url('admin/Lcmanager/shopping_list', array('p' => $p)));
} else {
$this->error("删除失败!", url('admin/Lcmanager/shopping_list', array('p' => $p)));
}
}
/**
* 商城删除(全选)
*/
public function shopping_alldel()
{
$p = input('p');
$ids = input('p_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Lcmanager/shopping_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'p_id in('.implode(',',$ids).')';
}else{
$where = 'p_id='.$ids;
}
$rst=Db::name('lc_sc')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Lcmanager/shopping_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Lcmanager/shopping_list',array('p'=>$p)));
}
}
/**
* 商城状态修改
*/
public function shopping_state()
{
$id=input('x');
$status=Db::name('lc_sc')->where(array('p_id'=>$id))->value('p_status');
$count=Db::name('lc_sc')->where(array('p_status'=>1))->count();
if($status==1){
$statedata = array('p_status'=>0);
Db::name('lc_sc')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
if($count<4){
$statedata = array('p_status'=>1);
Db::name('lc_sc')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态启用');
}else{
$this -> error("状态个数已达到!",url('admin/Lcmanager/shopping_list'));
}
}
}
/**
* 楼层投行列表
*/
public function bank_list()
{
$bank_list=Db::name('lc_th')->order('p_sort,p_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $bank_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('bank_list',$bank_list);
if(request()->isAjax()){
return $this->fetch('lcmanager/ajax_lc_bank_list');
}else{
return $this->fetch('lcmanager/lc_bank_list');
}
}
/**
*投行增加
*/
public function bank_add()
{
if(!request()->isAjax()) {
return $this->fetch('lcmanager/lc_bank_add');
}else{
$img_one='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
$count=Db::name('lc_th')->where(array('p_status'=>1))->count();
if($count<4){
$status =input('p_status',0);
}else{
$status =0;
}
$sl_data=array(
'p_name'=>input('p_name'),
'p_price'=>input('p_price'),
'p_url'=>input('p_url'),
'p_jd'=>input('p_jd'),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_logo'=>$img_one,
'p_uid'=>session('admin_auth.aid')
);
$rst=Db::name('lc_th')->insert($sl_data);
if($rst){
$this->success('增加成功',url('admin/Lcmanager/bank_list'));
}else{
$this->error('增加失败',url('admin/Lcmanager/bank_list'));
}
}
}
/**
* 投行修改
*/
public function bank_edit()
{
if(!request()->isAjax()) {
$p_id = input('p_id', 0, 'intval');
if (!$p_id) $this->error('参数错误', url('admin/Lcmanager/bank_list'));
$bank_list = Db::name('lc_th')->where('p_id', $p_id)->find();
$this->assign('bank_list',$bank_list);
return $this->fetch('lcmanager/lc_bank_edit');
}else{
$img_one='';
$picall_url='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcmanager/making_list'));
}
}
$count=Db::name('lc_th')->where(array('p_status'=>1))->count();
if($count<=4){
$status =input('p_status',0);
}else{
$status =0;
}
$sl_data=array(
'p_id'=>input('p_id'),
'p_name'=>input('p_name'),
'p_price'=>input('p_price'),
'p_jd'=>input('p_jd'),
'p_url'=>input('p_url'),
'p_uptime'=>input('p_uptime','')?strtotime(input('p_uptime','')):time(),
'p_status'=>$status,
'p_sort'=>input('p_sort'),
'p_time'=>time(),
'p_uid'=>session('admin_auth.aid')
);
if(!empty($img_one)){
$sl_data['p_logo']=$img_one;
}
$rst=Db::name('lc_th')->update($sl_data);
$countTow=Db::name('lc_th')->where(array('p_status'=>1))->count();
if($countTow>4){
$rst=Db::name('lc_th')->where(array('p_id'=>input('p_id')))->update(array('p_status'=>0));
}
if($rst!==false){
$this->success('修改成功',url('admin/Lcmanager/bank_list'));
}else{
$this->error('修改失败',url('admin/Lcmanager/bank_list'));
}
}
}
/**
* 投行排序
*/
public function bank_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Lcmanager/bank_list'));
}else{
foreach (input('post.') as $p_id => $p_sort){
Db::name('lc_th')->update(['p_id'=>$p_id,'p_sort'=>$p_sort]);
}
$this->success('排序更新成功',url('admin/Lcmanager/bank_list'));
}
}
/**
* 投行删除(单个)
*/
public function bank_del()
{
$p = input('p');
$rst = Db::name('lc_th')->delete(input('p_id'));
if ($rst !== false) {
$this->success('删除成功', url('admin/Lcmanager/bank_list', array('p' => $p)));
} else {
$this->error("删除失败!", url('admin/Lcmanager/bank_list', array('p' => $p)));
}
}
/**
* 投行删除(全选)
*/
public function bank_alldel()
{
$p = input('p');
$ids = input('p_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Lcmanager/bank_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'p_id in('.implode(',',$ids).')';
}else{
$where = 'p_id='.$ids;
}
$rst=Db::name('lc_th')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Lcmanager/bank_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Lcmanager/bank_list',array('p'=>$p)));
}
}
/**
* 投行状态修改
*/
public function bank_state()
{
$id=input('x');
$status=Db::name('lc_th')->where(array('p_id'=>$id))->value('p_status');
$count=Db::name('lc_th')->where(array('p_status'=>1))->count();
if($status==1){
$statedata = array('p_status'=>0);
Db::name('lc_th')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
if($count<4){
$statedata = array('p_status'=>1);
Db::name('lc_th')->where(array('p_id'=>$id))->setField($statedata);
$this->success('状态启用');
}else{
$this -> error("状态个数已达到!",url('admin/Lcmanager/bank_list'));
}
}
}
}

244
app/admin/controller/Lcwhcyb.php

@ -0,0 +1,244 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/27
* Time: 9:25
*/
namespace app\admin\controller;
use think\Db;
class Lcwhcyb extends Base
{
public $types=[
1=>[1=>'国有产权指定进场业务','文化和旅游产业专项债中介服务','文化产权登记托管平台','文化艺术资产托管','深圳市文化金融服务中心','区域股权中介服务','文化金融城市学院','','登记备案','托管转让','组织交易','交易见证'],
2=>[13=>'艺投资','艺术品资产管配','文化金融大讲堂','常态路演平台','上市公司艺术资产管理办公室','家族艺术资产管理办公室','深圳文化产权交易所俱乐部',],
];
/**
* 楼层文化产业列表
*/
public function whcyb_list()
{
//栏目
$whcyb_type='';
$whcyb_cid=input('cid','');
$this->assign('cid',$whcyb_cid);
$whcyb=Db::name('lc_whcyb')->where(['whcyb_cid'=>$whcyb_cid])->order('whcyb_sort desc,whcyb_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $whcyb->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('whcyb',$whcyb);
$this->assign('whcyb_type',$whcyb_type);
if(request()->isAjax()){
return $this->fetch('lc/ajax_lc_list');
}else{
return $this->fetch('lc/lc_list');
}
}
/**
* 添加显示
*/
public function whcyb_add()
{
$whcyb_cid=input('cid','');
$this->assign('types',$this->types[$whcyb_cid]);
$this->assign('cid',$whcyb_cid);
$whcyb_type=input('whcyb_type');
if (!request()->isAjax()){
$this->assign('whcyb_type',$whcyb_type);
return $this->fetch('lc/lc_add');
}else{
$type=input('whcyb_type');
$count = Db::name('lc_whcyb')->where(['whcyb_status'=>1,'whcyb_type'=>$type,'whcyb_cid'=>$whcyb_cid])->count();
if($count>=1){
$status=0;
}else{
$status=input('whcyb_status',0);
}
$name=$this->types[$whcyb_cid][$whcyb_type];
$sl_data=array(
'whcyb_name'=>$name,
'whcyb_sort'=>input('whcyb_sort'),
'whcyb_type'=>$type,
'whcyb_cid'=>$whcyb_cid,
'whcyb_status'=>$status,
'whcyb_time'=>input('whcyb_time','')?strtotime(input('whcyb_time','')):time(),
'whcyb_content'=>htmlspecialchars_decode(input('whcyb_content')),
'whcyb_uid'=>session('admin_auth.aid'),
);
$img_one=$this->_uploadOne();
//图片字段处理
if(!empty($img_one)){
$sl_data['whcyb_img']=$img_one;
}
$rst=Db::name('lc_whcyb')->insert($sl_data);
if($rst){
$this->success('新增成功',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}else{
$this->error('新增失败',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}
}
}
/**
* \删除(单个)
*/
public function whcyb_del()
{
$whcyb_cid=input('cid','');
$this->assign('cid',$whcyb_cid);
$type=input('whcyb_type');
$rst=Db::name('lc_whcyb')->delete(input('whcyb_id'));
if($rst!==false){
$this->success('删除成功',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}else{
$this -> error("删除失败!",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}
}
/**
* 删除(全选)
*/
public function whcyb_alldel()
{
$whcyb_cid=input('cid','');
$this->assign('cid',$whcyb_cid);
$type=input('whcyb_type');
$ids = input('whcyb_id/a');
if(empty($ids)){
$this -> error("请选择待删除的数据",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}
if(is_array($ids)){
$where = 'whcyb_id in('.implode(',',$ids).')';
}else{
$where = 'whcyb_id='.$ids;
}
$rst=Db::name('lc_whcyb')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}else{
$this -> error("删除失败!",url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}
}
/**
* 状态修改
*/
public function whcyb_state()
{
$whcyb_cid=input('cid','');
$this->assign('cid',$whcyb_cid);
$id=input('whcyb_id');
$status=Db::name('lc_whcyb')->where(array('whcyb_id'=>$id))->value('whcyb_status');
if($status==1){
$statedata = array('whcyb_status'=>0);
Db::name('lc_whcyb')->where(array('whcyb_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$type=input('whcyb_type');
$count = Db::name('lc_whcyb')->where(['whcyb_status'=>1,'whcyb_type'=>$type])->count();
if($count<1){
$statedata = array('whcyb_status'=>1);
Db::name('lc_whcyb')->where(array('whcyb_id'=>$id))->setField($statedata);
$this->success('已审');
}else{
$this -> error("状态个数已达到!",url('admin/Lcwhcyb/whcyb_list',['cid'=>$whcyb_cid]));
}
}
}
/**
* 上传单张图片
* @return string
*/
protected function _uploadOne(){
$validate = config('upload_validate');
$img_one='';
$file = request()->file('pic_one');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Gpgl/gp_list'));
}
}
return $img_one;
}
/**
* 排序
*/
public function whcyb_order()
{
$whcyb_cid=input('cid','');
$jumpParam=['cid'=>$whcyb_cid];
$jump=url('admin/Lcwhcyb/whcyb_list',$jumpParam);
if (!request()->isAjax()){
$this->error('提交方式不正确',$jump);
}else{
foreach (input('post.') as $n_id => $n_order){
Db::name('lc_whcyb')->update(['whcyb_id'=>$n_id,'whcyb_sort'=>$n_order]);
}
$this->success('排序更新成功',$jump);
}
}
//修改
public function whcyb_edit()
{
$whcyb_cid=input('cid','');
$this->assign('cid',$whcyb_cid);
$this->assign('types',$this->types[$whcyb_cid]);
if(!request()->isAjax()) {
$whcyb_id= input('whcyb_id', 0, 'intval');
if (!$whcyb_id) $this->error('参数错误', url('admin/Lcwhcyb/whcyb_list',['cid'=>$whcyb_cid]));
$gp_list = Db::name('lc_whcyb')->where('whcyb_id', $whcyb_id)->find();
$this->assign('gp_list',$gp_list);
return $this->fetch('lc/lc_edit');
}else{
$type=input('whcyb_type');
$name=$this->types[$whcyb_cid][$type];
$content=input('whcyb_content','','htmlspecialchars_decode');
$status=input('whcyb_status',0);
$sl_data=array(
'whcyb_name'=>$name,
'whcyb_id'=>input('whcyb_id'),
'whcyb_sort'=>input('whcyb_sort'),
'whcyb_type'=>$type,
'whcyb_cid'=>$whcyb_cid,
'whcyb_status'=>$status,
'whcyb_time'=>input('whcyb_time','')?strtotime(input('whcyb_time','')):time(),
'whcyb_content'=>$content,
'whcyb_uid'=>session('admin_auth.aid'),
);
$img_one=$this->_uploadOne();
//图片字段处理
if(!empty($img_one)){
$sl_data['whcyb_img']=$img_one;
}
$rst=Db::name('lc_whcyb')->update($sl_data);
$count = Db::name('lc_whcyb')->where(['whcyb_status'=>1,'whcyb_type'=>$type])->count();
if($count>1){
$rst=Db::name('lc_whcyb')->where(array('whcyb_id'=>input('whcyb_id')))->update(array('whcyb_status'=>0));
}
if($rst!==false){
$this->success('修改成功',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}else{
$this->error('修改失败',url('admin/Lcwhcyb/whcyb_list',['whcyb_type'=>$type,'cid'=>$whcyb_cid]));
}
}
}
}

100
app/admin/controller/License.php

@ -0,0 +1,100 @@
<?php
namespace app\admin\controller;
use think\Db;
use app\admin\model\Agency;
use think\Controller;
use think\db\Query;
class License extends Base
{
public function __construct(){
parent::__construct();
}
/**
* 列表
*/
public function index()
{
$map=array();
$admin_list=Db::name('license')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 修改
*/
public function edit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('license')->find(input('admin_id'));
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['state']=input('state');
$id=input('id');
$rst=Db::name('license')->where(['id'=>$id])->update($data);
if($rst!==false){
$this->success('修改成功',url('License/index',['kind'=>$kind]));
}else{
$this->error('修改失败',url('License/index',['kind'=>$kind]));
}
}
/**
* 删除
*/
public function del()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('License/index',['kind'=>$kind]));
}
$rst=Db::name('license')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('License/index',['kind'=>$kind]));
}else{
$this->error('删除失败',url('License/index',['kind'=>$kind]));
}
}
/**
* 审核/取消审核
*/
public function state()
{
$id=input('x');
$find=Db::name('license')->where(array('id'=>$id))->find();
$msg='未审';
if($find){
$status=$find['state'];
if($status==1){
$statedata = array('state'=>0);
}else{
$statedata = array('state'=>1);
$msg='已审';
}
$query=Db::name('license')->where(array('id'=>$id))->setField($statedata);
}
$this->success($msg);
}
}

250
app/admin/controller/Link.php

@ -0,0 +1,250 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Link extends Base
{
/**
* 链接列表
*/
public function link_list()
{
$lk_cid=input('cid',0,'intval');
$where['type_type']=14;
$where['lk_type']=14;
if($lk_cid){
$where['lk_cid']=$lk_cid;
}
$links=Db::name('link')->alias('a')
->join(config('database.prefix').'type b','a.lk_cid=b.type_id')
->where($where)->order('lk_order desc,lk_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $links->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('lk_cid',$lk_cid);
$this->assign('links',$links);
$this->assign('page',$show);
$lk_cids=Db::name('type')->where('type_type',14)->order('type_order')->select();
$this->assign('lk_cids',$lk_cids);
if(request()->isAjax()){
return $this->fetch('ajax_link_list');
}else{
return $this->fetch();
}
}
/**
* 添加显示
*/
public function link_add()
{
$lk_cid=input('cid',0,'intval');
if (!request()->isAjax()){
$lk_cids=Db::name('type')->where('type_type',14)->order('type_order')->select();
$this->assign('lk_cids',$lk_cids);
$this->assign('lk_cid',$lk_cid);
return $this->fetch();
}else{
//上传图片部分
$img_one='';
$file = request()->file('pic_one');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Link/link_list',['cid'=>$lk_cid]));//否则就是上传错误,显示错误原因
}
}
$sl_data=array(
'lk_name'=>input('lk_name'),
'lk_status'=>input('lk_status',0),
'lk_uid'=>session('admin_auth.aid'),
'lk_time'=>time(),
'lk_order'=>input('lk_order',50,'intval'),
'lk_url'=>input('lk_url'),
'lk_pic'=>$img_one,
'lk_cid'=>$lk_cid,
'lk_type'=>14
);
$rst=Db::name('link')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Link/link_list',['cid'=>$lk_cid]));
}else{
$this->error('添加失败',url('admin/Link/link_list',['cid'=>$lk_cid]));
}
}
}
/**
* 编辑显示
*/
public function link_edit()
{
$lk_cid=input('cid',0,'intval');
if (!request()->isAjax()) {
$lk_id = input('lk_id');
if (empty($lk_id)) {
if($lk_cid){
$this->error('参数错误', url('admin/Link/link_list',['cid'=>$lk_cid]));
}else{
$this->error('参数错误', url('admin/Link/link_list'));
}
}
$link_list = Db::name('link')->find($lk_id);
$lk_cids=Db::name('type')->where('type_type',14)->order('type_order')->select();
$this->assign('lk_cids',$lk_cids);
$this->assign('link_list', $link_list);
$this->assign('lk_cid',$link_list['lk_cid']);
return $this->fetch();
}else{
//上传图片部分
$img_one='';
$file = request()->file('pic_one');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Link/link_list',['cid'=>$lk_cid]));//否则就是上传错误,显示错误原因
}
}
$sl_data=array(
'lk_id'=>input('lk_id'),
'lk_name'=>input('lk_name'),
'lk_status'=>input('lk_status',0),
'lk_order'=>input('lk_order',50,'intval'),
'lk_url'=>input('lk_url'),
'lk_cid'=>$lk_cid
);
if(!empty($img_one)){
$sl_data['lk_pic']=$img_one;
}
$rst=Db::name('link')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Link/link_list',['cid'=>$lk_cid]));
}else{
$this->error('修改失败',url('admin/Link/link_list',['cid'=>$lk_cid]));
}
}
}
/**
* 排序
*/
public function link_order()
{
$lk_cid=input('cid',0,'intval');
if (!request()->isAjax()){
if($lk_cid){
$this->error('提交方式不正确', url('admin/Link/link_list',['cid'=>$lk_cid]));
}else{
$this->error('提交方式不正确', url('admin/Link/link_list'));
}
}else{
foreach (input('post.') as $lk_id => $lk_order){
Db::name('link')->update(['lk_id'=>$lk_id,'lk_order'=>$lk_order]);
}
if($lk_cid){
$this->success('排序更新成功',url('admin/Link/link_list',['cid'=>$lk_cid]));
}else{
$this->success('排序更新成功',url('admin/Link/link_list'));
}
}
}
/**
* 删除(单个)
*/
public function link_del()
{
$lk_cid=input('cid',0,'intval');
$p=input('p');
$rst=Db::name('link')->delete(input('lk_id'));
if($rst!==false){
if($lk_cid){
$this->success('删除成功',url('admin/Link/link_list',array('p'=>$p,'cid'=>$lk_cid)));
}else{
$this->success('删除成功',url('admin/Link/link_list',array('p'=>$p)));
}
}else{
if($lk_cid){
$this -> error("删除失败!",url('admin/Link/link_list',array('p'=>$p,'cid'=>$lk_cid)));
}else{
$this -> error("删除失败!",url('admin/Link/link_list',array('p'=>$p)));
}
}
}
/**
* 删除(全选)
*/
public function link_alldel()
{
$p = input('p');
$ids = input('lk_id/a');
$lk_cid=input('cid',0,'intval');
if(empty($ids)){
if($lk_cid){
$this -> error("请选择待删除数据",url('admin/Link/link_list',array('p'=>$p,'cid'=>$lk_cid)));
}else{
$this -> error("请选择待删除数据",url('admin/Link/link_list',array('p'=>$p)));
}
}
if(is_array($ids)){
$where = 'lk_id in('.implode(',',$ids).')';
}else{
$where = 'lk_id='.$ids;
}
$rst=Db::name('link')->where($where)->delete();
if($rst!==false){
if($lk_cid){
$this->success("删除成功",url('admin/Link/link_list',array('p'=>$p,'cid'=>$lk_cid)));
}else{
$this->success("删除成功",url('admin/Link/link_list',array('p'=>$p)));
}
}else{
if($lk_cid){
$this -> error("删除失败!",url('admin/Link/link_list',array('p'=>$p,'cid'=>$lk_cid)));
}else{
$this -> error("删除失败!",url('admin/Link/link_list',array('p'=>$p)));
}
}
}
/**
* 审核/取消审核
*/
public function link_state()
{
$id=input('x');
$status=Db::name('link')->where(array('lk_id'=>$id))->value('lk_status');
if($status==1){
$statedata = array('lk_status'=>0);
Db::name('link')->where(array('lk_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('lk_status'=>1);
Db::name('link')->where(array('lk_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

82
app/admin/controller/Login.php

@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Common;
use app\admin\model\Admin as AdminModel;
use think\Validate;
use think\captcha\Captcha;
class Login extends Common
{
protected function _initialize()
{
parent::_initialize();
}
/**
* 登录显示
*/
public function login()
{
// if(strcmp(input('key','123456'),'SZCAEECultureAdmin')!=0){
// $this->redirect('home/Index/index');//未登录
// }
if($this->check_admin_login()) $this->redirect('admin/Index/index');
return $this->fetch();
}
/**
* 验证码
*/
public function verify()
{
if($this->check_admin_login()) $this->redirect('admin/Index/index');
$config=config('verify');
$config['codeSet']='0123456789';
ob_end_clean();
$verify = new Captcha($config);
return $verify->entry('aid');
}
/**
* 登录验证
*/
public function runlogin()
{
if (!request()->isAjax()){
$this->error("提交方式错误!",url('admin/Login/login'));
}else{
if(config('geetest.geetest_on')){
if(!geetest_check(input('post.'))){
$this->error('验证不通过',url('admin/Login/login'));
};
}else{
$this->verify_check('aid');
}
$admin_username=input('admin_username');
$password=input('admin_pwd');
$rememberme=input('rememberme');
$admin=new AdminModel;
if($admin->login($admin_username,$password,$rememberme)){
$this->success('恭喜您,登陆成功',url('admin/Index/index'));
}else{
$this->error($admin->getError(),url('admin/Login/login'));
}
}
}
/**
* 退出登录
*/
public function logout()
{
session('admin_auth',null);
session('admin_auth_sign',null);
cookie('aid', null);
cookie('signin_token', null);
$this->redirect('admin/Login/login',['key'=>'SZCAEECultureAdmin']);
}
}

70
app/admin/controller/Lxwm.php

@ -0,0 +1,70 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Lxwm extends News
{
public function _initialize()
{
$this->table_name='lxwm';
$this->controller_name='Lxwm';
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 公告列表
*/
public function lxwm_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function lxwm_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function lxwm_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function lxwm_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function lxwm_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function lxwm_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function lxwm_state()
{
return $this->news_state();
}
}

341
app/admin/controller/Member.php

@ -0,0 +1,341 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use app\admin\model\MemberList;
class Member extends Base
{
/*
* 用户管理
*/
public function member_list(){
$key=input('key');
$opentype_check=input('opentype_check','');
$activetype_check=input('activetype_check','');
$membertype_check=input('membertype_check','');
$where=array();
if($opentype_check !== ''){
$where['member_list_open']=$opentype_check;
}
if($activetype_check !== ''){
$where['user_status']=$activetype_check;
}
if($membertype_check !== ''){
$where['member_list_groupid']=$membertype_check;
}
$member_model=new MemberList;
$member_list=$member_model->alias('a')->join(config('database.prefix').'member_group b','a.member_list_groupid=b.member_group_id')
->where($where)->where('member_list_username|member_list_tel|member_list_email|member_list_tel2|member_list_tel3','like',"%".$key."%")
->order('member_list_addtime desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show=$member_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('opentype_check',$opentype_check);
$this->assign('activetype_check',$activetype_check);
$this->assign('membertype_check',$membertype_check);
$this->assign('member_list',$member_list);
$this->assign('page',$show);
$this->assign('val',$key);
$member_group=Db::name('member_group')->order('member_group_order')->select();
$this->assign('groups',$member_group);
if(request()->isAjax()){
return $this->fetch('ajax_member_list');
}else{
return $this->fetch();
}
}
/*
* 添加用户显示
*/
public function member_add(){
$province = Db::name('Region')->where ( array('pid'=>1) )->select ();
$this->assign('province',$province);
$member_group=Db::name('member_group')->order('member_group_order')->select();
$this->assign('member_group',$member_group);
return $this->fetch();
}
/*
* 添加用户操作
*/
public function member_runadd(){
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Member/member_list'));
}else{
$member_list_salt=random(10);
$sl_data=array(
'member_list_groupid'=>input('member_list_groupid'),
'member_list_username'=>input('member_list_username'),
'first_pwd'=>input('first_pwd'),
'member_list_salt' => $member_list_salt,
'member_list_pwd'=>encrypt_password(input('member_list_pwd'),$member_list_salt),
'member_list_nickname'=>input('member_list_nickname'),
'member_list_province'=>input('member_list_province'),
'member_list_city'=>input('member_list_city'),
'member_list_town'=>input('member_list_town'),
'member_list_sex'=>input('member_list_sex'),
'member_list_tel'=>input('member_list_tel'),
'member_list_email'=>input('member_list_email'),
'member_list_open'=>input('member_list_open',0),
'user_url'=>input('user_url'),
'member_list_addtime'=>time(),
'user_status'=>input('user_status',0),
'signature'=>input('signature'),
'score'=>input('score',0,'intval'),
'coin'=>input('coin',0,'intval'),
);
$rst=MemberList::create($sl_data);
if($rst!==false){
$this->success('会员添加成功',url('admin/Member/member_list'));
}else{
$this->error('会员添加失败',url('admin/Member/member_list'));
}
}
}
/*
* 修改用户信息界面
*/
public function member_edit(){
$province = Db::name('Region')->where ( array('pid'=>1) )->select ();
$member_group=Db::name('member_group')->order('member_group_order')->select();
$member_list_edit=Db::name('member_list')->where(array('member_list_id'=>input('member_list_id')))->find();
$city=Db::name('Region')->where ( array('pid'=>$member_list_edit['member_list_province']) )->select ();
$town=Db::name('Region')->where ( array('pid'=>$member_list_edit['member_list_city']) )->select ();
$this->assign('member_list_edit',$member_list_edit);
$this->assign('province',$province);
$this->assign('city',$city);
$this->assign('town',$town);
$this->assign('member_group',$member_group);
return $this->fetch();
}
/*
* 修改用户操作
*/
public function member_runedit(){
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Member/member_list'));
}else{
$sl_data['member_list_id']=input('member_list_id');
$sl_data['member_list_groupid']=input('member_list_groupid');
$sl_data['member_list_username']=input('member_list_username');
$pwd=input('member_list_pwd');
if (!empty($pwd)){
$member_list_salt=random(10);
$sl_data['member_list_salt']=$member_list_salt;
$sl_data['member_list_pwd']=encrypt_password($pwd,$member_list_salt);
}
$sl_data['first_pwd']=input('first_pwd');
$sl_data['member_list_nickname']=input('member_list_nickname');
$sl_data['member_list_province']=input('member_list_province');
$sl_data['member_list_city']=input('member_list_city');
$sl_data['member_list_town']=input('member_list_town');
$sl_data['member_list_sex']=input('member_list_sex');
$sl_data['member_list_tel']=input('member_list_tel');
$sl_data['member_list_nickname2']=input('member_list_nickname2');
$sl_data['member_list_tel2']=input('member_list_tel2');
$sl_data['member_list_tel3']=input('member_list_tel3');
$sl_data['member_list_email']=input('member_list_email');
$sl_data['user_status']=input('user_status',0);
$sl_data['member_list_open']=input('member_list_open',0);
$sl_data['user_url']=input('user_url');
$sl_data['signature']=input('signature');
$sl_data['score']=input('score',0,'intval');
$sl_data['coin']=input('coin',0,'intval');
$rst=MemberList::update($sl_data);
if($rst!==false){
$this->success('会员修改成功',url('admin/Member/member_list'));
}else{
$this->error('会员修改失败',url('admin/Member/member_list'));
}
}
}
/*
* 会员禁止/取消禁止
*/
public function member_state(){
$id=input('x');
$member_model=new MemberList;
$status=$member_model->where(array('member_list_id'=>$id))->value('member_list_open');//判断当前状态情况
if($status==1){
$statedata = array('member_list_open'=>0);
$member_model->where(array('member_list_id'=>$id))->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('member_list_open'=>1);
$member_model->where(array('member_list_id'=>$id))->setField($statedata);
$this->success('状态开启');
}
}
/*
* 会员激活/取消激活
*/
public function member_active()
{
$id=input('x');
$member_model=new MemberList;
$status=$member_model->where(array('member_list_id'=>$id))->value('user_status');//判断当前状态情况
if($status==1){
$statedata = array('user_status'=>0);
$member_model->where(array('member_list_id'=>$id))->setField($statedata);
$this->success('未激活');
}else{
$statedata = array('user_status'=>1);
$member_model->where(array('member_list_id'=>$id))->setField($statedata);
$this->success('已激活');
}
}
/*
* 会员删除
*/
public function member_del()
{
$p=input('p');
$member_list_id=input('member_list_id');
$member_model=new MemberList;
$rst=Db::name('admin')->where('member_id',$member_list_id)->find();
if($rst){
$this->error('此会员已关联管理员,请从管理员处删除',url('admin/Member/member_list', array('p' => $p)));
}else{
$rst=$member_model->where(array('member_list_id'=>$member_list_id))->delete();
if($rst!==false){
$this->success('会员删除成功',url('admin/Member/member_list', array('p' => $p)));
}else{
$this->error('会员删除失败',url('admin/Member/member_list', array('p' => $p)));
}
}
}
/*
*会员组显示列表
*/
public function member_group_list()
{
$member_group=Db::name('member_group');
$member_group_list=$member_group->order('member_group_order')->select();
$this->assign('member_group_list',$member_group_list);
return $this->fetch();
}
/*
* 会员组添加方法
*/
public function member_group_runadd()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Member/member_group_list'));
}else{
$rst=Db::name('member_group')->insert(input('post.'));
if($rst!==false){
$this->success('会员组添加成功',url('admin/Member/member_group_list'));
}else{
$this->error('会员组添加失败',url('admin/Member/member_group_list'));
}
}
}
/*
* 会员组删除
*/
public function member_group_del()
{
$member_group_id=input('member_group_id');
if (empty($member_group_id)){
$this->error('会员组ID不存在',url('admin/Member/member_group_list'));
}
$rst=Db::name('member_group')->where(array('member_group_id'=>input('member_group_id')))->delete();
if($rst!==false){
$this->success('会员组删除成功',url('admin/Member/member_group_list'));
}else{
$this->error('会员组删除失败',url('admin/Member/member_group_list'));
}
}
/*
* 改变会员组状态
*/
public function member_group_state()
{
$member_group_id=input('x');
if (!$member_group_id){
$this->error('ID:'.$member_group_id.'不存在',url('admin/Member/member_group_list'));
}
$status=Db::name('member_group')->where(array('member_group_id'=>$member_group_id))->value('member_group_open');//判断当前状态情况
if($status==1){
$statedata = array('member_group_open'=>0);
Db::name('member_group')->where(array('member_group_id'=>$member_group_id))->setField($statedata);
$this->success('状态禁止');
}else{
$statedata = array('member_group_open'=>1);
Db::name('member_group')->where(array('member_group_id'=>$member_group_id))->setField($statedata);
$this->success('状态开启');
}
}
/*
* 排序更新
*/
public function member_group_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Member/member_group_list'));
}else{
$post=input('post.');
foreach ($post as $id => $sort){
Db::name('member_group')->where(array('member_group_id' => $id ))->setField('member_group_order' , $sort);
}
$this->success('排序更新成功',url('admin/Member/member_group_list'));
}
}
/*
* 修改会员组返回值
*/
public function member_group_edit()
{
$member_group_id=input('member_group_id');
$member_group=Db::name('member_group')->where(array('member_group_id'=>$member_group_id))->find();
$sl_data['member_group_id']=$member_group['member_group_id'];
$sl_data['member_group_name']=$member_group['member_group_name'];
$sl_data['member_group_open']=$member_group['member_group_open'];
//$sl_data['member_group_toplimit']=$member_group['member_group_toplimit'];
//$sl_data['member_group_bomlimit']=$member_group['member_group_bomlimit'];
$sl_data['member_group_order']=$member_group['member_group_order'];
$sl_data['code']=1;
return json($sl_data);
}
/*
* 修改用户组方法
*/
public function member_group_runedit()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Member/member_group_list'));
}else{
$sl_data=array(
'member_group_id'=>input('member_group_id'),
'member_group_name'=>input('member_group_name'),
//'member_group_toplimit'=>input('member_group_toplimit'),
//'member_group_bomlimit'=>input('member_group_bomlimit'),
'member_group_order'=>input('member_group_order'),
);
$rst=Db::name('member_group')->update($sl_data);
if($rst!==false){
$this->success('会员组修改成功',url('admin/Member/member_group_list'));
}else{
$this->error('会员组修改失败',url('admin/Member/member_group_list'));
}
}
}
}

331
app/admin/controller/Menu.php

@ -0,0 +1,331 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use app\admin\model\Menu as MenuModel;
use app\admin\model\Options as OptionsModel;
class Menu extends Base
{
public function _initialize()
{
parent::_initialize();
}
/**
* 前台菜单列表
*/
public function news_menu_list()
{
$menu_l=input('menu_l');
$where=array();
if(!empty($menu_l)){
$where['menu_l']=array('eq',$menu_l);
}
if(!config('lang_switch_on')){
$where['menu_l']= $this->lang;
}
$menu_model=new MenuModel;
$menus=$menu_model->where($where)->order('menu_l Desc,listorder')->select();
//$menus=get_menu_model($menus);
$show='';
$arr = menu_left($menus,'id','parentid');
$this->assign('arr',$arr);
$this->assign('menu_l',$menu_l);
$this->assign('page',$show);
if(request()->isAjax()){
return $this->fetch('ajax_news_menu_list');
}else{
return $this->fetch();
}
}
/**
* 前台菜单添加显示
*/
public function news_menu_add()
{
$parentid=input('id',0);
//id不为0,取lang
$menu_l='';
$menu_model=new MenuModel;
if($parentid){
$menu_l=$menu_model->where('id',$parentid)->value('menu_l');
}
$where=array();
if(!empty($menu_l)){
$where['menu_l']=array('eq',$menu_l);
}
if(!config('lang_switch_on')){
$where['menu_l']= $this->lang;
}
$options_model=new OptionsModel;
$tpls=$options_model->tpls($this->lang);
$model='';//Db::name('model')->select();
$this->assign('model',$model);
$menu_text=$menu_model->where($where)->order('menu_l Desc,listorder')->select();
$menu_text = menu_left($menu_text,'id','parentid');
$this->assign('menu_text',$menu_text);
$this->assign('parentid',$parentid);
$this->assign('menu_l',$menu_l);
$this->assign('tpls',$tpls);
return $this->fetch();
}
/**
* 前台菜单添加操作
*/
public function news_menu_runadd()
{
$lang_list=input('lang_list');
if(empty($lang_list)) $lang_list=input('menu_l',$this->lang);
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}else{
//处理图片
$img_url='';
$file = request()->file('file0');
if($file){
if(config('storage.storage_open')){
//七牛
$upload = \Qiniu::instance();
$info = $upload->upload();
$error = $upload->getError();
if ($info) {
$img_url= config('storage.domain').$info[0]['key'];
}else{
$this->error($error,url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}
}else{
$validate=config('upload_validate');
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if($info) {
$img_url=config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime']=time();
$data['filesize']=$info->getSize();
$data['path']=$img_url;
Db::name('plug_files')->insert($data);
}else{
$this->error($file->getError(),url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}
}
}
//处理语言
$parentid=input('parentid',0,'intval');
if($parentid){
$menu_l=Db::name('menu')->where('id',$parentid)->value('menu_l');
}else{
$menu_l=input('menu_l',$this->lang);
}
//构建数组
$data=array(
'menu_name'=>input('menu_name'),
'menu_l'=>$menu_l,
'menu_enname'=>input('menu_enname'),
'menu_type'=>input('menu_type'),
'menu_modelid'=>input('menu_modelid',0,'intval'),
'parentid'=>$parentid,
'menu_listtpl'=>input('menu_listtpl'),
'menu_newstpl'=>input('menu_newstpl'),
'menu_address'=>input('menu_address'),
'menu_open'=>input('menu_open',0),
'top'=>input('top',1),
'listorder'=>input('listorder'),
'menu_seo_title'=>input('menu_seo_title'),
'menu_seo_key'=>input('menu_seo_key'),
'menu_seo_des'=>input('menu_seo_des'),
'menu_target'=>input('menu_target'),
'menu_content'=>htmlspecialchars_decode(input('menu_content')),
'menu_img'=>$img_url,
);
$rst=MenuModel::create($data);
$menu_model=new MenuModel;
if($rst!==false){
$arr=MenuModel::get(input('parentid'));
if(input('menu_type')==3 && $arr['menu_type']==3){
$menu_model->where(array('id'=>input('parentid')))->setField('menu_type',1);
}
cache('site_nav_main',null);
$this->success('菜单添加成功',url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}else{
$this->error('菜单添加失败',url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}
}
}
/**
* 前台菜单编辑显示
*/
public function news_menu_edit()
{
$menu=MenuModel::get(input('id'));
$options_model=new OptionsModel;
$tpls=$options_model->tpls($this->lang);
$model='';//Db::name('model')->select();
$this->assign('model',$model);
$where=array();
$where['menu_l']=array('eq',$menu['menu_l']);
if(!config('lang_switch_on')){
$where['menu_l']= $this->lang;
}
$menu_text=Db::name('menu')->where($where)->order('menu_l Desc,listorder')->select();
$menu_text = menu_left($menu_text,'id','parentid');
$this->assign('menu_text',$menu_text);
$this->assign('menu',$menu);
$this->assign('tpls',$tpls);
return $this->fetch();
}
/**
* 前台菜单编辑操作
*/
public function news_menu_runedit()
{
$lang_list=input('lang_list');
if(empty($lang_list)) $lang_list=input('menu_l',$this->lang);
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}else{
$checkpic=input('checkpic');
$oldcheckpic=input('oldcheckpic');
$img_url='';
if ($checkpic!=$oldcheckpic){
$file = request()->file('file0');
if($file){
if(config('storage.storage_open')){
//七牛
$upload = \Qiniu::instance();
$info = $upload->upload();
$error = $upload->getError();
if ($info) {
$img_url= config('storage.domain').$info[0]['key'];
}else{
$this->error($error,url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));//否则就是上传错误,显示错误原因
}
}else{
$validate=config('upload_validate');
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if($info) {
$img_url=config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime']=time();
$data['filesize']=$info->getSize();
$data['path']=$img_url;
Db::name('plug_files')->insert($data);
}else{
$this->error($file->getError(),url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}
}
}
}
//处理语言
$parentid=input('parentid',0,'intval');
if($parentid){
$menu_l=Db::name('menu')->where('id',$parentid)->value('menu_l');
}else{
$menu_l=input('menu_l',$this->lang);
}
$data=array(
'id'=>input('id'),
'menu_name'=>input('menu_name'),
'menu_enname'=>input('menu_enname'),
'menu_type'=>input('menu_type'),
'menu_modelid'=>input('menu_modelid',0,'intval'),
'parentid'=>$parentid,
'menu_l'=>$menu_l,
'menu_listtpl'=>input('menu_listtpl'),
'menu_newstpl'=>input('menu_newstpl'),
'menu_address'=>input('menu_address'),
'menu_open'=>input('menu_open',0),
'top'=>input('top',1),
'listorder'=>input('listorder'),
'menu_seo_title'=>input('menu_seo_title'),
'menu_seo_key'=>input('menu_seo_key'),
'menu_seo_des'=>input('menu_seo_des'),
'menu_target'=>input('menu_target'),
'menu_content'=>htmlspecialchars_decode(input('menu_content')),
);
if ($checkpic!=$oldcheckpic){
$data['menu_img']=$img_url;
}
$rst=MenuModel::update($data);
if($rst!==false){
cache('site_nav_main',null);
cache('site_nav',null);
$this->success('菜单修改成功',url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}else{
$this->error('菜单修改失败',url('admin/Menu/news_menu_list',array('menu_l'=>$lang_list)));
}
}
}
/**
* 前台菜单删除
*/
public function news_menu_del()
{
$lang_list=input('lang_list');
$id=input('id');
$arr=MenuModel::get($id);
$model_id=$arr['menu_modelid'];
$parentid=$arr['parentid'];
$parent_arr=MenuModel::get($parentid);
$ids=get_menu_byid($id,1,2);//返回含自身id及子菜单id数组
$rst=MenuModel::destroy($ids);
$menu_model=new MenuModel;
//处理父级
if($rst!==false){
//判断其父菜单是否还存在子菜单,如无子菜单,且父菜单类型为1
if($parentid && $parent_arr['menu_type']==1){
$child=$menu_model->where(array('parentid'=>$parentid))->select();
if(empty($child)){
$menu_model->where(array('id'=>$parentid))->update(['menu_type'=>3,'menu_modelid'=>$model_id]);
}
}
cache('site_nav_main',null);
$this->success('菜单删除成功',url('admin/Menu/news_menu_list',['menu_l'=>$lang_list]));
}else{
$this -> error("菜单删除失败!",url('admin/Menu/news_menu_list',['menu_l'=>$lang_list]));
}
}
/**
* 前台菜单排序
*/
public function news_menu_order(){
$lang_list=input('lang_list');
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Menu/news_menu_list',['menu_l'=>$lang_list]));
}else{
$list=[];
foreach (input('post.') as $id => $sort){
$list[]=['id'=>$id,'listorder'=>$sort];
}
$menu_model=new MenuModel;
$menu_model->saveAll($list);
cache('site_nav_main',null);
$this->success('排序更新成功',url('admin/Menu/news_menu_list',['menu_l'=>$lang_list]));
}
}
/**
* 前台菜单开启/禁止
*/
public function news_menu_state()
{
$id=input('x');
$menu_model=new MenuModel;
$status=$menu_model->where(array('id'=>$id))->value('menu_open');//判断当前状态情况
if($status==1){
$statedata = array('menu_open'=>0);
$menu_model->where(array('id'=>$id))->setField($statedata);
cache('site_nav_main',null);
$this->success('状态禁止');
}else{
$statedata = array('menu_open'=>1);
$menu_model->where(array('id'=>$id))->setField($statedata);
cache('site_nav_main',null);
$this->success('状态开启');
}
}
}

713
app/admin/controller/News.php

@ -0,0 +1,713 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class News extends Base
{
protected $table_name='news';
protected $controller_name='news';
protected $has_img=true;
protected $has_imgs=true;
protected $has_source=true;
public function _initialize()
{
parent::_initialize();
$this->assign('table_name',$this->table_name);
$this->assign('controller',$this->controller_name);
$this->assign('has_img',$this->has_img);
$this->assign('has_imgs',$this->has_imgs);
$this->assign('has_source',$this->has_source);
}
/**
* 删除(单个)
*/
public function apply_del()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p=input('p');
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/apply_list',$jumpParam);
$rst=Db::name('apply')->delete(input('n_id'));
if($rst!==false){
$this->success('删除成功',$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 删除(全选)
*/
public function apply_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('n_id/a');
$n_cid=input('cid',0,'intval');
$n_kind=input('kind','','intval');
$jumpParam=['kind'=>$n_kind,'p' => $p,'cid'=>$n_cid,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/apply_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('apply')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 编辑显示
*/
public function apply_edit()
{
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$jumpParam=['kind'=>$n_kind,'cid'=>$n_cid,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/apply_list',$jumpParam);
$n_id = input('id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$this->assign('n_cid', $n_cid);
$this->assign('n_kind', $n_kind);
$news_list = Db::name('apply')->find($n_id);
$poster=$news_list['cred_poster'];
if($poster){
$news_list['cred_poster']=explode(';', $poster);
}
$this->assign('list', $news_list);
return $this->fetch('apply/news_edit');
}
public function apply_list(){
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$page=input('page',1,'intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$this->assign('n_kind',$n_kind);
$where=[];
if($n_cid)$where['cid']=$n_cid;
if($n_kind)$where['kind']=$n_kind;
$news=Db::name('apply')->where($where)->order(['create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
$show = $news->render();
$this->assign('pageshow',$show);
$this->assign('news',$news);
$this->assign('n_cid',$n_cid);
if(request()->isAjax()){
return $this->fetch('apply/ajax_news_list'.$n_cid);
}else{
return $this->fetch('apply/news_list'.$n_cid);
}
}
/**
* 导出名单
*/
public function export(){
$id=input('cid');
$kind=input('kind',1);
if(empty($kind))$this->error("请选择平台");
$map=['cid'=>$id,'kind'=>$kind];
$applys=Db::name('apply')->where($map)->select();
$expTitle="古建收藏俱乐部申请表(机构)";
if($id==2)$expTitle="古建收藏俱乐部申请表(个人)";
$expCellName=[];
if($id==1){
array_push($expCellName,['org_name','机构名称']);
array_push($expCellName,['org_code','机构信用代码']);
array_push($expCellName,['address','联系地址']);
array_push($expCellName,['username','法人代表人']);
array_push($expCellName,['cred_num','身份证号码']);
array_push($expCellName,['contact','联系人']);
array_push($expCellName,['mobile','联系电话']);
array_push($expCellName,['direction','古建收藏或意向投资方向']);
array_push($expCellName,['org_desc','机构简介']);
}
if($id==2){
array_push($expCellName,['username','姓名']);
array_push($expCellName,['cred_type','证件类型']);
array_push($expCellName,['cred_num','证件号码']);
array_push($expCellName,['address','联系地址']);
array_push($expCellName,['contact','联系人']);
array_push($expCellName,['mobile','联系电话']);
array_push($expCellName,['join_year','古建收藏/投资经验']);
array_push($expCellName,['infor','古建藏品介绍']);
array_push($expCellName,['experience','个人简介']);
}
array_push($expCellName,['create_time','报名时间','','date']);
foreach ($applys as &$row){
$ctype=$row['cred_type'];
if($ctype==1)$ctype="身份证";
if($ctype==2)$ctype="护照";
if($ctype==3)$ctype="军人证";
$row['cred_type']=$ctype;
}
$expTableData=$applys;
$res=exportExcel($expTitle,$expCellName,$expTableData);
}
/**
* 删除(单个)
*/
public function buildapply_del()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p=input('p');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/buildapply_list',$jumpParam);
$rst=Db::name('buildapply')->delete(input('id'));
if($rst!==false){
$this->success('删除成功',$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 删除(全选)
*/
public function buildapply_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('n_id/a');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/buildapply_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('buildapply')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 编辑显示
*/
public function buildapply_edit()
{
$page=input('page','','intval');
$this->assign('page',$page);
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/buildapply_list',$jumpParam);
$n_id = input('id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$news_list = Db::name('buildapply')->find($n_id);
$poster=$news_list['closepic'];
if($poster){
$news_list['closepic']=explode(';', $poster);
}
$style=$news_list['style'];
if($style){
$temp=['A'=>[],'B'=>[],'C'=>[],'D'=>[]];
try {
$style=json_decode($style,true);
} catch (Exception $e) {
$style=array();
}
if(!is_array($style))$style=[];
$temp=array_merge($temp,$style);
$news_list['style']=$temp;
}else{
$news_list['style']=['A'=>[],'B'=>[],'C'=>[],'D'=>[]];
}
$poster=$news_list['visionpic'];
if($poster){
$news_list['visionpic']=explode(';', $poster);
}
$poster=$news_list['allpic'];
if($poster){
$news_list['allpic']=explode(';', $poster);
}
$poster=$news_list['planepic'];
if($poster){
$news_list['planepic']=explode(';', $poster);
}
$service=$news_list['tgservice'];
if($service){
$news_list['tgservice']=explode(';', $service);
}else{
$news_list['tgservice']=[];
}
$service=$news_list['mgservice'];
if($service){
$news_list['mgservice']=explode(';', $service);
}else{
$news_list['mgservice']=[];
}
$service=$news_list['tfservice'];
if($service){
$news_list['tfservice']=explode(';', $service);
}else{
$news_list['tfservice']=[];
}
$service=$news_list['useservice'];
if($service){
$news_list['useservice']=explode(';', $service);
}else{
$news_list['useservice']=[];
}
$this->assign('list', $news_list);
return $this->fetch('apply/build_edit');
}
public function buildapply_list(){
$page=input('page',1,'intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$where=[];
$news=Db::name('buildapply')->where($where)->order(['create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
$show = $news->render();
$this->assign('pageshow',$show);
$this->assign('news',$news);
if(request()->isAjax()){
return $this->fetch('apply/ajax_build_list');
}else{
return $this->fetch('apply/build_list');
}
}
/**
* 删除(单个)
*/
public function cultureapply_del()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p=input('p');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/cultureapply_list',$jumpParam);
$rst=Db::name('cultureapply')->delete(input('id'));
if($rst!==false){
$this->success('删除成功',$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 删除(全选)
*/
public function cultureapply_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('n_id/a');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/cultureapply_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('cultureapply')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 编辑显示
*/
public function cultureapply_edit()
{
$page=input('page','','intval');
$this->assign('page',$page);
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/cultureapply_list',$jumpParam);
$n_id = input('id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$news_list = Db::name('cultureapply')->find($n_id);
$legal=$news_list['legal'];
if($legal){
$news_list['legal']=json_decode($legal);
}
$org=$news_list['org'];
if($org){
$news_list['org']=json_decode($org);
}
$cont=$news_list['cont'];
if($cont){
$news_list['cont']=json_decode($cont);
}
$this->assign('list', $news_list);
return $this->fetch('apply/culture_edit');
}
public function cultureapply_list(){
$page=input('page',1,'intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$where=[];
$news=Db::name('cultureapply')->where($where)->order(['create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
$show = $news->render();
$this->assign('pageshow',$show);
$this->assign('news',$news);
if(request()->isAjax()){
return $this->fetch('apply/ajax_culture_list');
}else{
return $this->fetch('apply/culture_list');
}
}
/**
* 列表
*/
public function news_list()
{
//栏目
$search_name=input('search_name','','trim');
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$page=input('page','','intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$this->assign('n_kind',$n_kind);
$this->assign('search_name',$search_name);
$where=[];
if($n_cid)$where['n_cid']=$n_cid;
if($n_kind)$where['n_kind']=$n_kind;
if($search_name){
$where['n_title|n_content']=array('like',['%'.$search_name.'%','%'.$search_name,$search_name.'%',$search_name],'or');
}
$order=['n_order'=>'asc','n_time'=>'desc'];
if($this->table_name=='bsgg'||$this->table_name=='bsyw'){
$order=['n_top'=>'desc','n_order'=>'asc','n_time'=>'desc'];
}
$query=get_query();
if(isset($query)&&$page){
$query['page']=$page;
}
$news=Db::name($this->table_name)->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>$query]);
$show = $news->render();
$this->assign('pageshow',$show);
$this->assign('news',$news);
$this->assign('n_cid',$n_cid);
if(request()->isAjax()){
return $this->fetch('news/ajax_news_list');
}else{
return $this->fetch('news/news_list');
}
}
/**
* 添加显示
*/
public function news_add()
{
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
if (!request()->isAjax()){
//栏目
$this->assign('n_cid',$n_cid);
$source=Db::name('source')->select();
$this->assign('source',$source);
$source=Db::name('finance')->field('c_id,c_name')->where(['c_status'=>1,'c_kind'=>4])->select();
$keys=array_column($source,'c_id');
$vals=array_column($source,'c_name');
$source=array_combine($keys, $vals);
$this->assign('flist',$source);
$this->assign('fjson',json_encode($source));
$this->assign('tablename',$this->table_name);
return $this->fetch('news/news_add');
}else{
//上传图片部分
$img_one='';
$picall_url='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
$jumpParam=['cid'=>$n_cid,'page'=>$page];
if($this->table_name!='bsgg'){
$jumpParam['kind']=$n_kind;
}
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
$n_time=input('n_time','');
if(empty($n_time))$n_time=time();
else $n_time=strtotime($n_time);
$ret=$this->dealFile($file,$files);
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
if(isset($ret['picall_url'])&&$ret['picall_url'])$picall_url=$ret['picall_url'];
}
$n_pids=isset($_POST['n_pids'])?$_POST['n_pids']:'';
$n_order=input('n_order','','intval');
$ncid=input('n_cid','','intval');
if($ncid)$n_cid=$ncid;
$sl_data=array(
'n_title'=>input('n_title'),
'n_cid'=>$n_cid,
'n_source'=>input('n_source',''),
'n_pics'=>$picall_url,//多图路径
'n_img'=>$img_one,//封面图片路径
'n_status'=>input('n_status',0),
'n_desc'=>input('n_desc',''),
'n_content'=>htmlspecialchars_decode(input('n_content')),
'n_uid'=>session('admin_auth.aid'),
'n_time'=>$n_time,
'n_order'=>$n_order,
);
if($n_pids)$sl_data['n_pids']=is_array($n_pids)?implode(';',$n_pids):'';
if($n_kind)$sl_data['n_kind']=$n_kind;
$n_top=input('n_top',0,'intval');
if($n_top!=='')$sl_data['n_top']=$n_top;
$rst=Db::name($this->table_name)->insert($sl_data);
$this->assign('tablename',$this->table_name);
if($rst){
if(empty($n_order)){
$lastId=Db::name($this->table_name)->getLastInsID();
Db::name($this->table_name)->where(['n_id'=>$lastId])->update(['n_order'=>$lastId]);
}
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
}
/**
* 编辑显示
*/
public function news_edit()
{
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['cid'=>$n_cid,'page'=>$page];
if($this->table_name!='bsgg'){
$jumpParam['kind']=$n_kind;
}
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
if (!request()->isAjax()) {
$n_id = input('n_id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$this->assign('n_cid', $n_cid);
$source=Db::name('finance')->field('c_id,c_name')->where(['c_status'=>1,'c_kind'=>4])->select();
$keys=array_column($source,'c_id');
$vals=array_column($source,'c_name');
$source=array_combine($keys, $vals);
$this->assign('flist',$source);
$this->assign('fjson',json_encode($source));
$news_list = Db::name($this->table_name)->find($n_id);
if(isset($news_list['n_pids'])){
$pids = array_filter(explode(";", $news_list['n_pids']));
$this->assign('pids',json_encode($pids));
}else{
$this->assign('pids',json_encode([]));
}
//多图字符串转换成数组
$pic_list = array_filter(explode(",", $news_list['n_pics']));
$this->assign('pic_list', $pic_list);
$source = Db::name('source')->select();//来源
$this->assign('source', $source);
$this->assign('news_list', $news_list);
$this->assign('tablename',$this->table_name);
return $this->fetch('news/news_edit');
}else{
$pic_oldlist=input('pic_oldlist');//老多图字符串
$img_one='';
$picall_url='';
$file = request()->file('pic_one');
$files = request()->file('pic_all');
//单图
$ret=$this->dealFile($file,$files);
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
if(isset($ret['picall_url'])&&$ret['picall_url'])$picall_url=$ret['picall_url'];
}
$n_pids=isset($_POST['n_pids'])?$_POST['n_pids']:'';
$sl_data=array(
'n_id'=>input('n_id'),
'n_title'=>input('n_title'),
'n_source'=>input('n_source',''),
'n_status'=>input('n_status',0),
'n_desc'=>input('n_desc',''),
'n_content'=>htmlspecialchars_decode(input('n_content')),
'n_order'=>input('n_order',50,'intval'),
);
if($n_pids){
$sl_data['n_pids']=is_array($n_pids)?implode(';',$n_pids):'';
}
$ncid=input('n_cid','','intval');
if($ncid)$sl_data['n_cid']=$ncid;
$n_time=input('n_time','');
if($n_time)$sl_data['n_time']=strtotime($n_time);
if($n_kind)$sl_data['n_kind']=$n_kind;
$n_top=input('n_top',0,'intval');
if($n_top!=='')$sl_data['n_top']=$n_top;
//图片字段处理
if(!empty($img_one)){
$sl_data['n_img']=$img_one;
}
$sl_data['n_pics']=$pic_oldlist.$picall_url;
$rst=Db::name($this->table_name)->update($sl_data);
$this->assign('tablename',$this->table_name);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
}
/**
* 排序
*/
public function news_order()
{
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
if (!request()->isAjax()){
$this->error('提交方式不正确',$jump);
}else{
foreach (input('post.') as $n_id => $n_order){
Db::name($this->table_name)->update(['n_id'=>$n_id,'n_order'=>$n_order]);
}
$this->success('排序更新成功',$jump);
}
}
/**
* 删除(单个)
*/
public function news_del()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p=input('p');
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
$rst=Db::name($this->table_name)->delete(input('n_id'));
if($rst!==false){
$this->success('删除成功',$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 删除(全选)
*/
public function news_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('n_id/a');
$n_cid=input('cid',0,'intval');
$n_kind=input('kind',0,'intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'n_id in('.implode(',',$ids).')';
}else{
$where = 'n_id='.$ids;
}
$rst=Db::name($this->table_name)->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 审核/取消审核
*/
public function news_state()
{
$id=input('x');
$status=Db::name($this->table_name)->where(array('n_id'=>$id))->value('n_status');
if($status==1){
$statedata = array('n_status'=>0);
Db::name($this->table_name)->where(array('n_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('n_status'=>1);
Db::name($this->table_name)->where(array('n_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

72
app/admin/controller/Nwwd.php

@ -0,0 +1,72 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Nwwd extends News
{
public function _initialize()
{
$this->table_name='nwwd';
$this->controller_name='Nwwd';
$this->has_source=false;
$this->has_imgs=false;
parent::_initialize();
}
/**
* 公告列表
*/
public function nwwd_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function nwwd_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function nwwd_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function nwwd_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function nwwd_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function nwwd_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function nwwd_state()
{
return $this->news_state();
}
}

62
app/admin/controller/Page.php

@ -0,0 +1,62 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Request;
class Page extends Base{
public function index(){
$kind=input('kind');
$this->assign('kind',$kind);
if (request()->isAjax()){
$id=input('id');
$jumpParam=['kind'=>$kind];
$jump=url('index',$jumpParam);
$n_order=input('sort','','intval');
$sl_data=array(
'title'=>input('title'),
'status'=>input('status',0),
'infor'=>input('infor',''),
'content'=>htmlspecialchars_decode(input('content')),
'uid'=>session('admin_auth.aid'),
'create_time'=>time(),
'sort'=>$n_order,
);
if($kind)$sl_data['kind']=$kind;
if($id){
unset($sl_data["create_time"]);
$rst=Db::name("page")->where(['id'=>$id])->update($sl_data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}else{
$rst=Db::name("page")->insert($sl_data);
if($rst){
if(empty($n_order)||$n_order==50){
$lastId=Db::name("page")->getLastInsID();
Db::name("page")->where(['id'=>$lastId])->update(['sort'=>$lastId]);
}
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
}else{
$page=Db::name("page")->where(['kind'=>$kind])->find();
$this->assign('page',$page);
}
return $this->fetch();
}
}

460
app/admin/controller/Plug.php

@ -0,0 +1,460 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Validate;
class Plug extends Base
{
protected $files_res_exists;
protected $files_res_used;
protected $files_unused;
/*
* 留言列表
* @author rainfer <81818832@qq.com>
*/
public function plug_sug_list()
{
$plug_sug=Db::name('plug_sug')->order('plug_sug_open,plug_sug_addtime desc')->paginate(config('paginate.list_rows'));
$show=$plug_sug->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('plug_sug',$plug_sug);
$this->assign('page',$show);
if(request()->isAjax()){
return $this->fetch('ajax_plug_sug_list');
}else{
return $this->fetch();
}
}
/*
* 留言回复返回数据
* @author rainfer <81818832@qq.com>
*/
public function plug_sug_reply()
{
$plug_sug_id=input('plug_sug_id');
$plug_sug=Db::name('plug_sug')->where(array('plug_sug_id'=>$plug_sug_id))->find();
$rule = [
['plug_sug_email','require|email','留言邮箱为空|留言邮箱格式不正确'],
];
$validate = new Validate($rule);
$rst = $validate->check(array(
'plug_sug_email'=>$plug_sug['plug_sug_email']
));
if(true !==$rst){
$sl_data['code']=0;
$sl_data['msg']=$validate->getError();
}else{
$sl_data['plug_sug_email']=$plug_sug['plug_sug_email'];
$sl_data['plug_sug_name']=$plug_sug['plug_sug_name'];
$sl_data['plug_sug_id']=$plug_sug['plug_sug_id'];
$sl_data['code']=1;
}
return json($sl_data);
}
/*
* 留言回复
* @author rainfer <81818832@qq.com>
*/
public function plug_sug_runreply()
{
$email=input('plug_sug_toemail');
$name=input('plug_sug_toname');
$plug_sug_id=input('plug_sug_id');
$content=htmlspecialchars_decode(input('plug_sug_replycontent'));
$send_result=sendMail($email,"Reply:". $name, $content);
if($send_result['error']){
$this->error('邮箱设置不正确或对方邮箱地址不存在',url('admin/Plug/plug_sug_list'));
}else{
$rst=Db::name('plug_sug')->where('plug_sug_id',$plug_sug_id)->setField('plug_sug_open',1);
if($rst!==false){
$this->success('回复留言成功',url('admin/Plug/plug_sug_list'));
}else{
$this->error('回复留言失败',url('admin/Plug/plug_sug_list'));
}
}
}
/*
* 留言删除
* @author rainfer <81818832@qq.com>
*/
public function plug_sug_del()
{
$p = input('p');
$plug_sug_id=input('plug_sug_id');
$rst=Db::name('plug_sug')->where(array('plug_sug_id'=>$plug_sug_id))->delete();
if($rst!==false){
$this->success('留言删除成功',url('admin/Plug/plug_sug_list',array('p'=>$p)));
}else{
$this->error('留言删除失败',url('admin/Plug/plug_sug_list',array('p'=>$p)));
}
}
/*
* 留言删除(全选)
* @author rainfer <81818832@qq.com>
*/
public function plug_sug_alldel()
{
$p = input('p');
$ids = input('sug_id/a');
if(empty($ids)){
$this -> error("请选择删除留言",url('admin/Plug/plug_sug_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'plug_sug_id in('.implode(',',$ids).')';
}else{
$where = 'plug_sug_id='.$ids;
}
$rst=Db::name('plug_sug')->where($where)->delete();
if($rst!==false){
$this->success("留言删除成功!",url('admin/Plug/plug_sug_list',array('p'=>$p)));
}else{
$this -> error("删除留言失败!",url('admin/Plug/plug_sug_list',array('p' => $p)));
}
}
/*
* 本地文件列表
* @author rainfer <81818832@qq.com>
*/
public function plug_file_list()
{
$map=array();
//查询:时间格式过滤
$sldate=input('reservation','');//获取格式 2015-11-12 - 2015-11-18
$arr = explode(" - ",$sldate);//转换成数组
if(count($arr)==2){
$arrdateone=strtotime($arr[0]);
$arrdatetwo=strtotime($arr[1].' 23:55:55');
$map['uptime'] = array(array('egt',$arrdateone),array('elt',$arrdatetwo),'AND');
}
//查询文件路径
$val=input('val');
if(!empty($val)){
$map['path']= array('like',"%".$val."%");
}
$plug_files=Db::name('plug_files')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $plug_files->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('plug_files',$plug_files);
$this->assign('sldate',$sldate);
$this->assign('val',$val);
if(request()->isAjax()){
return $this->fetch('ajax_plug_file_list');
}else{
return $this->fetch();
}
}
/**
* 文件过滤
*/
public function plug_file_filter()
{
//获取本地文件数组,'./data/upload/2016-01-21/56a03ff96b6ff.jpg' => int 224138
$file_list=list_file('data/upload');
$path="/data/upload/";
$this->files_res_exists=array();
foreach ($file_list as $a){
if ($a ['isDir']) {
foreach (list_file($a ['pathname'] . '/') as $d) {
if (!$d ['isDir']) {
//文件
if($d['ext']!='html' && $d['ext']!='lock'){
$this->files_res_exists [$path . $a ['filename'] . '/' . $d ['filename']] = $d ['size'];
}
}
}
}
}
//获取数据表datafile已存记录,并删除资源数组里的成员,完毕后得到未存入数据表datafile的资源文件
$datas = Db::name('plug_files')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
$f = $d ['path'];
if (isset ($this->files_res_exists [$f])) {
unset ($this->files_res_exists [$f]);
}
}
}
//未存入数据表的数据写入数据表
$time=time();
foreach ($this->files_res_exists as $d => $v) {
Db::name('plug_files')->insert(array(
'path' => $d,
'uptime' => $time,
'filesize' => $v
));
}
//获取利用到的资源文件
$this->files_res_used=array();
//avatar,涉及表admin里字段admin_avatar,member_list里member_list_headpic,头像只保存头像图片名
$datas = Db::name('admin')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
if($d['admin_avatar']){
if(stripos($d['admin_avatar'],'http')===false){
//本地头像
$this->files_res_used['/data/upload/avatar/' . $d['admin_avatar']]=true;
}
}
}
}
$datas = Db::name('member_list')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
if($d['member_list_headpic']){
if(stripos($d['member_list_headpic'],'http')===false){
//本地头像
$this->files_res_used['/data/upload/avatar/' . $d['member_list_headpic']]=true;
}
}
}
}
//news里的news_img,news_pic_allurl,news_content
$datas = Db::name('news')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
//字段保存'/data/....'
if($d['news_img']){
if(stripos($d['news_img'],'http')===false){
$this->files_res_used[$d['news_img']]=true;
}
}
//字段保存'/data/....'
if($d['news_pic_allurl']){
$imgs=array_filter(explode(",",$d['news_pic_allurl']));
foreach ($imgs as &$f) {
if(stripos($f,'http')===false && !empty($f)){
$this->files_res_used[$f]=true;
}
}
}
if($d['news_content']){
//匹配'/网站目录/data/....'
$preg_match=__ROOT__.'\/data\/upload\/([0-9]{4}[-][0-9]{2}[-][0-9]{2}\/[a-z0-9]{13}\.[a-z0-9]+)/i';
@preg_match_all($preg_match, $d['news_content'], $mat);
if(!empty($mat [1])){
foreach ($mat [1] as &$f) {
$this->files_res_used['/data/upload/'.$f]=true;
}
}
//匹配'./data/....'
$preg_match='/\.\/data\/upload\/([0-9]{4}[-][0-9]{2}[-][0-9]{2}\/[a-z0-9]{13}\.[a-z0-9]+)/i';
@preg_match_all($preg_match, $d['news_content'], $mat);
if(!empty($mat [1])){
foreach ($mat [1] as &$f) {
$this->files_res_used['/data/upload/'.$f]=true;
}
}
}
}
}
//options里'option_name'=>'site_options'的site_logo、site_qr,字段保存'/data/....'
$datas = Db::name('options')->where(array('option_name'=>'site_options'))->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
if($d['option_value']){
$smeta=json_decode($d['option_value'],true);
if($smeta['site_logo'] && stripos($smeta['site_logo'],'http')===false){
$this->files_res_used[$smeta['site_logo']]=true;
}
if(!empty($smeta['site_qr']) && stripos($smeta['site_qr'],'http')===false){
$this->files_res_used[$smeta['site_qr']]=true;
}
}
}
}
//plug_ad里plug_ad_pic,字段保存'/data/....'
$datas = Db::name('plug_ad')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
if($d['plug_ad_pic']){
if(stripos($d['plug_ad_pic'],'http')===false){
//本地图片
$this->files_res_used[$d['plug_ad_pic']]=true;
}
}
}
}
//menu里menu_img,字段保存'/data/....'
$datas = Db::name('menu')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
if($d['menu_img']){
if(stripos($d['menu_img'],'http')===false){
//本地图片
$this->files_res_used[$d['menu_img']]=true;
}
}
}
}
//model自定义模型
$table_arr=Db::name('model')->column('model_name,model_fields','model_name');
foreach ($table_arr as $table=>$fields){
$fields=json_decode($fields,true);
foreach ($fields as $field){
//文件或图片或富文本字段
if(in_array($field['type'],['imagefile','images','file','files','richtext'])){
$datas=Db::name($table)->field($field['name'])->select();
foreach ($datas as $d) {
if($d[$field['name']]){
if($field['type']=='richtext'){
//匹配'/网站目录/data/....'
$preg_match=__ROOT__.'\/data\/upload\/([0-9]{4}[-][0-9]{2}[-][0-9]{2}\/[a-z0-9]{13}\.[a-z0-9]+)/i';
@preg_match_all($preg_match, $d[$field['name']], $mat);
if(!empty($mat [1])){
foreach ($mat [1] as &$f) {
$this->files_res_used['/data/upload/'.$f]=true;
}
}
//匹配'./data/....'
$preg_match='/\.\/data\/upload\/([0-9]{4}[-][0-9]{2}[-][0-9]{2}\/[a-z0-9]{13}\.[a-z0-9]+)/i';
@preg_match_all($preg_match, $d[$field['name']], $mat);
if(!empty($mat [1])){
foreach ($mat [1] as &$f) {
$this->files_res_used['/data/upload/'.$f]=true;
}
}
}elseif($field['type']=='imagefile' || $field['type']=='file'){
if(stripos($d[$field['name']],'http')===false){
//本地图片
$this->files_res_used[$d[$field['name']]]=true;
}
}else{
//字段保存'/data/....'
if($d[$field['name']]){
$imgs=array_filter(explode(",",$d[$field['name']]));
foreach ($imgs as &$f) {
if(stripos($f,'http')===false && !empty($f)){
$this->files_res_used[$f]=true;
}
}
}
}
}
}
}
}
}
//找出未使用的资源文件
$this->files_unused=array();
$ids=array();
$datas = Db::name('plug_files')->select();
if (is_array($datas)) {
foreach ($datas as &$d) {
$f = $d ['path'];
if (isset ($this->files_res_used[$f])) {
unset ($this->files_res_used[$f]);
} else {
$ids[]=$d ['id'];
$this->files_unused [] = array(
'id' => $d ['id'],
'filesize' =>$d['filesize'],
'path' => $f,
'uptime' => $d ['uptime']
);
}
}
}
//数据库
$where=array();
$plug_files=array();
$show='';
if(!empty($ids)){
$where['id']=array('in',$ids);
$plug_files=Db::name('plug_files')->where($where)->order('id desc')->paginate(config('paginate.list_rows'));
$show = $plug_files->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
}
$this->assign('plug_files',$plug_files);
$this->assign('page',$show);
if(request()->isAjax()){
return $this->fetch('ajax_plug_file_filter');
}else{
return $this->fetch();
}
}
/**
* 文件删除(全选)
*/
public function plug_file_alldel(){
$p = input('p');
$ids = input('id/a');
if(empty($ids)){
$this -> error("请选择要删除的文件",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
foreach (Db::name('plug_files')->field('path')->where($where)->select() as $r) {
$file = $r ['path'];
if(stripos($file, "/")===0){
$file=substr($file,1);
}
if (file_exists($file)) {
unlink($file);
}
}
if (Db::name('plug_files')->where($where)->delete()!==false) {
$this->success("删除文件成功!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
} else {
$this->error("删除文件失败!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}
}else{
$r=Db::name('plug_files')->find($ids);
if($r){
$file=$r['path'];
if(stripos($file, "/")===0){
$file=substr($file,1);
}
if (file_exists($file)) {
unlink($file);
}
if (Db::name('plug_files')->delete($ids)!==false) {
$this->success("删除文件成功!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}else{
$this->error("删除文件失败!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}
}else{
$this->error("删除文件失败!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}
}
}
/**
* 文件删除
*/
public function plug_file_del()
{
$id=input('id');
$p = input('p');
if (empty($id)){
$this->error('参数错误',url('admin/Plug/plug_file_filter',array('p'=>$p)));
}else{
$r=Db::name('plug_files')->find($id);
if($r){
$file=$r['path'];
if(stripos($file, "/")===0){
$file=substr($file,1);
}
if (file_exists($file)) {
unlink($file);
}
if (Db::name('plug_files')->delete($id)!==false) {
$this->success("删除文件成功!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}else{
$this->error("删除文件失败!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}
}else{
$this->error("删除文件失败!",url('admin/Plug/plug_file_filter',array('p'=>$p)));
}
}
}
}

881
app/admin/controller/Product.php

@ -0,0 +1,881 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Image;
class Product extends Base
{
protected $table_name='product';
protected $controller_name='product';
protected $has_img=true;
protected $maps=[];
protected $has_imgs=true;
protected $has_source=true;
public function _initialize()
{
parent::_initialize();
$this->assign('table_name',$this->table_name);
$this->assign('controller',$this->controller_name);
$this->assign('has_img',$this->has_img);
$this->assign('has_imgs',$this->has_imgs);
$this->assign('has_source',$this->has_source);
$maps=[
'58'=>['name'=>'书画篆刻'],
'59'=>['name'=>'工艺作品'],
'60'=>['name'=>'造型艺术'],
'61'=>['name'=>'玉翠珠宝'],
'62'=>['name'=>'文玩杂项'],
'63'=>['name'=>'其他'],
];
$types=Db::name('type')->where(['type_type'=>58])->select();
$maps['58']['childs']=$types;
$types=Db::name('type')->where(['type_type'=>59])->select();
$maps['59']['childs']=$types;
$types=Db::name('type')->where(['type_type'=>60])->select();
$maps['60']['childs']=$types;
$types=Db::name('type')->where(['type_type'=>61])->select();
$maps['61']['childs']=$types;
$types=Db::name('type')->where(['type_type'=>62])->select();
$maps['62']['childs']=$types;
$types=Db::name('type')->where(['type_type'=>63])->select();
$maps['63']['childs']=$types;
$this->maps=$maps;
}
public function show_list(){
$this->assign('table_name','show');
$page=input('page',1,'intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$where=[];
$list=Db::name('proquarter')->where($where)->order(['sort'=>'asc','create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
$show = $list->render();
$this->assign('pageshow',$show);
$this->assign('list',$list);
if(request()->isAjax()){
return $this->fetch('product/ajax_show_list');
}else{
return $this->fetch('product/show_list');
}
}
/**
* 排序
*/
public function show_order()
{
$page=input('page','','intval');
$this->assign('page',$page);
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/show_list',$jumpParam);
if (!request()->isAjax()){
$this->error('提交方式不正确',$jump);
}else{
foreach (input('post.') as $n_id => $sort){
Db::name('proquarter')->update(['id'=>$n_id,'sort'=>$sort]);
}
$this->success('排序更新成功',$jump);
}
}
/**
* 删除(全选)
*/
public function show_del($id='')
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('id/a');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/show_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
$rst=Db::name('proquarter')->where(['id'=>$id])->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 删除(全选)
*/
public function show_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('id/a');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/show_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('proquarter')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
public function category_list(){
$this->assign('table_name','category');
$page=input('page',1,'intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$types=Db::name('proquarter')->field('id,title')->select();
$map=[];
if(count($types)){
$ids=array_search_key('id',$types);
$titles=array_search_key('title',$types);
$map=array_combine($ids,$titles);
}
$this->assign('types',$map);
$where=[];
$list=Db::name('procategory')->where($where)->order(['sort'=>'desc','create_time'=>'desc'])->paginate(config('paginate.list_rows'),false,['query'=>get_query(),'page'=>$page]);
$show = $list->render();
$this->assign('pageshow',$show);
$this->assign('list',$list);
if(request()->isAjax()){
return $this->fetch('product/ajax_category_list');
}else{
return $this->fetch('product/category_list');
}
}
public function category_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('id/a');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/category_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('procategory')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
public function category_del($id=''){
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('id/a');
$jumpParam=['p' => $p,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/category_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
$rst=Db::name('procategory')->where(['id'=>$id])->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 排序
*/
public function category_order()
{
$page=input('page','','intval');
$this->assign('page',$page);
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/category_list',$jumpParam);
if (!request()->isAjax()){
$this->error('提交方式不正确',$jump);
}else{
foreach (input('post.') as $n_id => $sort){
Db::name('procategory')->update(['id'=>$n_id,'sort'=>$sort]);
}
$this->success('排序更新成功',$jump);
}
}
/**
* 添加显示
*/
public function category_add()
{
$this->table_name='procategory';
$this->assign('table_name','category');
$page=input('page','','intval');
$this->assign('page',$page);
$types=Db::name('proquarter')->select();
$this->assign('types',$types);
if (!request()->isAjax()){
//栏目
return $this->fetch('product/category_add');
}else{
//上传图片部分
$img_one='';
$img_one2='';
$file = request()->file('pic_one');
$file2 = request()->file('pic_one2');
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/category_list',$jumpParam);
$ret=$this->dealFile($file,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
}
$ret=$this->dealFile($file2,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one2=$ret['img_one'];
}
$sort=input('sort','','intval');
$sl_data=array(
'title'=>input('title'),
'pid'=>input('pid'),
'style'=>input('style'),
'style2'=>input('style2'),
'uid'=>session('admin_auth.aid'),
'status'=>input('status',0),
'poster'=>$img_one,//封面图片路径
'create_time'=>time(),
'sort'=>$sort,
);
//图片字段处理
if(!empty($img_one)){
$sl_data['poster']=$img_one;
}
if(!empty($img_one2)){
$sl_data['poster2']=$img_one2;
}
$rst=Db::name($this->table_name)->insert($sl_data);
if($rst){
if(empty($sort)){
$lastId=Db::name($this->table_name)->getLastInsID();
Db::name($this->table_name)->where(['id'=>$lastId])->update(['sort'=>$lastId]);
}
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
}
/**
* 编辑显示
*/
public function category_edit()
{
$types=Db::name('proquarter')->select();
$this->assign('types',$types);
$this->assign('table_name','category');
$this->table_name='procategory';
$page=input('page','','intval');
$this->assign('page',$page);
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/category_list',$jumpParam);
if (!request()->isAjax()) {
$n_id = input('id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$product_list = Db::name($this->table_name)->find($n_id);
$this->assign('list', $product_list);
return $this->fetch('product/category_edit');
}else{
$img_one='';
$img_one2='';
$button='';
$file = request()->file('pic_one');
$file2 = request()->file('pic_one2');
//单图
$ret=$this->dealFile($file,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
}
$ret=$this->dealFile($file2,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one2=$ret['img_one'];
}
$sl_data=array(
'id'=>input('id'),
'pid'=>input('pid'),
'style'=>input('style'),
'style2'=>input('style2'),
'title'=>input('title'),
'status'=>input('status',0),
'sort'=>input('sort',50,'intval'),
);
//图片字段处理
if(!empty($img_one)){
$sl_data['poster']=$img_one;
}
if(!empty($img_one2)){
$sl_data['poster2']=$img_one2;
}
$rst=Db::name($this->table_name)->update($sl_data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
}
/**
* 添加显示
*/
public function show_add()
{
$this->table_name='proquarter';
$this->assign('table_name','show');
$page=input('page','','intval');
$this->assign('page',$page);
if (!request()->isAjax()){
//栏目
return $this->fetch('product/show_add');
}else{
//上传图片部分
$img_one='';
$img_one2='';
$button='';
$file = request()->file('pic_one');
$file2 = request()->file('pic_one2');
$file3 = request()->file('pic_one3');
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/show_list',$jumpParam);
$ret=$this->dealFile($file,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
}
$ret=$this->dealFile($file2,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one2=$ret['img_one'];
}
$ret=$this->dealFile($file3,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$button=$ret['img_one'];
}
$sort=input('sort','','intval');
$sl_data=array(
'title'=>input('title'),
'address'=>input('address'),
'open_time'=>input('open_time'),
'infor'=>input('infor'),
'color'=>input('color'),
'fcolor'=>input('fcolor'),
'style'=>input('style'),
'music'=>input('music'),
'uid'=>session('admin_auth.aid'),
'status'=>input('status',0),
'poster'=>$img_one,//封面图片路径
'create_time'=>time(),
'sort'=>$sort,
);
//图片字段处理
if(!empty($img_one)){
$sl_data['poster']=$img_one;
}
if(!empty($img_one2)){
$sl_data['poster2']=$img_one2;
}
if(!empty($button)){
$sl_data['button']=$button;
}
$rst=Db::name($this->table_name)->insert($sl_data);
if($rst){
if(empty($sort)){
$lastId=Db::name($this->table_name)->getLastInsID();
Db::name($this->table_name)->where(['id'=>$lastId])->update(['sort'=>$lastId]);
}
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
}
/**
* 编辑显示
*/
public function show_edit()
{
$this->assign('table_name','show');
$this->table_name='proquarter';
$page=input('page','','intval');
$this->assign('page',$page);
$jumpParam=['page'=>$page];
$jump=url('admin/'.$this->controller_name.'/show_list',$jumpParam);
if (!request()->isAjax()) {
$n_id = input('id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$product_list = Db::name($this->table_name)->find($n_id);
$this->assign('list', $product_list);
return $this->fetch('product/show_edit');
}else{
$img_one='';
$img_one2='';
$button='';
$file = request()->file('pic_one');
$file2 = request()->file('pic_one2');
$file3 = request()->file('pic_one3');
//单图
$ret=$this->dealFile($file,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
}
$ret=$this->dealFile($file2,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one2=$ret['img_one'];
}
$ret=$this->dealFile($file3,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$button=$ret['img_one'];
}
$sl_data=array(
'id'=>input('id'),
'infor'=>input('infor'),
'address'=>input('address'),
'open_time'=>input('open_time'),
'title'=>input('title'),
'style'=>input('style'),
'color'=>input('color'),
'fcolor'=>input('fcolor'),
'music'=>input('music'),
'status'=>input('status',0),
'sort'=>input('sort',50,'intval'),
);
//图片字段处理
if(!empty($img_one)){
$sl_data['poster']=$img_one;
}
if(!empty($img_one2)){
$sl_data['poster2']=$img_one2;
}
if(!empty($button)){
$sl_data['button']=$button;
}
$rst=Db::name($this->table_name)->update($sl_data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
}
/**
* 列表
*/
public function product_list()
{
$search_name=input('search_name','');
$this->assign('search_name',$search_name);
//栏目
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$page=input('page',1,'intval');
$postPage=input('post.page','','intval');
if($postPage)$page=$postPage;
$this->assign('page',$page);
$this->assign('n_kind',$n_kind);
$where=[];
if($n_cid)$where['cid']=$n_cid;
if($n_kind)$where['kind']=$n_kind;
$db=Db::name($this->table_name)->where($where);
if($search_name){
$db->where('title','like','%'.$search_name.'%');
}
$news=$db->order(['sort'=>'asc','create_time'=>'desc'])->paginate(10,false,['query'=>get_query(),'page'=>$page]);
$show = $news->render();
$this->assign('pageshow',$show);
$this->assign('news',$news);
$this->assign('n_cid',$n_cid);
if(request()->isAjax()){
return $this->fetch('product/ajax_product_list');
}else{
return $this->fetch('product/product_list');
}
}
/**
* 添加显示
*/
public function product_add()
{
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$this->assign('types',$this->maps);
if (!request()->isAjax()){
//栏目
$this->assign('n_cid',$n_cid);
return $this->fetch('product/product_add');
}else{
//上传图片部分
$img_one='';
$img_one2='';
$picall_url='';
$file = request()->file('pic_one');
$file2 = request()->file('pic_one2');
$files = request()->file('pic_all');
$jumpParam=['cid'=>$n_cid,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
$ret=$this->dealFile($file,$files);
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
if(isset($ret['picall_url'])&&$ret['picall_url'])$picall_url=$ret['picall_url'];
}
$ret=$this->dealFile($file2,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one2=$ret['img_one'];
}
$sort=input('sort','','intval');
$sl_data=array(
'title'=>input('title'),
'kind'=>input('kind'),
'year'=>input('year'),
'weight'=>input('weight'),
'author'=>input('author'),
'size'=>input('size'),
'price'=>input('price'),
'gprice'=>input('gprice'),
'video'=>input('video'),
'code'=>input('code'),
'style'=>input('style'),
'description'=>input('description'),
'topic'=>input('topic'),
'material'=>input('material'),
'uid'=>session('admin_auth.aid'),
'status'=>input('status',0),
'cid'=>$n_cid,
'photos'=>$picall_url,//多图路径
'poster'=>$img_one,//封面图片路径
'xcode'=>$img_one2,//封面图片路径
'link'=>input('link'),
'kind'=>input('kind'),
'create_time'=>time(),
'sort'=>$sort,
);
$rst=Db::name($this->table_name)->insert($sl_data);
if($rst){
if(empty($sort)){
$lastId=Db::name($this->table_name)->getLastInsID();
Db::name($this->table_name)->where(['id'=>$lastId])->update(['sort'=>$lastId]);
}
$this->success('添加成功',$jump);
}else{
$this->error('添加失败',$jump);
}
}
}
/**
* 编辑显示
*/
public function product_edit()
{
$this->assign('types',$this->maps);
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['cid'=>$n_cid,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
if (!request()->isAjax()) {
$n_id = input('id');
if (empty($n_id)) {
$this->error('参数错误', $jump);
}
$this->assign('n_cid', $n_cid);
$product_list = Db::name($this->table_name)->find($n_id);
//多图字符串转换成数组
$pic_list = array_filter(explode(",", $product_list['photos']));
$this->assign('pic_list', $pic_list);
$source = Db::name('source')->select();//来源
$this->assign('source', $source);
$this->assign('list', $product_list);
return $this->fetch('product/product_edit');
}else{
$pic_oldlist=input('pic_oldlist');//老多图字符串
$img_one='';
$img_one2='';
$picall_url='';
$file = request()->file('pic_one');
$file2 = request()->file('pic_one2');
$files = request()->file('pic_all');
//单图
$ret=$this->dealFile($file,$files);
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one=$ret['img_one'];
if(isset($ret['picall_url'])&&$ret['picall_url'])$picall_url=$ret['picall_url'];
}
$ret=$this->dealFile($file2,'');
if(isset($ret['error'])){
$this->error($ret['error'],$jump);
}else{
if(isset($ret['img_one'])&&$ret['img_one'])$img_one2=$ret['img_one'];
}
$sl_data=array(
'id'=>input('id'),
'year'=>input('year'),
'kind'=>input('kind'),
'weight'=>input('weight'),
'title'=>input('title'),
'author'=>input('author'),
'size'=>input('size'),
'price'=>input('price'),
'gprice'=>input('gprice'),
'video'=>input('video'),
'code'=>input('code'),
'style'=>input('style'),
'description'=>input('description'),
'topic'=>input('topic'),
'material'=>input('material'),
'status'=>input('status',0),
'link'=>input('link'),
'kind'=>input('kind'),
'sort'=>input('sort',50,'intval'),
);
//图片字段处理
if(!empty($img_one)){
$sl_data['poster']=$img_one;
}
if(!empty($img_one2)){
$sl_data['xcode']=$img_one2;//封面图片路径
}
$sl_data['photos']=$pic_oldlist.$picall_url;
$rst=Db::name($this->table_name)->update($sl_data);
if($rst!==false){
$this->success('修改成功',$jump);
}else{
$this->error('修改失败',$jump);
}
}
}
/**
* 处理上传图片
* @param string $file
* @param string $files
* @return NULL[]|string[]
*/
protected function dealFile($file='',$files=''){
$validate = config('upload_validate');
$img_one='';
$picall_url='';
//单图
if (!empty($file)) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
$imgfile='.'.$img_url;
//等比例宿放
if(file_exists($imgfile)){
$image=Image::open($imgfile);
$width=$image->width();
$height=$image->height();
if($width>1000){
$nhei=(1000/$width)*$height;
$image->thumb(1000,$nhei);
$image->save($imgfile);
}
}
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
return ['error'=>$file[0]->getError()];
}
}
//多图
if (!empty($files)) {
foreach ($files as $file) {
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
$imgfile='.'.$img_url;
//等比例宿放
if(file_exists($imgfile)){
$image=Image::open($imgfile);
$width=$image->width();
$height=$image->height();
if($width>1000){
$nhei=(1000/$width)*$height;
$image->thumb(1000,$nhei);
$image->save($imgfile);
}
}
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$picall_url = $img_url . ',' . $picall_url;
} else {
return ['error'=>$file[0]->getError()];
}
}
}
return ['img_one'=>$img_one,'picall_url'=>$picall_url];
}
/**
* 排序
*/
public function product_order()
{
$page=input('page','','intval');
$this->assign('page',$page);
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
if (!request()->isAjax()){
$this->error('提交方式不正确',$jump);
}else{
foreach (input('post.') as $n_id => $sort){
Db::name($this->table_name)->update(['id'=>$n_id,'sort'=>$sort]);
}
$this->success('排序更新成功',$jump);
}
}
/**
* 删除(单个)
*/
public function product_del()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p=input('p');
$n_cid=input('cid','','intval');
$n_kind=input('kind','','intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
$rst=Db::name($this->table_name)->delete(input('id'));
if($rst!==false){
$this->success('删除成功',$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 删除(全选)
*/
public function product_alldel()
{
$page=input('page','','intval');
$this->assign('page',$page);
$p = input('p');
$ids = input('id/a');
$n_cid=input('cid',0,'intval');
$n_kind=input('kind',0,'intval');
$this->assign('n_kind',$n_kind);
$jumpParam=['p' => $p,'cid'=>$n_cid,'kind'=>$n_kind,'page'=>$page];
$jump=url('admin/'.$this->controller_name.'/'.$this->table_name.'_list',$jumpParam);
if(empty($ids)){
$this -> error("请选择待删除数据",$jump);
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name($this->table_name)->where($where)->delete();
if($rst!==false){
$this->success("删除成功",$jump);
}else{
$this -> error("删除失败!",$jump);
}
}
/**
* 审核/取消审核
*/
public function product_state()
{
$id=input('x');
$status=Db::name($this->table_name)->where(array('id'=>$id))->value('status');
if($status==1){
$statedata = array('status'=>0);
Db::name($this->table_name)->where(array('id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('status'=>1);
Db::name($this->table_name)->where(array('nid'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

71
app/admin/controller/Rczp.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Rczp extends News
{
public function _initialize()
{
$this->table_name='rczp';
$this->controller_name='Rczp';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 本所荣誉列表
*/
public function rczp_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function rczp_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function rczp_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function rczp_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function rczp_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function rczp_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function rczp_state()
{
return $this->news_state();
}
}

162
app/admin/controller/Region.php

@ -0,0 +1,162 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Region extends Base
{
public function region_list(){
$key=input('key');
$where['pid']=0;
$province=input('province','');
$this->assign('province',$province);
if($province !== ''){
$where['pid']=$province;
}
$city=input('city','');
$this->assign('city',$city);
if($city !== ''){
$cityfind=DB::name('region')->where(array('type'=>2,'pid'=>$province,'id'=>$city))->find();
if($cityfind){
$where['pid']=$city;
}else{
$this->assign('city','');
}
}
if($where['pid']==0){
$where['pid']=array(array('eq',0),array('eq',1),'or');;
}
$province_list=DB::name('region')->where(array('type'=>1))->order('id,pid')->select();
$this->assign('province_list',$province_list);
$city_list=DB::name('region')->where(array('type'=>2,'pid'=>$province))->order('id,pid')->select();
$this->assign('city_list',$city_list);
$region_list=DB::name('region')->where($where)->where('name','like',"%".$key."%")->order('id,pid')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show=$region_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('region_list',$region_list);
$this->assign('page',$show);
$this->assign('val',$key);
if(request()->isAjax()){
return $this->fetch('ajax_region_list');
}else{
return $this->fetch();
}
}
public function region_add(){
$province = Db::name('Region')->where ( array('pid'=>1) )->select ();
$this->assign('province',$province);
return $this->fetch();
}
public function region_runadd(){
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Region/region_add'));
}else{
$input_type=input('input_type',0);
$province=input('region_list_province');
$city=input('region_list_city');
if($input_type==2){
if(!$province){
$this->error('请选择省份',url('admin/Region/region_add'));
}
$pid=$province;
}elseif($input_type==3){
if(!$city){
$this->error('请选择城市',url('admin/Region/region_add'));
}
$pid=$city;
}else{
$pid=1;
}
$sl_data=array(
'pid'=>$pid,
'name'=>input('areaname'),
'type' => $input_type,
);
$rst=DB::name('region')->insert($sl_data);
if($rst!==false){
$this->success('添加成功',url('admin/Region/region_list',array('province'=>$province,'city'=>$city)));
}else{
$this->error('添加失败',url('admin/Region/region_add'));
}
}
}
public function region_edit(){
$editdata = Db::name('Region')->where ( array('id'=>input('id')) )->find();
$this->assign('editdata',$editdata);
$province = Db::name('Region')->where ( array('pid'=>1) )->select ();
$this->assign('province',$province);
if($editdata['type']==2){//市
$provincedata = Db::name('Region')->where ( array('id'=>$editdata['pid']) )->find();
$this->assign('provinceid',$provincedata['id']);
$this->assign('cityid',0);
}elseif($editdata['type']==3){//县
$citydata = Db::name('Region')->where ( array('id'=>$editdata['pid']) )->find();
$provincedata = Db::name('Region')->where ( array('id'=>$citydata['pid']) )->find();
$this->assign('cityid',$citydata['id']);
$this->assign('provinceid',$provincedata['id']);
$city = Db::name('Region')->where ( array('pid'=>$citydata['pid']) )->select();
$this->assign('city',$city);
}else{//省
$this->assign('provinceid',0);
$this->assign('cityid',0);
}
return $this->fetch();
}
public function region_runedit(){
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Region/region_add'));
}else{
$input_type=input('input_type',0);
$province=input('region_list_province');
$city=input('region_list_city');
if($input_type==2){
if(!$province){
$this->error('请选择省份',url('admin/Region/region_edit'));
}
$pid=$province;
}elseif($input_type==3){
if(!$city){
$this->error('请选择城市',url('admin/Region/region_edit'));
}
$pid=$city;
}else{
$pid=1;
}
$sl_data['pid']=$pid;
$sl_data['name']=input('areaname');
$sl_data['type']=$input_type;
$rst=DB::name('region')->where(array('id'=>input('regionid')))->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Region/region_list',array('province'=>$province,'city'=>$city)));
}else{
$this->error('修改失败',url('admin/Region/region_edit'));
}
}
}
public function region_del()
{
$id=input('id');
$rst=Db::name('region')->where('id',$id)->delete();
if($rst!==false){
$this->success('删除成功',url('admin/Region/region_list'));
}else{
$this->error('删除失败',url('admin/Region/region_list'));
}
}
}

308
app/admin/controller/Roadshow.php

@ -0,0 +1,308 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/4/2
* Time: 9:56
*/
namespace app\admin\controller;
use think\Db;
class Roadshow extends Base
{
/**
* 固态栏目路演列表
*/
public function roadshow_list()
{
$roadshow_list=Db::name('lypt')->order('sort,create_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $roadshow_list->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('roadshow_list',$roadshow_list);
if(request()->isAjax()){
return $this->fetch('ajax_roadshow_list');
}else{
return $this->fetch('roadshow_list');
}
}
/**
* 添加显示
*/
public function roadshow_add()
{
if (!request()->isAjax()){
return $this->fetch('roadshow_add');
}else{
$count=Db::name('lypt')-> count();
if($count>=24){
$this->error('最多上传24个视频文件!',url('admin/Roadshow/roadshow_list'));
}else{
$img_one='';
$file = request()->file('pic_one');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcwhcyb/whcybly_list',['whcyb_type'=>$type]));
}
}
//视频(使用oss)
$files = request()->file('file_all');
$fileall_url='';
if($files){
if(config('aliyun_oss.oss_open')){
$config=config('aliyun_oss');
$oss=new \OSS\OssClient($config['accesskey'],$config['secretkey'],$config['endpoint'],true);
foreach ($files as $file) {
$fileinfo=$file->getInfo();
$size_list= $fileinfo['size'];
if($size_list>209715200){
$this->error('不能上传超过200M的视频文件!', url('admin/Roadshow/roadshow_list'));//限制上传大小
}
$filename=$fileinfo['name'];
$path=$fileinfo['tmp_name'];
try{
$oss->uploadFile($config['bucket'],$filename,$path);
} catch(OssException $e) {
$this->error($e->getMessage(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
}
$file_url = $config['endpoint'].'/'.$filename;
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $fileinfo['size'];
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
}
}else{
foreach ($files as $file) {
$info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
} else {
$this->error($file->getError(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
}
}
}
}
$sl_data=array(
'name'=>input('name'),
'activity_introduce'=>input('activity_introduce'),
'start_time'=>input('start_time','')?strtotime(input('start_time','')):time(),
'host_unit'=>input('host_unit'),
'status'=>input('status',0),
'create_uid'=>session('admin_auth.aid'),
'create_time'=>time(),
'sort'=>input('sort',20,'intval'),
'video'=>$fileall_url,
'pic'=>$img_one,
);
$rst=Db::name('lypt')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Roadshow/roadshow_list'));
}else{
$this->error('添加失败',url('admin/Roadshow/roadshow_list'));
}
}
}
}
/**
* 编辑显示
*/
public function roadshow_edit()
{
if (!request()->isAjax()) {
$id = input('id');
if (empty($id)) {
if($id){
$this->error('参数错误', url('admin/Roadshow/roadshow_list'));
}else{
$this->error('参数错误', url('admin/Roadshow/roadshow_list'));
}
}
$roadshow_list = Db::name('lypt')->find($id);
$this->assign('roadshow_list', $roadshow_list);
return $this->fetch('roadshow_edit');
}else{
$img_one='';
$file = request()->file('pic_one');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Lcwhcyb/whcybly_list',['whcyb_type'=>$type]));
}
}
//视频
$files = request()->file('file_all');
$fileall_url='';
if($files){
if(config('aliyun_oss.oss_open')){
$config=config('aliyun_oss');
$oss=new \OSS\OssClient($config['accesskey'],$config['secretkey'],$config['endpoint'],true);
foreach ($files as $file) {
$fileinfo=$file->getInfo();
$size_list= $fileinfo['size'];
if($size_list>209715200){
$this->error('不能上传超过200M的视频文件!', url('admin/Roadshow/roadshow_list'));//限制上传大小
}
$filename=$fileinfo['name'];
$path=$fileinfo['tmp_name'];
try{
$oss->uploadFile($config['bucket'],$filename,$path);
} catch(OssException $e) {
$this->error($e->getMessage(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
}
$file_url = $config['endpoint'].'/'.$filename;
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $fileinfo['size'];
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
}
}else{
foreach ($files as $file) {
$info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
} else {
$this->error($file->getError(), url('admin/Roadshow/roadshow_list'));//否则就是上传错误,显示错误原因
}
}
}
}
$sl_data=array(
'id'=>input('id'),
'name'=>input('name'),
'activity_introduce'=>input('activity_introduce'),
'start_time'=>input('start_time','')?strtotime(input('start_time','')):time(),
'host_unit'=>input('host_unit'),
'status'=>input('status',0),
'create_uid'=>session('admin_auth.aid'),
'create_time'=>time(),
'sort'=>input('sort',20,'intval'),
);
//图片字段处理
if(!empty($img_one)){
$sl_data['pic']=$img_one;
}
if(!empty($fileall_url)){
$sl_data['video']=$fileall_url;
}
$rst=Db::name('lypt')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Roadshow/roadshow_list'));
}else{
$this->error('修改失败',url('admin/Roadshow/roadshow_list'));
}
}
}
/**
* 排序
*/
public function roadshow_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确', url('admin/Roadshow/roadshow_list'));
}else{
foreach (input('post.') as $vd_id => $vd_order){
Db::name('lypt')->update(['id'=>$vd_id,'sort'=>$vd_order]);
}
$this->success('排序更新成功',url('admin/Roadshow/roadshow_list'));
}
}
/**
* 删除(单个)
*/
public function roadshow_del()
{
$p=input('p');
$rst=Db::name('lypt')->delete(input('id'));
if($rst!==false){
$this->success('删除成功',url('admin/Roadshow/roadshow_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
}
}
/**
* 删除(全选)
*/
public function roadshow_alldel()
{
$p = input('p');
$ids = input('id/a');
if(empty($ids)){
$this -> error("请选择待删除数据",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('lypt')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Roadshow/roadshow_list',array('p'=>$p)));
}
}
/**
* 审核/取消审核
*/
public function roadshow_state()
{
$id=input('x');
$status=Db::name('lypt')->where(array('id'=>$id))->value('status');
if($status==1){
$statedata = array('status'=>0);
Db::name('lypt')->where(array('id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('status'=>1);
Db::name('lypt')->where(array('id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

72
app/admin/controller/Scnew.php

@ -0,0 +1,72 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/23
* Time: 15:53
*/
namespace app\admin\controller;
class Scnew extends News
{
public function _initialize()
{
$this->table_name='zgwhjf_scnew';
$this->controller_name='Scnew';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zgwhjf_scnew_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zgwhjf_scnew_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zgwhjf_scnew_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zgwhjf_scnew_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zgwhjf_scnew_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zgwhjf_scnew_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zgwhjf_scnew_state()
{
return $this->news_state();
}
}

168
app/admin/controller/Scsj.php

@ -0,0 +1,168 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017/11/24
* Time: 14:04
*/
namespace app\admin\controller;
use think\Db;
/**
* 市场数据后台管理页面
*/
class Scsj extends Base
{
protected $table_name='scsj';
protected $controller_name='scsj';
public function _initialize()
{
parent::_initialize();
$this->assign('table_name',$this->table_name);
$this->assign('controller',$this->controller_name);
}
/**
* 列表
*/
public function scsj_list()
{
//栏目
$scsj=Db::name($this->table_name)->order('n_order,n_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $scsj->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
//市场分类
$hylb=Db::name('type')->where('type_type',49)->select();
$this->assign('hylb', $hylb);
$this->assign('scsj',$scsj);
if(request()->isAjax()){
return $this->fetch('scsj/ajax_scsj_list');
}else{
return $this->fetch('scsj/scsj_list');
}
}
/**
* 添加
*/
public function scsj_add()
{
$auth_group = Db::name('auth_group')->where('status', '1')->select();
//市场分类
$hylb=Db::name('type')->where('type_type',49)->select();
$this->assign('hylb', $hylb);
$this->assign('auth_group', $auth_group);
return $this->fetch();
}
/**
* 添加操作
*/
public function scsj_runadd()
{
$sl_data=array(
'n_title'=>input('n_title'),
'n_company'=>input('n_company'),
'n_type'=>input('n_type'),
'n_status'=>input('n_status',0),
'n_content'=>input('n_content'),
'n_uid'=>session('admin_auth.aid'),
'n_time'=>time(),
'n_order'=>input('n_order',50,'intval'),
);
$rst=Db::name($this->table_name)->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Scsj/scsj_list'));
}else{
$this->error('添加失败',url('admin/Scsj/scsj_list'));
}
}
/**
* 编辑
*/
public function scsj_edit()
{
$n_id = input('n_id');
if (empty($n_id)) {
$this->error('参数错误', url('admin/Scsj/scsj_list'));
}
$scsj_list = Db::name($this->table_name)->find($n_id);
//市场分类
$hylb=Db::name('type')->where('type_type',49)->select();
$this->assign('hylb', $hylb);
$this->assign('scsj_list', $scsj_list);
return $this->fetch('scsj/scsj_edit');
}
/**
* 编辑保存
*/
public function scsj_runedit()
{
$data=input('post.');
$rst=Db::name('scsj')->update($data);
if($rst){
$this->success('修改成功',url('admin/Scsj/scsj_list'));
}else{
$this->error('修改失败',url('admin/Scsj/scsj_list'));
}
}
/**
* 删除
*/
public function scsj_del()
{
$n_id=input('n_id');
if (empty($n_id)){
$this->error('ID不存在',url('admin/Scsj/scsj_list'));
}
$rst=Db::name('scsj')->delete($n_id);
if($rst!==false){
$this->success('删除成功',url('admin/Scsj/scsj_list'));
}else{
$this->error('删除失败',url('admin/Scsj/scsj_list'));
}
}
/**
* 删除(全选)
*/
public function scsj_alldel()
{
$p = input('p');
$ids = input('n_id/a');
if(empty($ids)){
$this -> error("请选择待删除数据",url('admin/Scsj/scsj_list'));
}
if(is_array($ids)){
$where = 'n_id in('.implode(',',$ids).')';
}else{
$where = 'n_id='.$ids;
}
$rst=Db::name($this->table_name)->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/Scsj/scsj_list'));
}else{
$this -> error("删除失败!",url('admin/Scsj/scsj_list'));
}
}
/**
* 审核/取消审核
*/
public function scsj_state()
{
$id=input('x');
$status=Db::name($this->table_name)->where(array('n_id'=>$id))->value('n_status');
if($status==1){
$statedata = array('n_status'=>0);
Db::name($this->table_name)->where(array('n_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('n_status'=>1);
Db::name($this->table_name)->where(array('n_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

71
app/admin/controller/Sczcxy.php

@ -0,0 +1,71 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017/11/23
* Time: 19:05
*/
namespace app\admin\controller;
class Sczcxy extends News
{
public function _initialize()
{
$this->table_name='sczcxy';
$this->controller_name='Sczcxy';
parent::_initialize();
}
/**
* 政策行研列表
*/
public function sczcxy_list()
{
$curr_menu= array([600,620]);
$this->assign('menus_curr',$curr_menu);
return $this->news_list();
}
/**
* 添加显示
*/
public function sczcxy_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function sczcxy_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function sczcxy_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function sczcxy_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function sczcxy_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function sczcxy_state()
{
return $this->news_state();
}
}

263
app/admin/controller/Sms.php

@ -0,0 +1,263 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use app\admin\model\Agency;
class Sms extends Base
{
/**
* 列表
*/
public function index()
{
$kind=input("kind");
$this->assign('kind',$kind);
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($kind)$map['sms_type']=$kind;
if($search_name){
$map['sms_content|sms_code']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('smslog')->where($map)->order('sms_id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
$types=['forget'=>'忘记密码','reg'=>'注册','activitys'=>'活动'];
$this->assign('types',$types);
return $this->fetch();
}
public function ajaxmem(){
$member_list =Db::name('member_list')->field("member_list_id,member_list_username,member_list_tel,member_list_nickname")->where(['user_status'=>1])->order('member_list_id desc')->paginate(60,false,['query'=>get_query()]);
return json($member_list);
}
/**
* 添加
*/
public function add()
{
$kind=input("kind");
$this->assign('kind',$kind);
$tpls=db('smstpl')->where(['status'=>1])->select();
$tags=db('smstag')->where(['status'=>1])->select();
$this->assign('tpls',$tpls);
$this->assign('tags',$tags);
return $this->fetch();
}
/**
* 添加操作
*/
public function runadd()
{
$kind=input("kind");
$tels=input('sms_tel');
$tels=nl2br($tels);
$tels=explode("<br />", $tels);
// 启动事务
Db::startTrans();
$query=true;
try{
foreach ($tels as $teline){
$teline=trim($teline);
if($teline){
$teline=explode(";", $teline);
foreach ($teline as $tel){
$tel=trim($tel);
if($tel){
$data=[];
$data['kind']=$kind;
$data['sms_type']=$kind;
$data['sms_state']=input('sms_state',-1);
$data['sms_txt']=input('sms_txt');
$data['sms_tel']=$tel;
$data['sms_time']=time();
$res=Db::name('smslog')->insert($data);
if(!$res){
$query=false;
Db::rollback();
break;
}
}
}
}
}
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
}
if($query){
$this->success('添加成功',url('index'));
}else{
$this->error('添加失败',url('index'));
}
}
/**
* 修改
*/
public function edit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('smslog')->find(input('id'));
if($list['sms_content']){
$list['sms_content']=json_decode($list['sms_content'],true);
}
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改
*/
public function check()
{
$kind=input("kind");
$this->assign('kind',$kind);
$list=Db::name('smslog')->find(input('id'));
if($list['sms_content']){
$list['sms_content']=json_decode($list['sms_content'],true);
}
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedit()
{
$kind=input("kind");
$this->assign('kind',$kind);
$data=[];
$data['sms_id']=input('id');
$state=input('sms_state');
if($state!='')$data['sms_state']=$state;
$data['sms_txt']=input('sms_txt');
$data['sms_tel']=input('sms_tel');
$rst=Db::name('smslog')->update($data);
if($rst!==false){
$this->success('修改成功',url('index'));
}else{
$this->error('修改失败',url('index'));
}
}
/**
* 删除
*/
public function del()
{
$kind=input("kind");
$this->assign('kind',$kind);
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('index'));
}
$rst=Db::name('smslog')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('index'));
}else{
$this->error('删除失败',url('index'));
}
}
/**
* 列表
*/
public function tag()
{
$search_name=input('search_name');
$this->assign('search_name',$search_name);
$map=array();
if($search_name){
$map['title']= array('like',"%".$search_name."%");
}
$admin_list=Db::name('smstag')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$page = $admin_list->render();
$this->assign('list',$admin_list);
$this->assign('page',$page);
return $this->fetch();
}
/**
* 添加
*/
public function addtag()
{
return $this->fetch();
}
/**
* 添加操作
*/
public function runaddtag()
{
$data=[];
$data['status']=input('status',-1);
$data['title']=input('title');
$data['infor']=input('infor');
$data['create_date']=time();
$query=Db::name('smstag')->insert($data);
if($query){
$this->success('添加成功',url('tag'));
}else{
$this->error('添加失败',url('tag'));
}
}
/**
* 修改
*/
public function edittag()
{
$list=Db::name('smstag')->find(input('id'));
if($list['infor']){
$list['infors']=explode(';',$list['infor']);
}
$this->assign('list',$list);
return $this->fetch();
}
/**
* 修改操作
*/
public function runedittag()
{
$data=[];
$data['id']=input('id');
$state=input('status');
if($state!='')$data['status']=$state;
$data['title']=input('title');
$data['infor']=input('infor');
$rst=Db::name('smstag')->update($data);
if($rst!==false){
$this->success('修改成功',url('tag'));
}else{
$this->error('修改失败',url('tag'));
}
}
/**
* 删除
*/
public function deltag()
{
$admin_id=input('id');
if (empty($admin_id)){
$this->error('ID不存在',url('tag'));
}
$rst=Db::name('smstag')->delete($admin_id);
if($rst!==false){
$this->success('删除成功',url('tag'));
}else{
$this->error('删除失败',url('tag'));
}
}
}

71
app/admin/controller/Ssyyzx.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Ssyyzx extends News
{
public function _initialize()
{
$this->table_name='ssyyzx';
$this->controller_name='Ssyyzx';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function ssyyzx_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function ssyyzx_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function ssyyzx_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function ssyyzx_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function ssyyzx_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function ssyyzx_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function ssyyzx_state()
{
return $this->news_state();
}
}

1636
app/admin/controller/Sys.php

File diff suppressed because it is too large

71
app/admin/controller/Tjjg.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Tjjg extends News
{
public function _initialize()
{
$this->table_name='tjjg';
$this->controller_name='Tjjg';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function tjjg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function tjjg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function tjjg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function tjjg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function tjjg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function tjjg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function tjjg_state()
{
return $this->news_state();
}
}

425
app/admin/controller/Type.php

@ -0,0 +1,425 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
class Type extends Base
{
/**
* 列表
*/
public function type_list()
{
$where=[];
$type_type=input('type_type',0,'intval');
if($type_type){
$where['type_type']=$type_type;
}
$lists=Db::name('type')->where($where)->order('type_type,type_order')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $lists->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('type_type',$type_type);
$this->assign('types',config('type'));
$this->assign('lists',$lists);
if(request()->isAjax()){
return $this->fetch('ajax_type_list');
}else{
return $this->fetch();
}
}
/**
* 添加显示
*/
public function type_add()
{
if (!request()->isAjax()){
$this->assign('types',config('type'));
return $this->fetch();
}else{
$type_type=input('type_type',0,'intval');
$type_id=input('type_id',0,'intval');
$type_name=input('type_name','');
//$rst=Db::name('type')->where('type_type',$type_type)->where('type_id='.$type_id.' or type_name=\''.$type_name.'\'')->find();
$rst=Db::name('type')->where('type_type',$type_type)->where('type_name=\''.$type_name.'\'')->find();
if($rst){
$this->error('存在相同的分类ID或分类名称',url('admin/Type/type_list'));
}else{
//查找对应类型,并自增typeid
$find=Db::name('type')->where('type_type',$type_type)->order('type_id desc')->find();
if($find){
$type_id=$find['type_id']+1;
}else{
$type_id=1;
}
$sl_data=array(
'type_name'=>$type_name,
'type_id'=>$type_id,
'type_type'=>$type_type,
'type_status'=>input('type_status',0),
'type_order'=>input('type_order',50,'intval')
);
//下载类型10 公告类型11 要闻类型12 你问我答13 文化四板行业15 这些需要修改auth_rule
if(in_array($type_type,[10,11,12,13,15])){
switch ($type_type) {
case 10:
$pid=141;
$name='admin/Download/download';
$level=3;
break;
case 11:
$pid=47;
$name='admin/Bsgg/bsgg';
$level=2;
break;
case 12:
$pid=72;
$name='admin/Bsyw/bsyw';
$level=2;
break;
case 13:
$pid=97;
$name='admin/Nwwd/nwwd';
$level=2;
break;
case 15:
$pid=230;
$name='admin/Culture/culture';
$level=3;
break;
}
// 启动事务
Db::startTrans();
try{
$id=Db::name('type')->insertGetId($sl_data);
$last=Db::name('auth_rule')->where(['pid'=>$pid])->order('sort desc')->find();
$data=[
'name'=>$name.'_list?cid='.$type_id,
'title'=>$type_name,
'type'=>1,
'status'=>1,
'notcheck'=>0,
'css'=>'',
'condition'=>'',
'pid'=>$pid,
'level'=>$level,
'sort'=>$last['sort']+10,
'addtime'=>time()
];
$rule_id=Db::name('auth_rule')->insertGetId($data);
//子菜单
$data = [
[
'name'=>$name.'_edit?cid='.$type_id,
'title'=>'编辑',
'type'=>1,
'status'=>0,
'notcheck'=>0,
'css'=>'',
'condition'=>'',
'pid'=>$rule_id,
'level'=>$level+1,
'sort'=>10,
'addtime'=>time()
],
[
'name'=>$name.'_add?cid='.$type_id,
'title'=>'增加',
'type'=>1,
'status'=>0,
'notcheck'=>0,
'css'=>'',
'condition'=>'',
'pid'=>$rule_id,
'level'=>$level+1,
'sort'=>20,
'addtime'=>time()
],
[
'name'=>$name.'_order?cid='.$type_id,
'title'=>'排序',
'type'=>1,
'status'=>0,
'notcheck'=>0,
'css'=>'',
'condition'=>'',
'pid'=>$rule_id,
'level'=>$level+1,
'sort'=>30,
'addtime'=>time()
],
[
'name'=>$name.'_del?cid='.$type_id,
'title'=>'删除',
'type'=>1,
'status'=>0,
'notcheck'=>0,
'css'=>'',
'condition'=>'',
'pid'=>$rule_id,
'level'=>$level+1,
'sort'=>40,
'addtime'=>time()
],
[
'name'=>$name.'_alldel?cid='.$type_id,
'title'=>'全选删除',
'type'=>1,
'status'=>0,
'notcheck'=>0,
'css'=>'',
'condition'=>'',
'pid'=>$rule_id,
'level'=>$level+1,
'sort'=>50,
'addtime'=>time()
]
];
Db::name('auth_rule')->insertAll($data);
cache('menus_admin_'.session('admin_auth.aid'),null);
//提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error('添加失败',url('admin/Type/type_list'));
}
$this->success('添加成功',url('admin/Type/type_list'));
}else{
$rst=Db::name('type')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Type/type_list'));
}else{
$this->error('添加失败',url('admin/Type/type_list'));
}
}
}
}
}
/**
* 编辑显示
*/
public function type_edit()
{
if (!request()->isAjax()) {
$id = input('id');
if (empty($id)) {
$this->error('参数错误', url('admin/Type/type_list'));
}
$list = Db::name('type')->find($id);
$this->assign('list', $list);
$this->assign('types',config('type'));
return $this->fetch();
}else{
$id=input('id',0,'intval');
$old=Db::name('type')->find($id);
$type_type=$old['type_type'];
$type_id=input('type_id',0,'intval');
$type_name=input('type_name','');
$rst=Db::name('type')->where('id','neq',$id)->where('type_type',$type_type)->where('type_id='.$type_id.' or type_name=\''.$type_name.'\'')->find();
if($rst){
$this->error('存在相同的分类ID或分类名称',url('admin/Type/type_list'));
}else{
$sl_data=array(
'id'=>$id,
'type_name'=>$type_name,
'type_type'=>$type_type,
'type_status'=>input('type_status',0),
'type_order'=>input('type_order',50,'intval')
);
//下载类型10 公告类型11 要闻类型12 你问我答13 文化四板行业15 这些需要修改auth_rule
if(in_array($type_type,[10,11,12,13,15])){
if($old['type_id']!=$type_id || $old['type_name']!=$type_name){
//需要更新auth_rule
switch ($type_type) {
case 10:
$pid=141;
$name='admin/Download/download';
$level=3;
break;
case 11:
$pid=47;
$name='admin/Bsgg/bsgg';
$level=2;
break;
case 12:
$pid=72;
$name='admin/Bsyw/bsyw';
$level=2;
break;
case 13:
$pid=97;
$name='admin/Nwwd/nwwd';
$level=2;
break;
case 15:
$pid=230;
$name='admin/Culture/culture';
$level=3;
break;
}
Db::startTrans();
try{
Db::name('type')->update($sl_data);
Db::name('auth_rule')->where(['pid'=>$pid,'name'=>$name.'_list?cid='.$old['type_id']])->update(['name'=>$name.'_list?cid='.$type_id,'title'=>$type_name]);
cache('menus_admin_'.session('admin_auth.aid'),null);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error('修改失败',url('admin/Type/type_list'));
}
$this->success('修改成功',url('admin/Type/type_list'));
}else{
//不需更新auth_rule
$rst=Db::name('type')->update($sl_data);
if($rst){
$this->success('修改成功',url('admin/Type/type_list'));
}else{
$this->error('修改失败',url('admin/Type/type_list'));
}
}
}else{
$rst=Db::name('type')->update($sl_data);
if($rst){
$this->success('修改成功',url('admin/Type/type_list'));
}else{
$this->error('修改失败',url('admin/Type/type_list'));
}
}
}
}
}
/**
* 排序
*/
public function type_order()
{
if (!request()->isAjax()){
$this->error('提交方式不正确',url('admin/Type/type_list'));
}else{
foreach (input('post.') as $id => $type_order){
Db::name('type')->update(['id'=>$id,'type_order'=>$type_order]);
}
$this->success('排序更新成功',url('admin/Type/type_list'));
}
}
/**
* 删除(单个)
*/
public function type_del()
{
$p=input('p');
$id=input('id',0,'intval');
$rst=$this->_type_del($id);
if($rst){
cache('menus_admin_'.session('admin_auth.aid'),null);
$this->success('删除成功',url('admin/Type/type_list',array('p'=>$p)));
}else{
$this -> error("删除失败!",url('admin/Type/type_list',array('p'=>$p)));
}
}
/**
* 删除(单个)
* @param int $id
* @return boolean
*/
private function _type_del($id)
{
$old=Db::name('type')->find($id);
//下载类型10 公告类型11 要闻类型12 你问我答13 文化四板行业15 这些需要修改auth_rule
if(in_array($old['type_type'],[10,11,12,13,15])){
switch ($old['type_type']) {
case 10:
$pid=141;
$name='admin/Download/download';
break;
case 11:
$pid=47;
$name='admin/Bsgg/bsgg';
break;
case 12:
$pid=72;
$name='admin/Bsyw/bsyw';
break;
case 13:
$pid=97;
$name='admin/Nwwd/nwwd';
break;
case 15:
$pid=230;
$name='admin/Culture/culture';
break;
}
Db::startTrans();
try{
$rule=Db::name('auth_rule')->where(['pid'=>$pid,'name'=>$name.'_list?cid='.$old['type_id']])->find();
$ids=get_rule_ids_child($rule['id']);
if($ids){
Db::name('auth_rule')->where('id','in',$ids)->delete();
}
Db::name('type')->delete($id);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return false;
}
return true;
}else{
$rst=Db::name('type')->delete($id);
if($rst!==false){
return true;
}else{
return false;
}
}
}
/**
* 审核/取消审核
*/
public function type_state()
{
$id=input('x');
$status=Db::name('type')->where(array('type_id'=>$id))->value('type_status');
if($status==1){
$statedata = array('types_status'=>0);
Db::name('type')->where(array('type_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('type_status'=>1);
Db::name('type')->where(array('type_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
/**
* 删除(全选)
*/
public function type_alldel()
{
$p = input('p');
$ids = input('id/a');
if(empty($ids)){
$this -> error("请选择待删除数据",url('admin/Type/type_list',array('p'=>$p)));
}
if(!is_array($ids)){
$ids=(array)$ids;
}
foreach ($ids as $id){
$this->_type_del($id);
}
cache('menus_admin_'.session('admin_auth.aid'),null);
$this->success("删除成功",url('admin/Type/type_list',array('p'=>$p)));
}
}

511
app/admin/controller/Ueditor.php

@ -0,0 +1,511 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Common;
use think\Db;
class Ueditor extends Common
{
protected $config;
protected $type;
protected function _initialize()
{
parent::_initialize();
$adminid=session('admin_auth.aid');
$userid=session('hid');
if(empty($adminid) && empty($userid)){
exit("非法上传!");
}
}
/**
* 上传
*/
public function upload()
{
$this->type=input('edit_type','');
date_default_timezone_set("Asia/chongqing");
error_reporting(E_ERROR);
header("Content-Type: text/html; charset=utf-8");
$CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("./public/ueditor/config.json")), true);
$storage_domain=config('storage.domain');
$config_qiniu=array(
"imageUrlPrefix"=> $storage_domain, /* 图片访问路径前缀 */
"scrawlUrlPrefix" => $storage_domain, /* 图片访问路径前缀 */
"snapscreenUrlPrefix" => $storage_domain, /* 图片访问路径前缀 */
"catcherUrlPrefix" => $storage_domain, /* 图片访问路径前缀 */
"fileUrlPrefix" => $storage_domain, /* 文件访问路径前缀 */
"imageManagerUrlPrefix" => $storage_domain, /* 图片访问路径前缀 */
);
if(config('storage.storage_open') && $this->type!='mats'){
$CONFIG=array_merge($CONFIG,$config_qiniu);
}
$this->config=$CONFIG;
$action = input('action');
switch ($action) {
case 'config':
$result = json_encode($CONFIG);
break;
/* 上传图片 */
case 'uploadimage':
$result = $this->_ueditor_upload();
break;
/* 上传涂鸦 */
case 'uploadscrawl':
$result = $this->_ueditor_upload_scrawl();
break;
/* 上传视频 */
case 'uploadvideo':
$result = $this->_ueditor_upload(array('maxSize' => 1073741824,/*1G*/'exts'=>array('mp4', 'avi', 'wmv','rm','rmvb','mkv')));
break;
/* 上传文件 */
case 'uploadfile':
$result = $this->_ueditor_upload(array('exts'=>array('jpg', 'gif', 'png', 'jpeg','txt','pdf','doc','docx','xls','xlsx','zip','rar','ppt','pptx',)));
break;
/* 列出图片 */
case 'listimage':
/* 列出文件 */
case 'listfile':
$result = $this->_ueditor_list($action);
break;
/* 抓取远程文件 */
case 'catchimage':
$result = $this->_ueditor_upload_catch();
break;
default:
$result = json_encode(array('state'=> '请求地址出错'));
break;
}
/* 输出结果 */
if (isset($_GET["callback"]) && false ) {
if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
} else {
echo json_encode(array(
'state'=> 'callback参数不合法'
));
}
} else {
exit($result) ;
}
}
private function _ueditor_list($action)
{
/* 判断类型 */
switch ($action) {
/* 列出文件 */
case 'listfile':
$allowFiles = $this->config['fileManagerAllowFiles'];
$listSize = $this->config['fileManagerListSize'];
$prefix='file/';
break;
/* 列出图片 */
case 'listimage':
default:
$allowFiles = $this->config['imageManagerAllowFiles'];
$listSize = $this->config['imageManagerListSize'];
$prefix='image/';
}
$allowFiles = substr(str_replace(".", "|", join("", $allowFiles)), 1);
/* 获取参数 */
$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $listSize;
$start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
$end = intval($start) + intval($size);
if($this->type=='mats'){
//微信公众平台图片列表
$files=Db::name('we_pic')->field('mtime,url')->select();
if(empty($files)){
return json_encode(array(
"state" => "no match file",
"list" => array(),
"start" => $start,
"total" => count($files)
));
}
/* 获取指定范围的列表 */
$len = count($files);
for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--){
$list[] = $files[$i];
}
}elseif(config('storage.storage_open')){
//七牛
$upload = \Qiniu::instance();
$files = $upload->listfile($prefix);
if (!count($files)) {
return json_encode(array(
"state" => "no match file",
"list" => array(),
"start" => $start,
"total" => count($files)
));
}
/* 获取指定范围的列表 */
$len = count($files);
for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--){
$tmp['url']= $files[$i]['key'];
$tmp['mtime']= $files[$i]['putTime'];
$list[]=$tmp;
}
}else{
/* 获取文件列表 */
$path = './data/upload/';
$files = $this->getfiles($path, $allowFiles);
if (!count($files)) {
return json_encode(array(
"state" => "no match file",
"list" => array(),
"start" => $start,
"total" => count($files)
));
}
/* 获取指定范围的列表 */
$len = count($files);
for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--){
$list[] = $files[$i];
}
}
/* 返回数据 */
$result = json_encode(array(
"state" => "SUCCESS",
"list" => $list,
"start" => $start,
"total" => count($files)
));
return $result;
}
/**
* 遍历获取目录下的指定类型的文件
* @author rainfer <81818832@qq.com>
* @param string $path
* @param string $allowFiles
* @param array $files
* @return array
*/
private function getfiles($path, $allowFiles, &$files = array())
{
if (!is_dir($path)) return null;
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
$path2 = $path . $file;
if (is_dir($path2)) {
$this->getfiles($path2, $allowFiles, $files);
} else {
if (preg_match("/\.(".$allowFiles.")$/i", $file)) {
$files[] = array(
'url'=> __ROOT__.substr($path2,1),
'mtime'=> filemtime($path2)
);
}
}
}
}
return $files;
}
//上传
private function _ueditor_upload($config=array())
{
$title = '';
$url='';
if(!empty($config)){
$this->config=array_merge($this->config,$config);;
}
if($this->type=='mats'){
$file = request()->file('upfile');
if($file){
$validate=array(
'size'=>5024*1024 ,// 设置附件上传大小1M
'ext'=>array('jpg', 'png', 'gif'),
);
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if($info) {
$imgurl=ROOT_PATH.config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//上传微信
$wechat=controller('wechat/WeBase');
$material = $wechat->app->material;
$result = $material->uploadArticleImage($imgurl);
$url = $result->url;
if(!empty($url)){
$data['mtime']=time();
$data['url']=$url;
Db::name('we_pic')->insert($data);
$title =$info->getFilename();
$state = 'SUCCESS';
}else{
$state ='上传微信平台失败';
}
$file = null;
@unlink($imgurl);
}else{
$state = $file->getError();
}
}else{
$state = '未接收到文件';
}
}elseif(config('storage.storage_open')){
//七牛云存储
$upload = \Qiniu::instance();
$info = $upload->upload();
$error = $upload->getError();
if ($info) {
$state = 'SUCCESS';
$url= $info[0]['key'];
$title =$info[0]['name'];
}else{
$state = $error;
}
}else{
//本地上传
$file = request()->file('upfile');
if($file){
$validate=array(
'size'=>3145728 ,// 设置附件上传大小
//'ext'=>array('jpg', 'gif', 'png', 'jpeg'),
);
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if($info) {
$img_url=config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入本地文件数据库
$data['uptime']=time();
$data['filesize']=$info->getSize();
$data['path']=$img_url;
Db::name('plug_files')->insert($data);
$title =$info->getFilename();
$state = 'SUCCESS';
$url= __ROOT__.$img_url;
}else{
$state = $file->getError();
}
}else{
$state = '未接收到文件';
}
}
$response=array(
"state" => $state,
"url" => $url,
"title" => $title,
"original" =>$title,
);
return json_encode($response);
}
//涂鸦
private function _ueditor_upload_scrawl()
{
$data = input('post.' . $this->config ['scrawlFieldName']);
$url='';
$title = '';
$oriName = '';
if (empty ($data)) {
$state= 'Scrawl Data Empty!';
} else {
if($this->type=='mats'){
//本地存储
$img = base64_decode($data);
if(strlen($img)>1024*1024){
$state ='文件超过1M';
}else{
$savepath = save_storage_content('png', $img);
//上传微信
$wechat=controller('wechat/WeBase');
$material = $wechat->app->material;
$result = $material->uploadArticleImage(ROOT_PATH.$savepath);
$url = $result->url;
if(!empty($url)){
$sldata['mtime']=time();
$sldata['url']=$url;
Db::name('we_pic')->insert($sldata);
$state = 'SUCCESS';
}else{
$state ='上传微信平台失败';
}
@unlink(ROOT_PATH.$savepath);
}
}elseif(config('storage.storage_open')){
//七牛
$upload = \Qiniu::instance();
$info = $upload->uploadOne('data:image/png;base64,'.$data,"image/");
$error = $upload->getError();
if ($info) {
$state = 'SUCCESS';
$url= $info['key'];
$title =$info['name'];
}else{
$state = $error;
}
}else{
//本地存储
$img = base64_decode($data);
$savepath = save_storage_content('png', $img);
if ($savepath) {
$state = 'SUCCESS';
$url = __ROOT__.'/'.$savepath;
//写入数据库
$file['uptime']=time();
$file['filesize']=strlen($img);
$file['path']='/'.$savepath;
Db::name('plug_files')->insert($file);
} else {
$state = 'Save scrawl file error!';
}
}
}
$response=array(
"state" => $state,
"url" => $url,
"title" => $title,
"original" =>$oriName ,
);
return json_encode($response);
}
//抓取远程文件
private function _ueditor_upload_catch()
{
set_time_limit(0);
$sret = array(
'state' => '',
'list' => null
);
$savelist = array();
$flist = input('post.' . $this->config ['catcherFieldName'].'/a');
if (empty ($flist)) {
$sret ['state'] = 'ERROR';
} else {
$sret ['state'] = 'SUCCESS';
foreach ($flist as $f) {
if (preg_match('/^(http|ftp|https):\\/\\//i', $f)) {
$ext = strtolower(pathinfo($f, PATHINFO_EXTENSION));
if (in_array('.' . $ext, $this->config ['catcherAllowFiles'])) {
if ($img = file_get_contents($f)) {
if($this->type=='mats' && in_array($ext,array('jpg','png')) && strlen($img)<1024*1024){
//本地
$savepath = save_storage_content($ext, $img);
if ($savepath) {
//上传微信
$wechat=controller('wechat/WeBase');
$material = $wechat->app->material;
$result = $material->uploadArticleImage(ROOT_PATH.$savepath);
$url = $result->url;
if(!empty($url)){
$sldata['mtime']=time();
$sldata['url']=$url;
Db::name('we_pic')->insert($sldata);
$savelist [] = array(
'state' => 'SUCCESS',
'url' => $url,
'size' => strlen($img),
'title' => '',
'original' => '',
'source' => htmlspecialchars($f)
);
}else{
$savelist [] = array(
'state' => 'Save remote file error!',
'url' => '',
'size' => '',
'title' => '',
'original' => '',
'source' => htmlspecialchars($f),
);
}
@unlink(ROOT_PATH.$savepath);
} else {
$savelist [] = array(
'state' => 'Save remote file error!',
'url' => '',
'size' => '',
'title' => '',
'original' => '',
'source' => htmlspecialchars($f),
);
}
}elseif(config('storage.storage_open') && stripos($f,config('storage.domain'))===false){
//七牛
$upload = \Qiniu::instance();
$info = $upload->uploadcatch($f,'','',$ext);
if ($info) {
$savelist [] = array(
'state' => 'SUCCESS',
'url' => $info[0]['key'],
'size' => 0,
'title' => '',
'original' => '',
'source' => htmlspecialchars($f)
);
}else{
$savelist [] = array(
'state' => 'Save remote file error!',
'url' => '',
'size' => '',
'title' => '',
'original' => '',
'source' => htmlspecialchars($f),
);
}
}else{
//本地
$savepath = save_storage_content($ext, $img);
if ($savepath) {
$savelist [] = array(
'state' => 'SUCCESS',
'url' => __ROOT__.'/'.$savepath,
'size' => strlen($img),
'title' => '',
'original' => '',
'source' => htmlspecialchars($f)
);
//写入数据库
$data['uptime']=time();
$data['filesize']=strlen($img);
$data['path']='/'.$savepath;
Db::name('plug_files')->insert($data);
} else {
$savelist [] = array(
'state' => 'Save remote file error!',
'url' => '',
'size' => '',
'title' => '',
'original' => '',
'source' => htmlspecialchars($f),
);
}
}
} else {
$savelist [] = array(
'state' => 'Get remote file error',
'url' => '',
'size' => '',
'title' => '',
'original' => '',
'source' => htmlspecialchars($f),
);
}
} else {
$sret ['state'] = 'File ext not allowed';
}
} else {
$savelist [] = array(
'state' => 'not remote image',
'url' => '',
'size' => '',
'title' => '',
'original' => '',
'source' => htmlspecialchars($f),
);
}
}
$sret ['list'] = $savelist;
}
return json_encode($sret);
}
}

345
app/admin/controller/Video.php

@ -0,0 +1,345 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use OSS\OssClient;
use OSS\Core\OssException;
class Video extends Base
{
/**
* 宣传片列表
*/
public function video_list()
{
$vd_cid=input('cid',0,'intval');
$where['type_type']=16;
if($vd_cid){
$where['vd_cid']=$vd_cid;
}
$videos=Db::name('video')->alias('a')
->join(config('database.prefix').'type b','a.vd_cid=b.type_id')
->where($where)->order('vd_order,vd_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show = $videos->render();
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
$this->assign('page',$show);
$this->assign('videos',$videos);
$this->assign('vd_cid',$vd_cid);
$vd_cids=Db::name('type')->where('type_type',16)->order('type_order')->select();
$this->assign('vd_cids',$vd_cids);
if(request()->isAjax()){
return $this->fetch('ajax_video_list');
}else{
return $this->fetch();
}
}
/**
* 添加显示
*/
public function video_add()
{
$vd_cid=input('cid',0,'intval');
if (!request()->isAjax()){
$vd_cids=Db::name('type')->where('type_type',16)->order('type_order')->select();
$this->assign('vd_cids',$vd_cids);
$this->assign('vd_cid',$vd_cid);
return $this->fetch();
}else{
//上传图片部分
$img_one='';
$file = request()->file('pic_one');
$validate = config('upload_validate');
//单图
if ($file) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Video/video_list',['cid'=>$vd_cid]));//否则就是上传错误,显示错误原因
}
}
//视频(使用oss)
$files = request()->file('file_all');
$fileall_url='';
if($files){
if(config('aliyun_oss.oss_open')){
$config=config('aliyun_oss');
$oss=new \OSS\OssClient($config['accesskey'],$config['secretkey'],$config['endpoint'],true);
foreach ($files as $file) {
$fileinfo=$file->getInfo();
$filename=$fileinfo['name'];
$path=$fileinfo['tmp_name'];
try{
$oss->uploadFile($config['bucket'],$filename,$path);
} catch(OssException $e) {
$this->error($e->getMessage(), url('admin/Video/video_list',['cid'=>$vd_cid]));//否则就是上传错误,显示错误原因
}
$file_url = $config['endpoint'].'/'.$filename;
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $fileinfo['size'];
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
}
}else{
$validate = config('upload_validate');
foreach ($files as $file) {
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
} else {
$this->error($file->getError(), url('admin/Video/video_list',['cid'=>$vd_cid]));//否则就是上传错误,显示错误原因
}
}
}
}
$file_path=request()->post('file_path');
if(empty($fileall_url)&&$file_path){
$fileall_url=$file_path;
}
$sl_data=array(
'vd_name'=>input('vd_name'),
'vd_img'=>$img_one,//封面图片路径
'vd_status'=>input('vd_status',0),
'vd_content'=>htmlspecialchars_decode(input('vd_content')),
'vd_uid'=>session('admin_auth.aid'),
'vd_time'=>time(),
'vd_order'=>input('vd_order',50,'intval'),
'vd_video'=>$fileall_url,
'vd_cid'=>$vd_cid
);
$rst=Db::name('video')->insert($sl_data);
if($rst){
$this->success('添加成功',url('admin/Video/video_list',['cid'=>$vd_cid]));
}else{
$this->error('添加失败',url('admin/Video/video_list',['cid'=>$vd_cid]));
}
}
}
/**
* 编辑显示
*/
public function video_edit()
{
$vd_cid=input('cid',0,'intval');
if (!request()->isAjax()) {
$vd_id = input('vd_id');
if (empty($vd_id)) {
if($vd_cid){
$this->error('参数错误', url('admin/Link/link_list',['cid'=>$vd_cid]));
}else{
$this->error('参数错误', url('admin/Link/link_list'));
}
}
$video_list = Db::name('video')->find($vd_id);
$this->assign('video_list', $video_list);
$vd_cids=Db::name('type')->where('type_type',16)->order('type_order')->select();
$this->assign('vd_cids',$vd_cids);
$this->assign('vd_cid',$video_list['vd_cid']);
return $this->fetch();
}else{
$img_one='';
$file = request()->file('pic_one');
$validate = config('upload_validate');
//单图
if (!empty($file)) {
$info = $file[0]->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $img_url;
Db::name('plug_files')->insert($data);
$img_one = $img_url;
} else {
$this->error($file->getError(), url('admin/Video/video_list',['cid'=>$vd_cid]));//否则就是上传错误,显示错误原因
}
}
//视频
$files = request()->file('file_all');
$fileall_url='';
if($files){
if(config('aliyun_oss.oss_open')){
$config=config('aliyun_oss');
$oss=new \OSS\OssClient($config['accesskey'],$config['secretkey'],$config['endpoint'],true);
foreach ($files as $file) {
$fileinfo=$file->getInfo();
$filename=$fileinfo['name'];
$path=$fileinfo['tmp_name'];
try{
$oss->uploadFile($config['bucket'],$filename,$path);
} catch(OssException $e) {
$this->error($e->getMessage(), url('admin/Video/video_list',['cid'=>$vd_cid]));//否则就是上传错误,显示错误原因
}
$file_url = $config['endpoint'].'/'.$filename;
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $fileinfo['size'];
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
}
}else{
$validate = config('upload_validate');
foreach ($files as $file) {
$info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
//写入数据库
$data['uptime'] = time();
$data['filesize'] = $info->getSize();
$data['path'] = $file_url;
Db::name('plug_files')->insert($data);
$fileall_url = $file_url;
} else {
$this->error($file->getError(), url('admin/Video/video_list',['cid'=>$vd_cid]));//否则就是上传错误,显示错误原因
}
}
}
}
$file_path=request()->post('file_path');
if(empty($fileall_url)&&$file_path){
$fileall_url=$file_path;
}
$sl_data=array(
'vd_id'=>input('vd_id'),
'vd_name'=>input('vd_name'),
'vd_status'=>input('vd_status',0),
'vd_content'=>htmlspecialchars_decode(input('vd_content')),
'vd_order'=>input('vd_order',50,'intval'),
'vd_cid'=>$vd_cid
);
//图片字段处理
if(!empty($img_one)){
$sl_data['vd_img']=$img_one;
}
if(!empty($fileall_url)){
$sl_data['vd_video']=$fileall_url;
}
$rst=Db::name('video')->update($sl_data);
if($rst!==false){
$this->success('修改成功',url('admin/Video/video_list',['cid'=>$vd_cid]));
}else{
$this->error('修改失败',url('admin/Video/video_list',['cid'=>$vd_cid]));
}
}
}
/**
* 排序
*/
public function video_order()
{
$vd_cid=input('cid',0,'intval');
if (!request()->isAjax()){
if($vd_cid){
$this->error('提交方式不正确', url('admin/Video/video_list',['cid'=>$vd_cid]));
}else{
$this->error('提交方式不正确', url('admin/Video/video_list'));
}
}else{
foreach (input('post.') as $vd_id => $vd_order){
Db::name('video')->update(['vd_id'=>$vd_id,'vd_order'=>$vd_order]);
}
if($vd_cid){
$this->success('排序更新成功',url('admin/Video/video_list',['cid'=>$vd_cid]));
}else{
$this->success('排序更新成功',url('admin/Video/video_list'));
}
}
}
/**
* 删除(单个)
*/
public function video_del()
{
$p=input('p');
$rst=Db::name('video')->delete(input('vd_id'));
$vd_cid=input('cid',0,'intval');
if($rst!==false){
if($vd_cid){
$this->success('删除成功',url('admin/Video/video_list',array('p'=>$p,'cid'=>$vd_cid)));
}else{
$this->success('删除成功',url('admin/Video/video_list',array('p'=>$p)));
}
}else{
if($vd_cid){
$this -> error("删除失败!",url('admin/Video/video_list',array('p'=>$p,'cid'=>$vd_cid)));
}else{
$this -> error("删除失败!",url('admin/Video/video_list',array('p'=>$p)));
}
}
}
/**
* 删除(全选)
*/
public function video_alldel()
{
$p = input('p');
$ids = input('vd_id/a');
$vd_cid=input('cid',0,'intval');
if(empty($ids)){
if($vd_cid){
$this -> error("请选择待删除数据",url('admin/Video/video_list',array('p'=>$p,'cid'=>$vd_cid)));
}else{
$this -> error("请选择待删除数据",url('admin/Video/video_list',array('p'=>$p)));
}
}
if(is_array($ids)){
$where = 'vd_id in('.implode(',',$ids).')';
}else{
$where = 'vd_id='.$ids;
}
$rst=Db::name('video')->where($where)->delete();
if($rst!==false){
if($vd_cid){
$this->success("删除成功",url('admin/Video/video_list',array('p'=>$p,'cid'=>$vd_cid)));
}else{
$this->success("删除成功",url('admin/Video/video_list',array('p'=>$p)));
}
}else{
if($vd_cid){
$this -> error("删除失败!",url('admin/Video/video_list',array('p'=>$p,'cid'=>$vd_cid)));
}else{
$this -> error("删除失败!",url('admin/Video/video_list',array('p'=>$p)));
}
}
}
/**
* 审核/取消审核
*/
public function video_state()
{
$id=input('x');
$status=Db::name('video')->where(array('vd_id'=>$id))->value('vd_status');
if($status==1){
$statedata = array('vd_status'=>0);
Db::name('video')->where(array('vd_id'=>$id))->setField($statedata);
$this->success('未审');
}else{
$statedata = array('vd_status'=>1);
Db::name('video')->where(array('vd_id'=>$id))->setField($statedata);
$this->success('已审');
}
}
}

213
app/admin/controller/WebLog.php

@ -0,0 +1,213 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Db;
use think\Cache;
class WebLog extends Base
{
/*
* 网站日志列表
*/
public function weblog_list()
{
$methods=['GET','POST','PUT','DELETE','HEAD','PATCH','OPTIONS','Ajax','Pjax'];
$request_module=input('request_module','');
$controllers=array();
$controllers_arr=array();
if($request_module){
$controllers_arr=\ReadClass::readDir(APP_PATH . $request_module. DS .'controller');
$controllers=array_keys($controllers_arr);
}
$request_controller=input('request_controller','');
$actions=array();
if($request_module && $request_controller){
$actions=$controllers_arr[$request_controller];
$actions=array_map('array_shift',$actions['method']);
}
$request_action=input('request_action','');
$request_method=input('request_method','');
//组成where
$where=array();
$join = [
[config('database.prefix').'member_list b','b.member_list_id=a.uid', 'LEFT']
];
if($request_module){
$where['module']=$request_module;
}
if($request_controller){
$where['controller']=$request_controller;
}
if($request_action){
$where['action']=$request_action;
}
if($request_method){
$where['method']=$request_method;
}
$weblog_list=Db::name('web_log')->where($where)
->order('otime desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
$show=$weblog_list->render();
if($weblog_list){
$weblog_list=$weblog_list->toArray();
$weblog_list=$weblog_list['data'];
foreach ($weblog_list as &$row){
$utype=$row['type'];
$uid=$row['uid'];
$name='';
if($utype==2){
$user=Db::name('admin')->where(['admin_id'=>$uid])->find();
if($user){
$name=$user['admin_username'];
}
}else{
$user=Db::name('member_list')->where(['member_list_id'=>$uid])->find();
if($user){
$name=$user['member_list_username'];
}
}
$row['member_list_id']=$uid;
$row['member_list_username']=$name;
}
}
$this->assign('weblog_list',$weblog_list);
$this->assign('page',$show);
$this->assign('request_module',$request_module);
$this->assign('request_controller',$request_controller);
$this->assign('request_action',$request_action);
$this->assign('request_method',$request_method);
$this->assign('controllers',$controllers);
$this->assign('actions',$actions);
$this->assign('methods',$methods);
if(request()->isAjax()){
return $this->fetch('ajax_weblog_list');
}else{
return $this->fetch();
}
}
/*
* 网站日志删除
*/
public function weblog_del()
{
$rst=Db::name('web_log')->delete(input('id'));
if($rst!==false){
$this->success('删除成功',url('admin/WebLog/weblog_list'));
}else{
$this -> error("删除失败",url('admin/WebLog/weblog_list'));
}
}
/*
* 网站日志全选删除
*/
public function weblog_alldel()
{
$ids = input('id/a');
if(empty($ids)){
$this -> error("请至少选择一行",url('admin/WebLog/weblog_list'));
}
if(is_array($ids)){
$where = 'id in('.implode(',',$ids).')';
}else{
$where = 'id='.$ids;
}
$rst=Db::name('web_log')->where($where)->delete();
if($rst!==false){
$this->success("删除成功",url('admin/WebLog/weblog_list'));
}else{
$this -> error("删除失败",url('admin/WebLog/weblog_list'));
}
}
/*
* 网站日志清空
*/
public function weblog_drop()
{
$rst=Db::name('web_log')->where('id','gt',0)->delete();
if($rst!==false){
$this->success('清空成功',url('admin/WebLog/weblog_list'));
}else{
$this -> error("清空失败",url('admin/WebLog/weblog_list'));
}
}
/*
* 网站日志设置显示
*/
public function weblog_setting()
{
$web_log=config('web_log');
//模块
$web_log['not_log_module']=(isset($web_log['not_log_module']) && $web_log['not_log_module'])?join(',',$web_log['not_log_module']):'';
$web_log['not_log_controller']=(isset($web_log['not_log_controller']) && $web_log['not_log_controller'])?join(',',$web_log['not_log_controller']):'';
$web_log['not_log_action']=(isset($web_log['not_log_action']) && $web_log['not_log_action'])?join(',',$web_log['not_log_action']):'';
$web_log['not_log_data']=(isset($web_log['not_log_data']) && $web_log['not_log_data'])?join(',',$web_log['not_log_data']):'';
$web_log['not_log_request_method']=(isset($web_log['not_log_request_method']) && $web_log['not_log_request_method'])?join(',',$web_log['not_log_request_method']):'';
//控制器 模块
$controllers=array();
$actions=array();
$modules=['home','admin'];
foreach($modules as $module){
$arr=cache('controllers_'.$module);
if(empty($arr)){
$arr=\ReadClass::readDir(APP_PATH . $module. DS .'controller');
cache('controllers'.'_'.$module,$arr);
}
if($arr){
foreach($arr as $key=>$v){
$controllers[$module][]=$module.'/'.$key;
$actions[$module.'/'.$key]=array_map('array_shift',$v['method']);
}
}
}
$methods=['GET','POST','PUT','DELETE','HEAD','PATCH','OPTIONS','Ajax','Pjax'];
$this->assign('methods',$methods);
$this->assign('actions',$actions);
$this->assign('modules',$modules);
$this->assign('controllers',$controllers);
$this->assign('web_log',$web_log);
return $this->fetch();
}
/*
* 网站日志设置保存
*/
public function weblog_runset()
{
$weblog_on=input('weblog_on',0,'intval')?true:false;
//设置tags
$configs=include APP_PATH.'tags.php';
$module_init=$configs['module_init'];
if($weblog_on){
if(!in_array('app\\common\\behavior\\WebLog',$module_init)){
$module_init[]='app\\common\\behavior\\WebLog';
}
}else{
$key = array_search('app\\common\\behavior\\WebLog', $module_init);
if($key!==false){
unset($module_init[$key]);
}
}
$configs=array_merge($configs,['module_init'=>$module_init]);
file_put_contents(APP_PATH.'tags.php', "<?php\treturn " . var_export($configs, true) . ";");
$web_log['weblog_on']=$weblog_on;
$web_log['not_log_module']=input('not_log_module/a');
$web_log['not_log_controller']=input('not_log_controller/a');
$web_log['not_log_action']=input('not_log_action/a');
$web_log['not_log_data']=input('not_log_data/a');
$web_log['not_log_request_method']=input('not_log_request_method/a');
$rst=sys_config_setbykey('web_log',$web_log);
if($rst){
Cache::clear();
$this->success('设置保存成功',url('admin/WebLog/weblog_setting'));
}else{
$this->error('设置保存失败',url('admin/WebLog/weblog_setting'));
}
}
}

71
app/admin/controller/Whjrfwzx.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Whjrfwzx extends News
{
public function _initialize()
{
$this->table_name='whjrfwzx';
$this->controller_name='Whjrfwzx';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function whjrfwzx_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function whjrfwzx_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function whjrfwzx_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function whjrfwzx_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function whjrfwzx_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function whjrfwzx_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function whjrfwzx_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Whsb.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Whsb extends News
{
public function _initialize()
{
$this->table_name='whsb';
$this->controller_name='Whsb';
$this->has_imgs=false;
$this->has_img=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 栏目列表
*/
public function whsb_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function whsb_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function whsb_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function whsb_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function whsb_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function whsb_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function whsb_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Whsbhd.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Whsbhd extends News
{
public function _initialize()
{
$this->table_name='bshd';
$this->controller_name='Whsbhd';
$this->has_imgs=false;
$this->has_img=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 栏目列表
*/
public function bshd_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function bshd_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function bshd_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function bshd_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function bshd_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function bshd_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function bshd_state()
{
return $this->news_state();
}
}

72
app/admin/controller/Ypnew.php

@ -0,0 +1,72 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/23
* Time: 15:47
*/
namespace app\admin\controller;
class Ypnew extends News
{
public function _initialize()
{
$this->table_name='zgwhjf_ypnew';
$this->controller_name='Ypnew';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zgwhjf_ypnew_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zgwhjf_ypnew_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zgwhjf_ypnew_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zgwhjf_ypnew_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zgwhjf_ypnew_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zgwhjf_ypnew_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zgwhjf_ypnew_state()
{
return $this->news_state();
}
}

72
app/admin/controller/Ysjyhnew.php

@ -0,0 +1,72 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/23
* Time: 15:57
*/
namespace app\admin\controller;
class Ysjyhnew extends News
{
public function _initialize()
{
$this->table_name='zgwhjf_ysjyhnew';
$this->controller_name='Ysjyhnew';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zgwhjf_ysjyhnew_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zgwhjf_ysjyhnew_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zgwhjf_ysjyhnew_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zgwhjf_ysjyhnew_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zgwhjf_ysjyhnew_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zgwhjf_ysjyhnew_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zgwhjf_ysjyhnew_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Zbxstgzx.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Zbxstgzx extends News
{
public function _initialize()
{
$this->table_name='zbxstgzx';
$this->controller_name='Zbxstgzx';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zbxstgzx_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zbxstgzx_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zbxstgzx_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zbxstgzx_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zbxstgzx_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zbxstgzx_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zbxstgzx_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Zbzq.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Zbzq extends News
{
public function _initialize()
{
$this->table_name='zbzq';
$this->controller_name='Zbzq';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zbzq_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zbzq_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zbzq_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zbzq_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zbzq_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zbzq_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zbzq_state()
{
return $this->news_state();
}
}

68
app/admin/controller/Zcfg.php

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Zcfg extends News
{
public function _initialize()
{
$this->table_name='zcfg';
$this->controller_name='Zcfg';
parent::_initialize();
}
/**
* 公告列表
*/
public function zcfg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zcfg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zcfg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zcfg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zcfg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zcfg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zcfg_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Zcfwjg.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Zcfwjg extends News
{
public function _initialize()
{
$this->table_name='zcfwjg';
$this->controller_name='Zcfwjg';
$this->has_img=false;
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 列表
*/
public function zcfwjg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zcfwjg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zcfwjg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zcfwjg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zcfwjg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zcfwjg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zcfwjg_state()
{
return $this->news_state();
}
}

71
app/admin/controller/Zjtd.php

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Zjtd extends News
{
public function _initialize()
{
$this->table_name='zjtd';
$this->controller_name='Zjtd';
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 公告列表
*/
public function zjtd_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zjtd_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zjtd_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zjtd_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zjtd_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zjtd_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zjtd_state()
{
return $this->news_state();
}
}

70
app/admin/controller/Zzjg.php

@ -0,0 +1,70 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Zzjg extends News
{
public function _initialize()
{
$this->table_name='zzjg';
$this->controller_name='Zzjg';
$this->has_imgs=false;
$this->has_source=false;
parent::_initialize();
}
/**
* 公告列表
*/
public function zzjg_list()
{
return $this->news_list();
}
/**
* 添加显示
*/
public function zzjg_add()
{
return $this->news_add();
}
/**
* 编辑显示
*/
public function zzjg_edit()
{
return $this->news_edit();
}
/**
* 排序
*/
public function zzjg_order()
{
return $this->news_order();
}
/**
* 删除(单个)
*/
public function zzjg_del()
{
return $this->news_del();
}
/**
* 删除(全选)
*/
public function zzjg_alldel()
{
return $this->news_alldel();
}
/**
* 审核/取消审核
*/
public function zzjg_state()
{
return $this->news_state();
}
}

210
app/admin/model/Admin.php

@ -0,0 +1,210 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use app\admin\model\MemberList;
use think\Model;
use think\Db;
/**
* 后台用户模型
* @package app\admin\model
*/
class Admin extends Model
{
protected $autoWriteTimestamp = true;
protected $createTime = 'admin_addtime';
protected $updateTime = false;
/**
* 用户登录
* @param string $username 用户名
* @param string $password 密码
* @param bool $rememberme 记住登录
* @return bool|mixed
*/
public function login($username = '', $password = '', $rememberme = false)
{
$username = trim($username);
$password = trim($password);
$map['admin_username']=$username;
$map['admin_open']=1;
$user = self::get($map);
if (!$user) {
$this->error = '用户不存在或被禁用!';
} else {
if (encrypt_password($password,$user['admin_pwd_salt'])!==$user['admin_pwd']) {
$this->error = '密码错误!';
} else {
$aid = $user['admin_id'];
// 更新登录信息
$user['admin_last_ip'] = request()->ip();
$user['admin_last_time'] = time();
$user['admin_hits'] = $user['admin_hits']+1;
if ($user->save()) {
// 自动登录
$this->auto_login(self::get($aid), $rememberme);
}
return $aid;
}
}
return false;
}
/**
* 自动登录
* @param mixed $user 用户对象
* @param bool $rememberme 是否记住登录,默认7天
*/
public function auto_login($user, $rememberme = false)
{
$avatar= $user->admin_avatar;
if(!file_exists($avatar))$avatar='/public/img/headicon.png';
// 记录登录
$auth = array(
'aid' => $user->admin_id,
'role' => '',
'admin_avatar' => $avatar,
'admin_last_change_pwd_time' => $user->admin_changepwd,
'admin_realname' => $user->admin_realname,
'admin_username' => $user->admin_username,
'member_id' => $user->member_id,
'admin_last_ip' => $user->admin_last_ip,
'admin_last_time' => $user->admin_last_time
);
$access=db('auth_group_access')->where(['uid'=>$auth['aid']])->order('group_id asc')->find();
if($access)$auth['role']=$access['group_id'];
session('admin_auth', $auth);
session('admin_auth_sign', data_signature($auth));
// 记住登录
if ($rememberme) {
$signin_token = $user->admin_username.$user->admin_id.$user->admin_last_time;
cookie('aid', $user->admin_id, 24 * 3600 * 7);
cookie('signin_token', data_signature($signin_token), 24 * 3600 * 7);
}
}
/**
* 判断是否登录
* @return int 0或用户id
*/
public function is_login()
{
$user = session('admin_auth');
if (empty($user)) {
if (cookie('?aid') && cookie('?signin_token')) {
$user = $this::get(cookie('aid'));
if ($user) {
$signin_token = data_signature($user['admin_username'].$user['admin_id'].$user['admin_last_time']);
if (cookie('signin_token') == $signin_token) {
$this->auto_login($user, true);
return $user['admin_id'];
}
}
};
return 0;
}else{
return session('admin_auth_sign') == data_signature($user) ? $user['aid'] : 0;
}
}
/**
* 增加管理员
*/
public static function add($admin_username,$admin_pwd_salt='',$admin_pwd,$admin_email='',$admin_tel='',$admin_open=0,$admin_realname='',$group_id=1)
{
$admin_pwd_salt=$admin_pwd_salt?:random(10);
$sldata=array(
'admin_username'=>$admin_username,
'admin_pwd_salt' => $admin_pwd_salt,
'admin_pwd'=>encrypt_password($admin_pwd,$admin_pwd_salt),
'admin_email'=>$admin_email,
'admin_tel'=>$admin_tel,
'admin_open'=>$admin_open,
'admin_realname'=>$admin_realname,
'admin_ip'=>request()->ip(),
'admin_addtime'=>time(),
'admin_changepwd'=>time(),
);
$admin=self::create($sldata);
if($admin){
//添加管理组
$admin_id=$admin['admin_id'];
$accdata=array(
'uid'=>$admin_id,
'group_id'=>$group_id,
);
Db::name('auth_group_access')->insert($accdata);
return $admin_id;
}else{
return 0;
}
}
/**
* 修改管理员
* @param array
* @return bool
*/
public static function edit($data)
{
$admin=self::get($data['admin_id'])->toArray();
$admin['admin_username']=$data['admin_username'];
$admin['admin_email']=$data['admin_email'];
$admin['admin_tel']=$data['admin_tel'];
$admin['admin_realname']=$data['admin_realname'];
$admin['admin_open']=isset($data['admin_open'])?$data['admin_open']:0;
if($data['admin_pwd']){
$admin['admin_pwd_salt']=random(10);
$admin['admin_pwd']=encrypt_password($data['admin_pwd'],$admin['admin_pwd_salt']);
$admin['admin_changepwd']=time();
}
$rst=self::where('admin_id',$data['admin_id'])->update($admin);
if($rst!==false){
$access=Db::name('auth_group_access')->where('uid',$data['admin_id'])->find();
if($access){
//修改
if($access['group_id']!=$data['group_id']){
Db::name('auth_group_access')->where('uid',$data['admin_id'])->setField('group_id',$data['group_id']);
}
}else{
//增加
$access['uid']=$data['admin_id'];
$access['group_id']=$data['group_id'];
Db::name('auth_group_access')->insert($access);
}
return true;
}else{
return false;
}
}
/**
* 修改管理员
* @param array
* @return bool
*/
public static function avatar_edit($data)
{
$admin=self::get($data['admin_id'])->toArray();
$admin['admin_email']=$data['admin_email'];
$admin['admin_tel']=$data['admin_tel'];
$admin['admin_realname']=$data['admin_realname'];
if($data['admin_pwd']){
$admin['admin_pwd_salt']=random(10);
$admin['admin_pwd']=encrypt_password($data['admin_pwd'],$admin['admin_pwd_salt']);
$admin['admin_changepwd']=time();
}
$rst=self::where('admin_id',$data['admin_id'])->update($admin);
if($rst!==false){
return true;
}else{
return false;
}
}
}

21
app/admin/model/Asklog.php

@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class Asklog extends Model
{
}

270
app/admin/model/AuthRule.php

@ -0,0 +1,270 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
use app\admin\controller\Auth;
/**
* 后台菜单模型
* @package app\admin\model
*/
class AuthRule extends Model
{
protected $not_check_id=[1];//不检测权限的管理员id
protected $not_check_url=['admin/Index/index','admin/Sys/clear','admin/Index/lang'];//不检测权限的url
/**
* 获取所有父节点id(含自身)
* @param int $id 节点id
* @return array
*/
public function get_admin_parents($id =0)
{
$id=$id?:$this->get_url_id('',1);
if(empty($id)) return [];
$lists=self::order('level desc,sort')->column('pid','id');
$ids = [];
while (isset($lists[$id]) && $lists[$id] !=0){
$ids[]=$id;
$id=$lists[$id];
}
if(isset($lists[$id]) && $lists[$id]==0) $ids[]=$id;
return array_reverse($ids);
}
/**
* 获取当前节点及父节点下菜单(仅显示状态)
* @param int $id 节点id
* @return array|mixed
*/
public function get_admin_parent_menus(&$id)
{
$id=$this->get_url_id('',1);
$pid=self::where('id',$id)->value('pid');
//取$pid下子菜单
$menus=self::where(array('status'=>1,'pid'=>$pid))->order('sort')->select();
return $menus;
}
/**
* 获取不需要验证的节点id
* @return array
*/
public static function get_notcheck_ids()
{
$ids = self::where('notcheck', 1)->column('id');
return $ids;
}
/**
* 获取指定url的id(可能为显示状态或非显示状态)
* @param string $url 为空获取当前操作的id
* @param int $status 1表示取显示状态,为空或为0则不限制
* @return int -1表示不需要检测 0表示无后台菜单 其他表示当前url对应id
*/
public function get_url_id($url='',$status=0)
{
$url=$url?:request()->module().'/'.request()->controller().'/'.request()->action();
if($url=='//'){
$routeInfo=request()->routeInfo();
//插件管理
if($routeInfo['route']=='\think\addons\Base@execute'){
$menu_id = self::where('name','admin/Addons/addons_list')->order('level desc,sort')->value('id');
return $menu_id?:0;
}
}
if(in_array($url,$this->not_check_url)) return -1;
if(in_array($url,['admin/Model/cmslist','admin/Model/cmsadd'])){
$id=get_query();
if(isset($id['id'])){
$id=$id['id'];
$url.='?id='.$id;
}
}
if(in_array(CONTROLLER_NAME,['Download','Lcwhcyb','Feedback','Culture','Link','Bsgg','Bsyw','Sczcxy','Nwwd','Bsjs','Zzjg','Zcfg','Gyzc','Hyzq','Zjtd','Lxwm','Lxwm','Video','Whsb','Whsbhd','Bsry','Bszc','Gpgl','Whjrfwzx','Zbzq','Zbxstgzx','Ssyyzx','Tjjg','Zcfwjg','Dsffwjg','Bjjg'])){
$query=get_query();
if(isset($query['cid'])){
$cid=$query['cid'];
$url.='?cid='.$cid;
}
}
//托管、合作机构选中菜单
if(in_array(CONTROLLER_NAME,['Trusteeship','Orgapply'])){
$query=get_query();
//托管、合作机构列表带有状态参数
if(isset($query['applystatus'])){
$applystatus=$query['applystatus'];
//审核页面,选中对应的状态的列表菜单
if(in_array($url,['tuoguan/Trusteeship/apply_check','org/Orgapply/apply_check'])){
$url.='?applystatus='.$applystatus;
$url = str_replace('apply_check','apply_list',$url);
}else{
$url.='?applystatus='.$applystatus;
}
}
}
// echo "<div style='display:none'>".$url."</div>";
if(in_array(CONTROLLER_NAME,['Gpgl','Bigdata','News','Page','Agencys','Ask'])){
$kind=input('kind','');
$module=ACTION_NAME;
$module=strtolower($module);
if($kind!=''&&$module!="export"){
$url.=strpos($url,'?')?'&kind='.$kind:'?kind='.$kind;
}
}
if(in_array(CONTROLLER_NAME,['Capital','Sys','Cult4'])){
$kind=input('apply_type','');
if($kind){
$url.=strpos($url,'?')?'&apply_type='.$kind:'?apply_type='.$kind;
}
}
if(in_array(CONTROLLER_NAME,['Download'])){
$catid=input('catid','');
if($catid){
$url.='&catid='.$catid;
}
}
if(in_array(CONTROLLER_NAME,['News'])){
$catid=input('cid','');
$module=strtolower($module);
if($catid){
if(strpos($module,"apply")!=-1||$module=='export'){
$url.='?cid='.$catid;
}else if($catid){
$url.='&cid='.$catid;
}
}
}
$where['name']=[['eq',$url],['eq',htmlentities($url)],'or'];
if($status) $where['status']=$status;
$menu_id = self::where($where)->order('level desc,sort')->value('id');//4级或3级(如果4级,status是0,不显示)
if(isset($query['cid'])&&empty($menu_id)){
$url=str_replace('?cid='.$query['cid'],'', $url);
$where['name']=$url;
$menu_id = self::where($where)->order('level desc,sort')->value('id');//4级或3级(如果4级,status是0,不显示)
}
$menu_id=$menu_id?:0;
return $menu_id;
}
/**
* 权限检测
* @param int
* @return boolean
*/
public function check_auth($id=0)
{
$id=$id?:$this->get_url_id();
if($id==-1) return true;
$uid=session('admin_auth.aid');
if(in_array($uid,$this->not_check_id)) return true;
$auth = new Auth();
//超管跳过
if(in_array(1,$auth->getGroupIds($uid))) return true;
$auth_ids_list=cache('auth_ids_list_'.$uid);
if(!$auth_ids_list){
$auth_ids_list=$auth->getAuthList($uid,1,'id');
cache('auth_ids_list_'.$uid,$auth_ids_list);
}
if(empty($auth_ids_list)) return false;
if(in_array($id,$auth_ids_list)){
return true;
}else{
return false;
}
}
/**
* 菜单检查是否有效
* @param int
* @return string 返回''表示无效,否则返回正确的name字符串
*/
public static function check_name($name,$level=1)
{
$module='admin';
$arr=explode('/',$name);
$count=count($arr);
$rst='';
if($level==1){
if($count>1){
$module=strtolower($arr[0]);
$controller=ucfirst($arr[1]);
}else{
$controller=ucfirst($name);
}
if (has_controller($module,$controller)) {
$rst=$module.'/'.$controller;
}
}elseif($level==2){
$rst=$name;
}else{
if($count>2){
$module=strtolower($arr[0]);
$controller=ucfirst($arr[1]);
$action=$arr[2];
}elseif($count==2){
$controller=ucfirst($arr[0]);
$action=$arr[1];
}else{
return $rst;
}
if($action){
//判断$action是否含?
$arr=explode('?',$action);
$_action=(count($arr)==1)?$action:$arr[0];
if(has_action($module,$controller,$_action)==2){
$rst=$module.'/'.$controller.'/'.$action;
}
}
}
return $rst;
}
/**
* 获取权限菜单
* @return array
*/
public function get_admin_menus()
{
$uid=session('admin_auth.aid');
$menus=cache('menus_admin_'.$uid);
if($menus) return $menus;
$where['status']=1;
if(!in_array($uid,$this->not_check_id)){
$auth_ids_list=cache('auth_ids_list_'.$uid);
if(empty($auth_ids_list)){
$auth = new Auth();
$auth_ids_list=$auth->getAuthList($uid,1,'id');
cache('auth_ids_list_'.$uid,$auth_ids_list);
}
if(empty($auth_ids_list)) return [];
$where['id']=array('in',$auth_ids_list);
}
$data = self::where($where)->order('sort')->select();
$tree=new \Tree();
$tree->init($data,['child'=>'_child','parentid'=>'pid']);
$menus=$tree->get_arraylist($data);
cache('menus_admin_'.$uid,$menus);
return $menus;
}
/**
* 获取权限菜单
* @return array
*/
public static function get_ruels_tree()
{
$data=self::order('sort')->select();
$data=collection($data)->toArray();
$tree=new \Tree();
$tree->init($data,['child'=>'sub','parentid'=>'pid']);
$rst=$tree->get_arraylist($data);
return $rst;
}
}

21
app/admin/model/Bigdata.php

@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class Bigdata extends Model
{
}

21
app/admin/model/Finance.php

@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class Finance extends Model
{
}

52
app/admin/model/MemberList.php

@ -0,0 +1,52 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 会员模型
* @package app\admin\model
*/
class MemberList extends Model
{
public function news()
{
return $this->hasMany('News','news_auto');
}
/**
* 增加会员
* @return int 0或会员id
*/
public static function add($username,$salt='',$pwd,$groupid=1,$nickname='',$email='',$tel='',$open=0,$status=0)
{
$salt=$salt?:random(10);
$sldata=array(
'member_list_username'=>$username,
'member_list_salt' => $salt,
'member_list_pwd'=>encrypt_password($pwd,$salt),
'member_list_groupid'=>$groupid,
'member_list_nickname'=>$nickname,
'member_list_email'=>$email,
'member_list_tel'=>$tel,
'member_list_open'=>$open,
'last_login_ip'=>request()->ip(),
'member_list_addtime'=>time(),
'last_login_time'=>time(),
'user_status'=>$status,
);
$member=self::create($sldata);
if($member){
return $member['member_list_id'];
}else{
return 0;
}
}
}

24
app/admin/model/Menu.php

@ -0,0 +1,24 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 前台菜单模型
* @package app\admin\model
*/
class Menu extends Model
{
public function news()
{
return $this->hasMany('News','news_columnid')->bind('menu_name');
}
}

29
app/admin/model/News.php

@ -0,0 +1,29 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class News extends Model
{
protected $insert = ['news_hits' => 200];
public function user()
{
return $this->belongsTo('MemberList','member_list_id');
}
public function menu()
{
return $this->belongsTo('Menu','id');
}
}

224
app/admin/model/Options.php

@ -0,0 +1,224 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 配置模型
* @package app\admin\model
*/
class Options extends Model
{
/*
* 前台模板文件数组
*/
public static function tpls($lang='zh-cn')
{
$tpls=cache('tpls_'.$lang);
if(empty($tpls)){
$sys=self::get_options('site_options',$lang);
$arr=list_file(APP_PATH.'home/view/'.$sys['site_tpl'],'*.html');
$tpls=array();
foreach($arr as $v){
$tpls[]=basename($v['filename'],'.html');
}
cache('tpls_'.$lang,$tpls);
}
return $tpls;
}
/*
* 前台themes
*/
public static function themes()
{
$themes=cache('themes');
if(empty($themes)){
$arr=list_file(APP_PATH.'home/view/');
foreach($arr as $v){
if($v['isDir'] && strtolower($v['filename']!='public')){
$themes[]=$v['filename'];
}
}
cache('themes',$themes);
}
return $themes;
}
/*
* 获取百度map
*/
public static function map($lang='zh-cn')
{
$map=cache('site_options_map');
if(empty($map)){
$site_options = self::get_options('site_options',$lang);
$map['map_lat']=isset($site_options['map_lat'])?$site_options['map_lat']:'';
$map['map_lng']=isset($site_options['map_lng'])?$site_options['map_lng']:'';
if((empty($map['map_lat']) || empty($map['map_lng'])) && $site_options['site_co_name']){
$strUrl='http://api.map.baidu.com/place/v2/search?query='.$site_options['site_co_name'].'&region=全国&city_limit=false&output=json&ak='.config('baidumap_ak');//自己去申请ak
$jsonStr = file_get_contents($strUrl);
$arr = json_decode($jsonStr,true);
if($arr['results'] && $arr['results'][0]['location']){
$map['map_lat']=$arr['results'][0]['location']['lat'];
$map['map_lng']=$arr['results'][0]['location']['lng'];
}
}
cache('site_options_map',$map);
}
return $map;
}
/*
* 获取系统基本设置
*/
public static function get_options($type='site_options',$lang='zh-cn')
{
$options = cache($type.'_'.$lang);
if(empty($options)){
switch ($type){
case 'email_options':
$sys=array(
'email_open'=>0,
'email_rename'=>'',
'email_name'=>'',
'email_smtpname'=>'',
'smtpsecure'=>'',
'smtp_port'=>'',
'email_emname'=>'',
'email_pwd'=>'',
);
break;
case 'active_options':
$sys=array(
'email_active'=>0,
'email_title'=>'',
'email_tpl'=>'',
);
break;
case 'agree_options':
case 'agree_options1':
case 'agree_options2':
case 'agree_options3':
case 'agree_options4':
case 'agree_options5':
case 'agree_options6':
$sys=array(
'content_tpl'=>'',
);
break;
case 'begincheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'dddcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'reviewcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'riskcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'notice_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'gjnotice_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'number_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'tgfee_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'tgcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'tgcheckfk_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'feecheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
default:
$sys=array(
'map_lat'=>'',
'map_lng'=>'',
'site_name'=>'',
'site_host'=>'',
'site_tpl'=>'',
'site_tpl_m'=>'',
'site_logo'=>'',
'site_icp'=>'',
'site_tongji'=>'',
'site_copyright'=>'',
'site_co_name'=>'',
'site_address'=>'',
'site_tel'=>'',
'site_admin_email'=>'',
'site_qq'=>'',
'site_seo_title'=>'',
'site_seo_keywords'=>'',
'site_seo_description'=>'',
'content_tpl'=>'',
);
}
$options=self::where(array('option_name'=>$type,'option_l'=>$lang))->find();
if($options)$options=$options->toArray();
if(empty($options)){
$options=self::where(array('option_name'=>$type,'option_l'=>'zh-cn'))->find();
if($options)$options=$options->toArray();
if($options){
$options['option_l']=$lang;
unset($options['option_id']);
}else{
$options=[
'option_name'=>$type,
'option_l'=>$lang,
'option_value'=>'{}'
];
}
self::create($options);
}
$options=json_decode($options['option_value'],true);
$options=array_merge($sys,$options);
cache($type.'_'.$lang,$options);
}
return $options;
}
/*
* 设置系统基本设置
*/
public static function set_options($options=[],$type='site_options',$lang='zh-cn')
{
return self::where(['option_l'=>$lang,'option_name'=>$type])->setField('option_value',json_encode($options));
}
}

218
app/admin/model/Options1218.php

@ -0,0 +1,218 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 配置模型
* @package app\admin\model
*/
class Options extends Model
{
/*
* 前台模板文件数组
*/
public static function tpls($lang='zh-cn')
{
$tpls=cache('tpls_'.$lang);
if(empty($tpls)){
$sys=self::get_options('site_options',$lang);
$arr=list_file(APP_PATH.'home/view/'.$sys['site_tpl'],'*.html');
$tpls=array();
foreach($arr as $v){
$tpls[]=basename($v['filename'],'.html');
}
cache('tpls_'.$lang,$tpls);
}
return $tpls;
}
/*
* 前台themes
*/
public static function themes()
{
$themes=cache('themes');
if(empty($themes)){
$arr=list_file(APP_PATH.'home/view/');
foreach($arr as $v){
if($v['isDir'] && strtolower($v['filename']!='public')){
$themes[]=$v['filename'];
}
}
cache('themes',$themes);
}
return $themes;
}
/*
* 获取百度map
*/
public static function map($lang='zh-cn')
{
$map=cache('site_options_map');
if(empty($map)){
$site_options = self::get_options('site_options',$lang);
$map['map_lat']=isset($site_options['map_lat'])?$site_options['map_lat']:'';
$map['map_lng']=isset($site_options['map_lng'])?$site_options['map_lng']:'';
if((empty($map['map_lat']) || empty($map['map_lng'])) && $site_options['site_co_name']){
$strUrl='http://api.map.baidu.com/place/v2/search?query='.$site_options['site_co_name'].'&region=全国&city_limit=false&output=json&ak='.config('baidumap_ak');//自己去申请ak
$jsonStr = file_get_contents($strUrl);
$arr = json_decode($jsonStr,true);
if($arr['results'] && $arr['results'][0]['location']){
$map['map_lat']=$arr['results'][0]['location']['lat'];
$map['map_lng']=$arr['results'][0]['location']['lng'];
}
}
cache('site_options_map',$map);
}
return $map;
}
/*
* 获取系统基本设置
*/
public static function get_options($type='site_options',$lang='zh-cn')
{
$options = cache($type.'_'.$lang);
if(empty($options)){
switch ($type){
case 'email_options':
$sys=array(
'email_open'=>0,
'email_rename'=>'',
'email_name'=>'',
'email_smtpname'=>'',
'smtpsecure'=>'',
'smtp_port'=>'',
'email_emname'=>'',
'email_pwd'=>'',
);
break;
case 'active_options':
$sys=array(
'email_active'=>0,
'email_title'=>'',
'email_tpl'=>'',
);
break;
case 'agree_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'begincheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'dddcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'reviewcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'riskcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'notice_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'number_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'tgfee_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'tgcheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'tgcheckfk_options':
$sys=array(
'content_tpl'=>'',
);
break;
case 'feecheck_options':
$sys=array(
'content_tpl'=>'',
);
break;
default:
$sys=array(
'map_lat'=>'',
'map_lng'=>'',
'site_name'=>'',
'site_host'=>'',
'site_tpl'=>'',
'site_tpl_m'=>'',
'site_logo'=>'',
'site_icp'=>'',
'site_tongji'=>'',
'site_copyright'=>'',
'site_co_name'=>'',
'site_address'=>'',
'site_tel'=>'',
'site_admin_email'=>'',
'site_qq'=>'',
'site_seo_title'=>'',
'site_seo_keywords'=>'',
'site_seo_description'=>'',
);
}
$options='';
$select=self::where(array('option_name'=>$type,'option_l'=>$lang))->find();
if($select){
$select=$select->toArray();
}
if(empty($options)){
$options='';
$select=self::where(array('option_name'=>$type,'option_l'=>'zh-cn'))->find();
if($select){
$select=$select->toArray();
}
if($options){
$options['option_l']=$lang;
unset($options['option_id']);
}else{
$options=[
'option_name'=>$type,
'option_l'=>$lang,
'option_value'=>'{}'
];
}
self::create($options);
}
$options=json_decode($options['option_value'],true);
$options=array_merge($sys,$options);
cache($type.'_'.$lang,$options);
}
return $options;
}
/*
* 设置系统基本设置
*/
public static function set_options($options=[],$type='site_options',$lang='zh-cn')
{
return self::where(['option_l'=>$lang,'option_name'=>$type])->setField('option_value',json_encode($options));
}
}

21
app/admin/model/Procategory.php

@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class Procategory extends Model
{
}

21
app/admin/model/Product.php

@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class Product extends Model
{
}

21
app/admin/model/Proquarter.php

@ -0,0 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 文章模型
* @package app\admin\model
*/
class Proquarter extends Model
{
}
Loading…
Cancel
Save