diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..a11777c Binary files /dev/null and b/favicon.ico differ diff --git a/logo192.png b/logo192.png new file mode 100644 index 0000000..fc44b0a Binary files /dev/null and b/logo192.png differ diff --git a/logo512.png b/logo512.png new file mode 100644 index 0000000..a4e47a6 Binary files /dev/null and b/logo512.png differ diff --git a/server/.htaccess b/server/.htaccess index 6b43e8b..eb8d1ca 100644 --- a/server/.htaccess +++ b/server/.htaccess @@ -2,4 +2,7 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] -SetEnvIfNoCase Request_URI ^ / index.php no-gzip -vary \ No newline at end of file +SetEnvIfNoCase Request_URI ^ / index.php no-gzip -vary +# HTID:21006778: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW +allow from 0.0.0.0 +# DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:21006778: diff --git a/server/DbConnect.php b/server/DbConnect.php index 0afbd96..479419e 100644 --- a/server/DbConnect.php +++ b/server/DbConnect.php @@ -4,14 +4,20 @@ */ class DbConnect { - // private $server = 'https://databases.000webhost.com'; - // private $dbname = 'id20087235_scandiweb_task'; - // private $user = 'id20087235_root'; - // private $pass = 'WpG)fM7WHlk%oEOX'; private $server = 'localhost'; - private $dbname = 'scandiweb_task'; - private $user = 'root'; - private $pass = ''; + private $dbname = 'id20087235_scandiweb_task'; + private $user = 'id20087235_root'; + private $pass = 'WpG)fM7WHlk%oEOX'; + +// private $server = 'sql7.freemysqlhosting.net'; +// private $dbname = 'sql7587618'; +// private $user = 'sql7587618'; +// private $pass = '2BbPJcDg3X'; + +// private $server = 'localhost'; +// private $dbname = 'scandiweb_task'; +// private $user = 'root'; +// private $pass = ''; diff --git a/server/index.php b/server/index.php index 74522dd..bdfc56e 100644 --- a/server/index.php +++ b/server/index.php @@ -3,7 +3,7 @@ ini_set('display_errors', 1); header("Access-Control-Allow-Origin: *"); header('Access-Control-Allow-Credentials: true'); -header('Access-Control-Max-Age: 86400'); +// header('Access-Control-Max-Age: 86400'); header("Access-Control-Allow-Headers: *"); header("Access-Control-Allow-Methods: *"); @@ -21,14 +21,21 @@ $products_list->getProducts($conn); break; case "POST": - $product = json_decode(file_get_contents('php://input')); - $type = $product->type; - $class = $type; - $product_object = new $class($product, true); - $product_object->addProduct($conn, $type); - break; - case "DELETE": - $products_list = new ProductList(); - $products_list->deleteProduct($conn); + $path = explode('/', $_SERVER['REQUEST_URI']); + if ($path[1] == "addproduct") { + $product = json_decode(file_get_contents('php://input')); + $type = $product->type; + $class = $type; + // echo json_encode($path); + $product_object = new $class($product, true); + $product_object->addProduct($conn, $type); + } else { + $products_list = new ProductList(); + $products_list->deleteProduct($conn, $path[2]); + } break; + // case "DELETE": + // $products_list = new ProductList(); + // $products_list->deleteProduct($conn); + // break; } \ No newline at end of file diff --git a/server/product.php b/server/product.php index 3749128..4bed1fe 100644 --- a/server/product.php +++ b/server/product.php @@ -53,7 +53,7 @@ public function addProduct($conn, $type) if ($valid) { try { $sql = - "INSERT INTO products(SKU, name, price, type) VALUES(:SKU, :name, :price, :type)" . + "INSERT INTO products(SKU, name, price, type) VALUES(:SKU, :name, :price, :type);" . "INSERT INTO dvds(SKU, size) VALUES(:SKU, :size)"; $stmt = $conn->prepare($sql); $stmt->bindParam(':SKU', $this->SKU); @@ -188,7 +188,7 @@ public function addProduct($conn, $type) if ($valid) { try { $sql = - "INSERT INTO products(SKU, name, price, type) VALUES(:SKU, :name, :price, :type)" . + "INSERT INTO products(SKU, name, price, type) VALUES(:SKU, :name, :price, :type);" . "INSERT INTO furniture(SKU, length, width, height) VALUES(:SKU, :length, :width, :height)"; $stmt = $conn->prepare($sql); $stmt->bindParam(':SKU', $this->SKU); @@ -241,13 +241,12 @@ public function getProducts($conn) } } - public function deleteProduct($conn) + public function deleteProduct($conn, $SKU) { try { $sql = "DELETE FROM products WHERE SKU = :id"; - $path = explode('/', $_SERVER['REQUEST_URI']); $stmt = $conn->prepare($sql); - $stmt->bindParam(':id', $path[4]); + $stmt->bindParam(':id', $SKU); $stmt->execute(); $response = ['status' => '200', 'message' => 'Record deleted successfully.']; } catch (\Throwable $error) { diff --git a/server/test.php b/server/test.php deleted file mode 100644 index 6c929e4..0000000 --- a/server/test.php +++ /dev/null @@ -1,11 +0,0 @@ - - - -
-