diff --git a/brain/utility/Setup.php b/brain/utility/Setup.php index 9d4cf1a..afa9a20 100644 --- a/brain/utility/Setup.php +++ b/brain/utility/Setup.php @@ -17,7 +17,7 @@ class SetUp public static function init($body) { - //grab template files + //grab template files $newFolks = json_decode( file_get_contents("../config/init/folks-template.json"), true @@ -26,15 +26,15 @@ class SetUp file_get_contents("../config/init/settings-template.json"), true ); - //get form values - //$body = $request->getParsedBody(); + //get form values + //$body = $request->getParsedBody(); $handle = $body["new_member_handle"]; $email = $body["new_member_email"]; $pass = $body["new_member_pass"]; $title = $body["new_member_title"]; $now = new \Moment\Moment(); - //setup folks config + //setup folks config $hash = password_hash($pass, PASSWORD_DEFAULT); $newFolks[0]["id"] = 0; $newFolks[0]["handle"] = $handle; @@ -45,17 +45,18 @@ class SetUp $newFolks[0]["role"] = "hnic"; $newFolks[0]["created"] = $now->format("Y-m-d\TH:i:sP"); $newFolks[0]["updated"] = $now->format("Y-m-d\TH:i:sP"); - //set up settings config + //set up settings config $newSettings["global"]["title"] = $title; - //create index file - //$rightNow = $now->format("Y-m-d\TH:i:sP"); - //var_dump($now->format("Y-m-d\TH:i:sP")); + //create index file + //$rightNow = $now->format("Y-m-d\TH:i:sP"); + //var_dump($now->format("Y-m-d\TH:i:sP")); $index = [ "id" => 1, "uuid" => StringTools::createUUID(), "title" => "FIRST!", "feature" => "/assets/images/global/default-bg.jpg", + "files" => "", "path" => "content/pages/start", "layout" => "index", "tags" => "start, welcome", @@ -73,7 +74,7 @@ class SetUp $freshIndex = DocTools::objectToMD($index); - //once all files created, write down + //once all files created, write down DocTools::writeSettings("../config/settings.json", $newSettings); DocTools::writeSettings("../config/folks.json", $newFolks); @@ -85,7 +86,7 @@ class SetUp $freshIndex ); - //if there is an older session file, get rid of it + //if there is an older session file, get rid of it if (is_file("../content/.session")) { unlink("../content/.session"); } @@ -108,16 +109,16 @@ class SetUp $size = $file->getSize(); $name = $file->getClientFileName(); - //park it so it can be read + //park it so it can be read $file->moveTo("../content" . "/" . $name); - //open it and get files to verify user + //open it and get files to verify user $zip = new ZipArchive(); if ($zip->open("../content" . "/" . $name) === true) { $folks = json_decode($zip->getFromName("settings/folks.json"), true); $found = find($folks, ["handle" => $body["restore_member_handle"]]); - //if member is found in back up, check pass + //if member is found in back up, check pass if ($found) { if (password_verify($body["restore_member_pass"], $found["password"])) { //backup verified, restore site @@ -144,25 +145,25 @@ class SetUp file_get_contents("../content/settings/settings.json"), true ); - //check for key, add if not there + //check for key, add if not there if (!isset($newConfig["global"]["externalAPI"])) { $newConfig["global"]["externalAPI"] = "false"; } - //write new config file - DocTools::writeSettings("../config/settings.json", $newConfig); + //write new config file + DocTools::writeSettings("../config/settings.json", $newConfig); - //rename("../content/settings/folks.json", "../config/folks.json"); - DocTools::writeSettings("../config/folks.json", $newFolks); + //rename("../content/settings/folks.json", "../config/folks.json"); + DocTools::writeSettings("../config/folks.json", $newFolks); - rename("../content/settings/tags.json", "../config/tags.json"); + rename("../content/settings/tags.json", "../config/tags.json"); - //images path for blog and user - $blogImagePath = "../public/assets/images/blog"; - $userImagePath = "../public/assets/images/user"; + //images path for blog and user + $blogImagePath = "../public/assets/images/blog"; + $userImagePath = "../public/assets/images/user"; - //check to see if image dirs are empty, if not chill + //check to see if image dirs are empty, if not chill if ($globs = glob($blogImagePath . "/*")) { - //directory not empty, relax + //directory not empty, relax } else { rename("../content/public/assets/images/blog", $blogImagePath); } @@ -175,22 +176,22 @@ class SetUp rename("../content/content/pages/", "../content/pages"); - //legacy check for old file structure + //legacy check for old file structure if (is_file("../content/pages/index.md")) { if (!is_dir("../content/pages/start")) { - //Directory does not exist, so lets create it. + //Directory does not exist, so lets create it. mkdir("../content/pages/start", 0755, true); - //move start page to appropriate spot + //move start page to appropriate spot rename( "../content/pages/index.md", "../content/pages/start/index.md" ); } } else { - //chill + //chill } - //clean up + //clean up DocTools::deleteFolder("../content/settings"); DocTools::deleteFolder("../content/public"); @@ -214,7 +215,7 @@ class SetUp $zip->close(); $zipPath = "../content/" . $name; - //trash zip when done + //trash zip when done unlink($zipPath); } else { $result = [ diff --git a/brain/views/dash/init.twig b/brain/views/dash/init.twig index fcae15e..121f8e6 100644 --- a/brain/views/dash/init.twig +++ b/brain/views/dash/init.twig @@ -12,7 +12,7 @@