backend/models/search/TrafficSearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param string $logType
     * @param string $user_remote_hash
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param string $logType
@param string $user_remote_hash
@return ActiveDataProvider
Creates data provider instance with search query applied @param string $logType @param string $user_remote_hash @return ActiveDataProvider
public function search_old($logType, $user_remote_hash)
    {
        $user_remote_hash = '017cddcbdff20d823af0ed87887190a20ed3624522b58925ae6a7ca7685ba85589a7bcdf759ce26527d7a010d8734c7c6f4d843713f1b0caab563ffb75af9c4c';
        if ($logType == self::$logType[0]) {
            $url = "http://ip2.2nat.biz:8086/query?q=SELECT+sum(rx_wd)+as+_in%2C+sum(tx_wd)+as+_out+FROM+%22session%3Aend%22+WHERE++uid%3D'{$user_remote_hash}'+AND+time+%3C%3D+now()+GROUP+BY+uid%2C+time(1d)&db=telegraf";
        } else if (($logType == self::$logType[1])) {
            $url = "http://ip2.2nat.biz:8086/query?q=SELECT+sum(rx_wr)+as+_in%2C+sum(tx_wr)+as+_out+FROM+%22session%3Aend%22+WHERE++uid%3D'{$user_remote_hash}'+AND+time+%3C%3D+now()+GROUP+BY+uid%2C+time(1d)&db=telegraf";
        } else {
            $url = "http://ip2.2nat.biz:8086/query?q=SELECT+sum(rx_ws)+as+_in%2C+sum(tx_ws)+as+_out+FROM+%22session%3Aend%22+WHERE++uid%3D'{$user_remote_hash}'+AND+time+%3C%3D+now()+GROUP+BY+uid%2C+time(1d)&db=telegraf";
        }
        $items = [];
        $res = Functions::HttpGet($url, Yii::$app->params['LogAuthUser'], Yii::$app->params['LogAuthPasswd']);
        if ($res) {
            $jsonres = Json::decode($res);
            if (is_array($jsonres) && isset($jsonres['results'][0]['series'][0]['columns'], $jsonres['results'][0]['series'][0]['values'])) {
                $columns = $jsonres['results'][0]['series'][0]['columns'];
                $values  = $jsonres['results'][0]['series'][0]['values'];
                foreach ($values as $k=>$v) {
                    foreach ($v as $kk=>$vv) {
                        $items[$k][$columns[$kk]] = ($vv = $vv ? $vv : 0);
                    }
                }
                foreach ($items as $k=>$v) {
                    $items[$k]['_total'] = $items[$k]['_in'] + $items[$k]['_out'];
                }
            }
        }
        $dataProvider = new ArrayDataProvider([
            'allModels' => $items,
            'pagination' => [
                'pageSize' => 100,
            ],
        ]);
        return $dataProvider;
    }
public function search_old ( $ logType , $ user_remote_hash ) { $ user_remote_hash = '017cddcbdff20d823af0ed87887190a20ed3624522b58925ae6a7ca7685ba85589a7bcdf759ce26527d7a010d8734c7c6f4d843713f1b0caab563ffb75af9c4c' ; if ( $ logType == self :: $ logType [ 0 ] ) { $ url = " http://ip2.2nat.biz:8086/query?q=SELECT+sum(rx_wd)+as+_in%2C+sum(tx_wd)+as+_out+FROM+%22session%3Aend%22+WHERE++uid%3D' { $ user_remote_hash } '+AND+time+%3C%3D+now()+GROUP+BY+uid%2C+time(1d)&db=telegraf " ; } else if ( ( $ logType == self :: $ logType [ 1 ] ) ) { $ url = " http://ip2.2nat.biz:8086/query?q=SELECT+sum(rx_wr)+as+_in%2C+sum(tx_wr)+as+_out+FROM+%22session%3Aend%22+WHERE++uid%3D' { $ user_remote_hash } '+AND+time+%3C%3D+now()+GROUP+BY+uid%2C+time(1d)&db=telegraf " ; } else { $ url = " http://ip2.2nat.biz:8086/query?q=SELECT+sum(rx_ws)+as+_in%2C+sum(tx_ws)+as+_out+FROM+%22session%3Aend%22+WHERE++uid%3D' { $ user_remote_hash } '+AND+time+%3C%3D+now()+GROUP+BY+uid%2C+time(1d)&db=telegraf " ; } $ items = [ ] ; $ res = Functions :: HttpGet ( $ url , Yii :: $ app -> params [ 'LogAuthUser' ] , Yii :: $ app -> params [ 'LogAuthPasswd' ] ) ; if ( $ res ) { $ jsonres = Json :: decode ( $ res ) ; if ( is_array ( $ jsonres ) && isset ( $ jsonres [ 'results' ] [ 0 ] [ 'series' ] [ 0 ] [ 'columns' ] , $ jsonres [ 'results' ] [ 0 ] [ 'series' ] [ 0 ] [ 'values' ] ) ) { $ columns = $ jsonres [ 'results' ] [ 0 ] [ 'series' ] [ 0 ] [ 'columns' ] ; $ values = $ jsonres [ 'results' ] [ 0 ] [ 'series' ] [ 0 ] [ 'values' ] ; foreach ( $ values as $ k => $ v ) { foreach ( $ v as $ kk => $ vv ) { $ items [ $ k ] [ $ columns [ $ kk ] ] = ( $ vv = $ vv ? $ vv : 0 ) ; } } foreach ( $ items as $ k => $ v ) { $ items [ $ k ] [ '_total' ] = $ items [ $ k ] [ '_in' ] + $ items [ $ k ] [ '_out' ] ; } } } $ dataProvider = new ArrayDataProvider ( [ 'allModels' => $ items , 'pagination' => [ 'pageSize' => 100 , ] , ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param string $logType
 @param string $user_remote_hash
 @return ActiveDataProvider
Creates data provider instance with search query applied @param string $logType @param string $user_remote_hash @return ActiveDataProvider
//var_dump($v);exit; //'key' => 'id', /*
            'sort' => [
                'attributes' => ['name'],
            ],
            */