| @@ -50,10 +50,10 @@ | ||
| 50 | 50 | public function get_stats( $args = [] ) { |
| 51 | 51 | $where = []; |
| 52 | 52 | $args = wp_parse_args( $args, [] ); |
| 53 | 53 | if ( ! empty( $args['startDate'] ) && ! empty( $args['endDate'] ) ) { |
| 54 | - $start_date = date( self::$date_format, strtotime( $args['startDate'] ) ); | |
| 55 | - $end_date = date( self::$date_format, strtotime( $args['endDate'] ) ); | |
| 54 | + $start_date = gmdate( self::$date_format, strtotime( $args['startDate'] ) ); | |
| 55 | + $end_date = gmdate( self::$date_format, strtotime( $args['endDate'] ) ); | |
| 56 | 56 | $where['created_at'] = [ 'BETWEEN', $start_date, $end_date ]; |
| 57 | 57 | } |
| 58 | 58 | $stats = Database::get_instance()->get_posts( Database::$table_stats, '*', $where ); |
| 59 | 59 | $posts = PostType::get_instance()->get_posts( [], 'DISTINCT nx_id, title, source, theme' ); |
| @@ -70,9 +70,9 @@ | ||
| 70 | 70 | } |
| 71 | 71 | $format = 'Y-m-d'; |
| 72 | 72 | $stats = $this->stats_exists([ |
| 73 | 73 | 'nx_id' => $nx_id, |
| 74 | - 'created_at' => date( self::$date_format, time() ), | |
| 74 | + 'created_at' => gmdate( self::$date_format, time() ), | |
| 75 | 75 | ] |
| 76 | 76 | ); |
| 77 | 77 | if ( empty( $stats ) ) { |
| 78 | 78 | $data = [ |
| @@ -81,9 +81,9 @@ | ||
| 81 | 81 | 'views' => 1, |
| 82 | 82 | ]; |
| 83 | 83 | $this->_insert_analytics( $data, time() ); |
| 84 | 84 | } else { |
| 85 | - $this->increment_count( $type, $nx_id, date( self::$date_format, time() ) ); | |
| 85 | + $this->increment_count( $type, $nx_id, gmdate( self::$date_format, time() ) ); | |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function _insert_analytics( $data, $time = null, $migration = false ) { |
| @@ -94,20 +94,20 @@ | ||
| 94 | 94 | $_data = $data; |
| 95 | 95 | $nx_id = $_data['nx_id']; |
| 96 | 96 | $stats = $this->stats_exists([ |
| 97 | 97 | 'nx_id' => $nx_id, |
| 98 | - 'created_at' => date( self::$date_format, $time ), | |
| 98 | + 'created_at' => gmdate( self::$date_format, $time ), | |
| 99 | 99 | ] |
| 100 | 100 | ); |
| 101 | 101 | if ( ! empty( $stats ) ) { |
| 102 | 102 | unset( $_data['nx_id'] ); |
| 103 | 103 | foreach ( $_data as $_type => $_s_data ) { |
| 104 | - $this->increment_count( $_type, $nx_id, date( self::$date_format, $time ), $_s_data ); | |
| 104 | + $this->increment_count( $_type, $nx_id, gmdate( self::$date_format, $time ), $_s_data ); | |
| 105 | 105 | } |
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | - $data['created_at'] = date( self::$date_format, $time ); | |
| 109 | + $data['created_at'] = gmdate( self::$date_format, $time ); | |
| 110 | 110 | Database::get_instance()->insert_post( Database::$table_stats, $data ); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function migrate_analytics( $rows ) { |
| @@ -240,9 +240,9 @@ | ||
| 240 | 240 | 'Sogou' => 'spider', |
| 241 | 241 | 'soso.com' => 'sosospider', |
| 242 | 242 | 'Yandex' => 'yandex', |
| 243 | 243 | ); |
| 244 | - $useragent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; | |
| 244 | + $useragent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; | |
| 245 | 245 | foreach ( $bots as $name => $lookfor ) { |
| 246 | 246 | if ( ! empty( $useragent ) && ( false !== stripos( $useragent, $lookfor ) ) ) { |
| 247 | 247 | $should_count = false; |
| 248 | 248 | break; |