CMXX - Include API authorization in index
This commit is contained in:
16
index.php
16
index.php
@@ -6,17 +6,29 @@ $base_url = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER[
|
||||
$base_url .= '://' . rtrim($_SERVER['HTTP_HOST'], '/');
|
||||
$base_url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 || strpos($_SERVER['HTTP_HOST'], ':') !== false ? '' : ':' . $_SERVER['SERVER_PORT'];
|
||||
$base_url .= '/' . ltrim(substr(str_replace('\\', '/', realpath(__DIR__)), strlen($_SERVER['DOCUMENT_ROOT'])), '/');
|
||||
|
||||
define('base_url', rtrim($base_url, '/') . '/');
|
||||
// If somehow the above URL fails to resolve the correct URL, you can simply comment out the below line and manually specifiy the URL to the system.
|
||||
// define('base_url', 'http://yourdomain.com/shoppingcart/');
|
||||
|
||||
// Initialize a new session
|
||||
session_start();
|
||||
|
||||
// Include the configuration file, this contains settings you can change.
|
||||
include './custom/settings/config.php';
|
||||
// Include functions and connect to the database using PDO MySQL
|
||||
include 'functions.php';
|
||||
// Include translation file
|
||||
include './custom/translations/translations_'.strtoupper(language_code).'.php';
|
||||
|
||||
//LOGIN TO API
|
||||
$data = json_encode(array("username" => "paul@veliti.nl", "password" => "test1234"), JSON_UNESCAPED_UNICODE);
|
||||
$responses = ioAPIv2('/v2/authorization', $data,'');
|
||||
//Decode Payload
|
||||
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
|
||||
$clientsecret = $responses['token'];
|
||||
|
||||
//IMAGE URL
|
||||
$img_url = substr(api_url, 0, -8);
|
||||
|
||||
// Connect to MySQL database
|
||||
$pdo = pdo_connect_mysql();
|
||||
// Output error variable
|
||||
|
||||
16
products.php
16
products.php
@@ -1,21 +1,7 @@
|
||||
<?php
|
||||
// Prevent direct access to file
|
||||
defined(security_key) or exit;
|
||||
//=====================================
|
||||
// MOVE TO INDEX
|
||||
//=====================================
|
||||
|
||||
//LOGIN TO API
|
||||
$data = json_encode(array("username" => "paul@veliti.nl", "password" => "test1234"), JSON_UNESCAPED_UNICODE);
|
||||
$responses = ioAPIv2('/v2/authorization', $data,'');
|
||||
//Decode Payload
|
||||
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
|
||||
$clientsecret = $responses['token'];
|
||||
|
||||
$img_url = substr(api_url, 0, -8);
|
||||
//=====================================
|
||||
//end move to index
|
||||
//=====================================
|
||||
//Pagination
|
||||
$current_page = isset($_GET['p']) && is_numeric($_GET['p']) ? (int)$_GET['p'] : 1;
|
||||
$num_products_on_each_page = 25;
|
||||
@@ -121,7 +107,7 @@ $view .= ' <div style="margin-top: 30px;display: flex;align-items: center;align-
|
||||
';
|
||||
foreach ($categories as $categorie){
|
||||
if ($categorie['parent_id'] == '0' && $categorie['status'] == 1 && $categorie['filter'] != 1){
|
||||
$weburl = url('index.php?page=test&category='.$categorie['rowID'].'');
|
||||
$weburl = url('index.php?page=products&category='.$categorie['rowID'].'');
|
||||
$view .= '<a href="'.$weburl.'">'.$categorie['name'].'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user