Forráskód Böngészése

2021-04-06 / ct_chen

Actions:
1. Webservice return result(1/0) and append to /mnt/update_file.txt after uploading file through http, command must add parameter "q",
ex: /bin/php-cgi -nq /var/www/ocpp_upload.php

Files:
1. EVSE/rootfs/var/www/ocpp_upload.php
ct_chen 4 éve
szülő
commit
16465f115e
1 módosított fájl, 23 hozzáadás és 10 törlés
  1. 23 10
      EVSE/rootfs/var/www/ocpp_upload.php

+ 23 - 10
EVSE/rootfs/var/www/ocpp_upload.php

@@ -1,34 +1,47 @@
 <?php
 <?php
 $content=file("/mnt/upload_file.txt");
 $content=file("/mnt/upload_file.txt");
 $url = $content[0];
 $url = $content[0];
-//system("yes|cp -f ".$content[1]." /var/www/");
-//echo "1=yes|cp -f ".$content[1]." /var/www/\r\n";
 $arr = explode("/",$content[1]);
 $arr = explode("/",$content[1]);
 $file=trim($arr[count($arr)-1]);
 $file=trim($arr[count($arr)-1]);
-//copy(trim($content[1]),"/var/www/".$file);
-
+$filename = '/mnt/upload_file.txt';
 $curl = curl_init();
 $curl = curl_init();
+$curl_log = fopen($filename, 'a+'); 
 
 
 curl_setopt_array($curl, array(
 curl_setopt_array($curl, array(
+  CURLINFO_HEADER_OUT => 1,
   CURLOPT_URL => $content[0],
   CURLOPT_URL => $content[0],
-  CURLOPT_RETURNTRANSFER => true,
+  CURLOPT_HEADER => 1,
+  CURLOPT_RETURNTRANSFER => 1,
+  CURLOPT_BINARYTRANSFER => 1,
+  CURLOPT_FAILONERROR => 1,
   CURLOPT_ENCODING => "",
   CURLOPT_ENCODING => "",
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_TIMEOUT => 0,
   CURLOPT_TIMEOUT => 0,
-  CURLOPT_FOLLOWLOCATION => true,
+  CURLOPT_STDERR          => $curl_log,
+  CURLOPT_FOLLOWLOCATION => 0,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_POSTFIELDS => array(''=> new CURLFILE(trim($content[1]),"application/zip",$file)),
   CURLOPT_POSTFIELDS => array(''=> new CURLFILE(trim($content[1]),"application/zip",$file)),
   CURLOPT_HTTPHEADER => array(
   CURLOPT_HTTPHEADER => array(
     "Content-Type: multipart/form-data"
     "Content-Type: multipart/form-data"
   ),
   ),
-  CURLOPT_VERBOSE => true,
+  CURLOPT_NOSIGNAL => 1,
+  CURLOPT_VERBOSE => 1,
 ));
 ));
 
 
 $response = curl_exec($curl);
 $response = curl_exec($curl);
-
+$response_text=1;
+if($response) {
+	$response_text=1;
+}
+else{
+	$response_text=0;
+}
+$error=curl_error($curl);
 curl_close($curl);
 curl_close($curl);
-//system("yes|rm  /var/www/".$file." -f");
 
 
-echo $response;
+fwrite($curl_log,$response_text."\n");
+fclose($curl_log);  
+
+echo $response_text;
 ?>
 ?>