bb_ksd_http_post

The BuddyPress bb ksd http post function.

Description

bb_ksd_http_post( $request, $host, $path, (int) $port = 80 ); 

Parameters (4)

0. $request
The request.
1. $host
The host.
2. $path
The path.
3. $port — Optional. (int) => 80
The port.

Usage

  1. if ( !function_exists( 'bb_ksd_http_post' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-plugins/akismet.php'; 
  3.  
  4. // The request. 
  5. $request = null; 
  6.  
  7. // The host. 
  8. $host = null; 
  9.  
  10. // The path. 
  11. $path = null; 
  12.  
  13. // The port. 
  14. $port = 80; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = bb_ksd_http_post($request, $host, $path, $port); 
  18.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-plugins/akismet.php  
  1. function bb_ksd_http_post( $request, $host, $path, $port = 80 ) 
  2. global $bb_ksd_user_agent; 
  3.  
  4. $http_request = 'POST ' . $path . ' HTTP/1.0' . "\r\n"; 
  5. $http_request .= 'Host: ' . $host . "\r\n"; 
  6. $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' . "\r\n"; // for now 
  7. $http_request .= 'Content-Length: ' . strlen($request) . "\r\n"; 
  8. $http_request .= 'User-Agent: ' . $bb_ksd_user_agent . "\r\n"; 
  9. $http_request .= "\r\n"; 
  10. $http_request .= $request; 
  11. $response = ''; 
  12. if ( false != ( $fs = @fsockopen( $host, $port, $errno, $errstr, 10 ) ) ) { 
  13. fwrite( $fs, $http_request ); 
  14.  
  15. while ( !feof( $fs ) ) { 
  16. $response .= fgets( $fs, 1160 ); // One TCP-IP packet 
  17. fclose( $fs ); 
  18. $response = explode( "\r\n\r\n", $response, 2 ); 
  19. return $response;