From d3cc0f8e48b626b540ebf7df7401503ca292a0e6 Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 16 Jul 2016 20:19:10 -0300 Subject: [PATCH] Cli mode updates, filename for posts and pages --- bl-kernel/abstract/content.class.php | 6 +- bl-kernel/abstract/dbjson.class.php | 8 +- bl-kernel/admin/controllers/dashboard.php | 48 +++- bl-kernel/boot/init.php | 11 +- bl-kernel/boot/rules/70.posts.php | 4 +- bl-kernel/boot/rules/71.pages.php | 2 +- bl-kernel/dbpages.class.php | 172 +++++++++++++- bl-kernel/dbposts.class.php | 271 +++++++++++++--------- bl-plugins/api/plugin.php | 4 +- install.php | 17 +- 10 files changed, 397 insertions(+), 146 deletions(-) diff --git a/bl-kernel/abstract/content.class.php b/bl-kernel/abstract/content.class.php index 8b0cd002..c0eaf294 100644 --- a/bl-kernel/abstract/content.class.php +++ b/bl-kernel/abstract/content.class.php @@ -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)); @@ -304,4 +304,4 @@ class Content { return json_encode($tmp); } -} \ No newline at end of file +} diff --git a/bl-kernel/abstract/dbjson.class.php b/bl-kernel/abstract/dbjson.class.php index 04dffaa9..adce8948 100644 --- a/bl-kernel/abstract/dbjson.class.php +++ b/bl-kernel/abstract/dbjson.class.php @@ -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. diff --git a/bl-kernel/admin/controllers/dashboard.php b/bl-kernel/admin/controllers/dashboard.php index e60a92d4..f08de032 100644 --- a/bl-kernel/admin/controllers/dashboard.php +++ b/bl-kernel/admin/controllers/dashboard.php @@ -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...'); } } diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 13acf17b..0f50b1d5 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -1,10 +1,10 @@ regenerateCli()) { +if( CLI_MODE && false) { + if($dbPosts->cliMode()) { reIndexTagsPosts(); } } diff --git a/bl-kernel/boot/rules/71.pages.php b/bl-kernel/boot/rules/71.pages.php index 63d64cb1..af3c8971 100644 --- a/bl-kernel/boot/rules/71.pages.php +++ b/bl-kernel/boot/rules/71.pages.php @@ -20,7 +20,7 @@ $pagesParentsPublished = array(); // Search for changes on pages by the user. if( CLI_MODE ) { - $dbPages->regenerateCli(); + $dbPages->cliMode(); } // Build specific page. diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php index 555ef9c4..cb6ca23e 100644 --- a/bl-kernel/dbpages.class.php +++ b/bl-kernel/dbpages.class.php @@ -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; } @@ -432,4 +592,4 @@ class dbPages extends dbJSON return $this->db!=$db; } -} \ No newline at end of file +} diff --git a/bl-kernel/dbposts.class.php b/bl-kernel/dbposts.class.php index 7f1d2588..4306d481 100644 --- a/bl-kernel/dbposts.class.php +++ b/bl-kernel/dbposts.class.php @@ -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(); - if($this->db!=$db) { - Log::set(__METHOD__.LOG_SEP.'There are new or deleted posts.'); - return true; - } + // LOG + Log::set('CLI MODE - POSTS - Finishing...'); - return false; + return true; } -} \ No newline at end of file + 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); + } + + // 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; + } + } + } + + // Insert row in the database + $this->db[$key] = $dataForDb; + + return true; + } + +} diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index d6501d6a..6a2aae80 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -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') { diff --git a/install.php b/install.php index 96030131..a8dcab6d 100644 --- a/install.php +++ b/install.php @@ -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; } @@ -720,4 +723,4 @@ $(document).ready(function() - \ No newline at end of file +