HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: 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
Upload Files
File: /www/wwwroot/bb.cwoyt.com/Application/Admin/Controller/IndexController.class.php
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 赛脑 <2233759493@qq.com> <http://www.sn.com>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi as UserApi;

/**
 * 后台首页控制器
 * @author 赛脑 <2233759493@qq.com>
 */
class IndexController extends AdminController {

    static protected $allow = array( 'verify');

    /**
     * 后台首页
     * @author 赛脑 <2233759493@qq.com>
     */
    public function index(){
		
        if(UID){
			if(is_mobile()){
				$this->redirect('mindex');
			}
			$sysinfo = get_sysinfo();
			$sysinfo['mysqlv'] = mysql_get_server_info();
			//p($sysinfo);
			$nav_type = 'index';
			$nav_type_li = 'index';
			$this->meta_title = '管理后台';
			$this->assign(get_defined_vars());
			$this->display();
        } else {
            $this->redirect('Public/login');
        }
    }
	
	public function mindex(){
		
		$stime = strtotime(date('Ymd')); 
		$etime = strtotime(date('Ymd'))+86400;
		$shangmonth=mktime(0,0,0,date('m')-1,1,date('Y'));
		$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
		$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'));
		$dwhere['reclaim'] = array('eq',0);
		$map['reclaim'] = array('eq',0);
		$zmap['reclaim'] = array('eq',0);
		$mdmap['reclaim'] = array('eq',0);
		$zmdmap['reclaim'] = array('eq',0);
		if(UID != 1){
			$infoadmin = $this->peradmin;
			if(!in_array("order_sum",$infoadmin['order'])){
				$this->error('参数错误!');
			}
			
			$dwhere['proid']  = array('in',$infoadmin['list']);
			$dwhere['uid']  = array('eq',UID);
			$map['proid']  = array('in',$infoadmin['list']);
			$map['addtime'] = array(array('gt',$stime),array('lt',$etime));
			$map['uid']  = array('eq',UID);
			
			$zmap['proid']  = array('in',$infoadmin['list']);
			$zmap['addtime'] = array(array('gt',$stime-86400),array('lt',$stime));
			$zmap['uid']  = array('eq',UID);
			
			$mdmap['proid']  = array('in',$infoadmin['list']);
			$mdmap['addtime'] = array(array('gt',$beginThismonth),array('lt',$endThismonth));
			$mdmap['uid']  = array('eq',UID);
			
			$zmdmap['proid']  = array('in',$infoadmin['list']);
			$zmdmap['addtime'] = array(array('gt',$shangmonth),array('lt',$beginThismonth));
			$zmdmap['uid']  = array('eq',UID);
			
		}else{
			$map['addtime'] = array(array('gt',$stime),array('lt',$etime));
			$zmap['addtime'] = array(array('gt',$stime-86400),array('lt',$stime));
			$mdmap['addtime'] = array(array('gt',$beginThismonth),array('lt',$endThismonth));
			$zmdmap['addtime'] = array(array('gt',$shangmonth),array('lt',$beginThismonth));
		}
		
		$news_day_count = M('order')->where($map)->count();
		$zuo_day_count = M('order')->where($zmap)->count();
		$news_month_count = M('order')->where($mdmap)->count();
		$zuo_month_count = M('order')->where($zmdmap)->count();
		
		
		$t = time(); 
		$t4 = mktime(0,0,0,1,1,date('Y',$t)); 	//今年起点
		$e1 = mktime(23,59,59,date('m',$t),date('d',$t),date('Y',$t)); 	//今天终点
		
		$d_arr = array();
		for($i=0;$i<8;$i++){
			$d_arr[$i] = strtotime("-$i day",$e1);
		}
		$td_arr = array();
		foreach($d_arr as $k=>$v){
			$td_arr[$k] = array(
				'0' => $v,
				'1' => $d_arr[$k+1],
			);
		}
		$d_list = array();
		foreach($td_arr as $k=>$v){
			$dwhere['addtime']  = array(array('gt',$v[1]),array('lt',$v[0]));
			$d_list[$k+1]['count'] = M('order')->where($dwhere)->count();
			$d_list[$k+1]['total'] = M('order')->where($dwhere)->sum('total');
			$d_list[$k+1]['stime'] = $v[1];
			$d_list[$k+1]['etime'] = $v[0];
			$d_list[$k+1]['day'] = date('d',$v[0]);
		}
		array_pop($d_list); 
				
		$this->assign('d_list', $d_list);
		$this->assign('news_day_count', $news_day_count);
		$this->assign('zuo_day_count', $zuo_day_count);
		$this->assign('news_month_count', $news_month_count);
		$this->assign('zuo_month_count', $zuo_month_count);
		$this->assign(get_defined_vars());
		$this->display();
	}
	
