<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
/*
首页等页面
*/
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021 http://mifenlei.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class Index extends Common
{
    //后台首页
    public function index()
    {
        return md5Qm();
    }
    //框架结构页
    public function admin()
    {
    	$this->assign('caxun',''.ps('my',g_p()).'caxun.html?alias=mi');
    	$this->assign('shengji',''.ps('my',g_p()).'xz.html?alias=mi&www='.$_SERVER['HTTP_HOST'].'&key='.MIFENLEI.'&bb='.config('web.banben').'');
    	$this->assign('tan',''.ps('my',g_p()).'tan.html?www='.$_SERVER['HTTP_HOST'].'');
        return md5Qm();
    }
    //框架结构页
    public function login()
    {
        return md5Qm();
    }
    //升级
    public function sj()
    { 
        if (socha(user('tid'), 22) != 1) {$this->error('无权限'); }
    	$xiazai = input('title');
    	if (strpos($xiazai, ps('my','FAyOqR5dmxzzPBN2aQtRlyQqg-hypAcCmBNlq')) !== false) {
            $url = $xiazai . urlencode(iconv("GB2312", "UTF-8", ""));
            $save_dir = 'runtime/';
            $filename = 'shengji.zip';
            $res = getFile($url, $save_dir, $filename, 0);
            header('location:/index.php/admin/index/ad.html');
    	} else {
            return $this->error('升级包有误');
        }
    }
    //解压
    public function ad()
    {
        if (socha(user('tid'), 22) != 1) {$this->error('无权限'); }
        $zip = new \ZipArchive();
        if ($zip->open('runtime/shengji.zip') === TRUE) {
            $zip->extractTo('.');
            $zip->close();
            unlink('runtime/shengji.zip');
            header("content-type:text/html;charset=utf-8");
            header('location:/index.php/admin/index/admin.html');
        }

    }
}