From 7170cb20a0867ecfa3234e6ffd552716d3bff185 Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Fri, 3 Jan 2025 15:06:34 -0500 Subject: [PATCH] wip from prod --- app/controllers/admin/routes.php | 30 +- app/controllers/home.php | 2 +- app/models/routes.php | 2 +- app/plugins/blog/models/posts.php | 4 +- app/plugins/blog/views/list.html | 2 +- app/plugins/blog/views/post.html | 2 +- .../bookmarks/controllers/bookmarks.php | 8 +- app/plugins/bookmarks/js/bookmarks.js | 1 - .../bookmarks/views/bookmarks/edit.html | 2 +- .../views/components/publicListRows.html | 2 +- .../views/components/shareListPanel.html | 3 +- .../bookmarks/views/extensions/edge.html | 2 +- app/plugins/bookmarks/views/folders/edit.html | 2 +- .../bookmarks/views/tutorials/edge/pin.html | 2 +- .../views/tutorials/edge/settings.html | 2 +- app/plugins/suggestions/views/create.html | 2 +- app/views/admin/routes/create.html | 2 +- app/views/admin/tokens/create.html | 2 +- app/views/admin/tokens/edit.html | 2 +- app/views/faq.html | 206 +++++++-- app/views/footer/social.html | 5 - install.php | 421 ------------------ 22 files changed, 219 insertions(+), 487 deletions(-) delete mode 100644 install.php diff --git a/app/controllers/admin/routes.php b/app/controllers/admin/routes.php index e21307b..0f65ccc 100644 --- a/app/controllers/admin/routes.php +++ b/app/controllers/admin/routes.php @@ -37,19 +37,25 @@ class Routes extends AdminController { public function create() { if ( Input::exists( 'redirect_type' ) ) { - if ( !TTPForms::check( 'createRoute' ) ) { - Issues::add( 'error', [ 'There was an error with your route.' => Check::userErrors() ] ); - } - if ( self::$routes->create( - Input::post( 'original_url' ), - Input::post( 'forwarded_url' ), - Input::post( 'nickname' ), - Input::post( 'redirect_type' ) - ) ) { - Session::flash( 'success', 'Route Created' ); - Redirect::to( 'admin/routes' ); - } + return Views::view( 'admin.routes.create' ); } + + if ( !TTPForms::check( 'createRoute' ) ) { + Issues::add( 'error', [ 'There was an error with your route.' => Check::userErrors() ] ); + return Views::view( 'admin.routes.create' ); + } + + if ( self::$routes->create( + Input::post( 'original_url' ), + Input::post( 'forwarded_url' ), + Input::post( 'nickname' ), + Input::post( 'redirect_type' ) + ) ) { + Session::flash( 'success', 'Route Created' ); + Redirect::to( 'admin/routes' ); + } + + Issues::add( 'error', 'There was an unknown error saving your redirect.' ); Views::view( 'admin.routes.create' ); } diff --git a/app/controllers/home.php b/app/controllers/home.php index a988f60..7fd1262 100644 --- a/app/controllers/home.php +++ b/app/controllers/home.php @@ -27,7 +27,7 @@ use TheTempusProject\TheTempusProject as App; class Home extends Controller { public function index() { self::$title = '{SITENAME}'; - self::$pageDescription = 'AllTheBookmarks.com is here to provide you a better, faster, and easier way - to manage bookmarks across multiple browser and multiple devices seamlessly.'; + self::$pageDescription = 'AllTheBookmarks.com is here to provide you a better, faster, and easier - way to manage bookmarks across multiple browsers and devices seamlessly.'; if ( App::$isLoggedIn ) { return Views::view( 'bookmarks.introduction' ); } diff --git a/app/models/routes.php b/app/models/routes.php index 63a23d1..8333692 100644 --- a/app/models/routes.php +++ b/app/models/routes.php @@ -72,7 +72,7 @@ class Routes extends DatabaseModel { return false; } if ( !Check::simpleName( $nickname ) ) { - Debug::warn( 'Invalid route nickname: ' . $name ); + Debug::warn( 'Invalid route nickname: ' . $nickname ); return false; } if ( 'external' == $type && !Check::url( $forwarded_url ) ) { diff --git a/app/plugins/blog/models/posts.php b/app/plugins/blog/models/posts.php index b42c1d9..f55275d 100644 --- a/app/plugins/blog/models/posts.php +++ b/app/plugins/blog/models/posts.php @@ -142,11 +142,11 @@ class Posts extends DatabaseModel { $contentSummary = $spaceSummary; if ( count( $wordsArray, 1 ) >= 100 ) { $contentSummaryNoLink = $contentSummary; - $contentSummary .= '... Read More'; + $contentSummary .= '... Read More'; } } else { $contentSummaryNoLink = $lineSummary; - $contentSummary = $lineSummary . '... Read More'; + $contentSummary = $lineSummary . '... Read More'; } $instance->contentSummaryNoLink = $contentSummaryNoLink; $instance->contentSummary = $contentSummary; diff --git a/app/plugins/blog/views/list.html b/app/plugins/blog/views/list.html index a924026..a0e7a20 100644 --- a/app/plugins/blog/views/list.html +++ b/app/plugins/blog/views/list.html @@ -1,7 +1,7 @@ {LOOP}

{title}

- +
{contentSummary}
diff --git a/app/plugins/blog/views/post.html b/app/plugins/blog/views/post.html index b955657..f7c9003 100644 --- a/app/plugins/blog/views/post.html +++ b/app/plugins/blog/views/post.html @@ -3,7 +3,7 @@

{title}


- + {content} {ADMIN}
diff --git a/app/plugins/bookmarks/controllers/bookmarks.php b/app/plugins/bookmarks/controllers/bookmarks.php index c69718f..434bb37 100644 --- a/app/plugins/bookmarks/controllers/bookmarks.php +++ b/app/plugins/bookmarks/controllers/bookmarks.php @@ -569,7 +569,7 @@ class Bookmarks extends Controller { self::$title = 'Bookmark Dashboards - {SITENAME}'; if ( !App::$isMember ) { - Issues::add( 'notice', 'You will need an active subscription to start creating dashboards. You can check our Pricing page for more details.' ); + Issues::add( 'notice', 'You will need an active subscription to start creating dashboards. You can check our Pricing page for more details.' ); return Views::view( 'bookmarks.dashboardExplainer' ); } $dashboards = self::$dashboards->byUser(); @@ -691,7 +691,7 @@ class Bookmarks extends Controller { public function import() { self::$title = 'Bookmark Import - {SITENAME}'; if ( !App::$isMember ) { - Issues::add( 'notice', 'You will need an active subscription to start importing bookmarks. You can check our Pricing page for more details.' ); + Issues::add( 'notice', 'You will need an active subscription to start importing bookmarks. You can check our Pricing page for more details.' ); return Views::view( 'bookmarks.importExplainer' ); } @@ -743,7 +743,7 @@ class Bookmarks extends Controller { public function export() { self::$title = 'Bookmark Export - {SITENAME}'; if ( !App::$isMember ) { - Issues::add( 'notice', 'You will need an active subscription to start exporting bookmarks. You can check our Pricing page for more details.' ); + Issues::add( 'notice', 'You will need an active subscription to start exporting bookmarks. You can check our Pricing page for more details.' ); return Views::view( 'bookmarks.exportExplainer' ); } @@ -806,7 +806,7 @@ class Bookmarks extends Controller { } } - public function share( $id = '' ) { + public function share() { $panelArray = []; $folders = self::$folders->byUser(); if ( empty( $folders ) ) { diff --git a/app/plugins/bookmarks/js/bookmarks.js b/app/plugins/bookmarks/js/bookmarks.js index 261151c..b73a23c 100644 --- a/app/plugins/bookmarks/js/bookmarks.js +++ b/app/plugins/bookmarks/js/bookmarks.js @@ -232,4 +232,3 @@ function loadDashLinkOrder() { bookmarkSort.innerHTML = ""; // Remove all children orderedElements.forEach(element => bookmarkSort.appendChild(element)); // Append in order } - \ No newline at end of file diff --git a/app/plugins/bookmarks/views/bookmarks/edit.html b/app/plugins/bookmarks/views/bookmarks/edit.html index fe61a5e..98db339 100644 --- a/app/plugins/bookmarks/views/bookmarks/edit.html +++ b/app/plugins/bookmarks/views/bookmarks/edit.html @@ -30,7 +30,7 @@
- diff --git a/app/plugins/bookmarks/views/components/publicListRows.html b/app/plugins/bookmarks/views/components/publicListRows.html index 5fdeacd..85005ff 100644 --- a/app/plugins/bookmarks/views/components/publicListRows.html +++ b/app/plugins/bookmarks/views/components/publicListRows.html @@ -1,7 +1,7 @@ {LOOP}
  • {iconHtml} - {title} + {title} diff --git a/app/plugins/bookmarks/views/components/shareListPanel.html b/app/plugins/bookmarks/views/components/shareListPanel.html index 965a1e2..4794f6c 100644 --- a/app/plugins/bookmarks/views/components/shareListPanel.html +++ b/app/plugins/bookmarks/views/components/shareListPanel.html @@ -1,8 +1,7 @@ {LOOP} -
    +
    -
    diff --git a/app/plugins/bookmarks/views/extensions/edge.html b/app/plugins/bookmarks/views/extensions/edge.html index 19e2ce5..29e9f70 100644 --- a/app/plugins/bookmarks/views/extensions/edge.html +++ b/app/plugins/bookmarks/views/extensions/edge.html @@ -55,7 +55,7 @@ diff --git a/app/plugins/bookmarks/views/folders/edit.html b/app/plugins/bookmarks/views/folders/edit.html index 5eb4e4c..57671ad 100644 --- a/app/plugins/bookmarks/views/folders/edit.html +++ b/app/plugins/bookmarks/views/folders/edit.html @@ -20,7 +20,7 @@
    - diff --git a/app/plugins/bookmarks/views/tutorials/edge/pin.html b/app/plugins/bookmarks/views/tutorials/edge/pin.html index 823c1aa..57efd73 100644 --- a/app/plugins/bookmarks/views/tutorials/edge/pin.html +++ b/app/plugins/bookmarks/views/tutorials/edge/pin.html @@ -6,7 +6,7 @@

    Once installed, you can add the extension to your Edge toolbar with just a few easy steps. diff --git a/app/plugins/bookmarks/views/tutorials/edge/settings.html b/app/plugins/bookmarks/views/tutorials/edge/settings.html index 4abcda8..4f4a0c3 100644 --- a/app/plugins/bookmarks/views/tutorials/edge/settings.html +++ b/app/plugins/bookmarks/views/tutorials/edge/settings.html @@ -6,7 +6,7 @@


    With Edge, accessing the extension settings couldn't be easier. diff --git a/app/plugins/suggestions/views/create.html b/app/plugins/suggestions/views/create.html index 243ea96..08e419a 100644 --- a/app/plugins/suggestions/views/create.html +++ b/app/plugins/suggestions/views/create.html @@ -26,7 +26,7 @@

    - +
    diff --git a/app/views/admin/routes/create.html b/app/views/admin/routes/create.html index fa71f49..b198dfc 100644 --- a/app/views/admin/routes/create.html +++ b/app/views/admin/routes/create.html @@ -1,5 +1,5 @@
    - Edit Route: {nickname} + Create Route
    {ADMIN_BREADCRUMBS}
    diff --git a/app/views/admin/tokens/create.html b/app/views/admin/tokens/create.html index ede854d..c496486 100644 --- a/app/views/admin/tokens/create.html +++ b/app/views/admin/tokens/create.html @@ -14,7 +14,7 @@
    - diff --git a/app/views/admin/tokens/edit.html b/app/views/admin/tokens/edit.html index d84a542..b2f36b3 100644 --- a/app/views/admin/tokens/edit.html +++ b/app/views/admin/tokens/edit.html @@ -14,7 +14,7 @@
    - {OPTION=token_type} diff --git a/app/views/faq.html b/app/views/faq.html index 05483e6..d680e7e 100644 --- a/app/views/faq.html +++ b/app/views/faq.html @@ -3,63 +3,217 @@
    -
    -

    Table of Contents

    + - -
    + +
    -

    -

    -
    -
    - Yes, this works seamlessly on mobile devices. +
    +
    + + Yes, the web app works seamlessly on mobile devices. At this time, the app is being optimized for even better mobile friendly use. + While our browser extensions cannot be used on mobile, users are given the ability to use our bookmarklet. + The Bookmarklet is similar to a small app you can save in your mobile browser. More information can be found on our extensions page. +
    -

    +

    -
    -
    - Yes, it is compatible with Mac, PC, and Linux platforms. +
    +
    + + Yes, the web app is compatible with Mac, PC, and Linux platforms. + At this time, there is no extension support directly for safari, but you can use one of the other available browsers on a Mac computer to achieve similar results. +
    -

    +

    +

    +
    +
    + + All major browsers have a method for exporting bookmarks to a file. + Conveniently, you can find a tutorial on this process for your browser, on our tutorials page. + Our members can access the bookmark imports feature which will allow you to take that file and upload all the bookmarks to your dashboard. + +
    +
    +
    +
    +

    + +

    +
    +
    + + All major browsers have a method for importing bookmarks from a file. + Conveniently, you can find a tutorial on this process for your browser, on our tutorials page. + Our members can access the bookmark export feature which will allow you to generate a file from any number of folders and bookmarks on the site. + This file can be used to import all those bookmarks right into your browser of choice. + +
    +
    +
    +
    + + + + +
    +
    +

    + +

    +
    +
    + + Adding bookmarks from your mobile device is incredibly easy with our bookmarklet, available for use on all mobile devices with supported web-browsing. + In addition to the bookmarklet, you always have the ability to add a bookmark directly from the web app here. + +
    +
    +
    +
    +

    +

    -
    -
    - To use the extension on mobile, open your browser, install the extension, and follow the setup instructions. +
    +
    + + At this time, none of our browser extensions are directly supported on mobile. You can still utilize the web-app or mobile-bookmarklet from any device. + This is more of an industry choice than a design decision as most mobile browsers have no support at all for mobile extensions. +
    -

    -

    -
    -
    - You can add it to your phone by installing the app or creating a shortcut from your browser to your home screen. +
    +
    + + While there isn't currently and Android or iPhone app available, you can add shortcut to your phone's home-screen for easy access to our web-app. + We have tutorials on how to do this available for both iPhone and Android devices. + +
    +
    +
    +
    + + + + +
    +
    +

    + +

    +
    +
    + + While the site and extension both support Dark-Mode, they aren't sharing that setting between them both. + If you would like to change DarkMode in the web app, you can find the toggle in your profile settings. + If you would like to change DarkMode in the extension, you can find the toggle in your settings. + If you need more info on finding the extension settings, we have tutorials available that can help. + +
    +
    +
    +
    +

    + +

    +
    +
    + + To Sign out, simply open the extension settings page and there should be a log-out button in grey, at the top-right of the page. + If you need more info on finding the extension settings, we have tutorials available that can help. + +
    +
    +
    +
    +

    + +

    +
    +
    + + Unfortunately, as part of our commitment to your privacy, the extension works in a fairly one-sided manner. + This means the app is never pushing new data to your extension, instead the extension must request the list from the web-app. + In some cases this can lead to a miss-match between what you have saved in the app vs what you have available in the extension. + To fix this, simply open the extension settings page. This should sync your folders with the web-app. + If you need more info on finding the extension settings, we have tutorials available that can help. + +
    +
    +
    +
    +

    + +

    +
    +
    + + The extension settings page provides a convenient way to change your default settings when adding folders or bookmarks. + You can select the Folder, color, and privacy defaults all from a single page. + If you need more info on finding the extension settings, we have tutorials available that can help. +
    diff --git a/app/views/footer/social.html b/app/views/footer/social.html index ae6ddac..c14a294 100644 --- a/app/views/footer/social.html +++ b/app/views/footer/social.html @@ -19,9 +19,4 @@
  • -
  • - - - -
  • \ No newline at end of file diff --git a/install.php b/install.php deleted file mode 100644 index b8874d7..0000000 --- a/install.php +++ /dev/null @@ -1,421 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -require_once 'bin/autoload.php'; - -use TheTempusProject\TheTempusProject; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Classes\Plugin; -use TheTempusProject\Classes\Installer; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Models\User; -use TheTempusProject\Classes\Email; -use TheTempusProject\Bedrock\Functions\Code; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Cookie; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Upload; -use TheTempusProject\Bedrock\Functions\Hash; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Hermes\Functions\Route; -use TheTempusProject\Canary\Bin\Canary as Debug; - -class Install extends Controller { - private $installer; - private $location = false; - private $steps = [ - 'Welcome', - 'Terms', - 'Verify', - 'Configure', - 'Routing', - 'Models', - 'Plugins', - 'Install', - 'Resources', - 'User', - 'Complete', - ]; - - /** - * This is the main builder for the rest of the controller. It mostly handle template variables used on all pages. - */ - public function __construct() { - parent::__construct(); - self::$title = 'TP Installer'; - self::$pageDescription = 'This is the install script for The Tempus Project.'; - $this->installer = new Installer(); - Template::noIndex(); - Template::noFollow(); - foreach ( $this->steps as $step ) { - Components::set( 'menu-' . $step, 'disabled' ); - } - if ( $this->checkSession() !== false ) { - $this->location = $this->getStep(); - Components::set( 'menu-' . ucfirst( $this->location ), 'active' ); - } else { - Components::set( 'menu-Welcome', 'active' ); - } - Components::set( 'installer-nav', Views::simpleView( 'install.nav' ) ); - } - - /** - * This method will reset the install hash, set the saved install step, update the session and cookie, and refresh if required. - * - * @param string $page - * @param boolean $redirect - * @return void - */ - public function nextStep( $page, $redirect = false ) { - $newHash = Code::genInstall(); - $this->installer->setNode( 'installHash', $newHash, true ); - $this->installer->setNode( 'installStep', $page, true ); - Session::put( 'installHash', $newHash ); - Cookie::put( 'installHash', $newHash ); - if ( $redirect === true ) { - Redirect::reload(); - } - return true; - } - - public function checkSession() { - if ( empty( $this->installer->getNode('installHash') ) ) { - Debug::error( 'install hash not found on file.' ); - return false; - } - $session = Session::get( 'installHash' ); - $cookie = Cookie::get( 'installHash' ); - $file = $this->installer->getNode('installHash'); - - if ( ! $session && ! $cookie ) { - Debug::error( 'install hash not found in session or cookie.' ); - return false; - } - if ( $cookie && ! $session ) { - if ( $cookie !== $file ) { - Debug::error( 'install cookie did not match install file.' ); - Cookie::delete( 'installHash' ); - return false; - } - Debug::error( 'cookie matches file, using as session' ); - Session::put( 'installHash', $cookie ); - return true; - } - if ( $session !== $file ) { - Debug::error( 'session did not match file, deleting session' ); - Session::delete( 'installHash' ); - return false; - } - return true; - } - - public function getStep() { - if ( !empty( $this->installer->getNode('installStep') ) ) { - return $this->installer->getNode('installStep'); - } - Debug::error( 'install status not found.' ); - return false; - } - - /** - * The index method is called on the first request and all requests thereafter and is responsible for routing - * the current request to the appropriate installer step/method. - */ - public function index() { - if ( false === $this->location ) { - return $this->welcome(); - } - // this seems dumb, i could probably do this better - $location = $this->location; - return $this->$location(); - } - - /** - * The welcome method is is just a page to submit a form and save the install.json for the first time. - */ - public function welcome() { - if ( Forms::Check( 'installStart' ) ) { - return $this->nextStep( 'terms', true ); - } - if ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with the Installation.' => Check::userErrors()] ); - } - Views::view( 'install.start' ); - } - - /** - * The terms step is pretty straight forward. You simply need to continue to the next step, understanding - * that you agree to these terms when you continue the installation. - */ - public function terms() { - if ( Forms::Check( 'installAgreement' ) ) { - return $this->nextStep( 'verify', true ); - } - if ( Input::exists( 'submit' ) ) { - Issues::add( 'error', [ 'There was an error with the Installation.' => Check::userErrors() ] ); - } - Components::set( 'TERMS', Views::simpleView( 'terms' ) ); - Views::view( 'install.agreement' ); - } - - /** - * There is a small list a of requirements for the application to run properly. These are things like sessions, emails, cookies, etc. - * This step verifies that all of these features are working as expected. - */ - public function verify() { - if ( Forms::Check( 'installCheck' ) ) { - return $this->nextStep( 'configure', true ); - } - if ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with the Installation.' => array_merge( Check::userErrors(), Check::systemErrors() )] ); - } - Views::view( 'install.check' ); - } - - - /** - * One of the most important steps for installation, is the configuration. In this step, we will define some very core settings - * for the app including the app's name and database credentials. - */ - public function configure() { - if ( Forms::Check( 'installConfigure' ) ) { - $logo = 'images/logo180.png'; - if ( Input::exists( 'logo' ) && Upload::image( 'logo', 'System' ) ) { - $logo = 'Uploads/Images/System/' . Upload::last(); - } - TheTempusProject::$activeConfig->load( BEDROCK_CONFIG_JSON ); - $baseConfig = TheTempusProject::$configMatrix; - $baseConfig['main']['logo']['value'] = $logo; - $baseConfig['main']['name']['value'] = Input::postNull( 'siteName' ); - $baseConfig['main']['template']['value'] = $baseConfig['main']['template']['default']; - $baseConfig['main']['tokenEnabled']['value'] = $baseConfig['main']['tokenEnabled']['default']; - $baseConfig['main']['loginLimit']['value'] = $baseConfig['main']['loginLimit']['default']; - $baseConfig['database']['dbEnabled']['value'] = $baseConfig['database']['dbEnabled']['default']; - $baseConfig['database']['dbHost']['value'] = Input::postNull( 'dbHost' ); - $baseConfig['database']['dbMaxQuery']['value'] = $baseConfig['database']['dbMaxQuery']['default']; - $baseConfig['database']['dbName']['value'] = Input::postNull( 'dbName' ); - $baseConfig['database']['dbPassword']['value'] = Input::postNull( 'dbPassword' ); - $baseConfig['database']['dbPrefix']['value'] = Input::postNull( 'dbPrefix' ); - $baseConfig['database']['dbUsername']['value'] = Input::postNull( 'dbUsername' ); - if ( ! TheTempusProject::$activeConfig->generate( CONFIG_JSON, $baseConfig ) ) { - return Issues::add( 'error', 'Config file already exists so the installer has been halted. If there was an error with installation, please delete app/config/config.json manually and try again. The installer should automatically bring you back to this step.' ); - } - Session::flash( 'success', 'Config saved successfully.' ); - return $this->nextStep( 'routing', true ); - } - if ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with your form.' => Check::userErrors()] ); - } - Views::view( 'install.configure' ); - } - - /** - * For the application to function properly on nginx or apache, the web servers must be configured correctly. - * Depending on which server you use, this step will help you set up and test the routing required for the - * application to function as expected. - */ - public function routing() { - if ( Input::exists( 'submit' ) && Forms::Check( 'installRouting' ) ) { - // if its Apache, attempt to generate the htaccess file before testing - if ( Check::isApache() ) { - if ( !$this->installer->checkHtaccess() ) { - if ( !$this->installer->saveHtaccess() ) { - Issues::add( 'error', 'There was an unexpected error when generating your htaccess file. Please see the error logs for more information.' ); - } - } - } - // Apache should have the htaccess now, and Nginx should have been configured this way out of the box - if ( Route::testRouting() ) { - Session::flash( 'success', 'Routing is working as expected.' ); - return $this->nextStep( 'models', true ); - } else { - Issues::add( 'error', 'Could not verify url routing' ); - } - // routing is busted, if its Apache, we already have the error from htaccess generation - // so Nginx is the only one that needs more info - if ( Check::isNginx() ) { - Issues::add( 'error', 'There appears to be an issue with your configuration. Certain urls are not being routed as expected.' ); - } - } elseif ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with your form.' => Check::userErrors()] ); - } - Views::view( 'install.routing' ); - } - - /** - * Since models are required for the proper function of the app, this step is required and has no selection to make. - * This step will install all the required models excluding resources. - */ - public function models() { - $errors = []; - $options = [ 'installResources' => false ]; - $models = $this->installer->getModelList( MODEL_DIRECTORY ); - if ( Input::exists( 'submit' ) && Forms::Check( 'installModels' ) ) { - $error = false; - foreach ( $models as $model ) { - $result = $this->installer->installModel( $model, $options ); - - if ( $result === false ) { - $error = true; - continue; - } - } - if ( $error ) { - Issues::add( 'error', [ 'There was an error with the Installation.' => $this->installer->getErrors() ] ); - } else { - Session::flash( 'success', [ 'Models Have been installed successfully.' => $this->installer->getErrors() ] ); - return $this->nextStep( 'plugins', true ); - } - } elseif ( Input::exists( 'submit' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - } - Views::view( 'install.models', $models ); - } - - /** - * This step will allow the user to install any plugins currently available for installing excluding resources. - */ - public function plugins() { - $errors = []; - $options = [ 'resources_installed' => false ]; - $plugins = $this->installer->getAvailablePlugins(); - $selected_plugins = Input::post( 'P_' ); - - if ( Input::exists( 'submit' ) && Forms::Check( 'installPlugins' ) ) { - $error = false; - foreach ( $plugins as $plugin ) { - if ( ! in_array( $plugin->name, $selected_plugins ) ) { - continue; - } - $result = $this->installer->installPlugin( $plugin, $options ); - - if ( !$result ) { - $error = true; - continue; - } - Plugin::enable( $plugin->name, true ); - } - if ( $error ) { - Issues::add( 'error', ['There was an error with the Installation.' => $this->installer->getErrors()] ); - } else { - Session::flash( 'success', [ 'Plugins Have been installed successfully.' => $this->installer->getErrors() ] ); - return $this->nextStep( 'resources', true ); - } - } elseif ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with your form.' => Check::userErrors()] ); - } - Views::view( 'install.plugins', $plugins ); - } - - /** - * The resource step will cycle through the partially installed models and install any missing resources. - */ - public function resources() { - $errors = []; - if ( Input::exists( 'submit' ) && Forms::Check( 'installResources' ) ) { - $error = false; - $allModules = $this->installer->getModules(true); - foreach ( $allModules as $name => $module ) { - if ( empty( $module ) || 'unknown' === $name || empty( $name ) || empty( $module['installedVersion'] ) ) { - continue; - } - - if ( 'plugin' == $module['type'] ) { - $installResult = $this->installer->installPlugin( (object) $module, [ 'resources_installed' => true ], false ); - } else { - $installResult = $this->installer->installModel( (object) $module, [ 'installResources' => true ], false ); - } - if ( !$installResult ) { - $error = true; - } - } - if ( $error ) { - Issues::add( 'error', ['There was an error with the Installation.' => $this->installer->getErrors()] ); - } else { - Session::flash( 'success', ['Resources have been installed successfully.' => $this->installer->getErrors()] ); - return $this->nextStep( 'user', true ); - } - } elseif ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with your form.' => Check::userErrors()] ); - } - Views::view( 'install.resources' ); - } - - /** - * This is the registration step; allowing the installer to create the super admin account. - */ - public function user() { - if ( Input::exists( 'submit' ) && Forms::Check( 'installAdminUser' ) ) { - $user = new User(); - if ( !$user->create( [ - 'username' => Input::post( 'newUsername' ), - 'password' => Hash::make( Input::post( 'userPassword' ) ), - 'email' => Input::post( 'userEmail' ), - 'lastLogin' => time(), - 'registered' => time(), - 'confirmed' => 1, - 'terms' => 1, - 'userGroup' => 1, - ] ) ) { - Issues::add( 'error', 'There was an error creating the admin user.' ); - return; - } - $this->nextStep( 'complete' ); - return $this->complete( true ); - } elseif ( Input::exists( 'submit' ) ) { - Issues::add( 'error', ['There was an error with your form.' => Check::userErrors()] ); - } - Views::view( 'install.adminUser' ); - } - - /** - * This is the final step of installation. On first load it will send an email and show the final view. - * It will then redirect to the index controller and prompt the user to delete this file on any subsequent loads. - * - * @param bool $sendEmail - */ - public function complete( $sendEmail = false ) { - if ( $sendEmail ) { - Issues::add( 'success', 'The Tempus Project has been installed successfully.' ); - Email::send( Input::post( 'email' ), 'install', null, [ 'template' => true ] ); - return Views::view( 'install.complete' ); - } - Session::flash( 'notice', 'Installation has been completed. Updates and installation can be managed in the admin panel. Please delete the install.php file.' ); - Redirect::to( 'home/index' ); - } -} - -$app = new TheTempusProject(); - -if ( CANARY_ENABLED ) { - // ini_set( 'display_errors', '1' ); - // ini_set( 'display_startup_errors', '1' ); - // error_reporting( E_ALL ); - // $app->printDebug(); -} - -$app->setUrl( 'install/index' ); -$app->load(); - -if ( CANARY_DEBUG_TO_CONSOLE ) { - Components::set( 'DEBUGGING_LOG', Debug::dump() ); - register_shutdown_function( [ $app::class, 'handle_shutdown' ] ); -} - -exit;