<?php
//date_default_timezone_set('UTC');
//date('Y-m-d',time());
date_default_timezone_set('America/Mexico_City');
//echo date('Y-m-d h:i:s', strtotime('now'));
//die;
class baseDeDatosVisita{
    public function connectDBBDD(){
        $servername = "localhost";
        $username = "root";
        $password = "PkJXPQFykKLmS3cWhqmZKNYE";
        $dbname =   "RIR";
        $conn = new mysqli($servername, $username, $password, $dbname);
        $conn->set_charset("utf8");
        if ($conn->connect_error) {
            die("Connection failed: " . $conn->connect_error);
        }
        return $conn;
        return 2;
    }
    public function readtableDB8(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59' ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        //echo "<pre>";
        echo "[";
        //echo "[1514764800000,0],";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            //$info[$a][1] = $cRow[0];
            //$info[$a][2] = $cRow[1];
            //echo "<br>".$cRow[0]." - ".$cRow[1]." - ".$cRow[2]." - ".$cRow[3]." - ".$cRow[4]." - ".$cRow[5];
            $dia = explode(" ",$cRow[0],10)[0];
            //echo "<br>".$cRow[0]." - ".$dia." - ".$ban." - ".$cRow[1];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        //echo "[".substr(time(),0,8)."00000,50]]";
        //echo "[1514764800000,0]]";
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        //echo "</pre>";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB9(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE site LIKE '%doc%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        //echo "<pre>";
        echo "[";
        //echo "[1514764800000,0],";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            //$info[$a][1] = $cRow[0];
            //$info[$a][2] = $cRow[1];
            //echo "<br>".$cRow[0]." - ".$cRow[1]." - ".$cRow[2]." - ".$cRow[3]." - ".$cRow[4]." - ".$cRow[5];
            $dia = explode(" ",$cRow[0],10)[0];
            //echo "<br>".$cRow[0]." - ".$dia." - ".$ban." - ".$cRow[1];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        //echo "[".substr(time(),0,8)."00000,50]]";
        //echo "[1514764800000,0]]";
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        //echo "</pre>";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB10(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE site LIKE '%colaborador%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB11(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE site LIKE '%categorias%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB12(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE site LIKE '%descargables.html%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB13(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE site LIKE '%metaDes%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB14(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time FROM tbl_registro_general WHERE site LIKE '%grafica%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB15(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        //$res = mysqli_query($conn,"SELECT date,time,site FROM tbl_registro_general WHERE (expl LIKE '%Chrome%' OR expl LIKE '%Opera%' OR expl LIKE '%Version%' OR expl LIKE '%Edge%' OR expl LIKE '%MSIE%') AND (expl NOT LIKE '%bot%') AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        $res = mysqli_query($conn,"SELECT date,time,site FROM tbl_registro_general WHERE expl NOT LIKE '%bot%' AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB16(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time,site FROM tbl_registro_general WHERE (expl LIKE '%bot%') AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB17(){
        $conn = $this->connectDBBDD();
        $res = mysqli_query($conn,"SELECT COUNT(id) FROM tbl_registro_general WHERE site NOT LIKE '%/RIR/index.php/panel/%' AND (date >= '".date('Y-m-d', strtotime('now'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59');");
        $res2 = mysqli_query($conn,"SELECT COUNT(id) FROM tbl_registro_general WHERE site NOT LIKE '%/RIR/index.php/panel/%' AND (date >= '".date('Y-m-d', strtotime('-1 week'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59');");
        echo ((mysqli_fetch_array($res)[0])*100)/(mysqli_fetch_array($res2)[0]/6);
        //echo mysqli_fetch_array($res)[0].","."SELECT COUNT(id) FROM tbl_registro_general WHERE site NOT LIKE '%/RIR/index.php/panel/%' AND (date >= '".date('Y-m-d', strtotime('now'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59');";
        //echo rand(0,100);
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB18(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time,site FROM tbl_registro_general WHERE (site LIKE '%/RIR/index.php/panel/%') AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB19(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time,site FROM tbl_registro_general WHERE (site = '/RIR/') AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
    public function readtableDB20(){
        $conn = $this->connectDBBDD();
        $a = 0;
        $ban = "";
        $dia = "";
        $diaux = "";
        $total = 1;
        $res = mysqli_query($conn,"SELECT date,time,site FROM tbl_registro_general WHERE (site NOT LIKE '%/RIR/index.php/panel/%') AND (date >= '".date('Y-m-d', strtotime('-1 year'))." 00:00:00' AND date <= '".date('Y-m-d', strtotime('now'))." 23:59:59') ORDER BY tbl_registro_general.date ASC LIMIT 0,100000;");
        echo "[";
        while($cRow = mysqli_fetch_array($res)){
            $a++;
            $dia = explode(" ",$cRow[0],10)[0];
            if($ban == ""){
                $ban = $dia;
                $diaux = $cRow[1];
            }else if($ban != $dia){
                echo "[".substr($diaux,0,8)."00000,".$total."],";
                $ban = $dia;
                $diaux = $cRow[1];
                $total = 1;
            }else $total++;
        }
        echo "[".substr($diaux,0,8)."00000,".$total."]]";
        die();
        //$conn->close();
        //return $str;
    }
}
$op = $_GET["hea89wheaiw8f4ao8374y5684w"];
if($op == "fh48fgid8os74e47is7y3grt73s0"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB8();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s1"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB9();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s2"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB10();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s3"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB11();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s4"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB12();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s5"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB13();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s6"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB14();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s7"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB15();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s8"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB16();
    die();
}else if($op == "snef9s8fe398jrsh98j3re4tzsse4gvr5"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB17();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s9"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB18();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s10"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB19();
    die();
}else if($op == "fh48fgid8os74e47is7y3grt73s11"){
    $baseDeDatosVisita = new baseDeDatosVisita();
    $baseDeDatosVisita -> readtableDB20();
    die();
}else{die();} ?>