If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > convert a php program to perl

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-31-09, 04:56
darren5559 darren5559 is offline
Registered User
 
Join Date: May 2009
Posts: 1
convert a php program to perl

hi,

i need a expert of php and perl. i have a php program here, i need someone to convert the php code into perl, the php code is listed in the following, i have been trying to write a new code in perl, but does not work, i really appreciate if any of u can help me on this.

php code :-

function get_headers1($url,$format) {
$string = "0a";
$hstring = pack('H*', $string);
$url_info=parse_url($url);
$port = isset($url_info['port']) ? $url_info['port'] : 80;
$fp=fsockopen($url_info['host'], $port, $errno, $errstr, 30);
if($fp) {
$head = "HEAD ".@$url_info['path']."?".@$url_info['query'];
$head .= " HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n";
$head .= " \r\npassname: ".urlencode('passname')."\r\n";
$head .= " \r\npassword: ".urlencode('password')."\r\n";
$head .= " \r\ntrx_id: ".urlencode('0')."\r\n";
$head .= " \r\nshort_code: ".urlencode('xxxxx')."\r\n";
$head .= " \r\noriginating_no: ".urlencode('xxxxx')."\r\n";
$head .= " \r\ndestination_no: ".urlencode('xxxxx')."\r\n";
$head .= " \r\ncp_ref_id: ".urlencode('0')."\r\n";
$head .= " \r\nbill_type: ".urlencode('0')."\r\n";
$head .= " \r\nbill_price: ".urlencode('0')."\r\n";
$head .= " \r\ncontent_type: ".urlencode('1')."\r\n";
$head .= " \r\nmsg: ".urlencode('this is a test')."\r\n";
$head .= " \r\nbulk_fg: ".urlencode('1')."\r\n\r\n";
//echo $head."
";
//$head .= " \r\ndomain: ".$_POST['txtDomainName'].".".$_POST['comboDomainRoot']."\r\n\r\n";
fputs($fp, $head);
while(!feof($fp)) {
if($header=trim(fgets($fp, 1024))) {
echo $header."
";
//echo $errno." ".$errstr."
";
if($format == 1) {
$h2 = explode(':',$header);
// the first element is the http header type, such as HTTP/1.1 200 OK,
// it doesn't have a separate name, so we have to check for it.
if($h2[0] == $header) {
$headers['status'] = $header;
}
else {
$headers[strtolower($h2[0])] = trim($h2[1]);
}
}
else {
$headers[] = $header;
}
}
}
return $headers;
}
else {
return false;
}
}
$data = get_headers1("(URL address blocked: See forum rules):81/test.aspx", 1);
?>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On