C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\App\Libs\Customer\Customer.php
}
private function initSessionIfNecessary() {
if (\session_status() === \PHP_SESSION_NONE) {
// use cookies to store session IDs
\ini_set('session.use_cookies', 1);
// use cookies only (do not send session IDs in URLs)
\ini_set('session.use_only_cookies', 1);
// do not send session IDs in URLs
\ini_set('session.use_trans_sid', 0);
Session::get();
// start the session (requests a cookie to be written on the client)
Helper::rewriteCookieHeader();
}
}
/** Improves the application's security over HTTP(S) by setting specific headers */
private function enhanceHttpSecurity()
{
// remove exposure of PHP version (at least where possible)
\header_remove('X-Powered-By');
// if the user is signed in
if ($this->isLoggedIn()) {
// prevent clickjacking
\header('X-Frame-Options: sameorigin');
// prevent content sniffing (MIME sniffing)
\header('X-Content-Type-Options: nosniff');
// disable caching of potentially sensitive data
\header('Cache-Control: no-store, no-cache, must-revalidate', true);
\header('Expires: Thu, 19 Nov 1981 00:00:00 GMT', true);
\header('Pragma: no-cache', true);
}
}
/** Checks if there is a "remember me" directive set and handles the automatic login (if appropriate) */
private function processRememberDirective()
{
// if the user is not signed in yet
if (!$this->isLoggedIn()) {
// if there is currently no cookie for the 'remember me' feature
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\App\Libs\Customer\Customer.php
}
private function initSessionIfNecessary() {
if (\session_status() === \PHP_SESSION_NONE) {
// use cookies to store session IDs
\ini_set('session.use_cookies', 1);
// use cookies only (do not send session IDs in URLs)
\ini_set('session.use_only_cookies', 1);
// do not send session IDs in URLs
\ini_set('session.use_trans_sid', 0);
Session::get();
// start the session (requests a cookie to be written on the client)
Helper::rewriteCookieHeader();
}
}
/** Improves the application's security over HTTP(S) by setting specific headers */
private function enhanceHttpSecurity()
{
// remove exposure of PHP version (at least where possible)
\header_remove('X-Powered-By');
// if the user is signed in
if ($this->isLoggedIn()) {
// prevent clickjacking
\header('X-Frame-Options: sameorigin');
// prevent content sniffing (MIME sniffing)
\header('X-Content-Type-Options: nosniff');
// disable caching of potentially sensitive data
\header('Cache-Control: no-store, no-cache, must-revalidate', true);
\header('Expires: Thu, 19 Nov 1981 00:00:00 GMT', true);
\header('Pragma: no-cache', true);
}
}
/** Checks if there is a "remember me" directive set and handles the automatic login (if appropriate) */
private function processRememberDirective()
{
// if the user is not signed in yet
if (!$this->isLoggedIn()) {
// if there is currently no cookie for the 'remember me' feature
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\App\Libs\Customer\Customer.php
/** @var int the interval in seconds after which to resynchronize the session data with its authoritative source in the database */
private $sessionResyncInterval;
/** @var string the name of the cookie used for the 'remember me' feature */
private $rememberCookieName;
/**
* @param PdoDatabase|PdoDsn|\PDO $databaseConnection the database connection to operate on
* @param string $ipAddress the IP address that should be used instead of the default setting (if any), e.g. when behind a proxy
* @param string|null $dbTablePrefix (optional) the prefix for the names of all database tables used by this component
* @param bool|null $throttling (optional) whether throttling should be enabled (e.g. in production) or disabled (e.g. during development)
* @param int|null $sessionResyncInterval (optional) the interval in seconds after which to resynchronize the session data with its authoritative source in the database
*/
public function __construct($databaseConnection = null, $ipAddress = null, $dbTablePrefix = null, $throttling = null, $sessionResyncInterval = null)
{
$this->ipAddress = !empty($ipAddress) ? $ipAddress : (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null);
$this->throttling = isset($throttling) ? (bool) $throttling : true;
$this->sessionResyncInterval = isset($sessionResyncInterval) ? ((int) $sessionResyncInterval) : (60 * 5);
$this->rememberCookieName = self::createRememberCookieName();
$this->initSessionIfNecessary();
$this->enhanceHttpSecurity();
$this->processRememberDirective();
$this->resyncSessionIfNecessary();
}
private function initSessionIfNecessary() {
if (\session_status() === \PHP_SESSION_NONE) {
// use cookies to store session IDs
\ini_set('session.use_cookies', 1);
// use cookies only (do not send session IDs in URLs)
\ini_set('session.use_only_cookies', 1);
// do not send session IDs in URLs
\ini_set('session.use_trans_sid', 0);
Session::get();
// start the session (requests a cookie to be written on the client)
Helper::rewriteCookieHeader();
}
}
/** Improves the application's security over HTTP(S) by setting specific headers */
private function enhanceHttpSecurity()
{
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\System\Facades\Facade.php
}
/**
* Call Methods in Application Object
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
// Get Facade Accessor
$accessor = static::getFacadeAccessor();
// Get Service Provider
$provider = static::resolveInstance($accessor);
// Get Instance of Service Provider If it doesn't exist
if (!array_key_exists($accessor, static::$createdInstances)) {
static::$createdInstances[$accessor] = new $provider;
}
return call_user_func_array([static::$createdInstances[$accessor], $method], $args);
}
}
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\App\Controllers\Shop\BaseController.php
// parent::__construct();
Import::helper('General');
Import::helper('Category');
View::theme('shop');
$this->data["main_lang"] = Model::namespace("Shop")->run("language")->getMainLang();
if (!Session::has('lang')) {
Session::set('lang',$this->data["main_lang"]->id);
$this->data["active_lang"] = $this->data["main_lang"];
}else {
$this->data["active_lang"] = Model::namespace("Shop")->run("language")->getLanguage(Session::get('lang'));
Session::set('lang',$this->data["active_lang"]->id);
}
Settings::set('config_language_id',Session::get('lang'));
if (!Session::has('currency') && !Session::has('currency_id')) {
$currency = Model::namespace("Shop")->run("Currency")->getCurrency(Settings::get('config_currency'));
Session::set('currency',$currency->code);
Session::set('currency_id',$currency->currency_id);
}
$this->language = Session::get('lang');
if (Customer::isLoggedIn()) {
$this->data["customer"] =$this->customer = Model::namespace("Shop")->run("Account")->getAccount(Customer::getUserId());
}else{
$customer = ['firstname' => lang('general','visitor')];
$this->data["customer"] = json_decode(json_encode($customer));
}
if (Session::has('shipping_address')) {
Tax::setShippingAddress(Session::get('shipping_address')->country_id, Session::get('shipping_address')->zone_id);
}
if (Settings::get('config_tax_default') == 'shipping') {
Tax::setShippingAddress(Settings::get('config_country_id'), Settings::get('config_zone_id'));
}
if (Session::has('payment_address')) {
Tax::setPaymentAddress(Session::get('payment_address')->country_id, Session::get('payment_address')->zone_id);
}elseif (Settings::get('config_tax_default') == 'payment') {
Tax::setPaymentAddress(Settings::get('config_country_id'), Settings::get('config_zone_id'));
}
Tax::setStoreAddress(Settings::get('config_country_id'),Settings::get('config_zone_id'));
$this->data["meta_title"] = Settings::get('config_meta_title');
$this->data["meta_description"] = Settings::get('config_meta_description');
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\System\Libs\Router\Router.php
$params = array_merge($params, $val["params"]);
}
// Checking middlewares
if (array_key_exists('middlewares', $val)) {
foreach ($val['middlewares'] as $midKey => $midVal) {
list($controller, $method) = explode('@', $midVal['callback']);
if (class_exists($controller)) {
call_user_func_array([new $controller, $method], []);
}
}
}
if (is_callable($val['callback'])) {
call_user_func_array($val['callback'], array_values($params));
} elseif (stripos($val['callback'], '@') !== false) {
list($controller, $method) = explode('@', $val['callback']);
if (class_exists($controller)) {
call_user_func_array([new $controller, $method], array_values($params));
} else {
self::pageNotFound();
}
}
break;
}
}
}
if ($matched === 0) {
self::pageNotFound();
}
}
/**
* Check Domain
*
* @param array $params
* @return bool
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\System\Kernel\Kernel.php
use System\Facades\Facade;
use Whoops\Run as WhoopsRun;
use Whoops\Handler\PrettyPageHandler as WhoopsPrettyPageHandler;
class Kernel
{
public function __construct()
{
// Initialize Whoops Error Handler
$this->initWhoops();
// Initialize Config
$this->initApplications();
// Getting Routes
Import::config('routes');
// Starting Router
Router::run();
}
/**
* Whoops Initializer
*
* @return object
*/
private function initWhoops()
{
$whoops = new WhoopsRun;
$whoops->pushHandler(new WhoopsPrettyPageHandler);
$whoops->register();
return $this;
}
/**
* Application Initializer
*
* @return void
C:\inetpub\vhosts\ecom.teknolobi.com\httpdocs\index.php
* Titan-2 Mini Framework
* Simple and Modern Web Application Framework
*
* Author : Turan Karatuğ
* Web : http://www.titanphp.com
* Docs : http://kilavuz.titanphp.com
* Version : 2.2.0
* Github : http://github.com/tkaratug/titan2
* License : MIT
*
*************************************************/
// Require Composer Autoload
require_once __DIR__ . '/vendor/autoload.php';
// Require Starter
require_once __DIR__ . '/System/Kernel/Starter.php';
// Run Kernel
new System\Kernel\Kernel();