Esempio n. 1
0
 public function verifyUserByToken($username, $token)
 {
     $username = Sanitize::html($username);
     $token = Sanitize::html($token);
     $username = trim($username);
     $token = trim($token);
     if (empty($username) || empty($token)) {
         Log::set(__METHOD__ . LOG_SEP . 'Username or Token-email empty. Username: '******' - Token-email: ' . $token);
         return false;
     }
     $user = $this->dbUsers->getDb($username);
     if ($user == false) {
         Log::set(__METHOD__ . LOG_SEP . 'Username does not exist: ' . $username);
         return false;
     }
     $currentTime = Date::current(DB_DATE_FORMAT);
     if ($user['tokenEmailTTL'] < $currentTime) {
         Log::set(__METHOD__ . LOG_SEP . 'Token-email expired: ' . $username);
         return false;
     }
     if ($token === $user['tokenEmail']) {
         // Set the user loggued.
         $this->setLogin($username, $user['role']);
         // Invalidate the current token.
         $this->dbUsers->generateTokenEmail($username);
         Log::set(__METHOD__ . LOG_SEP . 'User logged succeeded by Token-email - Username: '******'Token-email incorrect.');
     }
     return false;
 }
Esempio n. 2
0
 public function reindexPosts($db)
 {
     $tagsIndex = array();
     $currentDate = Date::current(DB_DATE_FORMAT);
     // Foreach post
     foreach ($db as $postKey => $values) {
         $tags = $values['tags'];
         // Foreach tag from post
         foreach ($tags as $tagKey => $tagName) {
             if (isset($tagsIndex[$tagKey])) {
                 array_push($tagsIndex[$tagKey]['posts'], $postKey);
             } else {
                 $tagsIndex[$tagKey]['name'] = $tagName;
                 $tagsIndex[$tagKey]['posts'] = array($postKey);
             }
         }
     }
     $this->db['postsIndex'] = $tagsIndex;
     if ($this->save() === false) {
         Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to save the database file.');
         return false;
     }
     return true;
 }
Esempio n. 3
0
echo '<li>';
// --- BLUDIT COVER IMAGE ---
echo '<hr>';
HTML::bluditCoverImage();
echo '<hr>';
// --- BLUDIT QUICK IMAGES ---
HTML::bluditQuickImages();
// --- BLUDIT IMAGES V8 ---
HTML::bluditImagesV8();
echo '</li>';
// ---- ADVANCED TAB ----
echo '<li>';
// Status input
HTML::formSelect(array('name' => 'status', 'label' => $L->g('Status'), 'class' => 'uk-width-1-1 uk-form-medium', 'options' => array('published' => $L->g('Published'), 'draft' => $L->g('Draft')), 'selected' => 'published', 'tip' => ''));
// Date input
HTML::formInputText(array('name' => 'date', 'value' => Date::current(DB_DATE_FORMAT), 'class' => 'uk-width-1-1 uk-form-large', 'tip' => $L->g('To schedule the post just select the date and time'), 'label' => $L->g('Date')));
// Slug input
HTML::formInputText(array('name' => 'slug', 'value' => '', 'class' => 'uk-width-1-1 uk-form-large', 'tip' => $L->g('you-can-modify-the-url-which-identifies'), 'label' => $L->g('Friendly URL')));
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
HTML::formClose();
?>

<script>

