function au_fatal_error($error_code, $error_message)
{
    // These need to be global
    global $aulis;
    // Transfer error information
    $aulis['error_code'] = $error_code;
    $aulis['error_message'] = $error_message;
    // Time to include the error template
    include_once au_get_path_from_root("library/static/error_include/error.php");
    // Stardust
    die;
    // An error is never good news
    return false;
}
function au_load_core($core)
{
    // So did we actually provide ourselves with a core?
    if (empty($core)) {
        return die('Fatal error: core not found.');
    }
    // Let's create a variable to make things a little more readable
    $core_path = au_get_path_from_root('core/' . $core . '.php');
    // We did! Cool. Now, does it exist?
    if (file_exists($core_path)) {
        return include_once $core_path;
    } else {
        return die('Fatal error: core not found.');
    }
}
function au_load_language($language = '')
{
    global $aulis, $setting;
    // So did we actually provide ourselves with a language? If the language is empty... it doesn't work, like at all
    if (empty($language)) {
        return false;
    }
    // Let's create a variable to make things a little more readable
    $language_main_path = au_get_path_from_root('languages/' . $language . '.php');
    // Does this language exist?
    if (!file_exists($language_main_path)) {
        return au_fatal_error(4, "Language files were not found.");
    }
    // It does exists, let's load the main file
    include_once $language_main_path;
    // Now all other files
    foreach ($setting['sub_files'] as $filename) {
        include au_get_path_from_root('languages/' . $language . '.' . $filename . '.php');
    }
    // We might need this
    $setting['lang_current'] = $language;
    return true;
}
function au_load_template($template, $execute_function = true)
{
    // Global setting
    global $setting;
    // Which file paths do we need?
    $filename = au_get_path_from_root("themes/" . $setting['theme'] . "/templates/" . $template . ".php");
    $filename_hannover = au_get_path_from_root("themes/hannover/templates/" . $template . ".php");
    $settings_file_hannover = au_get_path_from_root("themes/hannover/theme_settings.php");
    // If it exists, all is right, return the include
    if (file_exists($filename)) {
        $fallback = !(require_once $filename);
    } elseif (file_exists($filename_hannover)) {
        $fallback = (require_once $filename_hannover);
    } else {
        return au_fatal_error(3, "Template '" . $filename_hannover . "' was not found.");
    }
    // We need to load the hannover settings file, if we have a fallback situation and if it hasn't been loaded already
    if ($fallback and !defined('HANNOVER_SETTINGS')) {
        // We need to load the settings from hannover
        if (file_exists($settings_file_hannover)) {
            require_once $settings_file_hannover;
        } else {
            return au_fatal_error(3, "Settings file '{$settings_hannover}' could not be loaded, it does not exist.");
        }
    }
    // The name of the template's main function
    $function = 'au_template_' . $template;
    // We need to know whether we can exectute the template's main function
    if ($execute_function == true and !function_exists($function)) {
        return au_fatal_error(3, "The template '{$template}' ('" . $filename . "') should have a function called '{$function}();', this function was not found.");
    }
    // We can execute our function, hooray
    if ($execute_function == true) {
        return call_user_func($function);
    }
}
function au_parse_markdown($content, $line = false)
{
    // We need to require the parsedown file, but only once.
    require_once au_get_path_from_root('library/parsedown.require.php');
    require_once au_get_path_from_root('library/parsedown_extra.require.php');
    $parse = new ParsedownExtra();
    if ($line) {
        return $parse->line($content);
    } else {
        return $parse->text($content);
    }
}
Example #6
0
|| Developed by: 	Robert Monden
					Thomas de Roo
