get_row( "SELECT count(DISTINCT ip) AS visitors FROM `$table_name` WHERE feed='' AND spider=''" )->$row; // phpcs:ignore $result_j[ $row . '_tyear' ] = $wpdb->get_row( $wpdb->prepare( "SELECT count(DISTINCT ip) AS visitors FROM `$table_name` WHERE feed='' AND spider='' AND date LIKE %s", $thisyear . '%' ) )->$row; // phpcs:ignore $result_j[ $row . '_total' ] += $offsets['alltotalvisits']; break; case 'visitors_feeds': $row_title = __( 'Visitors through Feeds', 'newstatpress' ); // db call ok; no-cache ok; unprepared SQL OK. $result_j[ $row . '_total' ] = $wpdb->get_row( "SELECT count(DISTINCT ip) AS visitors_feeds FROM `$table_name` WHERE feed<>'' AND spider='' AND agent<>''" )->$row; // phpcs:ignore $result_j[ $row . '_tyear' ] = $wpdb->get_row( $wpdb->prepare( "SELECT count(DISTINCT ip) AS visitors_feeds FROM `$table_name` WHERE feed<>'' AND spider='' AND agent<>'' AND date LIKE %s", $thisyear . '%' ) )->$row; // phpcs:ignore $result_j[ $row . '_total' ] += $offsets['visitorsfeeds']; break; case 'pageview': $row_title = __( 'Pageviews', 'newstatpress' ); // db call ok; no-cache ok; unprepared SQL OK. $result_j[ $row . '_total' ] = $wpdb->get_row( "SELECT count(date) AS pageview FROM `$table_name` WHERE feed='' AND spider=''" )->$row; // phpcs:ignore $result_j[ $row . '_tyear' ] = $wpdb->get_row( $wpdb->prepare( "SELECT count(date) AS pageview FROM `$table_name` WHERE feed='' AND spider='' AND date LIKE %s", $thisyear . '%' ) )->$row; // phpcs:ignore $result_j[ $row . '_total' ] += $offsets['pageviews']; break; case 'spiders': $row_title = __( 'Spiders', 'newstatpress' ); // db call ok; no-cache ok; unprepared SQL OK. $result_j[ $row . '_total' ] = $wpdb->get_row( "SELECT count(date) AS spiders FROM `$table_name` WHERE feed='' AND spider<>''" )->$row; // phpcs:ignore $result_j[ $row . '_tyear' ] = $wpdb->get_row( $wpdb->prepare( "SELECT count(date) AS spiders FROM `$table_name` WHERE feed='' AND spider<>'' AND date LIKE %s", $thisyear . '%' ) )->$row; // phpcs:ignore $result_j[ $row . '_total' ] += $offsets['spy']; break; case 'feeds': $row_title = __( 'Pageviews through Feeds', 'newstatpress' ); // db call ok; no-cache ok; unprepared SQL OK. $result_j[ $row . '_total' ] = $wpdb->get_row( "SELECT count(date) AS feeds FROM `$table_name` WHERE feed<>'' AND spider=''" )->$row; // phpcs:ignore $result_j[ $row . '_tyear' ] = $wpdb->get_row( $wpdb->prepare( "SELECT count(date) AS feeds FROM `$table_name` WHERE feed<>'' AND spider='' AND date LIKE %s", $thisyear . '%' ) )->$row; // phpcs:ignore $result_j[ $row . '_total' ] += $offsets['pageviewfeeds']; break; } } // make graph. $maxxday = 0; for ( $gg = $gdays - 1;$gg >= 0;$gg-- ) { $date = gmdate( 'Ymd', current_time( 'timestamp' ) - 86400 * $gg ); // db call ok; no-cache ok; unprepared SQL OK. $qry_visitors = $wpdb->get_row( $wpdb->prepare( "SELECT count(DISTINCT ip) AS total FROM `$table_name` WHERE feed='' AND spider='' AND date = %s", $date ) ); // phpcs:ignore $visitors[ $gg ] = $qry_visitors->total; // db call ok; no-cache ok; unprepared SQL OK. $qry_pageviews = $wpdb->get_row( $wpdb->prepare( "SELECT count(date) AS total FROM `$table_name` WHERE feed='' AND spider='' AND date = %s", $date ) ); // phpcs:ignore $pageviews[ $gg ] = $qry_pageviews->total; // db call ok; no-cache ok; unprepared SQL OK. $qry_spiders = $wpdb->get_row( $wpdb->prepare( "SELECT count(date) AS total FROM `$table_name` WHERE feed='' AND spider<>'' AND date = %s", $date ) ); // phpcs:ignore $spiders[ $gg ] = $qry_spiders->total; // db call ok; no-cache ok; unprepared SQL OK. $qry_feeds = $wpdb->get_row( $wpdb->prepare( "SELECT count(date) AS total FROM `$table_name` WHERE feed<>'' AND spider='' AND date = %s", $date ) ); // phpcs:ignore $feeds[ $gg ] = $qry_feeds->total; $total = $visitors[ $gg ] + $pageviews[ $gg ] + $spiders[ $gg ] + $feeds[ $gg ]; if ( $total > $maxxday ) { $maxxday = $total; } } if ( 0 === $maxxday ) { $maxxday = 1; } $result_j['visitors'] = $visitors; // export. $result_j['pageviews'] = $pageviews; // export. $result_j['spiders'] = $spiders; // export. $result_j['feeds'] = $feeds; // export. $result_j['max'] = $maxxday; // export. // output an HTML representation of the collected data. $overview_table = ''; // dashboard. $overview_table .= "
| " . __( 'Total since', 'newstatpress' ) . " | " . __( 'This year', 'newstatpress' ) . " | " . __( 'Last month', 'newstatpress' ) . " | " . __( 'This month', 'newstatpress' ) . " | " . __( 'Target This month', 'newstatpress' ) . " | " . __( 'Yesterday', 'newstatpress' ) . " | " . __( 'Today', 'newstatpress' ) . " | |||
|---|---|---|---|---|---|---|---|---|---|
| $since | $thisyear_header | $lastmonth_header | $thismonth_header | $thismonth_header | $yesterday_header | $today_header | |||
| " . $result_j[ $row . '_title' ] . ' | '; $overview_table .= "" . $result_j[ $row . '_total' ] . " | \n"; $overview_table .= "" . $result_j[ $row . '_tyear' ] . " | \n"; $overview_table .= "" . $result_j[ $row . '_lmonth' ] . " | \n"; $overview_table .= "" . $result_j[ $row . '_tmonth' ] . $result[0] . " | \n"; $overview_table .= "$result[1] $result[2] | \n"; $overview_table .= "" . $result_j[ $row . '_qry_y' ] . " | \n"; $overview_table .= "" . $result_j[ $row . '_qry_t' ] . " | \n"; $overview_table .= '||
| ";
$overview_graph .= "
";
if ( gmdate( 'w', current_time( 'timestamp' ) - 86400 * $gg === $start_of_week ) ) {
$overview_graph .= " ";
} else {
$overview_graph .= " ";
}
$overview_graph .= gmdate( 'd', current_time( 'timestamp' ) - 86400 * $gg ) . ' ' . gmdate( 'M', current_time( 'timestamp' ) - 86400 * $gg ) . " | \n";
}
$overview_graph .= '