Linux vps-61133.fhnet.fr 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
Apache/2.4.25 (Debian)
Server IP : 93.113.207.21 & Your IP : 216.73.216.152
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
html /
foa_test_api /
shopify /
Delete
Unzip
Name
Size
Permission
Date
Action
ERROR
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
SUCCES
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
import
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
clients.json
126.04
KB
-rw-r--r--
2024-07-19 15:54
collections.json
419
B
-rw-r--r--
2024-07-19 16:08
config.php
273
B
-rw-r--r--
2023-10-28 20:56
createProductFromCSV.php
2.25
KB
-rw-r--r--
2023-10-28 23:18
getClients.php
576
B
-rw-r--r--
2023-10-28 22:39
getCollections.php
664
B
-rw-r--r--
2023-10-28 22:37
getOrders.php
2.05
KB
-rw-r--r--
2023-10-28 23:37
getProducts.php
1.82
KB
-rw-r--r--
2023-11-29 15:51
getProducts.php.foa
2.22
KB
-rw-r--r--
2023-10-28 22:28
getStocks.php
637
B
-rw-r--r--
2023-10-28 22:42
helper.php
858
B
-rw-r--r--
2023-10-28 22:40
launcher.php
712
B
-rw-r--r--
2023-10-28 23:04
logs.txt
1008
B
-rw-r--r--
2023-10-30 10:25
products.csv
64.87
KB
-rw-r--r--
2024-07-19 17:17
products.json
289.43
KB
-rw-r--r--
2024-07-14 04:59
products.xml
17.13
KB
-rw-r--r--
2023-10-28 21:48
shopify_to_csv.php
1.96
KB
-rw-r--r--
2023-10-28 21:35
updateOrderStatus.php
1.49
KB
-rw-r--r--
2023-10-28 23:29
Save
Rename
<?php require 'config.php'; function writeToLog($message) { $logFile = fopen("logs.txt", "a"); fwrite($logFile, date('Y-m-d H:i:s') . ": " . $message . "\n"); fclose($logFile); } function sendErrorMail($errorMessage) { $to = 'maintenance@anexys.fr'; $subject = 'Erreur intégration produits Shopify'; $message = 'Erreur rencontrée: ' . $errorMessage; $headers = 'From: no-reply@anexys.fr' . "\r\n"; mail($to, $subject, $message, $headers); } function createShopifyProduct($productData) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, SHOPIFY_API_URL . "products.json"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['product' => $productData])); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'X-Shopify-Access-Token: ' . SHOPIFY_ACCESS_TOKEN ]); $response = curl_exec($ch); curl_close($ch); return json_decode($response, true); } $allSuccessful = true; // Assume all operations are successful to start $filePath = "import/products.csv"; $file = fopen($filePath, "r"); $headers = fgetcsv($file); // Ignore the first line (headers) while ($row = fgetcsv($file)) { if (count($row) < 5 || in_array("", $row)) { writeToLog("Ligne ignorée en raison d'un champ manquant ou vide: " . implode(", ", $row)); $allSuccessful = false; continue; } $productData = [ "title" => $row[0], "body_html" => $row[1], "vendor" => $row[2], "product_type" => $row[3], "tags" => explode(',', $row[4]) ]; $response = createShopifyProduct($productData); if ($response && isset($response['product'])) { echo "Produit créé avec l'ID : " . $response['product']['id'] . PHP_EOL; } else { $allSuccessful = false; echo "Erreur lors de la création du produit:" . $row[0] . PHP_EOL; writeToLog("Erreur lors de la création du produit:" . $row[0]); sendErrorMail("Erreur lors de la création du produit:" . $row[0]); } } fclose($file); // Move the file to the appropriate directory $destDirectory = $allSuccessful ? "SUCCES" : "ERROR"; rename($filePath, $destDirectory . "/products.csv"); ?>