Ejemplo n.º 1
0
 public function getToday()
 {
     foreach (StatsMainh::model()->findAll() as $rw) {
         $dt_i = $rwz["dt"][] = $rw->dt;
         $rwz["cnt1"][$dt_i] = $rw->cnt1;
         $rwz["cnt2"][$dt_i] = $rw->cnt2;
         $rwz["cnt3"][$dt_i] = $rw->cnt3;
         $rwz["cnt4"][$dt_i] = $rw->cnt4;
         $rwz["cnt5"][$dt_i] = $rw->cnt5;
     }
     foreach (StatsMainp::model()->findAll() as $rww) {
         $dt_i = $rww["dt"] . $rww->god;
         $rwzz[$dt_i]["cnt1"] = $rww->cnt1;
         $rwzz[$dt_i]["cnt2"] = $rww->cnt2;
         $rwzz[$dt_i]["cnt3"] = $rww->cnt3;
         $rwzz[$dt_i]["cnt4"] = $rww->cnt4;
         $rwzz[$dt_i]["cnt5"] = $rww->cnt5;
     }
     list($s_date, $f_date) = str_replace("+", "", array('13.03.2015', '15.03.2015'));
     $sdate = StatsHelper::dtconv2(trim($s_date));
     $fdate = StatsHelper::dtconv2(trim($f_date));
     /* if ($robots = file(Yii::getPathOfAlias('webroot.stats') . "/robots.dat")) {
        $i = 0;
        for ($i = 0; $i < count($robots); $i++)
        $robots[$i] = iconv("CP1251", "UTF-8", $robots[$i]);
        foreach ($robots as $val) {
        list($rb1, $rb2) = explode("|", $val);
        $rb2 = trim($rb2);
        $this->rbd[$i++] = rtrim($rb1);
        if (!empty($rb2))
        $rbdn[$rb2][] = rtrim($rb1);
        $robo[] = $rb2;
        }
        }
        if ($hosts = file(Yii::getPathOfAlias('webroot.stats') . "/hosts.dat")) {
        $i = 0;
        for ($i = 0; $i < count($hosts); $i++)
        $hosts[$i] = iconv("CP1251", "UTF-8", $hosts[$i]);
        foreach ($hosts as $val) {
        list($hb1, $hb2) = explode("|", $val);
        $hb2 = trim($hb2);
        $hbd[$i++] = rtrim($hb1);
        if (!empty($hb2))
        $hbdn[$hb2][] = rtrim($hb1);
        $robo[] = $hb2;
        }
        }
        $this->robo = array_unique($robo); */
     $iniRun = $this->initRun();
     $this->rbd = $iniRun['rbd'];
     $hbd = $iniRun['hbd'];
     foreach ($this->rbd as $val) {
         $zp .= " LOWER(user) NOT LIKE '%" . mb_strtolower($val) . "%' AND";
     }
     if (filesize(Yii::getPathOfAlias('webroot.stats') . "/hosts.dat")) {
         foreach ($hbd as $val) {
             $zp .= " LOWER(host) NOT LIKE '%" . mb_strtolower($val) . "%' AND";
         }
     }
     $zp .= " LOWER(user) NOT LIKE '' AND";
     if (file_exists(Yii::getPathOfAlias('webroot.stats') . "/skip.dat")) {
         if ($skip = file(Yii::getPathOfAlias('webroot.stats') . "/skip.dat")) {
             foreach ($skip as $vl) {
                 list($s1, $s2) = explode("|", $vl);
                 $zp2 .= " {$s1} NOT LIKE '%" . rtrim($s2) . "%' AND";
             }
         }
     }
     $zp .= $zp2;
     $this->_zp = substr($zp, 0, -4);
     if ($se_m = file(Yii::getPathOfAlias('webroot.stats') . "/se.dat")) {
         for ($i = 0; $i < count($se_m); $i++) {
             $se_m[$i] = iconv("CP1251", "UTF-8", $se_m[$i]);
         }
         foreach ($se_m as $vl) {
             list($s1, $s2, $s3) = explode("|", $vl);
             $se_n[$s1] = rtrim($s3);
             $se_nn[$s1] = $s2;
         }
     }
     if (file_exists(Yii::getPathOfAlias('webroot.stats') . "/fix.dat")) {
         if ($fx_m = file(Yii::getPathOfAlias('webroot.stats') . "/fix.dat")) {
             $this->_zfx = "";
             $pf = "";
             for ($i = 0; $i < count($fx_m); $i++) {
                 $fx_m[$i] = iconv("CP1251", "UTF-8", $fx_m[$i]);
             }
             foreach ($fx_m as $vl) {
                 list($s1, $s2, $s3) = explode("|", $vl);
                 $this->_zfx .= $pf . "LOWER(" . $s1 . ") LIKE '%" . mb_strtolower($s2) . "%'";
                 $pf = " OR ";
                 $s3 = rtrim($s3);
                 if (!empty($s3)) {
                     $fxn[$s3][] = $s1 . "|" . $s2;
                 }
                 $fxo[] = $s3;
             }
         }
     }
     foreach ($se_nn as $val) {
         $this->_cse_m .= " OR LOWER(refer) LIKE '%{$val}%'";
         $this->_cot_m .= " AND LOWER(refer) NOT LIKE '%{$val}%'";
     }
     $c = 0;
     $sdate = 0;
     $all_uniqs = 0;
     $all_hits = 0;
     $all_se = 0;
     $all_other = 0;
     $all_fix = 0;
     // $r = Yii::app()->db->createCommand();
     // $r->selectDistinct('day, dt');
     // $r->from('cms_surf');
     // $r->order('i');
     $i = 0;
     //$res1 = $r->queryRow();
     //  $fdate = $res1['dt'];
     $visits = $this->visits(date('Ymd'));
     $system = $this->visitSystem(date('Ymd'));
     return array('hosts' => $visits['hosts'], 'hits' => $visits['hits'], 'search' => $system['search'], 'sites' => $system['sites']);
 }