<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
/*
首页等页面
*/
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021 http://guojicms.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 作者@梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class Index extends Common
{
    //后台首页
    public function index()
    {
        return md5Qm();
    }
    //框架结构页
    public function admin()
    {
        return md5Qm();
    }
    //框架结构页
    public function login()
    {
        return md5Qm();
    }
    public function sj(){
        hook('phpadminindexsj');
        //权限
        if (socha(user('tid'), 13) != 1) {
            $this->error('权限不足');
        }
        $name = file_get_contents(http().ps('my','IY2VyGRVwaukkDuwyDhIaTN8hWh8dZB1cXxcqbucgGeYpSO4iVyb1').ps(1).'&id='.input('id'));
        if ($name) {
            $url=$name.urlencode(iconv("GB2312","UTF-8",""));  
    	    $save_dir = '';  
    	    $filename ='app.zip';
    	    $res = getFile($url, $save_dir, $filename,0);
            $this->success('正在升级等待跳转',url('admin/index/ad'));
        } else {
            $this->success('确定是否填写了授权码','/');
        }
    }
    //解压升级
    public function ad()
    {
        hook('phpadminindexad');
    	$zip = new \ZipArchive;
    	if ($zip->open('app.zip') === TRUE)
    	{
        	$zip->extractTo('.');
        	$zip->close();
        	//执行sql
        	$sqldata = file_get_contents('shengji.sql');
            sql($sqldata);
        	unlink('app.zip');
        	unlink('shengji.sql');
            header("content-type:text/html;charset=utf-8");
            header('location:/index.php/admin/index/index.html');
    	} else {
            $this->error('压缩包不存在','/');
        }
    }
}