<?php
session_start();
include('../defines.php');
include('../fn.php');
include('../dbq.php');

function _redirect() {
  exit('<script>window.top.location="/simple-checkout/";</script>');
}

if (isset($_GET['provider']) && !empty($_GET['provider'])) {
  $_SESSION['provider'] = tst($_GET['provider']);
  if ($_SESSION['provider'] == 'cc') {
    $_GET['p'] = 'card-detail';
  } else {
    _redirect();
  }
} else if (!isset($_SESSION['provider']) || empty($_SESSION['provider'])) {
  redirectHome();
}

function formatPrice($price) {
  return number_format($price, 2, ',', '.');
}
// echo $_SESSION['provider'];

$db = new Database(DB_HOST, DB_TABLE, DB_USER, DB_PASS);
$p = isset($_GET['p']) ? $_GET['p'] : 'home';
include('pages/' . $p . '.php');