Server : nginx/1.22.1
System : Linux iZwz9daxib3w3i063fw434Z 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64
User : www ( 1000)
PHP Version : 7.2.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Directory :  /www/wwwroot/www.jkmold.com/phpcms/modules/banner/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : /www/wwwroot/www.jkmold.com/phpcms/modules/banner/banner.php
<?php

/**

 * 自定义变量

 *

 * @author frontLon [front_diablo@163.com]

 */

defined('IN_PHPCMS') or exit('No permission resources.'); 

pc_base::load_app_class('admin', 'admin', 0);

class banner extends admin {

	private $banner,$banner_cate, $siteid;

	public function __construct() {

		$this->banner_cate = pc_base::load_model('banner_cate_model');

		$this->banner = pc_base::load_model('banner_model');

		$this->siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : $this->get_siteid();

		parent::__construct();

	}

	



	

	/* 字段管理(普通管理员) */

	public function init() {

		//状态

		if($_SERVER['REQUEST_METHOD']=="POST"){

			$kq=$_POST['status']==0?'关闭':'开启';

			if($this->banner->update(array('status'=>$_POST['status']),array('id'=>$_POST['id']))){

				echo json_encode(array('title'=>$kq.'成功','code'=>2000,'icon'=>1,'times'=>4000,'datas'=>''));

			}else{

				echo json_encode(array('title'=>$kq.'失败','code'=>4000,'icon'=>2,'times'=>4000,'datas'=>''));

			}

		

		}else{

			$banner_cates=$this->banner_cate->select(array('siteid'=>$this->siteid),"*","","bannerid ASC");

			$count = count($banner_cates);

			$j = 0;

			foreach ($banner_cates as $key =>$r) {

				$banners = $this->banner->select(array('bannerid'=>$r['bannerid']),"*","","listorder ASC");

				foreach($banners as $j => $f){

					$banner_list[$r['bannerid']][] = $f;

					$banner_list[$r['bannerid']][$j]['title'] = $banner_list[$r['bannerid']][$j]['title'];



				}

			}

			include $this->admin_tpl('init_list');

		 

		

		

		}

	

			

	}

	/*添加幻灯片*/

	public function banner_add(){

		

		if($_SERVER['REQUEST_METHOD']=="POST"){

			$siteid=$_POST['siteid']==''?$this->siteid:$_POST['siteid'];

			$info=$_POST['info'];

			if(trim($info['title'])==""){

				showmessage('名称不能为空', HTTP_REFERER);

			}

			if(trim($info['thum'])==""){

				showmessage('轮播图不能为空', HTTP_REFERER);

			}

			$info['siteid']=$siteid;

			$info['addtime']=time();

			if($this->banner->insert($info)){

				//更新缓存

			showmessage(L('operation_success'), HTTP_REFERER);

		

			}

			

		}else{

			$banner_cates=$this->banner_cate->select(array('siteid'=>$this->siteid),"*","","bannerid ASC");

			include $this->admin_tpl('banner_add');

		}

	}

	/*分类*/

	public function banner_cate(){

		if($_SERVER['REQUEST_METHOD']=="POST"){

		$info=$_POST['info'];

		$info['siteid']=$info['siteid']==""?1:$info['siteid'];

		if(trim($info['title'])==""){

			showmessage('分类名称不能为空', HTTP_REFERER);

		}

		$titles=$this->banner_cate->get_one(array('title'=>trim($info['title'])));

		if(empty($titles)){

			if($this->banner_cate->insert($info)){

				showmessage('添加成功', HTTP_REFERER);

				

			}

		}else{

			showmessage('分类名称存在', HTTP_REFERER);

			

		}

		}else{

			$banner_cates=$this->banner_cate->select(array('siteid'=>$this->siteid),"*","","bannerid ASC");

			include $this->admin_tpl('banner_cate');

		}

	}	

	/*编辑*/

	public function banner_edit(){

		$cateedit=$_GET['cateedit'];

		$id=$_GET['id'];

		if($_SERVER['REQUEST_METHOD']=="POST"){

			if($cateedit==1){

				$info=$_POST['info'];

				$titles=$this->banner_cate->get_one(array('title'=>trim($info['title'])));

				if(empty($titles)){

					if($this->banner_cate->update($info,array('bannerid'=>$info['bannerid']))){

						showmessage('编辑成功', HTTP_REFERER);

						

					}

				}else{

					showmessage('分类名称存在', HTTP_REFERER);

					

				}

			}else{

				$info=$_POST['info'];

				if($this->banner->update($info,array('id'=>$info['id']))){

						showmessage(L('operation_success'), HTTP_REFERER);

				}

			}

		}else{

			

			

			if($cateedit==1){

				$bedit=$this->banner_cate->get_one(array('bannerid'=>$id)) ;

				include $this->admin_tpl('banner_cate_edit');

			}else{

				$edit_list=$this->banner->get_one(array('id'=>$id)) ;

				$banner_title=$this->banner_cate->get_one(array('bannerid'=>$edit_list['bannerid'])) ;

				$banner_cates=$this->banner_cate->select(array('siteid'=>$this->siteid),"*","","bannerid ASC");

				include $this->admin_tpl('banner_edit');

			}

		}

	}

	/*删除*/

	public function banner_delete(){

		if($_SERVER['REQUEST_METHOD']=="POST"){

		$mid=$_POST['mid'];

		$id=$_POST['id'];



		$modules=$mid==0?$this->banner:$this->banner_cate;

		$ids=$mid==0?'id':'bannerid';

		

		if($modules->delete(array($ids=>$id))){

			echo json_encode(array('title'=>'删除成功','code'=>2000,'icon'=>1,'times'=>4000,'datas'=>''));

		}else{

			echo json_encode(array('title'=>'删除失败','code'=>4000,'icon'=>2,'times'=>4000,'datas'=>''));

		}

		}else{

			showmessage('非法操作', HTTP_REFERER);

		}

	}

	/*

	排序

	*/

	public function banner_index(){

		if($_SERVER['REQUEST_METHOD']=="POST"){

		$bannerid=$_POST['bannerid'];

		$info=$_POST['info'];

		foreach($info as $v){

			//print_r($v);

			$this->banner->update($v,array('id'=>$v['id'],'bannerid'=>$bannerid));

		}

		showmessage(L('operation_success'), HTTP_REFERER);

		}else{

		showmessage('非法操作', HTTP_REFERER);

		}

	}



}