')) { $errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)'; error_log($errorText, 0); array_push($stdOut, $errorText); } if(!in_array('dom', $phpModules)) { $errorText = 'PHP module DOM does not exist. (ERR_203)'; error_log($errorText, 0); array_push($stdOut, $errorText); } if(!in_array('json', $phpModules)) { $errorText = 'PHP module JSON does not exist. (ERR_204)'; error_log($errorText, 0); array_push($stdOut, $errorText); } if(!is_writable(PATH_CONTENT)) { $errorText = 'Writing test failure, check directory content permissions. (ERR_205)'; error_log($errorText, 0); array_push($stdOut, $errorText); } return $stdOut; } function install($adminPassword, $email) { $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, $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_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'=>'Footer text - ©2015', 'language'=>'english', 'locale'=>'en_US', '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 index.txt for error page $data = 'Title: Error Content: 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: First post Content: Congratulations, you have installed **Bludit** successfully! --- What\'s next: --- - Administrate your Bludit from the [Admin Area](./admin/) - Follow Bludit on [Twitter](https://twitter.com/bludit) / Facebook / Google+ - Visit the forum for support - Read the documentation for more information - Share with your friend :D'; file_put_contents(PATH_POSTS.$firstPostSlug.DS.'index.txt', $data, LOCK_EX); return true; } // ============================================================================ // MAIN // ============================================================================ if( alreadyInstalled() ) { exit('Bludit already installed'); } if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { if(install($_POST['password'],$_POST['email'])) { if(!headers_sent()) { header("Location:".HTML_PATH_ROOT, TRUE, 302); exit; } exit(''); } } ?> Bludit Installer

Bludit Installer

Welcome to the Bludit installer

Complete the form, choose a password for the username admin

'; echo ''; foreach ($system as $value) { echo ''; } echo '
'.$value.'
'; echo '