/** * Constructor * * @throws Exception if `default` group connection fails * @return void */ public function __construct() { if (static::$init == FALSE) { // Register exception and error handler set_exception_handler(function ($e) { Gas::exception($e); }); // Access current instance singleton $CI =& get_instance(); // Load necessary configuration(s) $CI->config->load('gas', TRUE, TRUE); $CI->config->load('migration', TRUE, TRUE); // Set temporary config handler $config = array_merge($CI->config->item('gas'), array('migration' => $CI->config->item('migration'))); // Validate DB instance if (!class_exists('CI_DB')) { $DB = $CI->load->database('default', TRUE); // Register into CI super object, so we could monitore it $CI->db = $DB; } else { $DB = $CI->db; } if ($config['auto_create_models'] == TRUE or $config['auto_create_tables'] == TRUE) { // Load necessary helper and library $CI->load->helper('file'); $CI->load->library('migration'); } // Include the bootstrap include_once APPPATH . 'third_party' . DIRECTORY_SEPARATOR . 'gas' . DIRECTORY_SEPARATOR . 'bootstrap.php'; if (array_key_exists('auto', Gas\Core::$migration)) { // Execute migration if necessary if (!$CI->migration->latest()) { show_error($CI->migration->error_string()); } } // Set initialization flag static::$init = TRUE; } }
<?php require 'includes/simple_html_dom.php'; require 'classes/connect.php'; require 'classes/gas.php'; // Establish a database connection. $database = new Database(); $db = $database->connect(); // Crawl the most recent prices from the web and update our own database with these prices. $gas = new Gas(); $prices = $gas->crawlPrices(); $gas->pushPrices($db, $prices);
launchError('We konden uw kentekengegevens niet vinden.'); } } } else { launchError('We konden niet alle benodigde gegevens vinden.'); } // Returns the user the index page with an error. function launchError($error) { header('Location: index.php?error=' . $error . ' Heeft u onderstaand formulier correct ingevuld?'); } // Establish a database connection. $database = new Database(); $db = $database->connect(); // Fetch the prices from the databases. $gas = new Gas(); $gasPrices = $gas->fetchPrices($db); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php print 'Trein of Auto: Van ' . $from . ' naar ' . $to; ?> </title> <link rel="stylesheet" type="text/css" href="css/libs/semantic.min.css">