<commit_before><?php

namespace App\Controllers;

use App\Models\InviteCode;
use App\Services\Auth;
use App\Models\Node, App\Models\TrafficLog, App\Models\CheckInLog;
use App\Services\Config,App\Services\DbConfig;
use App\Utils\Hash, App\Utils\Tools;


/**
 *  HomeController
 */
class UserController extends BaseController
{

    private $user;

    public function __construct()
    {
        $this->user = Auth::getUser();
    }
    
    public function view()
    {
        $userFooter = DbConfig::get('user-footer');
        return parent::view()->assign('userFooter',$userFooter); 
    }

    public function index($request, $response, $args)
    {
        $msg = DbConfig::get('user-index');
        if($msg == null ){
            $msg = "在后台修改用户中心公告...";
        }
        return $this->view()->assign('msg',$msg)->display('user/index.tpl');
    }

    public function node($request, $response, $args)
    {
        $msg = DbConfig::get('user-node');
        $user = Auth::getUser();
        $nodes = Node::where('type', 1)->orderBy('sort')->get();
        return $this->view()->assign('nodes', $nodes)->assign('user', $user)->assign('msg',$msg)->display('user/node.tpl');
    }


    public function nodeInfo($request, $response, $args)
    {
        $id = $args['id'];
        $node = Node::find($id);<commit_msg>sort node list<commit_after><?php

namespace App\Controllers;

use App\Models\InviteCode;
use App\Services\Auth;
use App\Models\Node, App\Models\TrafficLog, App\Models\CheckInLog;
use App\Services\Config,App\Services\DbConfig;
use App\Utils\Hash, App\Utils\Tools;


/**
 *  HomeController
 */
class UserController extends BaseController
{

    private $user;

    public function __construct()
    {
        $this->user = Auth::getUser();
    }
    
    public function view()
    {
        $userFooter = DbConfig::get('user-footer');
        return parent::view()->assign('userFooter',$userFooter); 
    }

    public function index($request, $response, $args)
    {
        $msg = DbConfig::get('user-index');
        if($msg == null ){
            $msg = "在后台修改用户中心公告...";
        }
        return $this->view()->assign('msg',$msg)->display('user/index.tpl');
    }
    private function sortNode($x, $y) {
        if($x->getNodeTrafficLoad() > $y->getNodeTrafficLoad()){
            return 1;
        }else{
            return -1;
        }
    }
    public function node($request, $response, $args)
    {
        $msg = DbConfig::get('user-node');
        $user = Auth::getUser();
        $nodes = Node::where('type', 1)->orderBy('sort')->get();
        usort($nodes, 'sortNode');
        return $this->view()->assign('nodes', $nodes)->assign('user', $user)->assign('msg',$msg)->display('user/node.tpl');
    }


    public function nodeInfo($request, $response, $args)
    {
        $id = $args['id'];
        $node = Node::find($id);
{'fraction_non_alphanumeric': 0.18448637316561844, 'fraction_numerical': 0.001397624039133473, 'mean_word_length': 2.787037037037037, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6940069', 'n_tokens_mistral': 922, 'n_tokens_neox': 913, 'n_words': 160}