I wrote a PHP script to export orders from an e-commerce store, save them in an XML file, and then copy them to a remote FTP folder. Another company controls this FTP folder for new files and uses them to execute orders.
For some reason, the script only downloads the file from time to time, and I find debugging / getting it to the end is very difficult. This is the main part of the offensive script:
if ($ftp_conn = ftp_connect($ftp_server)) {
if ($login = ftp_login($ftp_conn, $ftp_user, $ftp_pass)) {
$filename = time() . '-orders.xml';
ftp_pasv($ftp_conn, true);
if (ftp_put($ftp_conn, $filename, $xmlPath, FTP_ASCII)) {
$logString .= ' - Successfully run';
ftp_close($ftp_conn);
} else {
$logString .= ' - Failed to upload file';
$error = error_get_last();
$logString .= ' - ' . $error['message'];
ftp_close($ftp_conn);
}
} else {
$logString .= ' - Failed to log in to server';
ftp_close($ftp_conn);
}
} else {
$logString .= ' - Failed to connect to server';
};
I save the $ logString variable in a text file. The only error I really see about is:
ftp_put(): Type set to A
I can not find anything on the Internet about what this means, or if this should be the cause of the problem.
The FTP connection log does not help either. This is all you see when it does not start:
"PASS (hidden)" 230 -
"TYPE A" 200 -
, . , . XML .
, 3 , 2, , .
PHP script , , - , , , , ?