I am a bit worried about this small PHP base as it has been running a bit slow. Can anyone notice anything majorly wrong with it?
root/Index.php:
define('START', microtime(true));
define('RAM', memory_get_usage(true));
define('ROOT', dirname(__FILE__) . '/');
define("SECURE", true);
ini_set('date.timezone', 'Europe/London');
session_start();
include_once ROOT . '/application/global.php';
Application/global.php:
<?php
require_once 'environment.php';
Application/environment.php
<?php
require_once 'autoloader.php';
require_once 'include/config.php';
if (!isset($config))
exit('Unable to load configuration data.');
function rutime($ru, $rus, $index) {
return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
- ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
}
try {
$dns = "mysql:host=".$config['database']['host'].";dbname=".$config['database']['name']."";
$pdo = new PDO($dns, $config['database']['username'], $config['database']['password']);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch (PDOException $ex) {
exit('Unable to connect to the master database! ' . $ex);
}
$c = new Core($config, $_GET['page'], new User($pdo), new Form(), $pdo, new template());
// Google Analytics
/*echo "<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-73890636-1', 'auto');
ga('send', 'pageview');
</script>";*/
?>