PHP Classes

File: includes/startup.php

Recommend this page to a friend!
  Classes of Mark Richards   CliqonV4   includes/startup.php   Download  
File: includes/startup.php
Role: Example script
Content type: text/plain
Description: Example script
Class: CliqonV4
Framework with modules to build Web applications
Author: By
Last change: Cookie problem
Added support for Blog

Added support for Blog and other changes
Release 4.0.2

Production Release including changes to Install
Merge branch 'master' of https://github.com/webcliq/CliqonV4
Date: 6 years ago
Size: 2,061 bytes
 

Contents

Class file image Download
<?php
// If PHP7, you may declare
// declare(strict_types = 1);

// Load Debug
if (!file_exists($basedir.'log')) {
   
mkdir($basedir.'log', 0777, true);
};
require_once
$basedir.'framework/logging/tracy.php';
T::enable(T::DEVELOPMENT, $basedir."log/"); // PRODUCTION or DEVELOPMENT
T::$logSeverity = E_NOTICE | E_WARNING;

// Miscellaneous functions
// Also includes subdirectories on which autoload should function
require_once $basedir.'includes/functions.php';

// Framework
loadFile('framework/Registry.php');
$clq = Registry::singleton();

$clq->resolve('Cookie');

// Set System variables here
$clq->set('protocol', $protocol); // http:// or https://
$clq->set('rootpath', $rootpath); // protocol + domain.com/
$clq->set('basedir', $basedir); // d:\wwwroot\sitedir\ or /var/www/sitedir/
$clq->set('rootdir', "/");

// Get Site Config(s)
$config = $clq->resolve('Config');
$cfg = $config->cfgReadFile('config/config.cfg');
$clq->set('cfg', $cfg); global $clq;
date_default_timezone_set($cfg['site']['timezone']);

// Database - Redbean R::static or PDO - ODBC with DSN
loadFile('includes/database.php');

// Main Framework handlers

$clq->resolve('Framework');
$clq->resolve('Cliq');
$clq->resolve('Html');
$clq->resolve('Form');
$clq->resolve('Log');

// Setup Session with Security
$clq->resolve('Session');
session_start();
if(isset(
$_SESSION['HTTP_USER_AGENT'])) {
    if(
$_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) {
       
session_regenerate_id();
       
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
    }
} else {
   
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
}

$clq->resolve('Image');
$clq->resolve('Website');

// API Auth handling
$clq->resolve('Auth');

// Routing and Controllers
$routes = $config->cfgReadFile('config/routes.cfg', false);
$clq->resolve('Router');

// L::cLog('Startup Completed - Now Routing');
// Fired for 404 errors; must be defined before Router::serve() call
RouterHook::add("404", function() {
    echo
"Page not found";
});

Router::serve($routes);
// Startup completed