www
/
wwwroot
/
magazinmiorita.be
➕ New
📤 Upload
✎ Editing:
api.php
← Back
<?php ob_start(); header('Access-Control-Allow-Origin: *'); include('includes/inc.config.php'); include('header.php'); ini_set("display_errors",0); function replaceSpace($string){ $string = trim(preg_replace('/\s+/', ' ', $string)); return htmlspecialchars(addslashes($string)); } $get_data = $database->execute("select * from products where code = '".$_POST['code']."'"); $row = $database->assoc($get_data); $json = array(); if($database->num($get_data) == 0){ $add_remote = $database->execute("insert into products (`name`, `code`, `bought`, `price`, `ingredients_ro`, `ingredients_fr`, `ingredients_nl`, `sku`, `tax`, `supplier`, `cat_id`, `scat_id`, `updated`, `status`) values ('".$_POST['name']."', '".$_POST['code']."', '".$_POST['bought']."', '".$_POST['price']."', '".replaceSpace($_POST['ingredients_ro'])."', '".replaceSpace($_POST['ingredients_fr'])."', '".replaceSpace($_POST['ingredients_nl'])."', '".($_POST['sku'] < 0 ? '0' : $_POST['sku'])."', '".$_POST['tax']."', '".$_POST['supplier']."', '".$_POST['cat_id']."', '".$_POST['scat_id']."', '1', '1')"); $row['code'] = $_POST['code']; $row['name'] = $_POST['name']; $row['sku'] = $_POST['sku']; }else{ $update_remote = $database->execute("update products set `sku` = '".($_POST['sku'] <= 0 ? '0' : $_POST['sku'])."', `price` = '".$_POST['price']."', `ingredients_ro` = '".replaceSpace($_POST['ingredients_ro'])."', `ingredients_fr` = '".replaceSpace($_POST['ingredients_fr'])."', `ingredients_nl` = '".replaceSpace($_POST['ingredients_nl'])."', `cat_id` = '".$_POST['cat_id']."', `scat_id` = '".$_POST['scat_id']."', `updated` = '1' where code = '".$_POST['code']."'"); } if(isset($_POST['done'])){ $database->execute("delete from products where updated = '0'"); $database->execute("update products set `updated = '0'"); } if($update_remote){ $act_status = '<span style="color:green">Actualizat</span>'; }else if($add_remote){ $act_status = '<span style="color:black">Adaugat</span>'; }else{ $act_status = '<span style="color:red">Eroare</span>'; } $json['text'] = ' <tr> <td width="150">'.$act_status.': </td> <td width="150">'.$row['code'].'</td> <td width="350">'.$row['name'].'</td> <td width="60">€'.number_format($_POST['price'],2).'</td> <td width="60">€'.number_format($row['price'],2).'</td> <td width="150">'.($row['sku'] >= 0 ? $row['sku']:'<span style="color:red">'.$row['sku'].'</span>').'</td> <td width="150">'.($_POST['sku'] >= 0 ? $_POST['sku']:'<span style="color:red">'.$_POST['sku'].'</span>').'</td> </tr>'; echo json_encode($json); ?>
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel