Changeset 5621
- Timestamp:
- 01/07/2012 12:36:24 AM (13 years ago)
- Location:
- trunk/bp-activity
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/admin/css/admin.css
r5528 r5621 1 #wp-bp-activities-wrap{padding:5px 0;}#bp-activities{height:120px;}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0;}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center;}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center;}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top;}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px;}.activity-errors{list-style-type:disc;margin-left:2em;}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0;}#bp_activity_action h3,#bp_activity_content h3{cursor:auto;}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white;}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px;}#bp_activity_link input{width:99%;}#bp-activities-primaryid{margin-bottom:1em;}1 .akismet-status{float:right;}.akismet-status a{color:#AAA;font-style:italic;}#wp-bp-activities-wrap{padding:5px 0;}#bp-activities{height:120px;}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0;}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center;}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center;}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top;}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px;}.activity-errors{list-style-type:disc;margin-left:2em;}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0;}#bp_activity_action h3,#bp_activity_content h3{cursor:auto;}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white;}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px;}#bp_activity_link input{width:99%;}#bp-activities-primaryid{margin-bottom:1em;} -
trunk/bp-activity/admin/css/admin.dev.css
r5528 r5621 1 .akismet-status { 2 float: right; 3 } 4 .akismet-status a { 5 color: #AAA; 6 font-style: italic; 7 } 1 8 #wp-bp-activities-wrap { 2 9 padding: 5px 0; -
trunk/bp-activity/bp-activity-akismet.php
r5414 r5621 460 460 461 461 // Send to Akismet 462 $response = $this->http_post( $query_string, $akismet_api_host, $path, $akismet_api_port ); 462 add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) ); 463 $response = akismet_http_post( $query_string, $akismet_api_host, $path, $akismet_api_port ); 464 remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) ); 465 463 466 $activity_data['bp_as_result'] = $response[1]; 464 467 … … 467 470 468 471 /** 469 * Submit data to the Akismet service with a unique user agent. 470 * 471 * Props to WordPress core Akismet plugin, and bbPress, for alot of this 472 * 473 * @param string $request The request we are sending 474 * @param string $host The host to send our request to 475 * @param string $path The path from the host 476 * @param string $port The port to use 477 * @param string $ip Optional Override $host with an IP address 478 * @return mixed WP_Error on error, array on success, empty on failure 479 * @since 1.6 480 */ 481 private function http_post( $request, $host, $path, $port = 80, $ip = '' ) { 482 $blog_charset = bp_get_option( 'blog_charset' ); 483 $content_length = strlen( $request ); 484 $errno = null; 485 $errstr = null; 486 $http_host = $host; 487 $response = ''; 488 489 // Unique User Agent 490 $akismet_ua = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' ); 491 492 // Use specific IP (if provided) 493 if ( !empty( $ip ) && long2ip( ip2long( $ip ) ) ) 494 $http_host = $ip; 495 496 // WP HTTP class is available 497 if ( function_exists( 'wp_remote_post' ) ) { 498 499 // Setup the arguments 500 $http_args = array( 501 'body' => $request, 502 'headers' => array( 503 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . $blog_charset, 504 'Host' => $host, 505 'User-Agent' => $akismet_ua 506 ), 507 'httpversion' => '1.0', 508 'timeout' => 15 509 ); 510 511 // Where we are sending our request 512 $akismet_url = 'http://' . $http_host . $path; 513 514 // Send the request 515 $response = wp_remote_post( $akismet_url, $http_args ); 516 517 // Bail if the response is an error 518 if ( is_wp_error( $response ) ) 519 return ''; 520 521 // No errors so return response 522 return array( $response['headers'], $response['body'] ); 523 524 // WP HTTP class is not available (Why not?) 525 } else { 526 527 // Header info to use with our socket 528 $http_request = "POST {$path} HTTP/1.0\r\n"; 529 $http_request .= "Host: {$host}\r\n"; 530 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset={$blog_charset}\r\n"; 531 $http_request .= "Content-Length: {$content_length}\r\n"; 532 $http_request .= "User-Agent: {$akismet_ua}\r\n"; 533 $http_request .= "\r\n"; 534 $http_request .= $request; 535 536 // Open a socket connection 537 if ( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) { 538 539 // Write our request to the pointer 540 fwrite( $fs, $http_request ); 541 542 // Loop through pointer and compile a response 543 while ( !feof( $fs ) ) { 544 // One TCP-IP packet at a time 545 $response .= fgets( $fs, 1160 ); 546 } 547 548 // Close our socket 549 fclose( $fs ); 550 551 // Explode the response into usable data 552 $response = explode( "\r\n\r\n", $response, 2 ); 553 } 554 555 // Return the response ('' if error/empty) 556 return $response; 557 } 472 * Filters user agent when sending to Akismet. 473 * 474 * @param string $user_agent 475 * @since 1.0 476 */ 477 public function buddypress_ua( $user_agent ) { 478 return 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' ); 558 479 } 559 480
Note: See TracChangeset
for help on using the changeset viewer.