$(document).ready(function() {

	$("#jsdate").datetimepicker({format:"<?php 
echo DB_DATE_FORMAT;
Esempio n. 4
0
 public function regenerateCli()
 {
     $db = $this->db;
     $newPaths = array();
     $fields = array();
     // Default fields and value
     foreach ($this->dbFields as $field => $options) {
         if (!$options['inFile']) {
             $fields[$field] = $options['value'];
         }
     }
     //$tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR);
     $tmpPaths = Filesystem::listDirectories(PATH_PAGES);
     foreach ($tmpPaths as $directory) {
         $key = basename($directory);
         if (file_exists($directory . DS . 'index.txt')) {
             // The key is the directory name
             $newPaths[$key] = true;
         }
         // Recovery pages from subdirectories
         //$subPaths = glob($directory.DS.'*', GLOB_ONLYDIR);
         $subPaths = Filesystem::listDirectories($directory . DS);
         foreach ($subPaths as $subDirectory) {
             $subKey = basename($subDirectory);
             if (file_exists($subDirectory . DS . 'index.txt')) {
                 // The key is composed by the directory/subdirectory
                 $newPaths[$key . '/' . $subKey] = true;
             }
         }
     }
     foreach ($newPaths as $key => $value) {
         if (!isset($this->db[$key])) {
             // Default values for the new pages.
             $fields['status'] = CLI_STATUS;
             $fields['date'] = Date::current(DB_DATE_FORMAT);
             $fields['username'] = '******';
             // Create the entry for the new page.
             $this->db[$key] = $fields;
         }
         $Page = new Page($key);
         // Update all fields from FILE to DATABASE.
         foreach ($fields as $f => $v) {
             // If the field exists on the FILE, update it.
             if ($Page->getField($f)) {
                 $valueFromFile = $Page->getField($f);
                 if ($f == 'tags') {
                     // Generate tags array.
                     $this->db[$key]['tags'] = $this->generateTags($valueFromFile);
                 } elseif ($f == 'date') {
                     // Validate Date from file
                     if (Valid::date($valueFromFile, DB_DATE_FORMAT)) {
                         $this->db[$key]['date'] = $valueFromFile;
                     }
                 } else {
                     // Sanitize the values from file.
                     $this->db[$key][$f] = Sanitize::html($valueFromFile);
                 }
             }
         }
     }
     // Remove old pages from db
     foreach (array_diff_key($db, $newPaths) as $key => $data) {
         unset($this->db[$key]);
     }
     // Save the database.
     if ($this->save() === false) {
         Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to save the database file.');
         return false;
     }
     return $this->db != $db;
 }
Esempio n. 5
0
 public function regenerateCli()
 {
     $db = $this->db;
     $allPosts = array();
     $fields = array();
     $currentDate = Date::current(DB_DATE_FORMAT);
     // Generate default fields and values.
     foreach ($this->dbFields as $field => $options) {
         if (!$options['inFile']) {
             $fields[$field] = $options['value'];
         }
     }
     $fields['status'] = CLI_STATUS;
     $fields['date'] = $currentDate;
     $fields['username'] = '******';
     // Recovery posts from the first level of directories
     $tmpPaths = Filesystem::listDirectories(PATH_POSTS);
     foreach ($tmpPaths as $directory) {
         if (file_exists($directory . DS . 'index.txt')) {
             // The key is the directory name.
             $key = basename($directory);
             // All keys posts
             $allPosts[$key] = true;
             // Create the new entry if not exists on DATABASE.
             if (!isset($this->db[$key])) {
                 // New entry on database
                 $this->db[$key] = $fields;
             }
             // Create the post from FILE.
             $Post = new Post($key);
             // Update all fields from FILE to DATABASE.
             foreach ($fields as $f => $v) {
                 // If the field exists on the FILE, update it.
                 if ($Post->getField($f)) {
                     $valueFromFile = $Post->getField($f);
                     if ($f == 'tags') {
                         // Generate tags array.
                         $this->db[$key]['tags'] = $this->generateTags($valueFromFile);
                     } elseif ($f == 'date') {
                         // Validate Date from file
                         if (Valid::date($valueFromFile, DB_DATE_FORMAT)) {
                             $this->db[$key]['date'] = $valueFromFile;
                             if ($valueFromFile > $currentDate) {
                                 $this->db[$key]['status'] = 'scheduled';
                             }
                         }
                     } else {
                         // Sanitize the values from file.
                         $this->db[$key][$f] = Sanitize::html($valueFromFile);
                     }
                 }
             }
         }
     }
     // Remove orphan posts from db, the orphan posts are posts deleted by hand (directory deleted).
     foreach (array_diff_key($db, $allPosts) as $key => $data) {
         unset($this->db[$key]);
     }
     // Sort posts before save.
     $this->sortByDate();
     // Save the database.
     if ($this->save() === false) {
         Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to save the database file.');
         return false;
     }
     return $this->db != $db;
 }
Esempio n. 6
0
function install($adminPassword, $email, $timezone)
{
    global $Language;
    $stdOut = array();
    if (!date_default_timezone_set($timezone)) {
        date_default_timezone_set('UTC');
    }
    $currentDate = Date::current(DB_DATE_FORMAT);
    // ============================================================================
    // 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_PAGES . 'about', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PAGES . 'about';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'pages', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'pages';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'simplemde', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'simplemde';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'tags', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'tags';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'about', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'about';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_UPLOADS_PROFILES, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_UPLOADS_PROFILES;
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_TMP, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_TMP;
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_UPLOADS_THUMBNAILS, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_UPLOADS_THUMBNAILS;
        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' => array(), 'status' => 'published', 'date' => $currentDate, 'position' => 0), 'about' => array('description' => $Language->get('About your site or yourself'), 'username' => 'admin', 'tags' => array(), 'status' => 'published', 'date' => $currentDate, 'position' => 1));
    file_put_contents(PATH_DATABASES . 'pages.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File posts.php
    $data = array($firstPostSlug => array('description' => $Language->get('Welcome to Bludit'), 'username' => 'admin', 'status' => 'published', 'tags' => array('bludit' => 'Bludit', 'cms' => 'CMS', 'flat-files' => 'Flat files'), 'allowComments' => 'false', 'date' => $currentDate));
    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' => 'Copyright © ' . Date::current('Y'), 'language' => $Language->getCurrentLocale(), 'locale' => $Language->getCurrentLocale(), 'timezone' => $timezone, 'theme' => 'log', 'adminTheme' => 'default', 'homepage' => '', 'postsperpage' => '6', 'uriPost' => '/post/', 'uriPage' => '/', 'uriTag' => '/tag/', 'url' => PROTOCOL . DOMAIN . HTML_PATH_ROOT, 'emailFrom' => 'no-reply@' . DOMAIN);
    file_put_contents(PATH_DATABASES . 'site.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File users.php
    $salt = getRandomString();
    $passwordHash = sha1($adminPassword . $salt);
    $data = array('admin' => array('firstName' => $Language->get('Administrator'), 'lastName' => '', 'twitter' => '', 'role' => 'admin', 'password' => $passwordHash, 'salt' => $salt, 'email' => $email, 'registered' => $currentDate));
    file_put_contents(PATH_DATABASES . 'users.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File security.php
    $randomKey = getRandomString();
    $randomKey = sha1($randomKey);
    $data = array('key1' => $randomKey, 'minutesBlocked' => 5, 'numberFailuresAllowed' => 10, 'blackList' => array());
    file_put_contents(PATH_DATABASES . 'security.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File tags.php
    file_put_contents(PATH_DATABASES . 'tags.php', $dataHead . json_encode(array('postsIndex' => array('bludit' => array('name' => 'Bludit', 'posts' => array('first-post')), 'cms' => array('name' => 'CMS', 'posts' => array('first-post')), 'flat-files' => array('name' => 'Flat files', 'posts' => array('first-post'))), 'pagesIndex' => array()), JSON_PRETTY_PRINT), LOCK_EX);
    // PLUGINS
    // File plugins/pages/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'pages' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'homeLink' => true, 'label' => $Language->get('Pages')), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/about/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'about' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'label' => $Language->get('About'), 'text' => $Language->get('this-is-a-brief-description-of-yourself-our-your-site')), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/simplemde/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'simplemde' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'tabSize' => 4, 'toolbar' => '&quot;bold&quot;, &quot;italic&quot;, &quot;heading&quot;, &quot;|&quot;, &quot;quote&quot;, &quot;unordered-list&quot;, &quot;|&quot;, &quot;link&quot;, &quot;image&quot;, &quot;code&quot;, &quot;horizontal-rule&quot;, &quot;|&quot;, &quot;preview&quot;, &quot;side-by-side&quot;, &quot;fullscreen&quot;, &quot;guide&quot;'), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/tags/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'tags' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'label' => $Language->get('Tags')), JSON_PRETTY_PRINT), LOCK_EX);
    // File FILENAME for error page
    $data = 'Title: ' . $Language->get('Error') . '
Content: ' . $Language->get('The page has not been found');
    file_put_contents(PATH_PAGES . 'error' . DS . FILENAME, $data, LOCK_EX);
    // File FILENAME for about page
    $data = 'Title: ' . $Language->get('About') . '
Content:
' . $Language->get('the-about-page-is-very-important') . '

' . $Language->get('change-this-pages-content-on-the-admin-panel');
    file_put_contents(PATH_PAGES . 'about' . DS . FILENAME, $data, LOCK_EX);
    // File FILENAME for welcome post
    $text1 = Text::replaceAssoc(array('{{ADMIN_AREA_LINK}}' => PROTOCOL . DOMAIN . HTML_PATH_ROOT . 'admin'), $Language->get('Manage your Bludit from the admin panel'));
    $data = 'Title: ' . $Language->get('First post') . '
Content:

## ' . $Language->get('Whats next') . '
- ' . $text1 . '
- ' . $Language->get('Follow Bludit on') . ' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/bluditcms) / [Google+](https://plus.google.com/+Bluditcms)
- ' . $Language->get('Chat with developers and users on Gitter') . '
- ' . $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 . FILENAME, $data, LOCK_EX);
    return true;
}
Esempio n. 7
0
 public function add($args)
 {
     $dataForDb = array();
     // Verify arguments with the database fields.
     foreach ($this->dbFields as $field => $options) {
         // If the user send the field.
         if (isset($args[$field])) {
             // Sanitize if will be saved on database.
             if (!$options['inFile']) {
                 $tmpValue = Sanitize::html($args[$field]);
             } else {
                 $tmpValue = $args[$field];
             }
         } else {
             $tmpValue = $options['value'];
         }
         // Set type
         settype($tmpValue, gettype($options['value']));
         // Save on database
         $dataForDb[$field] = $tmpValue;
     }
     // Check if the user alredy exists.
     if ($this->userExists($dataForDb['username'])) {
         return false;
     }
     // Current date.
     $dataForDb['registered'] = Date::current(DB_DATE_FORMAT);
     // Password
     $dataForDb['salt'] = Text::randomText(SALT_LENGTH);
     $dataForDb['password'] = sha1($dataForDb['password'] . $dataForDb['salt']);
     // Save the database
     $this->db[$dataForDb['username']] = $dataForDb;
     if ($this->save() === false) {
         Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to save the database file.');
         return false;
     }
     return true;
 }
Esempio n. 8
0
function install($adminPassword, $email, $timezoneOffset)
{
    global $Language;
    $stdOut = array();
    $timezone = timezone_name_from_abbr("", $timezoneOffset, 0);
    date_default_timezone_set($timezone);
    $currentDate = Date::current(DB_DATE_FORMAT);
    // ============================================================================
    // 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 . 'pages';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'simplemde', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'simplemde';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'tags', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'tags';
        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' => array(), 'status' => 'published', 'date' => $currentDate, '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' => array('bludit' => 'Bludit', 'cms' => 'CMS', 'flat-files' => 'Flat files'), 'allowComments' => 'false', 'date' => $currentDate));
    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' => Date::current('Y'), 'language' => $Language->getCurrentLocale(), 'locale' => $Language->getCurrentLocale(), 'timezone' => $timezone, 'theme' => 'pure', 'adminTheme' => 'default', 'homepage' => '', 'postsperpage' => '6', 'uriPost' => '/post/', 'uriPage' => '/', 'uriTag' => '/tag/', 'url' => 'http://' . DOMAIN . HTML_PATH_ROOT, 'cliMode' => 'true', 'emailFrom' => 'no-reply@' . DOMAIN);
    file_put_contents(PATH_DATABASES . 'site.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    $salt = getRandomString();
    $passwordHash = sha1($adminPassword . $salt);
    // File users.php
    $data = array('admin' => array('firstName' => '', 'lastName' => '', 'twitter' => '', 'role' => 'admin', 'password' => $passwordHash, 'salt' => $salt, 'email' => $email, 'registered' => $currentDate));
    file_put_contents(PATH_DATABASES . 'users.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File security.php
    $data = array('minutesBlocked' => 5, 'numberFailuresAllowed' => 10, 'blackList' => array());
    file_put_contents(PATH_DATABASES . 'security.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File tags.php
    file_put_contents(PATH_DATABASES . 'tags.php', $dataHead . json_encode(array('postsIndex' => array('bludit' => array('name' => 'Bludit', 'posts' => array('first-post')), 'cms' => array('name' => 'CMS', 'posts' => array('first-post')), 'flat-files' => array('name' => 'Flat files', 'posts' => array('first-post'))), 'pagesIndex' => array()), JSON_PRETTY_PRINT), LOCK_EX);
    // PLUGINS
    // File plugins/pages/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'pages' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'homeLink' => true, 'label' => $Language->get('Pages')), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/simplemde/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'simplemde' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'tabSize' => 4, 'toolbar' => '&quot;bold&quot;, &quot;italic&quot;, &quot;heading&quot;, &quot;|&quot;, &quot;quote&quot;, &quot;unordered-list&quot;, &quot;|&quot;, &quot;link&quot;, &quot;image&quot;, &quot;code&quot;, &quot;horizontal-rule&quot;, &quot;|&quot;, &quot;preview&quot;, &quot;side-by-side&quot;, &quot;fullscreen&quot;, &quot;guide&quot;'), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/tags/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'tags' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'label' => $Language->get('Tags')), 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;
}
Esempio n. 9
0
 private function createXML()
 {
     global $Site;
     global $dbPages;
     global $dbPosts;
     global $Url;
     $doc = new DOMDocument('1.0', 'UTF-8');
     // Friendly XML code
     $doc->formatOutput = true;
     // Create urlset element
     $urlset = $doc->createElement('urlset');
     $attribute = $doc->createAttribute('xmlns');
     $attribute->value = 'http://www.sitemaps.org/schemas/sitemap/0.9';
     $urlset->appendChild($attribute);
     // --- Base URL ---
     // Create url, loc and lastmod elements
     $url = $doc->createElement('url');
     $loc = $doc->createElement('loc', $Site->url());
     $lastmod = $doc->createElement('lastmod', Date::current(SITEMAP_DATE_FORMAT));
     // Append loc and lastmod -> url
     $url->appendChild($loc);
     $url->appendChild($lastmod);
     // Append url -> urlset
     $urlset->appendChild($url);
     // --- Pages and Posts ---
     $all = array();
     $url = trim($Site->url(), '/');
     // --- Pages ---
     $filter = trim($Url->filters('page'), '/');
     $pages = $dbPages->getDB();
     unset($pages['error']);
     foreach ($pages as $key => $db) {
         if ($db['status'] == 'published') {
             $permalink = empty($filter) ? $url . '/' . $key : $url . '/' . $filter . '/' . $key;
             $date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
             array_push($all, array('permalink' => $permalink, 'date' => $date));
         }
     }
     // --- Posts ---
     $filter = rtrim($Url->filters('post'), '/');
     $posts = $dbPosts->getDB();
     foreach ($posts as $key => $db) {
         if ($db['status'] == 'published') {
             $permalink = empty($filter) ? $url . '/' . $key : $url . '/' . $filter . '/' . $key;
             $date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
             array_push($all, array('permalink' => $permalink, 'date' => $date));
         }
     }
     // Generate the XML for posts and pages
     foreach ($all as $db) {
         // Create url, loc and lastmod elements
         $url = $doc->createElement('url');
         $loc = $doc->createElement('loc', $db['permalink']);
         $lastmod = $doc->createElement('lastmod', $db['date']);
         // Append loc and lastmod -> url
         $url->appendChild($loc);
         $url->appendChild($lastmod);
         // Append url -> urlset
         $urlset->appendChild($url);
     }
     // Append urlset -> XML
     $doc->appendChild($urlset);
     $doc->save(PATH_PLUGINS_DATABASES . $this->directoryName . DS . 'sitemap.xml');
 }
Esempio n. 10
0
function install($adminPassword, $email, $timezoneOffset)
{
    global $Language;
    $stdOut = array();
    $timezone = timezone_name_from_abbr('', $timezoneOffset, 0);
    if ($timezone === false) {
        $timezone = timezone_name_from_abbr('', $timezoneOffset, 0);
    }
    // Workaround bug #44780
    date_default_timezone_set($timezone);
    $currentDate = Date::current(DB_DATE_FORMAT);
    // ============================================================================
    // 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_PAGES . 'about', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PAGES . 'about';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'pages', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'pages';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'tinymce', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'tinymce';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'tags', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'tags';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'about', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'about';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_UPLOADS_PROFILES, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_UPLOADS_PROFILES;
        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' => array(), 'status' => 'published', 'date' => $currentDate, 'position' => 0), 'about' => array('description' => $Language->get('About your site or yourself'), 'username' => 'admin', 'tags' => array(), 'status' => 'published', 'date' => $currentDate, 'position' => 1));
    file_put_contents(PATH_DATABASES . 'pages.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File posts.php
    $data = array($firstPostSlug => array('description' => $Language->get('Welcome to Bludit'), 'username' => 'admin', 'status' => 'published', 'tags' => array('bludit' => 'Bludit', 'cms' => 'CMS', 'flat-files' => 'Flat files'), 'allowComments' => 'false', 'date' => $currentDate));
    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' => 'Copyright © ' . Date::current('Y'), 'language' => $Language->getCurrentLocale(), 'locale' => $Language->getCurrentLocale(), 'timezone' => $timezone, 'theme' => 'pure', 'adminTheme' => 'default', 'homepage' => '', 'postsperpage' => '6', 'uriPost' => '/post/', 'uriPage' => '/', 'uriTag' => '/tag/', 'url' => 'http://' . DOMAIN . HTML_PATH_ROOT, 'cliMode' => 'true', 'emailFrom' => 'no-reply@' . DOMAIN);
    file_put_contents(PATH_DATABASES . 'site.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File users.php
    $salt = getRandomString();
    $passwordHash = sha1($adminPassword . $salt);
    $data = array('admin' => array('firstName' => $Language->get('Administrator'), 'lastName' => '', 'twitter' => '', 'role' => 'admin', 'password' => $passwordHash, 'salt' => $salt, 'email' => $email, 'registered' => $currentDate));
    file_put_contents(PATH_DATABASES . 'users.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File security.php
    $randomKey = getRandomString();
    $randomKey = sha1($randomKey);
    $data = array('key1' => $randomKey, 'minutesBlocked' => 5, 'numberFailuresAllowed' => 10, 'blackList' => array());
    file_put_contents(PATH_DATABASES . 'security.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File tags.php
    file_put_contents(PATH_DATABASES . 'tags.php', $dataHead . json_encode(array('postsIndex' => array('bludit' => array('name' => 'Bludit', 'posts' => array('first-post')), 'cms' => array('name' => 'CMS', 'posts' => array('first-post')), 'flat-files' => array('name' => 'Flat files', 'posts' => array('first-post'))), 'pagesIndex' => array()), JSON_PRETTY_PRINT), LOCK_EX);
    // PLUGINS
    // File plugins/pages/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'pages' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'homeLink' => true, 'label' => $Language->get('Pages')), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/about/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'about' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'label' => $Language->get('About'), 'text' => $Language->get('this-is-a-brief-description-of-yourself-our-your-site')), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/tinymce/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'tinymce' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'plugins' => 'autoresize, fullscreen, pagebreak, link, textcolor, code', 'toolbar' => 'bold italic underline strikethrough | alignleft aligncenter alignright | bullist numlist | styleselect | link forecolor backcolor removeformat | pagebreak code fullscreen'), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/tags/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'tags' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'label' => $Language->get('Tags')), 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 about page
    $data = 'Title: ' . $Language->get('About') . '
Content:
' . $Language->get('the-about-page-is-very-important') . '

' . $Language->get('change-this-pages-content-on-the-admin-panel');
    file_put_contents(PATH_PAGES . 'about' . DS . 'index.txt', $data, LOCK_EX);
    // File index.txt for welcome post
    $data = 'Title: ' . $Language->get('First post') . '
Content:

## ' . $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/bluditcms) / [Google+](https://plus.google.com/+Bluditcms)
- ' . $Language->get('Chat with developers and users on Gitter') . '
- ' . $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;
}
Esempio n. 11
0
<?php

HTML::title(array('title' => $L->g('Language and timezone'), 'icon' => 'globe'));
HTML::formOpen(array('class' => 'uk-form-horizontal'));
HTML::formInputHidden(array('name' => 'tokenCSRF', 'value' => $Security->getTokenCSRF()));
HTML::legend(array('value' => $L->g('General'), 'class' => 'first-child'));
HTML::formSelect(array('name' => 'language', 'label' => $L->g('Language'), 'options' => $Language->getLanguageList(), 'selected' => $Site->language(), 'class' => 'uk-width-1-3 uk-form-medium', 'tip' => $L->g('select-your-sites-language')));
HTML::formSelect(array('name' => 'timezone', 'label' => $L->g('Timezone'), 'options' => Date::timezoneList(), 'selected' => $Site->timezone(), 'class' => 'uk-width-1-3 uk-form-medium', 'tip' => $L->g('select-a-timezone-for-a-correct')));
HTML::formInputText(array('name' => 'locale', 'label' => $L->g('Locale'), 'value' => $Site->locale(), 'class' => 'uk-width-1-2 uk-form-medium', 'tip' => $L->g('you-can-use-this-field-to-define-a-set-of')));
HTML::legend(array('value' => $L->g('Date and time formats')));
HTML::formInputText(array('name' => 'dateFormat', 'label' => $L->g('Date format'), 'value' => $Site->dateFormat(), 'class' => 'uk-width-1-2 uk-form-medium', 'tip' => $L->g('Current format') . ': ' . Date::current($Site->dateFormat())));
echo '<div class="uk-form-row">
		<div class="uk-form-controls">
		<button type="submit" class="uk-button uk-button-primary">' . $L->g('Save') . '</button>
		</div>
	</div>';
HTML::formClose();
?>

<script>

$(document).ready(function() {

	$("#jslanguage").change(function () {
		var locale = $("#jslanguage option:selected").val();
		$("#jslocale").attr("value",locale);
	});

});

</script>