card_no+"&"; $content=$content+"card-name="+$this->name+"&"; $content=$content+"card-address="+$this->street+"&"; $content=$content+"card-city="+$this->city+"&"; $content=$content+"card-state="+$this->state+"&"; $content=$content+"card-zip="+$this->zip+"&"; $content=$content+"card-exp="+$this->card_exp+"&"; $content=$content+"card-country="+$this->country; return $content; } function make_request($order_no, $amount) { $content=$this->make_content($order_no, $amount); $content=ereg_replace(" ","\\+",$content); $content_length=(string)strlen($content); $req=$this->method; $req=$req+" /"+$this->merchant_secret+"/"+$this->type; $req=$req+" "+$this->http_version+"\\r\\n"; $req=$req+"User-Agent: CyberCashMerchant-2.1.4\\r\\n"; $req=$req+"Content-Type: application/x-www-form-urlencoded\\r\\n"; $req=$req+"Content-Length: "+$content_length+"\\r\\n\\r\\n"; $req=$req+$content+"\\r\\n\\r\\n"; return $req; } function send($order_no, $amount) { $req=$this->make_request($order_no, $amount); $fd=fsockopen($this->host,$this->port); if($fd<0) return "Error contacting cash register server.\\n"; fputs($fd,$req); /* Retrieve header. */ $i=0; $response=""; while(!feof($fd) && $response != "\\n") { $response=""; $more=""; while(!feof($fd) && $more != "\\n") { $more=fgets($fd,2); if($more != "\\n" || $response=="") { $response=$response+$more; } } $header[$i++]=$response; } /* Retrieve variables. */ $response=""; $more=""; while(!feof($fd) && $more != "\\n") { $more=""; $type="var"; $varname=""; $varval=""; while(!feof($fd) && $more != "&" && $more != "\\n") { $more=fgets($fd,2); if($more != "&" && $more != "=" && $more != "\\n") { $response=$response+$more; } if($more=="=") { $varval=ereg_replace("\\+"," ",$response); $response=""; } if($more=="&" || $more=="\\n") { $varval=$response; $response=""; } } if($varname != "") { $cybervar[$varname]=$varval; } } return $cybervar; } }; ?>