Exemplo n.º 1
5
<?php

use app\config\Config;
// Initialize the app
require_once '../../app/init.php';
// Include the pusher library
require_once '../../lib/pusher/Pusher.php';
// Gather the pusher key, secret and application ID
$authKey = Config::getValue('pusher', 'auth_key', '');
$secret = Config::getValue('pusher', 'secret', '');
$appId = Config::getValue('pusher', 'app_id', '0');
// Create a pusher instance with the proper key, secret and application ID
$pusher = new Pusher($authKey, $secret, $appId);
// Authenticate the request
echo $pusher->socket_auth($_POST['channel_name'], $_POST['socket_id']);
Exemplo n.º 2
0
 /**
  * Connect to the database, with the credentials provided in the configuration file.
  */
 public static function connect()
 {
     // Retrieve the database data from the configuration
     $host = Config::getValue('database', 'host', 'localhost');
     $port = Config::getValue('database', 'port', 3306);
     $dbname = Config::getValue('database', 'database', '');
     $user = Config::getValue('database', 'username', 'root');
     $password = Config::getValue('database', 'password', '');
     // Connect to the database using PDO, store the instance globally
     try {
         static::$db = new PDO('mysql:host=' . $host . ';port=' . $port . ';dbname=' . $dbname, $user, $password);
     } catch (Exception $e) {
         throw new Exception('An error occurred while connecting to the database!');
     }
 }
Exemplo n.º 3
0
 /**
  * Hash data.
  *
  * @param string $data Data to hash.
  * @param string $algorithm [Optional] The algorithm to use, null to use the default algorithm specified in the config.
  * @param string $salt [Optional] The salt to use, null to use the default salt specified in the config.
  *
  * @return string The hashed data.
  */
 public static function hash($data, $algorithm = null, $salt = null)
 {
     // If the $algo param is not set, get the default value from the config set_file
     if ($algorithm == null) {
         $algorithm = Config::getValue('hash', 'algorithm');
     }
     // If the $salt param was not set, get the default value from the config set_file
     if ($salt == null) {
         $salt = Config::getValue('hash', 'salt');
     }
     // Hash the data
     $context = hash_init($algorithm, HASH_HMAC, $salt);
     hash_update($context, $data);
     // Return the hashed data
     return hash_final($context);
 }
Exemplo n.º 4
0
 /**
  * Get the database table name of the guesses.
  *
  * @return string The database table name.
  */
 public static function getDatabaseTableName()
 {
     return Config::getValue('database', 'table_prefix', '') . static::DB_TABLE_NAME;
 }
