note 91554 added to function.fsockopen
| From: | andypsv at rcdrugs dot com | Date: | Tue, 16 Jun 2009 20:15:42 +0000 |
| Subject: | note 91554 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156943@lists.php.net to get a copy of this message | ||
look at this smart ssl/http fsockopen function as a good solution for dealing with things
[code]function _get($type,$host,$port='80',$path='/',$data='') {
$_err = 'lib sockets::'.__FUNCTION__.'(): ';
switch($type) { case 'http': $type = ''; case 'ssl': continue;
default: die($_err.'bad $type'); } if(!ctype_digit($port)) die($_err.'bad
port');
if(!empty($data)) foreach($data AS $k => $v) $str .=
urlencode($k).'='.urlencode($v).'&'; $str = substr($str,0,-1);
$fp = fsockopen($host,$port,$errno,$errstr,$timeout=30);
if(!$fp) die($_err.$errstr.$errno); else {
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($str)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $str."\r\n\r\n");
while(!feof($fp)) $d .= fgets($fp,4096);
fclose($fp);
} return $d;
}[/code]
----
Server IP: 92.48.74.199
Probable Submitter: 81.155.117.114
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- https://master.php.net/note/edit/91554
Del: integrated -- https://master.php.net/note/delete/91554/integrated
Del: useless -- https://master.php.net/note/delete/91554/useless
Del: bad code -- https://master.php.net/note/delete/91554/bad+code
Del: spam -- https://master.php.net/note/delete/91554/spam
Del: non-english -- https://master.php.net/note/delete/91554/non-english
Del: in docs -- https://master.php.net/note/delete/91554/in+docs
Del: other reasons-- https://master.php.net/note/delete/91554
Reject -- https://master.php.net/note/reject/91554
Search -- https://master.php.net/manage/user-notes.php