	public function deldir(){
		
		//清除缓存
		delDirAndFile('Runtime');
		
		//清除没有用上的视频
		$file = M('file')->field('id,savepath,savename,ext')->select();
		foreach($file as $k=>$v){
			$path = '/Uploads/Download/'.$v['savepath'].$v['savename'];
			if($v['ext'] == 'mp4'){
				$where['video'] = array('eq',$path);
				if(!M('video')->where($where)->find()){
					if(is_file('.'.$path)){
						unlink('.'.$path);
					}
					M('file')->where('id = '.$v['id'])->delete();
				}
			}else{
				if(is_file('.'.$path)){
					unlink('.'.$path);
				}
				M('file')->where('id = '.$v['id'])->delete();
			}
			
		}
		
		//清除没有编辑器没有用上的图片
		$dir = './Uploads/ueditor/';
		$dir_arr = getDir($dir);
		$file_arr = array();
		$i = 1;
		foreach($dir_arr as $k=>$v){
			$getFile = getFile($dir.$v);
			foreach($getFile as $kg => $vg){
				$file_arr[$i] = $vg;
				$i++;
			}
			
		}
		
		$list = M('product_data')->select();
		$strstr_arr = array();
		
		foreach($list as $k=>$v){
			foreach($file_arr as $ke=>$ve){
				$strstr = strstr($v['content'],$ve);
				if($strstr){ $strstr_arr[] = $ve; }
			}
		}
		$diff =  array_merge(array_diff($strstr_arr,$file_arr),array_diff($file_arr,$strstr_arr));
		foreach($diff as $k=>$v){
			if(is_file('.'.$v)){
				unlink('.'.$v);
			}
		}
		
		//清除没有用上的图片
		$PictureList =  M('picture')->field('id,path')->select();
		$PictureArr = array();
		foreach($PictureList as $k=>$v){
			$PictureArr[$v['id']] = $v['path'];
		}
		
		foreach($PictureArr as $k=>$v){
			$BWhere['thumb'] = array('like',"%".$v."%");
			$banner = M('banner')->where($BWhere)->getField('thumb');
			
			if($banner){
			//	echo $k.$banner.' - banner</br>';
			}else{
				$PWhere['thumb'] = array('like',"%".$v."%");
				$paycode = M('paycode')->where($PWhere)->getField('thumb');
				if($paycode){
				//	echo $k.$paycode.' - paycode </br>';
				}else{
					$ProWhere['thumb'] = array('like',"%".$v."%");
					$ProThumb = M('Product')->where($ProWhere)->getField('thumb');
					if($ProThumb){
					//	echo $k.$ProThumb.' - ProThumb </br>';
					}else{
						$ProFootWhere['foot_thumb'] = array('like',"%".$v."%");
						$ProFootThumb = M('Product')->where($ProFootWhere)->getField('foot_thumb');
						if($ProFootThumb){
						//	echo $k.$ProFootThumb.' - ProFootThumb </br>';
						}else{
							$NormsWhere['thumb'] = array('like',"%".$v."%");
							$NormsThumb = M('Product_norms')->where($NormsWhere)->getField('thumb');
							if($NormsThumb){
								//	echo $k.$NormsThumb.' - NormsThumb </br>';
							}else{
								
								$ProImagesWhere['images'] = array('like',"%".$v."%");
								$ProImages = M('Product')->where($ProImagesWhere)->getField('images');
								if($ProImages){
								//	echo $k.$ProImages.' - ProImages </br>';
								}else{
									$PaWhere['path'] = array('like',"%".$v."%");
								//	echo $k.$v.' - ProImages - No </br>';
									if(is_file('.'.$v)){
										M('picture')->where($PaWhere)->delete();
										unlink('.'.$v);
									}
								}
							}
							
						}
					}
				}
			}
		}

		//清除根目录的日志文件.log
		$LogDir = './';
		$LogDirArr = getFile($LogDir);
		$LogArr = array();
		foreach($LogDirArr as $k=>$v){
			if(stripos($v,'.log')){
				$LogArr[$k] = $v;
				if(is_file('.'.$v)){
					unlink('.'.$v);
				}
			}
		}
		
		//清除cookie缓存
		$cookieFlie = './log/cookie';
		$cookieFlieArr = getFile($cookieFlie);
		$t = time();
		$time = '';
		$cookieArr = array();
		foreach($cookieFlieArr as $k=>$v){
			$time = substr($v,12,12);
			$s = strtotime($time);
			if(($s+7200) < $t){
				unlink('.'.$v);
			}
		}
		
		
		$this->success('清除成功!',U('index'));
	}
	
	
	public function test(){
		/*
		$cookieFlie = './log/cookie';
		$cookieFlieArr = getFile($cookieFlie);
		$t = time();
		$time = '';
		$cookieArr = array();
		foreach($cookieFlieArr as $k=>$v){
		
			$time = substr($v,12,12);
			$s = strtotime($time);
			if(($s+7200) < $t){
				unlink('.'.$v);
			}
		}*/
		
	}

}