Пример #1
0
function get_cache()
{
    //Bind global veriables
    global $cache_path;
    //Try to read cache file
    if (!($json = file_easy_read(correct_path($cache_path) . "dwbn.cache"))) {
        echo "Error. Cannot read cache file";
        exit;
    } else {
        return json_decode($json, true);
    }
}
Пример #2
0
function template_get($template_name, $replacements = array())
{
    if (template_exists($template_name)) {
        //Получаем текст из файла
        $text = file_easy_read($_SERVER['DOCUMENT_ROOT'] . "/templates/{$template_name}.html");
        //Делаем замены, если массив замен не пуст
        if (count($replacements) > 0) {
            //Проходим все замены одна за другой
            foreach ($replacements as $match => $replacement) {
                //Заменяем все вхождения, соответствующие '{$match}' на '$replacement'
                $text = str_replace("{" . $match . "}", $replacement, $text);
            }
        }
        return $text;
    } else {
        echo "Файл шаблона '{$template_name}' не существует.";
    }
}