|| License: 		MIT
|| Version: 		0.01
|| * File information * 
||		-> index.php -> The empty file
| 		-> // This handles caching, if enabled.
|| 		-> Last change: July, 2015
*/
// The caching feature is yet to come, but this file will start it all.
// There are some apps that can't be cached
$cache_blacklist = array('');
// Get the request hash
$hash = md5('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$cache_folder = au_get_path_from_root('cache/output');
$cache_file = au_get_path_from_root('cache/output/' . $hash . '.cache');
$cache_time = $setting['caching_time'];
// We need to if our cache file exists
if (file_exists($cache_file) and is_writable($cache_folder)) {
    // Our file exists... let's get its creation time
    $cache_file_time = filemtime($cache_file);
    // We need to know if our file is from yesterday, we only accept files from today
    // ... we also need to know if our cache file is valid
    if (!(date('Ymd', $cache_file_time) == date('Ymd', strtotime('yesterday'))) && time() - $cache_file_time < $cache_time) {
        die(file_get_contents($cache_file));
    } else {
        if (unlink($cache_file)) {
            ob_start();
        }
    }
} else {
function au_query($original_sql, $force_no_cache = false, $force_no_count = false)
{
    global $aulis, $setting;
    // We like counting
    if (!$force_no_count) {
        $aulis['db_query_count']++;
    }
    // Make sure we have the right database prefix.
    $search = array("FROM ", "INTO ", "UPDATE ", "JOIN ");
    $replace = array("FROM " . $aulis['db_prefix'], "INTO " . $aulis["db_prefix"], "UPDATE " . $aulis["db_prefix"], "JOIN " . $aulis["db_prefix"]);
    $sql = str_replace($search, $replace, $original_sql);
    // Are we in debug mode? ONLY ALPHA :: NOTE: THIS WILL SEND THE HEADERS AWAY
    if (DEBUG_SHOW_QUERIES) {
        echo "<div class='notice bg1 cwhite'>" . $sql . "</div>";
    }
    // If query caching is disabled, we just need to execute the query
    if ($force_no_cache or @$setting['enable_query_caching'] == 0) {
        return $aulis["db"]->query($sql);
    }
    // If this is not a select query, it will change something, therefore the cache needs to be cleaned
    if (!au_string_starts_with($sql, "SELECT")) {
        au_force_clean_cache();
    }
    // Only select queries can be cached
    if (!au_string_starts_with($sql, "SELECT")) {
        return $aulis["db"]->query($sql);
    }
    // We need the queries hash
    $hash = md5($sql);
    $cache_file = au_get_path_from_root('cache/queries/' . $hash . '.cache');
    $cache_folder = au_get_path_from_root('cache/queries');
    $cache_time = $setting['query_caching_time'];
    // If we are not writable, we have to run the query without cache
    if (!is_writable($cache_folder)) {
        return $aulis["db"]->query($sql);
    }
    // We need to see if there are any queries like these done within the query_cache_time
    if (file_exists($cache_file)) {
        // Our file exists... let's get its creation time
        $cache_file_time = filemtime($cache_file);
        // Is the file still valid?
        if (time() - $cache_file_time < $cache_time and $aulis['db_query_count']--) {
            return unserialize(file_get_contents($cache_file));
        } else {
            if (unlink($cache_file)) {
                return au_query($original_sql, false, true);
            }
        }
    } else {
        // We need to execute the query, cache it and return the cached object
        $execute = $aulis['db']->query($sql);
        // If the rowCount is 0, we can just create an empty cached query
        if ($execute->rowCount() == 0) {
            $cache_query = new au_class_cached_query();
        } else {
            // Fetching the objects in order to cache them
            $objects = array();
            while ($object = $execute->fetchObject()) {
                $objects[] = $object;
            }
            // Create the cached query
            $cache_query = new au_class_cached_query($objects, $execute->rowCount());
        }
        // Cache the whole thing, if we cannot do that, we need to fallback
        if (!file_put_contents($cache_file, serialize($cache_query))) {
            return au_query($original_sql, true);
        }
        return $cache_query;
    }
}
Example #8
0
    $current_app = 'frontpage';
} else {
    $current_app = $_GET['app'];
}
// Do we need to load an extra file?
if ($aulis['apps'][$current_app]['load_file'] == true) {
    require_once $aulis['root_path'] . '/core/' . $aulis['apps'][$current_app]['core'];
}
// So where are we now?
$aulis['active'] = $aulis['apps'][$current_app]['section'];
// We need a page title. Let's create one.
$aulis['page_title'] = (!empty($aulis['apps'][$current_app]['title']) ? $aulis['apps'][$current_app]['title'] . ' | ' : '') . $setting['site_title'] . (!empty($setting['site_slogan']) ? ' | ' . $setting['site_slogan'] : '');
// Let's execute the function, if we need to.
if ($aulis['apps'][$current_app]['execute_function'] == true) {
    // Let's check if the function even exists
    if (function_exists($aulis['apps'][$current_app]['function'])) {
        call_user_func($aulis['apps'][$current_app]['function']);
    } else {
        return au_fatal_error(6, "Core '{$current_app}' wanted to excecute the function '{$aulis['apps'][$current_app]['function']}();'.");
    }
}
// Now it's time to finalize our output and call in the theme's base template
au_finalize_output();
// Calling the theme..., let's hope it responds our call.
au_load_theme($setting['theme']);
// Now if we need to cache, we need to cache, obviously
if ($setting['enable_cache'] == 1 && !DEBUG_FORCE_DISABLE_CACHE) {
    require_once au_get_path_from_root('cache/cache_end.php');
}
// In the end, there is nothing left but star dust.
die;