if ($proxy) {
$conn['scheme']=strtolower($conn['scheme']);
switch ($conn['scheme']) {
case 'socks4':
case 'socks4a':
$str = "\04\01".($url_p['port'] ? pack('n',intval($url_p['port'])) : "\00\x50");
if ($conn['scheme']=='socks4a') { $str .= "\00\00\00\01\00$url_p[host]\00";
} else {
$ip = gethostbyname($url_p['host']);
if ($ip == $url_p['host']) return array('Error: cannot resolve ip: '.$url_p['host']);
foreach (explode (".", $ip) as $v) $str .= chr($v);
$str .= "\00";
}
fputs ($fp, $str);
$str = fread ($fp, 8);
if ($str == '') return array('Error: connection timeout.');
if ($str[0] != "\00") return array('Error: proxy connection error.');
$errors = array ('', 'Request rejected or failed', 'Cannot connect to identd on the client', 'identd report different user-ids');
$code = ord($str[1]);
if ($code>90) return array('Error: '.$errors[$code-90]);
break;