<?php

namespace app\controller;
use think\facade\Db;
use laytp\BaseController;
use think\facade\Cache;

class Index extends BaseController
{
    public function index()
    {
        
        return redirect("/admin/index.html");
    }
    public function getnumber()
    {   
        $uplist=Cache::get("getnumber");
        if(empty($uplist)){
          $url="http://git.zf789.life/kaifa/premium/graph";
       $html= file_get_contents($url);
        preg_match_all('/<span class="message tw-inline-block gt-ellipsis tw-mr-2">\s*<span>(.*?)<\/span>\s*<\/span>/', $html, $matches);
        $uplist=array();
    if ($matches[1]) {
        $messages = $matches[1]; // Array of all matched messages
        foreach ($messages as $message) {
            $uplist[]=$message;
           // var_dump($message);
            // Process each message
        }
    }
    
        Cache::set("getnumber",$uplist,1024);  
        }
        
        //平台总用户
        $ptzuser=Db::name("member")->count();
        //平台托管机器人
         $ptzbot=Db::name("admin_bot")->count();
        //平台机器人总余额
        $ptzbotmoney=Db::name("admin_bot")->sum('money');
        //平台总利润
        $ptlirun=Db::name("order")->sum('slirun');
        
         return $this->success('返回成功', ['uplist'=>$uplist,'ptzuser'=>$ptzuser,'ptzbot'=>$ptzbot,'ptzbotmoney'=>$ptzbotmoney,'ptlirun'=>$ptlirun]);
    }
}
