| 1290 | | header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
| | 1292 | // Set content-type |
| | 1293 | @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
| | 1294 | |
| | 1295 | // Cache-related variables |
| | 1296 | $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); |
| | 1297 | $modified_timestamp = strtotime( $last_modified ); |
| | 1298 | $etag = md5( $last_modified ); |
| | 1299 | |
| | 1300 | // Set cache-related headers |
| | 1301 | @header( 'Last-Modified: ' . $last_modified ); |
| | 1302 | @header( 'Pragma: no-cache' ); |
| | 1303 | @header( 'ETag: ' . '"' . $etag . '"' ); |
| | 1304 | |
| | 1305 | // First commit of BuddyPress! (Easter egg) |
| | 1306 | @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT'); |
| | 1307 | |
| | 1308 | // Get ETag from supported user agents |
| | 1309 | if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { |
| | 1310 | $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); |
| | 1311 | |
| | 1312 | // Remove quotes from ETag |
| | 1313 | $client_etag = trim( $client_etag, '"' ); |
| | 1314 | |
| | 1315 | // Strip suffixes from ETag if they exist (eg. "-gzip") |
| | 1316 | if ( $etag_suffix_pos = strpos( $client_etag, '-' ) ) { |
| | 1317 | $client_etag = substr( $client_etag, 0, $etag_suffix_pos ); |
| | 1318 | } |
| | 1319 | |
| | 1320 | // No ETag found |
| | 1321 | } else { |
| | 1322 | $client_etag = false; |
| | 1323 | } |
| | 1324 | |
| | 1325 | // Get client last modified timestamp from supported user agents |
| | 1326 | $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); |
| | 1327 | $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; |
| | 1328 | |
| | 1329 | // Set 304 status if feed hasn't been updated since last fetch |
| | 1330 | if ( ( $client_last_modified && $client_etag ) ? |
| | 1331 | ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) : |
| | 1332 | ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) { |
| | 1333 | $status = 304; |
| | 1334 | } else { |
| | 1335 | $status = false; |
| | 1336 | } |
| | 1337 | |
| | 1338 | // If feed hasn't changed as reported by the user agent, set 304 status header |
| | 1339 | if ( ! empty( $status ) ) { |
| | 1340 | status_header( $status ); |
| | 1341 | |
| | 1342 | // cached response, so stop now! |
| | 1343 | if ( $status == 304 ) { |
| | 1344 | exit(); |
| | 1345 | } |
| | 1346 | } |
| | 1347 | } |
| | 1348 | |
| | 1349 | /** OUTPUT ***************************************************************/ |
| | 1350 | |
| | 1351 | /** |
| | 1352 | * Output the RSS feed. |
| | 1353 | * |
| | 1354 | * @access protected |
| | 1355 | */ |
| | 1356 | protected function output() { |
| | 1357 | $this->http_headers(); |