<?php

namespace app\controllers;
use app\models\Bot;

if(!defined('ACCESS_CONTROL')) {header($_SERVER['SERVER_PROTOCOL']. ' 404'); exit('404 not found');}

class Bots extends ControllerSession {

    public function get_index()
    {
        $per_page = 150;
        $m_bots = new Bot();
        $page = isset($this->params['get']['page']) ? abs((int)$this->params['get']['page']) : 1;
        if($page<1)
            $page = 1;

        $bots = $m_bots->pagination($page, $per_page);
        $count_pages = $m_bots->total_bots();
        $this->render('bots/index', array('bots'=>$bots, 'count_pages'=>ceil($count_pages[0]/$per_page), 'current_page'=>$page, 'countries'=>\lib\Helpers::country_list(), 'platforms'=> \lib\Helpers::platforms()));
    }

    public function delete_clear()
    {
        $m_bots = new Bot();
        $m_bots->truncate();
        $this->render('layouts/page_reload', [], array('layout'=>false, 'type'=>'js'));
    }

} 