Exemplo n.º 5
0
    /**
     * Print the top of the error page
     * @param string $page_title Page title to use
     */
    private static function printPageTop($page_title)
    {
        $site_path = '';
        if (Config::isConfigLoaded()) {
            $site_path = Config::getValue('general', 'site_path', $site_path);
        }
        // TODO: Make sure the correct stylesheet is being used
        ?>
        <html>
        <head>
            <title>Carbon CMS - <?php 
        echo $page_title;
        ?>
</title>
            <style>
                * {
                    margin: 0;
                    padding: 0;
                }

                body {
                    padding: 15px;
                    background: #EEEEEE;
                    color: #000;
                    font-family: Arial, Helvetica, sans-serif;
                    font-size: 14px;
                }

                hr {
                    margin: 8px 0;
                    border: none;
                    border-top: 1px solid #ccc;
                }

                h1 {
                    margin: 16px -8px 8px -8px;
                    padding: 6px 6px 5px 8px;
                    background: #EEE;
                    font-family: Arial, Helvetica, sans-serif;
                    font-size: 16px;
                    font-weight: normal;
                    border-top: 1px solid #ccc;
                    border-bottom: 1px solid #ccc;
                }

                h1:first-child {
                    margin: -8px -8px 8px -8px;
                    padding: 6px 6px 5px 8px;
                    border-top: none;
                    -moz-border-radius-topleft: 5px;
                    -webkit-border-top-left-radius: 5px;
                    border-top-left-radius: 5px;
                    -moz-border-radius-topright: 5px;
                    -webkit-border-top-right-radius: 5px;
                    border-top-right-radius: 5px;
                }

                h2 {
                    margin-bottom: 3px;
                    padding-bottom: 3px;
                    color: #666;
                    font-family: Arial, Helvetica, sans-serif;
                    font-size: 16px;
                    border-bottom: 1px dotted #666;
                }

                #page-wrap {
                    width: 100%;
                    background: none;
                }

                #page-wrap #page {
                    margin-bottom: 15px;
                    padding: 8px;
                    background: #fff;
                    border: 1px solid #ccc;
                    -moz-border-radius: 5px;
                    -webkit-border-radius: 5px;
                    border-radius: 5px;
                }

                #page-wrap #page ul li {
                    margin-left: 20px;
                }

                #page-wrap #page td:first-child {
                    color: #666;
                    padding-right: 10px;
                }

                #page-wrap #page table tr td  {
                    font-size: 14px;
                }

                #page-wrap #page #trace div.step {
                    width: auto;
                    margin-bottom: 20px;
                }

                #page-wrap #page #trace div.step:last-child {
                    margin-bottom: 0;
                }

                #page-wrap #page #trace div.step table tr td  {
                    width: 100%;
                }

                #page-wrap #page #trace div.step table tr td:first-child  {
                    width: 80px;
                    padding-right: 10px;
                    vertical-align: top;
                }

                #page-wrap #page .function {
                    white-space: pre-wrap;
                    white-space: -moz-pre-wrap;
                    white-space: -o-pre-wrap;
                    word-wrap: break-word;
                }

                #page-wrap #page .file {
                    margin-bottom: 6px;
                    color: #666;
                    white-space: pre-wrap;
                    white-space: -moz-pre-wrap;
                    white-space: -o-pre-wrap;
                    word-wrap: break-word;
                }

                #page-wrap #page #trace div.step p.file span.line {
                    color: #000;
                    font-style: normal;
                }

                #page-wrap #page #code {
                    width: auto;
                    max-height: 300px;
                    padding: 0;
                    background: #fff;
                    font-size: 12px;
                    border: 1px solid #ccc;
                    -moz-border-radius: 5px;
                    -webkit-border-radius: 5px;
                    border-radius: 5px;
                    overflow: auto;
                    min-width: 100px;
                }

                #page-wrap #page #code .lines {
                    min-width: 18px;
                    margin-right: 8px;
                    padding: 6px 8px 6px 6px;
                    float: left;
                    background: #eee;
                    text-align: right;
                    border-right: 1px solid #ccc;
                    -moz-border-radius-topleft: 5px;
                    -webkit-border-top-left-radius: 5px;
                    border-top-left-radius: 5px;
                    -moz-border-radius-bottom-left: 5px;
                    -webkit-border-bottom-left-radius: 5px;
                    border-bottom-left-radius: 5px;
                }

                #page-wrap #page #code .code {
                    padding: 6px 0 6px 6px;
                    white-space: nowrap;
                }

                #footer-wrap {
                    width: auto;
                    height: 15px;
                    margin: 10px 0;
                    padding: 0;
                    color: #bbb;
                    font-size: 12px;
                    text-shadow: 0 1px 0 #FFF;
                }

                #footer-wrap a{
                    color: #bbb;
                    text-decoration: none;
                }

                #footer-wrap a:hover{
                    color: #bbb;
                    text-decoration: underline;
                }

                #footer-wrap div.footer-left {
                    float: left;
                }

                #footer-wrap div.footer-right {
                    float: right;
                }            </style>
        </head>
        <body>
            <div id="page-wrap">
        <?php 
    }
Exemplo n.º 6
0
use carbon\core\autoloader\Autoloader;
Autoloader::addLoader(new AppLoader());
// Load the configuration
use app\config\Config;
Config::load();
// Set up the error handler
use carbon\core\ErrorHandler;
ErrorHandler::init(true, true, Config::getValue('app', 'debug'));
// Connect to the database
use app\database\Database;
Database::connect();
// Set up the cookie manager
use carbon\core\cookie\CookieManager;
CookieManager::setCookieDomain(Config::getValue('cookie', 'domain', ''));
CookieManager::setCookiePath(Config::getValue('cookie', 'path', '/'));
CookieManager::setCookiePrefix(Config::getValue('cookie', 'prefix', ''));
// Set up the language manager
use app\language\LanguageManager;
LanguageManager::init(true, Registry::getValue('language.default.tag')->getValue());
$languageTag = LanguageManager::getCookieLanguageTag();
if ($languageTag !== null) {
    LanguageManager::setCurrentLanguageTag($languageTag);
}
// Setup a simplified language function
/**
 * Get a language value for the current preferred language.
 *
 * @param string $section Value section.
 * @param string $key Value key.
 * @param string|null $default The default value, or null.
 *
 /**
  * Get the language files directory.
  *
  * @return Directory The directory.
  */
 public static function getLanguageDirectory()
 {
     return new Directory(CARBON_SITE_ROOT, Config::getValue('app', 'language.directory', '/language'));
 }
Exemplo n.º 8
0
<?php

use app\config\Config;
use app\template\PageFooterBuilder;
use app\template\PageHeaderBuilder;
// Initialize the app
require_once 'app/init.php';
// Set the site's path
$site_root = Config::getValue('general', 'site_url', '');
?>
<!DOCTYPE>
<html>
<head>

    <!-- Title -->
    <title>Hoe zwaar is de taart? &middot; Mohicanen NJO 2016</title>

    <!-- Meta -->
    <meta charset="UTF-8">
    <meta name="description" content="<?php 
echo APP_NAME;
?>
 by Tim Vis&eacute;e">
    <meta name="keywords" content="<?php 
echo APP_NAME;
?>
,Pie,Guesser">
    <meta name="author" content="Tim Vis&eacute;e">
    <link rel="copyright" href="about.php">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="theme-color" content="#0067B2">