13 changed files with 227 additions and 6 deletions
@ -0,0 +1,2 @@ |
|||
API_URL=http://iolovolio.local/api |
|||
SITE_URL=http://iolovolio.local |
@ -0,0 +1,2 @@ |
|||
API_URL=http://iolovolio.com/api |
|||
SITE_URL=http://iolovolio.com |
@ -0,0 +1,29 @@ |
|||
<?php |
|||
session_start(); |
|||
include_once './config.php'; |
|||
include_once './database.php'; |
|||
|
|||
header("Access-Control-Allow-Origin: *"); |
|||
header("Content-Type: application/json; charset=UTF-8"); |
|||
header("Access-Control-Allow-Methods: POST"); |
|||
header("Access-Control-Max-Age: 3600"); |
|||
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); |
|||
|
|||
$databaseService = new DatabaseService(); |
|||
$conn = $databaseService->getConnection(); |
|||
|
|||
$sid = trim($_POST['sid']); |
|||
$pid = trim($_POST['pid']); |
|||
$qty = trim($_POST['qty']); |
|||
|
|||
$_SESSION['CART'][] = array("pid" => intval($pid), "qty" => intval($qty)); |
|||
|
|||
http_response_code(200); |
|||
echo json_encode( |
|||
array( |
|||
"status" => 200, |
|||
"cart" => $_SESSION['CART'] |
|||
)); |
|||
|
|||
?> |
|||
|
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
$GLOBALS['CONF']['DB']['HOST'] = "localhost"; |
|||
$GLOBALS['CONF']['DB']['USER'] = "root"; |
|||
$GLOBALS['CONF']['DB']['PASSWORD'] = "root"; |
|||
$GLOBALS['CONF']['DB']['DB_NAME'] = "iolovolio"; |
|||
|
|||
?> |
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
class DatabaseService { |
|||
|
|||
protected $glob; |
|||
|
|||
private $db_host; |
|||
private $db_name; |
|||
private $db_user; |
|||
private $db_password; |
|||
private $connection; |
|||
|
|||
public function __construct() { |
|||
global $GLOBALS; |
|||
$this->glob =& $GLOBALS; |
|||
} |
|||
|
|||
public function getConnection() { |
|||
|
|||
$this->connection = null; |
|||
$this->db_host = $this->glob['CONF']['DB']['HOST']; |
|||
$this->db_name = $this->glob['CONF']['DB']['DB_NAME']; |
|||
$this->db_user = $this->glob['CONF']['DB']['USER']; |
|||
$this->db_password = $this->glob['CONF']['DB']['PASSWORD']; |
|||
|
|||
try { |
|||
$this->connection = new PDO("mysql:host=" . $this->db_host . ";dbname=" . $this->db_name, $this->db_user, $this->db_password); |
|||
} catch(PDOException $exception) { |
|||
echo "Connection failed: " . $exception->getMessage(); |
|||
} |
|||
|
|||
return $this->connection; |
|||
} |
|||
} |
|||
?> |
@ -1 +1,2 @@ |
|||
@import url('https://fonts.googleapis.com/css?family=DM+Serif+Display&family=Open+Sans:300,400,500,700&display=swap'); |
|||
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700&display=swap'); |
|||
@import url('https://fonts.googleapis.com/css?family=DM+Serif+Display:300,400,500,700&display=swap'); |
|||
|
Loading…
Reference in new issue