Cli mode updates, filename for posts and pages

This commit is contained in:
dignajar 2016-07-16 20:19:10 -03:00
parent ceb0e29714
commit d3cc0f8e48
10 changed files with 397 additions and 146 deletions

View File

@ -40,12 +40,12 @@ class Content {
// Parse the content from the file index.txt
private function build($path)
{
if( !Sanitize::pathFile($path.'index.txt') ) {
if( !Sanitize::pathFile($path.FILENAME) ) {
return false;
}
$tmp = 0;
$lines = file($path.'index.txt');
$lines = file($path.FILENAME);
foreach($lines as $lineNumber=>$line)
{
$parts = array_map('trim', explode(':', $line, 2));

View File

@ -81,7 +81,13 @@ class dbJSON
$this->dbBackup = $this->db;
// LOCK_EX flag to prevent anyone else writing to the file at the same time.
return file_put_contents($this->file, $data, LOCK_EX);
if( file_put_contents($this->file, $data, LOCK_EX) ) {
return true;
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
}
// Returns a JSON encoded string on success or FALSE on failure.

View File

@ -12,28 +12,53 @@ function updateBludit()
// Check if Bludit need to be update.
if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) )
{
// --- Update dates on posts ---
foreach($dbPosts->db as $key=>$post)
{
// LOG
Log::set('UPDATE SYSTEM - Starting...');
// LOG
Log::set('UPDATE SYSTEM - Checking posts.');
// Update posts
foreach($dbPosts->db as $key=>$post) {
// Dates
$date = Date::format($post['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
if($date !== false) {
$dbPosts->setPostDb($key,'date',$date);
$dbPosts->setPostDb($key, 'date', $date);
}
// Checksum
if( empty($post['md5file']) ) {
$checksum = md5_file(PATH_POSTS.$key.DS.FILENAME);
$dbPosts->setPostDb($key, 'md5file', $checksum);
}
}
$dbPosts->save();
// --- Update dates on pages ---
foreach($dbPages->db as $key=>$page)
{
// LOG
Log::set('UPDATE SYSTEM - Checking pages.');
// Update pages
foreach($dbPages->db as $key=>$page) {
$date = Date::format($page['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
if($date !== false) {
$dbPages->setPageDb($key,'date',$date);
$dbPages->setPageDb($key, 'date', $date);
}
// Checksum
if( empty($post['md5file']) ) {
$checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
$dbPages->setPageDb($key, 'md5file', $checksum);
}
}
$dbPages->save();
// LOG
Log::set('UPDATE SYSTEM - Checking directories.');
// --- Update directories ---
$directories = array(
PATH_POSTS,
@ -44,8 +69,8 @@ function updateBludit()
PATH_TMP
);
foreach($directories as $dir)
{
foreach($directories as $dir) {
// Check if the directory is already created.
if(!file_exists($dir)) {
// Create the directory recursive.
@ -56,7 +81,8 @@ function updateBludit()
// Set and save the database.
$Site->set(array('currentBuild'=>BLUDIT_BUILD));
Log::set('updateBludit'.LOG_SEP.'System updated');
// LOG
Log::set('UPDATE SYSTEM - Updated...');
}
}

View File

@ -1,10 +1,10 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// Bludit version
define('BLUDIT_VERSION', '1.4');
define('BLUDIT_VERSION', '1.5-beta');
define('BLUDIT_CODENAME', 'Spot');
define('BLUDIT_RELEASE_DATE', '2016-06-20');
define('BLUDIT_BUILD', '20160620');
define('BLUDIT_RELEASE_DATE', '2016-07-16');
define('BLUDIT_BUILD', '20160716');
// Debug mode
define('DEBUG_MODE', TRUE);
@ -91,7 +91,7 @@ define('NO_PARENT_CHAR', '3849abb4cb7abd24c2d8dac17b216f17');
define('POSTS_PER_PAGE_ADMIN', 10);
// Cli mode status for new posts/pages
define('CLI_MODE', false);
define('CLI_MODE', TRUE);
// Cli mode status for new posts/pages
define('CLI_STATUS', 'published');
@ -99,6 +99,9 @@ define('CLI_STATUS', 'published');
// Cli mode username for new posts/pages
define('CLI_USERNAME', 'admin');
// Filename for posts and pages
define('FILENAME', 'index.txt');
// Database date format
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');

View File

@ -13,8 +13,8 @@ $posts = array();
// ============================================================================
// Search for changes on posts by the user.
if( CLI_MODE ) {
if($dbPosts->regenerateCli()) {
if( CLI_MODE && false) {
if($dbPosts->cliMode()) {
reIndexTagsPosts();
}
}

View File

@ -20,7 +20,7 @@ $pagesParentsPublished = array();
// Search for changes on pages by the user.
if( CLI_MODE ) {
$dbPages->regenerateCli();
$dbPages->cliMode();
}
// Build specific page.

View File

@ -84,7 +84,7 @@ class dbPages extends dbJSON
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_PAGES.$key.'/index.txt', $data) === false ) {
if( file_put_contents(PATH_PAGES.$key.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
return false;
}
@ -172,7 +172,7 @@ class dbPages extends dbJSON
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_PAGES.$newKey.DS.'index.txt', $data) === false ) {
if( file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
return false;
}
@ -198,7 +198,7 @@ class dbPages extends dbJSON
}
// Delete the index.txt file.
if( Filesystem::rmfile(PATH_PAGES.$key.DS.'index.txt') === false ) {
if( Filesystem::rmfile(PATH_PAGES.$key.DS.FILENAME) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
}
@ -340,6 +340,166 @@ class dbPages extends dbJSON
return $count - 1;
}
public function cliMode()
{
// LOG
Log::set('CLI MODE - PAGES - Starting...');
$pageList = array();
$pagesDirectories = Filesystem::listDirectories(PATH_PAGES);
foreach( $pagesDirectories as $directory ) {
if( Sanitize::pathFile($directory.DS.FILENAME) ) {
// The key is the directory name
$key = basename($directory);
// Add the page key to the list
$pageList[$key] = true;
// LOG
Log::set('CLI MODE - Page found, key: '.$key);
// Search sub-pages
$subPaths = Filesystem::listDirectories($directory.DS);
foreach( $subPaths as $subDirectory )
{
// The key of the sub-page
$subKey = basename($subDirectory);
if( Sanitize::pathFile($subDirectory.DS.FILENAME) ) {
// Add the key of the sub-page, the key is composed by the directory/subdirectory
$pageList[$key.'/'.$subKey] = true;
// LOG
Log::set('CLI MODE - Page found, key: '.$key);
}
}
}
}
foreach( $pageList as $key=>$value ) {
if( !isset($this->db[$key]) ) {
// LOG
Log::set('CLI MODE - The page is not in the database, key: '.$key);
// Insert new post
$this->cliModeInsert($key);
}
else {
$checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
// If checksum is different, update the post
if( $this->db[$key]['md5file']!==$checksum ) {
// LOG
Log::set('CLI MODE - Different md5 checksum, key: '.$key);
// Update the post
$this->cliModeInsert($key, $update=true);
}
}
}
// LOG
Log::set('CLI MODE - Cleaning database...');
foreach( array_diff_key($this->db, $pageList) as $key=>$data ) {
// LOG
Log::set('CLI MODE - Removing page from database, key: '.$key);
// Remove the page from database
unset( $this->db[$key] );
}
// Save the database
$this->save();
// LOG
Log::set('CLI MODE - PAGES - Finishing...');
return true;
}
private function cliModeInsert($key, $update=false)
{
if($update) {
// LOG
Log::set('CLI MODE - cliModeInsert() - Updating the page, key: '.$key);
// Database from the current database
$dataForDb = $this->db[$key];
$dataForDb['dateModified'] = Date::current(DB_DATE_FORMAT);
}
else {
// LOG
Log::set('CLI MODE - cliModeInsert() - Inserting the new post, key: '.$key);
// Database for the new page, fields with the default values
$dataForDb = array();
foreach( $this->dbFields as $field=>$options ) {
if( !$options['inFile'] ) {
$dataForDb[$field] = $options['value'];
}
}
// Fields and value predefined in init.php
$dataForDb['username'] = CLI_USERNAME;
$dataForDb['status'] = CLI_STATUS;
$dataForDb['date'] = Date::current(DB_DATE_FORMAT);
}
// MD5 checksum
$dataForDb['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
// Generate the Object from the file
$Page = new Page($key);
foreach( $this->dbFields as $field=>$options ) {
if( !$options['inFile'] ) {
// Get the field from the file
// If the field doesn't exist, the function returns FALSE
$data = $Page->getField($field);
if( $data!==false ) {
$tmpValue = '';
if( $field=='tags' ) {
$tmpValue = $this->generateTags($data);
}
elseif( $field=='date' ) {
// Validate format date from file
if( Valid::date($data, DB_DATE_FORMAT) ) {
$tmpValue = $data;
}
}
else {
$tmpValue = Sanitize::html($data);
}
settype($tmpValue, gettype($options['value']));
$dataForDb[$field] = $tmpValue;
}
}
}
// Insert row in the database
$this->db[$key] = $dataForDb;
return true;
}
public function regenerateCli()
{
$db = $this->db;
@ -359,7 +519,7 @@ class dbPages extends dbJSON
{
$key = basename($directory);
if(file_exists($directory.DS.'index.txt')) {
if(file_exists($directory.DS.FILENAME)) {
// The key is the directory name
$newPaths[$key] = true;
}
@ -371,7 +531,7 @@ class dbPages extends dbJSON
{
$subKey = basename($subDirectory);
if(file_exists($subDirectory.DS.'index.txt')) {
if(file_exists($subDirectory.DS.FILENAME)) {
// The key is composed by the directory/subdirectory
$newPaths[$key.'/'.$subKey] = true;
}

View File

@ -12,7 +12,8 @@ class dbPosts extends dbJSON
'allowComments'=> array('inFile'=>false, 'value'=>0),
'date'=> array('inFile'=>false, 'value'=>''),
'dateModified'=> array('inFile'=>false, 'value'=>''),
'coverImage'=> array('inFile'=>false, 'value'=>'')
'coverImage'=> array('inFile'=>false, 'value'=>''),
'md5file'=> array('inFile'=>false, 'value'=>'')
);
function __construct()
@ -25,7 +26,7 @@ class dbPosts extends dbJSON
// $total = FALSE, return the amount of published posts
public function numberPost($total=false)
{
// Amount of posts, published, scheduled and draft
// Amount of total posts, published, scheduled and draft
if($total) {
return count($this->db);
}
@ -69,7 +70,7 @@ class dbPosts extends dbJSON
// Return TRUE if the post exists, FALSE otherwise.
public function postExists($key)
{
return isset($this->db[$key]);
return isset( $this->db[$key] );
}
// Generate a valid Key/Slug.
@ -104,15 +105,17 @@ class dbPosts extends dbJSON
{
$dataForDb = array(); // This data will be saved in the database
$dataForFile = array(); // This data will be saved in the file
// Current date, format of DB_DATE_FORMAT
$currentDate = Date::current(DB_DATE_FORMAT);
// Generate the database key.
// Generate the database key / index
$key = $this->generateKey($args['slug']);
// The user is always who is loggued.
// The user is always who is loggued
$args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) {
Log::set(__METHOD__.LOG_SEP.'The session does not have the username.');
Log::set(__METHOD__.LOG_SEP.'Session username doesnt exists.');
return false;
}
@ -129,7 +132,7 @@ class dbPosts extends dbJSON
// Verify arguments with the database fields.
foreach($this->dbFields as $field=>$options)
{
// If the field is in the arguments.
// If the field is in the arguments
if( isset($args[$field]) )
{
if($field=='tags') {
@ -145,13 +148,13 @@ class dbPosts extends dbJSON
}
}
}
// Default value if not in the arguments.
// Set a default value if not in the arguments
else
{
$tmpValue = $options['value'];
}
// Check where the field will be written, if in the file or in the database.
// Check where the field will be written, in the file or in the database
if($options['inFile']) {
$dataForFile[$field] = Text::firstCharUp($field).': '.$tmpValue;
}
@ -173,18 +176,27 @@ class dbPosts extends dbJSON
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_POSTS.$key.DS.'index.txt', $data) === false ) {
if( file_put_contents(PATH_POSTS.$key.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
return false;
}
// Calculate the checksum of the file
$dataForDb['md5file'] = md5_file(PATH_POSTS.$key.DS.FILENAME);
// Save the database
$this->db[$key] = $dataForDb;
// Sort posts before save.
// Sort posts before save
$this->sortByDate();
if( $this->save() === false ) {
// Trying to rollback
Log::set(__METHOD__.LOG_SEP.'Rollback...');
Filesystem::rmfile(PATH_POSTS.$key.DS.FILENAME);
Filesystem::rmdir(PATH_POSTS.$key);
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
@ -214,7 +226,7 @@ class dbPosts extends dbJSON
}
// Delete the index.txt file.
if( Filesystem::rmfile(PATH_POSTS.$key.DS.'index.txt') === false ) {
if( Filesystem::rmfile(PATH_POSTS.$key.DS.FILENAME) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
}
@ -261,20 +273,15 @@ class dbPosts extends dbJSON
return array();
}
// Delete all posts from an user.
// Delete all posts from an user
public function deletePostsByUser($username)
{
foreach($this->db as $key=>$value)
{
if($value['username']==$username) {
unset($this->db[$key]);
}
}
foreach($this->db as $key=>$value) {
// Save the database.
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
if($value['username']==$username) {
$this->delete($key);
Log::set(__METHOD__.LOG_SEP.'Post deleted: '.$key);
}
}
Log::set(__METHOD__.LOG_SEP.'Posts from the user '.$username.' were delete.');
@ -284,8 +291,8 @@ class dbPosts extends dbJSON
// Link-up all posts from an user to another user.
public function linkPostsToUser($oldUsername, $newUsername)
{
foreach($this->db as $key=>$value)
{
foreach($this->db as $key=>$value) {
if($value['username']==$oldUsername) {
$this->db[$key]['username'] = $newUsername;
}
@ -308,6 +315,7 @@ class dbPosts extends dbJSON
public function removeUnpublished()
{
foreach($this->db as $key=>$values) {
if($values['status']!='published') {
unset($this->db[$key]);
}
@ -319,7 +327,7 @@ class dbPosts extends dbJSON
// Return TRUE if there are new posts published, FALSE otherwise.
public function scheduler()
{
// Get current date.
// Get current date
$currentDate = Date::current(DB_DATE_FORMAT);
$saveDatabase = false;
@ -327,10 +335,11 @@ class dbPosts extends dbJSON
// Check scheduled posts
foreach($this->db as $postKey=>$values)
{
if($values['status']=='scheduled')
{
// Publish post.
if($values['status']=='scheduled') {
// Publish post
if($values['date']<=$currentDate) {
$this->db[$postKey]['status'] = 'published';
$saveDatabase = true;
}
@ -348,7 +357,7 @@ class dbPosts extends dbJSON
return false;
}
Log::set(__METHOD__.LOG_SEP.'New post published from scheduler.');
Log::set(__METHOD__.LOG_SEP.'New posts published from the scheduler.');
return true;
}
@ -401,110 +410,152 @@ class dbPosts extends dbJSON
return $a['date']<$b['date'];
}
// Return TRUE if there are new posts or orphan post deleted, FALSE otherwise.
public function regenerateCli()
public function cliMode()
{
$db = $this->db;
$allPosts = array();
$fields = array();
$currentDate = Date::current(DB_DATE_FORMAT);
// LOG
Log::set('CLI MODE - POSTS - Starting...');
// Generate default fields and values.
// --------------------------------------------------------------------------
foreach($this->dbFields as $field=>$options) {
if(!$options['inFile']) {
$fields[$field] = $options['value'];
}
}
$postList = array();
$fields['status'] = CLI_STATUS;
$fields['username'] = CLI_USERNAME;
$fields['date'] = $currentDate;
// Get all posts from the first level of directories.
$postsDirectories = Filesystem::listDirectories(PATH_POSTS);
foreach($postsDirectories as $directory)
{
// Check if the post has the index.txt file.
if(Sanitize::pathFile($directory.DS.'index.txt'))
{
// The key is the directory name.
foreach( $postsDirectories as $directory ) {
if( Sanitize::pathFile($directory.DS.FILENAME) ) {
// The key is the directory name
$key = basename($directory);
Log::set('----------------');
Log::set('CliMode - Post KEY: '.$key);
// Add the key to the list
$postList[$key] = true;
// This post exists
$allPosts[$key] = true;
// Checksum
$checksum = md5_file($directory.DS.FILENAME);
// LOG
Log::set('CLI MODE - Post found, key: '.$key);
// Create the new entry if not exist inside the DATABASE.
if( !isset($this->db[$key]) ) {
// New entry on database with the default fields and values.
$this->db[$key] = $fields;
Log::set('CliMode - New post: '.$key);
// LOG
Log::set('CLI MODE - The post is not in the database, key: '.$key);
// Insert new post
$this->cliModeInsert($key);
}
else {
// If checksum is different, update the post
if( $this->db[$key]['md5file']!==$checksum ) {
// Create the post from FILE.
$Post = new Post($key);
// LOG
Log::set('CLI MODE - Different md5 checksum, key: '.$key);
// Update all fields from FILE to DATABASE.
foreach($fields as $f=>$v)
{
// Get the value from FILE.
$valueFromFile = $Post->getField($f);
// If the field exists on the FILE, update it.
if( !empty($valueFromFile) )
{
Log::set('CliMode - Field to replace: '.$f);
Log::set('CliMode - value from file: '.$valueFromFile);
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);
}
// Update the post
$this->cliModeInsert($key, $update=true);
}
}
}
}
// 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]);
Log::set('CliMode - Deleted post: '.$key);
// LOG
Log::set('CLI MODE - Cleaning database...');
foreach( array_diff_key($this->db, $postList) as $key=>$data ) {
// LOG
Log::set('CLI MODE - Removing post from database, key: '.$key);
// Removing the post from database
unset( $this->db[$key] );
}
// Sort posts before save.
// 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;
// Save the database
$this->save();
// LOG
Log::set('CLI MODE - POSTS - Finishing...');
return true;
}
private function cliModeInsert($key, $update=false)
{
if($update) {
// LOG
Log::set('CLI MODE - cliModeInsert() - Updating the post, key: '.$key);
// Database from the current database
$dataForDb = $this->db[$key];
$dataForDb['dateModified'] = Date::current(DB_DATE_FORMAT);
}
else {
// LOG
Log::set('CLI MODE - cliModeInsert() - Inserting the new post, key: '.$key);
// Database for the new post, fields with the default values
$dataForDb = array();
foreach( $this->dbFields as $field=>$options ) {
if( !$options['inFile'] ) {
$dataForDb[$field] = $options['value'];
}
}
// Fields and value predefined in init.php
$dataForDb['username'] = CLI_USERNAME;
$dataForDb['status'] = CLI_STATUS;
$dataForDb['date'] = Date::current(DB_DATE_FORMAT);
}
if($this->db!=$db) {
Log::set(__METHOD__.LOG_SEP.'There are new or deleted posts.');
return true;
// MD5 checksum
$dataForDb['md5file'] = md5_file(PATH_POSTS.$key.DS.FILENAME);
// Generate the Object from the file
$Post = new Post($key);
foreach( $this->dbFields as $field=>$options ) {
if( !$options['inFile'] ) {
// Get the field from the file
// If the field doesn't exist, the function returns FALSE
$data = $Post->getField($field);
if( $data!==false ) {
$tmpValue = '';
if( $field=='tags' ) {
$tmpValue = $this->generateTags($data);
}
elseif( $field=='date' ) {
// Validate format date from file
if( Valid::date($data, DB_DATE_FORMAT) ) {
$tmpValue = $data;
if( $data > $currentDate ) {
$dataForDb['status'] = 'scheduled';
}
}
}
else {
$tmpValue = Sanitize::html($data);
}
settype($tmpValue, gettype($options['value']));
$dataForDb[$field] = $tmpValue;
}
}
}
return false;
// Insert row in the database
$this->db[$key] = $dataForDb;
return true;
}
}

View File

@ -157,7 +157,7 @@ class pluginAPI extends Plugin {
// Get parameters
$parameters = explode('/', $URI);
for($i=0; $i<4; $i++) {
for($i=0; $i<3; $i++) {
if(empty($parameters[$i])) {
return false;
} else {
@ -173,6 +173,8 @@ class pluginAPI extends Plugin {
'message'=>'Check the parameters'
));
if($parameters[0]==='show') {
if($parameters[1]==='all') {

View File

@ -40,6 +40,9 @@ define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
// Protecting against Symlink attacks.
define('CHECK_SYMBOLIC_LINKS', TRUE);
// Filename for posts and pages
define('FILENAME', 'index.txt');
// Domain and protocol
define('DOMAIN', $_SERVER['HTTP_HOST']);
@ -486,22 +489,22 @@ function install($adminPassword, $email, $timezone)
LOCK_EX
);
// File index.txt for error page
// 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.'index.txt', $data, LOCK_EX);
file_put_contents(PATH_PAGES.'error'.DS.FILENAME, $data, LOCK_EX);
// File index.txt for about page
// 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.'index.txt', $data, LOCK_EX);
file_put_contents(PATH_PAGES.'about'.DS.FILENAME, $data, LOCK_EX);
// File index.txt for welcome post
// File FILENAME for welcome post
$text1 = Text::replaceAssoc(
array(
'{{ADMIN_AREA_LINK}}'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT.'admin'
@ -520,7 +523,7 @@ Content:
- '.$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);
file_put_contents(PATH_POSTS.$firstPostSlug.DS.FILENAME, $data, LOCK_EX);
return true;
}