';
+ return Template::parse( $html );
+ }
+
public function convertFormToArray( $fillMissing = true, $defaultsOnly = true ) {
$prefsArray = [];
foreach ( self::$preferences as $name => $details ) {
diff --git a/app/config/constants.php b/app/config/constants.php
index 2f59171..2f1863c 100644
--- a/app/config/constants.php
+++ b/app/config/constants.php
@@ -38,7 +38,7 @@ if ( ! defined( 'CONFIG_DIRECTORY' ) ) {
# Tempus Debugger
define( 'CANARY_SECURE_HASH', 'd73ed7591a30f0ca7d686a0e780f0d05' );
# Tempus Project Core
-define( 'APP_NAME', 'All The Bookmarks');
+define( 'APP_NAME', 'The Tempus Project');
define( 'TP_DEFAULT_LOGO', 'images/logo.png');
// Check
define( 'MINIMUM_PHP_VERSION', 8.1);
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/api/login.php b/app/controllers/api/login.php
index 279a1cb..74536eb 100644
--- a/app/controllers/api/login.php
+++ b/app/controllers/api/login.php
@@ -27,15 +27,14 @@ class Login extends ApiController {
parent::__construct( false );
self::$tokens = new Token;
self::$user = new User;
- // Template::addHeader( 'Access-Control-Allow-Origin: *' );
- // Template::addHeader( 'Content-Type: application/json; charset=utf-8' );
+ Template::addHeader( 'Access-Control-Allow-Origin: *' );
+ Template::addHeader( 'Content-Type: application/json; charset=utf-8' );
}
public function index() {
- header('Access-Control-Allow-Origin: *');
- if ( !Forms::check( 'apiLogin' ) ) {
+ if ( ! Forms::check( 'apiLogin' ) ) {
$responseType = 'error';
- $response = 'malformed input1';
+ $response = 'malformed input';
return Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]);
}
$user = self::$user->authorize( Input::post( 'username' ), Input::post( 'password' ) );
@@ -45,7 +44,7 @@ class Login extends ApiController {
return Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]);
}
$responseType = 'token';
- $token = self::$tokens->findOrCreateUserToken( $user->ID );
+ $token = self::$tokens->findOrCreateUserToken( $user->ID, true );
return Views::view( 'api.response', ['response' => json_encode( [ $responseType => $token ], true )]);
}
}
\ No newline at end of file
diff --git a/app/controllers/home.php b/app/controllers/home.php
index daf116d..fe71cbc 100644
--- a/app/controllers/home.php
+++ b/app/controllers/home.php
@@ -27,13 +27,13 @@ use TheTempusProject\TheTempusProject as App;
class Home extends Controller {
public function index() {
self::$title = '{SITENAME}';
- self::$pageDescription = 'This is the homepage of your new Tempus Project Installation. Thank you for installing. find more info at https://thetempusproject.com';
+ self::$pageDescription = '{SITENAME} is here to provide you a better, faster, and easier - way to create and manage your own web applications.';
Views::view( 'index' );
}
public function login() {
self::$title = 'Portal - {SITENAME}';
- self::$pageDescription = 'Please log in to use {SITENAME} member features.';
+ self::$pageDescription = 'Please log in to access all of the great features {SITENAME} has to offer.';
if ( App::$isLoggedIn ) {
return Issues::add( 'notice', 'You are already logged in. Please click here to log out.' );
}
@@ -69,7 +69,7 @@ class Home extends Controller {
public function profile( $id = null ) {
self::$title = 'User Profile - {SITENAME}';
- self::$pageDescription = 'User Profiles for {SITENAME}';
+ self::$pageDescription = 'User Profile - {SITENAME}';
if ( !App::$isLoggedIn ) {
return Issues::add( 'notice', 'You must be logged in to view this page.' );
}
@@ -89,38 +89,28 @@ class Home extends Controller {
Views::view( 'termsPage' );
}
- public function hashtag( $id = null ) {
- self::$title = 'HashTag - {SITENAME}';
- self::$pageDescription = 'HashTags for {SITENAME}';
- if ( !App::$isLoggedIn ) {
- return Issues::add( 'notice', 'You must be logged in to view this page.' );
- }
- // this should look up comments and blog posts with the hashtag in them
- Views::view( 'hashtags' );
- }
-
public function about() {
self::$title = 'About - {SITENAME}';
- self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
+ self::$pageDescription = '{SITENAME} was started by a developer with years of industry experience which has lead to a refined no-nonsense tool for everyone. Find out more about us here.';
Views::view( 'about' );
}
public function contact() {
self::$title = 'Contact Us - {SITENAME}';
- self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
+ self::$pageDescription = 'On this page, you\'ll be able to reach out to the team directly with any questions, comments, or concerns you may have.';
Views::view( 'contact' );
}
public function privacy() {
self::$title = 'Privacy Policy - {SITENAME}';
- self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
+ self::$pageDescription = 'At {SITENAME} you privacy is very important to us. On this page you can find a detailed outline of all the information we collect and how its used.';
Components::set( 'PRIVACY', Views::simpleView( 'privacy' ) );
Views::raw( '
{PRIVACY}
' );
}
public function faq() {
self::$title = 'Frequently Asked Questions - {SITENAME}';
- self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
+ self::$pageDescription = 'Many times, we aren\'t the first to ask why or how something works. Here you will find a list of {SITENAME} commonly asked questions and our best answers.' ;
Views::view( 'faq' );
}
}
diff --git a/app/controllers/register.php b/app/controllers/register.php
index f07cb19..275fdc2 100644
--- a/app/controllers/register.php
+++ b/app/controllers/register.php
@@ -27,6 +27,7 @@ use TheTempusProject\Classes\Forms;
class Register extends Controller {
public function confirm( $code = null ) {
+ Template::noIndex();
self::$title = 'Confirm Email';
if ( !isset( $code ) && !Input::exists( 'confirmationCode' ) ) {
return Views::view( 'confirmation' );
@@ -43,8 +44,8 @@ class Register extends Controller {
}
public function index() {
- self::$title = 'Register';
- self::$pageDescription = 'Many features of the site are disabled or even hidden from unregistered users. On this page you can sign up for an account to access all the app has to offer.';
+ self::$title = '{SITENAME} Sign Up';
+ self::$pageDescription = 'Many features of {SITENAME} are disabled or hidden from unregistered users. On this page you can sign up for an account to access all the app has to offer.';
Components::set( 'TERMS', Views::simpleView( 'terms' ) );
if ( App::$isLoggedIn ) {
return Issues::add( 'notice', 'You are currently logged in.' );
@@ -94,6 +95,7 @@ class Register extends Controller {
public function resend() {
self::$title = 'Resend Confirmation';
+ Template::noIndex();
if ( !App::$isLoggedIn ) {
return Issues::add( 'notice', 'Please log in to resend your confirmation email.' );
}
@@ -110,6 +112,7 @@ class Register extends Controller {
public function reset( $code = null ) {
self::$title = 'Password Reset';
+ Template::noIndex();
if ( !isset( $code ) && !Input::exists( 'resetCode' ) ) {
Issues::add( 'info', 'Please provide a reset code.' );
return Views::view( 'password_reset_code' );
diff --git a/app/controllers/usercp.php b/app/controllers/usercp.php
index 55f7c58..c0b13cf 100644
--- a/app/controllers/usercp.php
+++ b/app/controllers/usercp.php
@@ -36,12 +36,12 @@ class Usercp extends Controller {
Redirect::home();
}
Template::noIndex();
- $menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
- Navigation::activePageSelect( $menu, null, true, true );
}
public function email() {
self::$title = 'Email Settings';
+ $menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
+ Navigation::activePageSelect( $menu, null, true, true );
if ( App::$activeUser->confirmed != '1' ) {
return Issues::add( 'notice', 'You need to confirm your email address before you can make modifications. If you would like to resend that confirmation link, please click here', true );
}
@@ -68,11 +68,15 @@ class Usercp extends Controller {
public function index() {
self::$title = 'User Control Panel';
+ $menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
+ Navigation::activePageSelect( $menu, null, true, true );
Views::view( 'profile', App::$activeUser );
}
public function password() {
self::$title = 'Password Settings';
+ $menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
+ Navigation::activePageSelect( $menu, null, true, true );
if ( !Input::exists() ) {
return Views::view( 'user_cp.password_change' );
}
@@ -94,11 +98,12 @@ class Usercp extends Controller {
public function settings() {
self::$title = 'Preferences';
+ $menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
+ Navigation::activePageSelect( $menu, null, true, true );
$prefs = new Preferences;
$fields = App::$activePrefs;
if ( Input::exists( 'submit' ) ) {
$fields = $prefs->convertFormToArray( true, false );
- // dv( $fields );
// @TODO now i may need to rework the form checker to work with this....
// if (!Forms::check('userPrefs')) {
// Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
@@ -110,4 +115,39 @@ class Usercp extends Controller {
Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) );
Views::view( 'user_cp.settings', App::$activeUser );
}
+
+ public function updatePref() {
+ Template::setTemplate( 'api' );
+ if ( ! App::$isLoggedIn ) {
+ return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Not Logged In' ], true )]);
+ }
+ if ( ! Forms::check( 'updatePreference' ) ) {
+ return Views::view( 'api.response', ['response' => json_encode( [ 'error' => Check::userErrors() ], true )]);
+ }
+ $name = Input::post( 'prefName' );
+ $value = Input::post('prefValue' );
+
+ if ( 'false' === $value ) {
+ $value = false;
+ } elseif ( 'true' === $value ) {
+ $value = true;
+ }
+
+ if ( empty( Preferences::get( $name ) ) ) {
+ return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Unknown Preference' ], true )]);
+ }
+
+ $prefs = new Preferences;
+ $fields1 = $prefs->convertFormToArray( true, false );
+ $fields2 = [];
+ $fields3 = $fields1;
+
+ if ( isset( $fields1[ $name ] ) ) {
+ $fields2[ $name ] = $value;
+ $fields3[ $name ] = $value;
+ }
+ $result = self::$user->updatePrefs( $fields3, App::$activeUser->ID );
+
+ return Views::view( 'api.response', ['response' => json_encode( $result, true )]);
+ }
}
diff --git a/app/css/main-dark.css b/app/css/main-dark.css
index 226a12b..ce195ba 100644
--- a/app/css/main-dark.css
+++ b/app/css/main-dark.css
@@ -135,3 +135,16 @@ body {
.text-shadow-3 {
text-shadow: 0 .5rem 1.5rem rgba(255, 255, 255, .25);
}
+
+.form-control {
+ background-color: #1f1f1f;
+ color: #e0e0e0;
+}
+.form-control:focus {
+ color: #e0e0e0;
+ /* border-color: #85bd3e; */
+ border-color: #1b947f;
+ background-color: #1f1f1f;
+ /* box-shadow: 0 0 0 .25rem #1b947f; */
+ box-shadow: 0 0 0 .25rem #85bd3e;
+}
\ No newline at end of file
diff --git a/app/css/main.css b/app/css/main.css
index 7f64ee8..c05624d 100644
--- a/app/css/main.css
+++ b/app/css/main.css
@@ -92,8 +92,10 @@ html {
pre {
white-space: pre-wrap;
}
+
body {
- background-image: linear-gradient(180deg, #eee, #fff 100px, #fff);
+ background-color: #e4e4e4;
+ /* background-image: linear-gradient(180deg, #eee, #fff 100px, #fff); */
}
@media ( min-width: 768px ) {
.main {
diff --git a/app/images/ttp.png b/app/images/ttp.png
index 2ad7269..ebb70f8 100644
Binary files a/app/images/ttp.png and b/app/images/ttp.png differ
diff --git a/app/js/main.js b/app/js/main.js
index 5b38519..3173ece 100644
--- a/app/js/main.js
+++ b/app/js/main.js
@@ -119,35 +119,46 @@ document.addEventListener('DOMContentLoaded', function () {
if ( enableButton ) {
enableButton.addEventListener('click', function () {
- if (darkModeStylesheet.disabled) {
- darkModeStylesheet.disabled = false;
- localStorage.setItem('darkMode', 'enabled');
- enableButton.innerText = 'Disable Now';
- } else {
- darkModeStylesheet.disabled = true;
- localStorage.setItem('darkMode', 'disabled');
- enableButton.innerText = 'Enable Now';
- }
+ if (darkModeStylesheet.disabled) {
+ darkModeStylesheet.disabled = false;
+ localStorage.setItem('darkMode', 'enabled');
+ enableButton.innerText = 'Disable Now';
+ } else {
+ darkModeStylesheet.disabled = true;
+ localStorage.setItem('darkMode', 'disabled');
+ enableButton.innerText = 'Enable Now';
+ }
});
}
toggleButton.addEventListener('click', function () {
- if (darkModeStylesheet.disabled) {
- darkModeStylesheet.disabled = false;
- localStorage.setItem('darkMode', 'enabled');
- } else {
- darkModeStylesheet.disabled = true;
- localStorage.setItem('darkMode', 'disabled');
- }
-
- document.querySelectorAll('.table-striped').forEach((table) => {
- if (localStorage.getItem('darkMode') === 'enabled') {
- table.classList.add('table-dark');
- table.classList.remove('table-light');
+ if (darkModeStylesheet.disabled) {
+ toggleDarkModePref( true );
+ darkModeStylesheet.disabled = false;
+ localStorage.setItem('darkMode', 'enabled');
} else {
- table.classList.add('table-light');
- table.classList.remove('table-dark');
+ toggleDarkModePref( false );
+ darkModeStylesheet.disabled = true;
+ localStorage.setItem('darkMode', 'disabled');
}
+
+ document.querySelectorAll('.table-striped').forEach((table) => {
+ if (localStorage.getItem('darkMode') === 'enabled') {
+ table.classList.add('table-dark');
+ table.classList.remove('table-light');
+ } else {
+ table.classList.add('table-light');
+ table.classList.remove('table-dark');
+ }
+ });
});
- });
+
+ function toggleDarkModePref( value ) {
+ var fields = {};
+ fields.prefName = 'darkMode';
+ fields.prefValue = value;
+ $.post( '/usercp/updatePref', fields ).done(function(response) {
+ // alert('Timer updated successfully!');
+ });
+ }
});
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/models/token.php b/app/models/token.php
index 167e961..fe9198a 100644
--- a/app/models/token.php
+++ b/app/models/token.php
@@ -94,10 +94,15 @@ class Token extends DatabaseModel {
return false;
}
- public function findOrCreateUserToken( $user_id ) {
+ public function findOrCreateUserToken( $user_id, $refresh = false ) {
$test = $this->findUserToken( $user_id );
if ( ! empty( $test ) ) {
- return $test->token;
+ if ( ! empty( $refresh ) ) {
+ $token = $this->refresh( $test->ID, 'user' );
+ } else {
+ $token = $test->token;
+ }
+ return $token;
}
$expiration = Config::getValue( 'api/UserAccessTokenExpiration' );
diff --git a/app/models/user.php b/app/models/user.php
index 5eb8a38..62012fa 100644
--- a/app/models/user.php
+++ b/app/models/user.php
@@ -121,6 +121,11 @@ class User extends DatabaseModel {
'50',
],
],
+ 'darkMode' => [
+ 'pretty' => 'Enable Dark-Mode viewing',
+ 'type' => 'checkbox',
+ 'default' => 'false',
+ ],
];
protected static $avatars;
protected static $preferences;
diff --git a/app/plugins/blog/models/posts.php b/app/plugins/blog/models/posts.php
index 471f51d..7a4e158 100644
--- a/app/plugins/blog/models/posts.php
+++ b/app/plugins/blog/models/posts.php
@@ -131,34 +131,34 @@ class Posts extends DatabaseModel {
}
$draft = '';
$authorName = self::$user->getUsername( $instance->author );
+
$cleanPost = Sanitize::contentShort( $instance->content );
- $postSpace = explode( ' ', $cleanPost );
+ $wordsArray = explode( ' ', $cleanPost );
$postLine = explode( "\n", $cleanPost );
- // summary by words: 100
- $spaceSummary = implode( ' ', array_splice( $postSpace, 0, 100 ) );
- // summary by lines: 5
+ $spaceSummary = implode( ' ', array_splice( $wordsArray, 0, 100 ) );
$lineSummary = implode( "\n", array_splice( $postLine, 0, 5 ) );
if ( strlen( $spaceSummary ) < strlen( $lineSummary ) ) {
+ $contentSummaryNoLink = $spaceSummary;
$contentSummary = $spaceSummary;
- if ( count( $postSpace, 1 ) <= 100 ) {
+ if ( count( $wordsArray, 1 ) >= 100 ) {
$contentSummaryNoLink = $contentSummary;
- $contentSummary .= '... Read More';
+ $contentSummary .= '... Read More';
}
} else {
- // @todo: need to refine this after testing
$contentSummaryNoLink = $lineSummary;
- $contentSummary = $lineSummary . '... Read More';
+ $contentSummary = $lineSummary . '... Read More';
+ }
+ $instance->contentSummaryNoLink = $contentSummaryNoLink;
+ $instance->contentSummary = $contentSummary;
+
+ if ( isset( $params['stripHtml'] ) && $params['stripHtml'] === true ) {
+ $instance->contentSummary = strip_tags( $instance->content );
}
if ( $instance->draft != '0' ) {
$draft = ' Draft';
}
$instance->isDraft = $draft;
$instance->authorName = $authorName;
- $instance->contentSummaryNoLink = $contentSummaryNoLink;
- $instance->contentSummary = $contentSummary;
- if ( isset( $params['stripHtml'] ) && $params['stripHtml'] === true ) {
- $instance->contentSummary = strip_tags( $instance->content );
- }
if ( self::$comments !== false ) {
$instance->commentCount = self::$comments->count( 'blog', $instance->ID );
}
diff --git a/app/plugins/blog/views/list.html b/app/plugins/blog/views/list.html
index a924026..0a42697 100644
--- a/app/plugins/blog/views/list.html
+++ b/app/plugins/blog/views/list.html
@@ -1,7 +1,7 @@
{LOOP}
\ No newline at end of file
diff --git a/app/plugins/blog/views/sidebar2.html b/app/plugins/blog/views/sidebar2.html
index b135d93..d64ac19 100644
--- a/app/plugins/blog/views/sidebar2.html
+++ b/app/plugins/blog/views/sidebar2.html
@@ -2,7 +2,7 @@
Thank you for visiting our bug reporting page. We value our users' input highly and in an effort to better serve your needs, please fill out the form below to help us address this issue.
We read each and every bug report submitted, and by submitting this form you allow us to send you a follow-up email.