示例#1
0
function install($adminPassword, $email, $locale)
{
    $Language = new dbLanguage($locale);
    $stdOut = array();
    // ============================================================================
    // Create directories
    // ============================================================================
    // 7=read,write,execute | 5=read,execute
    $dirpermissions = 0755;
    $firstPostSlug = 'first-post';
    if (!mkdir(PATH_POSTS . $firstPostSlug, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_POSTS . $firstPostSlug;
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PAGES . 'error', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PAGES . 'error';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'pages', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES;
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_UPLOADS, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_UPLOADS;
        error_log($errorText, 0);
    }
    // ============================================================================
    // Create files
    // ============================================================================
    $dataHead = "<?php defined('BLUDIT') or die('Bludit CMS.'); ?>" . PHP_EOL;
    // File pages.php
    $data = array('error' => array('description' => 'Error page', 'username' => 'admin', 'tags' => '', 'status' => 'published', 'unixTimeCreated' => 1430686755, 'unixTimeModified' => 0, 'position' => 0));
    file_put_contents(PATH_DATABASES . 'pages.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File posts.php
    $data = array($firstPostSlug => array('description' => 'Welcome to Bludit', 'username' => 'admin', 'status' => 'published', 'tags' => 'welcome, bludit, cms', 'allowComments' => false, 'unixTimeCreated' => 1430875199, 'unixTimeModified' => 0));
    file_put_contents(PATH_DATABASES . 'posts.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File site.php
    $data = array('title' => 'Bludit', 'slogan' => 'cms', 'description' => '', 'footer' => '©2015', 'language' => $locale, 'locale' => $locale, 'timezone' => 'UTC', 'theme' => 'pure', 'adminTheme' => 'default', 'homepage' => '', 'postsperpage' => '6', 'uriPost' => '/post/', 'uriPage' => '/', 'uriTag' => '/tag/', 'advancedOptions' => 'false', 'url' => 'http://' . DOMAIN . HTML_PATH_ROOT);
    file_put_contents(PATH_DATABASES . 'site.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    $salt = getRandomString();
    $passwordHash = sha1($adminPassword . $salt);
    $registered = time();
    // File users.php
    $data = array('admin' => array('firstName' => '', 'lastName' => '', 'twitter' => '', 'role' => 'admin', 'password' => $passwordHash, 'salt' => $salt, 'email' => $email, 'registered' => $registered));
    file_put_contents(PATH_DATABASES . 'users.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/pages/db.php
    $data = array('homeLink' => true, 'label' => $Language->get('Pages'));
    file_put_contents(PATH_PLUGINS_DATABASES . 'pages' . DS . 'db.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File index.txt for error page
    $data = 'Title: ' . $Language->get('Error') . '
	Content: ' . $Language->get('The page has not been found');
    file_put_contents(PATH_PAGES . 'error' . DS . 'index.txt', $data, LOCK_EX);
    // File index.txt for welcome post
    $data = 'Title: ' . $Language->get('First post') . '
Content:

' . $Language->get('Congratulations you have successfully installed your Bludit') . '
---

' . $Language->get('Whats next') . '
---
- ' . $Language->get('Manage your Bludit from the admin panel') . '
- ' . $Language->get('Follow Bludit on') . ' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/pages/Bludit/239255789455913) / [Google+](https://plus.google.com/+Bluditcms)
- ' . $Language->get('Visit the support forum') . '
- ' . $Language->get('Read the documentation for more information') . '
- ' . $Language->get('Share with your friends and enjoy');
    file_put_contents(PATH_POSTS . $firstPostSlug . DS . 'index.txt', $data, LOCK_EX);
    return true;
}
示例#2
0
    $localeFromHTTP = Sanitize::html($_GET['language']);
} else {
    // Try to detect the locale
    if (function_exists('locale_accept_from_http')) {
        $localeFromHTTP = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
    } else {
        $explodeLocale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        $localeFromHTTP = empty($explodeLocale[0]) ? 'en_US' : str_replace('-', '_', $explodeLocale[0]);
    }
}
// Check if the dictionary exists, otherwise the default language is English.
if (!file_exists(PATH_LANGUAGES . $localeFromHTTP . '.json')) {
    $localeFromHTTP = 'en_US';
}
// Get language file
$Language = new dbLanguage($localeFromHTTP);
// Set locale
setlocale(LC_ALL, $localeFromHTTP);
// --- TIMEZONE ---
// Check if timezone is defined in php.ini
$iniDate = ini_get('date.timezone');
if (empty($iniDate)) {
    // Timezone not defined in php.ini, then set UTC as default.
    date_default_timezone_set('UTC');
}
// ============================================================================
// FUNCTIONS
// ============================================================================
// Returns an array with all languages
function getLanguageList()
{
示例#3
0
}
// PHP Classes
include PATH_HELPERS . 'sanitize.class.php';
include PATH_HELPERS . 'valid.class.php';
include PATH_HELPERS . 'text.class.php';
include PATH_ABSTRACT . 'dbjson.class.php';
include PATH_KERNEL . 'dblanguage.class.php';
include PATH_HELPERS . 'log.class.php';
include PATH_HELPERS . 'date.class.php';
// Try to detect language from HTTP
$explode = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$localeFromHTTP = empty($explode[0]) ? 'en_US' : str_replace('-', '_', $explode[0]);
if (isset($_GET['language'])) {
    $localeFromHTTP = Sanitize::html($_GET['language']);
}
$Language = new dbLanguage($localeFromHTTP);
// ============================================================================
// FUNCTIONS
// ============================================================================
function getLanguageList()
{
    $files = glob(PATH_LANGUAGES . '*.json');
    $tmp = array();
    foreach ($files as $file) {
        $t = new dbJSON($file, false);
        $native = $t->db['language-data']['native'];
        $locale = basename($file, '.json');
        $tmp[$locale] = $native;
    }
    return $tmp;
}