tags:

views:

9

answers:

0

Hey,

So I have my email on a site w/ cpanel and my support site currently running locally. I've set up a forwarder to automail.php which triggers correctly. Here is the code:

#!/usr/bin/php -q
<?php

try {

#pre-checks
function_exists('file_get_contents') or die('upgrade php >=4.3');
set_time_limit(30);


#Configuration: Enter the url and key. That is it.
#  url=> URL to pipe.php e.g http://yourdomain.com/support/api/pipe.php
#  key=> API's Key (see admin panel on how to generate a key)
$config=array('url'=>'http://76.103.8.18:8002/osticket/api/pipe.php',
              'key'=>'san francisco california');

#read stdin 
$data=file_get_contents('php://stdin');
if(empty($data)) die('Error reading stdin. No message');

#curl post
$ch = curl_init();        
curl_setopt($ch, CURLOPT_URL,$config['url']);        
curl_setopt($ch, CURLOPT_POST,1);        
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_USERAGENT,$config['key']);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
$result=curl_exec($ch);        
$err=curl_errno($ch);
curl_close($ch);
$code=0;
if(preg_match('/HTTP\/.* ([0-9]+) .*/', $result, $status))
    $code=$status[1];
//Depending on your MTA add the exit codes.
//echo $code;

$myFile = "completed.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $err);
fclose($fh);

} catch (Exception $e) {


    $myFile = "error.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = $e->getMessage();
    fwrite($fh, $stringData);
    fclose($fh);

}
?>

If I check the text file after execution I have an error #7 which is CURLE_COULDNT_CONNECT. If I manually hit the url it works as it writes a text file to my local drive. This never happens thru the php.

The pipe.php file curl is trying to connect to is located on a windows server 2008 box running WAMP.

Any ideas? Been troubleshooting this for two hours with no luck!

Thanks!