I want to open a csv file with following entries:
Firma,Anrede,Titel,Vorname,Nachname,Strasse,PLZ,Telefon,Fax,Email,Nachricht,CopyFlag,Importiert,Importdate,Importtime
Testfirma1,Herr,Dr.,Vorname1,Name1,Strasse1,11111,12345567,123456,1@keine.de,nachricht1,1,,24.03.2016,22:00:00
Testfirma2,Herr,Dr.,Vorname2,Name2,Strasse2,22222,22345567,223456,2@keine.de,nachricht2,1,,25.03.2016,22:00:00
Testfirma3,Herr,Dr.,Vorname3,Name3,Strasse3,33333,32345567,323456,3@keine.de,nachricht3,1,,25.03.2016,22:00:00
Testfirma4,Herr,Dr.,Vorname4,Name4,Strasse4,44444,42345567,423456,4@keine.de,nachricht4,1,,25.03.2016,22:00:00
Than I want to check if there's nothing in Column 12 (Importiert
), and check if the importtime
is < than the systemtime
. If both are true I want to send this data to curl doing some post. When this is done, I want to write a timestamp in column 12. I tried it with this example:
$fp = fopen("Testformular.csv", "r+");
$line = 0;
while ( $row = fgetcsv($fp) ) {
if($line === 0){
$line++;
continue;};
$actual = date("d.m.Y - H:i:s", time());
$csvtime= date("d.m.Y - H:i:s", strtotime($row[13]. $row[14]));
if (empty($row[12])){
if ($actual > $csvtime){
$output = "";
$output .= 'tx_btsimplecontact_pi1[name]=' . urlencode("");
$output .= '&tx_btsimplecontact_pi1[firma]=' . urlencode($row[0]);
$output .= '&tx_btsimplecontact_pi1[sex]=' . urlencode($row[1]);
$output .= '&tx_btsimplecontact_pi1[titel]=' . urlencode($row[2]);
$output .= '&tx_btsimplecontact_pi1[vorname]=' . urlencode($row[3]);
$output .= '&tx_btsimplecontact_pi1[nachname]=' . urlencode($row[4]);
$output .= '&tx_btsimplecontact_pi1[strasse]=' . urlencode($row[5]);
$output .= '&tx_btsimplecontact_pi1[plz_ort]=' . urlencode($row[6]);
$output .= '&tx_btsimplecontact_pi1[telefon]=' . urlencode($row[7]);
$output .= '&tx_btsimplecontact_pi1[fax]=' . urlencode($row[8]);
$output .= '&tx_btsimplecontact_pi1[email]=' . urlencode($row[9]);
$output .= '&tx_btsimplecontact_pi1[nachricht]=' . urlencode($row[10]);
$output .= '&tx_btsimplecontact_pi1[copy]=' . urlencode($row[11]);
$output .= '&submit=Abschicken';
print_r ($row);
print ($output);
$row[12]= $actual;
print_r ($row);
fputcsv($fp,$row);
};
};
curl ('http://www.post.html', "$output");
};
The output in CSV is following:
Firma,Anrede,Titel,Vorname,Nachname,Strasse,PLZ,Telefon,Fax,Email,Nachricht,CopyFlag,Importiert,Importdate,Importtime
Testfirma1,Herr,Dr.,Vorname1,Name1,Strasse1,11111,12345567,123456,1@keine.de,nachricht1,1,,24.03.2016,22:00:00
Testfirma1,Herr,Dr.,Vorname1,Name1,Strasse1,11111,12345567,123456,1@keine.de,nachricht1,1,"25.03.2016 - 01:10:15",24.03.2016,22:00:00
name3,Name3,Strasse3,33333,32345567,323456,3@keine.de,nachricht3,1,,25.03.2016,22:00:00
name3,Name3,Strasse3,33333,32345567,323456,3@keine.de,nachricht3,1,,25.03.2016,22:00:00,"25.03.2016 - 01:10:16"