Added cookie sessions and changed error pages location.

main
Robert 3 years ago
parent 7c402571ab
commit 9b495f254f
  1. 137
      src/configs/ex/loadall.php
  2. 3
      src/configs/ex/on_tts.php
  3. 3
      src/configs/live/on_tts.php
  4. 162
      src/configs/mockup/loadall.php
  5. 9
      src/ex/inputs/app/home_in.php
  6. 39
      src/mockup/controllers/app/cookie_ctrl.php
  7. 2
      src/mockup/controllers/app/home_ctrl.php
  8. 60
      src/mockup/views/on_error/404_page.php
  9. 31
      src/mockup/views/on_error/dev_error.php
  10. 48
      src/mockup/views/on_error/prod_error.php

@ -2,74 +2,71 @@
/* /*
* This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration! * This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration!
*/ */
/* Contents of : on_email.php */ /* Contents of : on_email.php */
\main_tts\configure::set('email', array( \main_tts\configure::set('email', array(
// 'host' => '', // SMTP Hosts - seperated by ; // 'host' => '', // SMTP Hosts - seperated by ;
// 'username' => '', // 'username' => '',
// 'password' => '', // 'password' => '',
'send_emails' => false, // Enable emails 'send_emails' => false, // Enable emails
'email_on_errors' => false, 'email_on_errors' => false,
'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localost'), // Email Admins on error 'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localost'), // Email Admins on error
)); ));
/* Contents of : on_html.php */ /* Contents of : on_html.php */
\main_tts\configure::set('html', array( \main_tts\configure::set('html', array(
'author' => 'Robert Strutts', 'author' => 'Robert Strutts',
'title' => 'In Example Project...', 'title' => 'In Example Project...',
'javascript' => array('js/error_handler.js'=>'tts', 'js/store.js'=>'tts'), //'js/analytics.js'=>'project' 'javascript' => array('js/error_handler.js'=>'tts', 'js/store.js'=>'tts'), //'js/analytics.js'=>'project'
'robots' => 'noindex', 'robots' => 'noindex',
'keywords' => '', 'keywords' => '',
'description' => '', 'description' => '',
)); ));
/* Contents of : on_http_request.php */ /* Contents of : on_http_request.php */
\main_tts\configure::set('http_request', array( \main_tts\configure::set('http_request', array(
'use' => 'sockets', // curl or sockets 'use' => 'sockets', // curl or sockets
)); ));
/* Contents of : on_security.php */ /* Contents of : on_security.php */
\main_tts\configure::set('security', array( \main_tts\configure::set('security', array(
'show_dumps' => true, 'show_dumps' => true,
'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==',
'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1',
'csrf_security_level' => 'high', // Stop Attacks at what cost?? 'csrf_security_level' => 'high', // Stop Attacks at what cost??
'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it... 'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it...
'throttling_login_seconds' => 20, // Seconds to deny more login attempts 'throttling_login_seconds' => 20, // Seconds to deny more login attempts
'password_hash' => PASSWORD_BCRYPT, 'password_hash' => PASSWORD_BCRYPT,
'password_hash_options' => ['cost' => 10], // Default=10. This is a good baseline cost, but you may want to consider increasing it depending on your hardware. 'password_hash_options' => ['cost' => 10], // Default=10. This is a good baseline cost, but you may want to consider increasing it depending on your hardware.
)); ));
/* Contents of : on_sessions.php */ /* Contents of : on_sessions.php */
\main_tts\configure::set('sessions', array( \main_tts\configure::set('sessions', array(
'engine' => 'php', // php, db 'engine' => 'php', // php, db
'type' => 'none', // Session Type: files, database, or cache 'type' => 'none', // Session Type: files, database, or cache
'session_variable' => 'ses_app_aaa_', // set session variable name for project 'session_variable' => 'ses_app_aaa_', // set session variable name for project
'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID 'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID
'session_table' => false, // DB PHP Session Table name, false = USE FILES 'session_table' => false, // DB PHP Session Table name, false = USE FILES
'session_security_level' => 'blaze', // Faster Reqests keep at: blaze 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze
'session_key' => '6cb0d56f2345917624f2c5473e4d32cd', 'session_key' => '6cb0d56f2345917624f2c5473e4d32cd',
)); ));
/* Contents of : on_tts.php */ /* Contents of : on_tts.php */
\main_tts\configure::set_key('important', 'private_ip_as_local', false); \main_tts\configure::set_key('important', 'private_ip_as_local', false);
\main_tts\configure::set('tts', array( \main_tts\configure::set('tts', array(
'error_page' => 'tts', // or project 'site_name' => 'Testing',
'404_page' => 'tts', // or project 'short_url' => true,
'ui_kit' => 'tts', // or project 'default_project' => 'home',
'site_name' => 'Testing', 'check_HTML_tags' => true,
'short_url' => true, 'live' => false, //(! \tts\security::is_localhost() ) // Is this Production??
'default_project' => 'home', ));
'check_HTML_tags' => true,
'live' => false, //(! \tts\security::is_localhost() ) // Is this Production?? /* Contents of : on_view_mode.php */
));
\main_tts\configure::set('view_mode', array(
/* Contents of : on_view_mode.php */ 'default_paths' => array('json', 'common', 'flexbox', 'default')
\main_tts\configure::set('view_mode', array(
'default_paths' => array('json', 'common', 'flexbox', 'default')
)); ));

@ -3,9 +3,6 @@
\main_tts\configure::set_key('important', 'private_ip_as_local', false); \main_tts\configure::set_key('important', 'private_ip_as_local', false);
\main_tts\configure::set('tts', array( \main_tts\configure::set('tts', array(
'error_page' => 'tts', // or project
'404_page' => 'tts', // or project
'ui_kit' => 'tts', // or project
'site_name' => 'Testing', 'site_name' => 'Testing',
'short_url' => true, 'short_url' => true,
'default_project' => 'home', 'default_project' => 'home',

@ -5,9 +5,6 @@ declare(strict_types=1);
//\main_tts\configure::update('important', 'private_ip_as_local', true); //\main_tts\configure::update('important', 'private_ip_as_local', true);
\main_tts\configure::set('tts', array( \main_tts\configure::set('tts', array(
'error_page' => 'tts', // or project
'404_page' => 'tts', // or project
'ui_kit' => 'tts', // or project
'site_name' => 'My_Site_NAME_HERE', 'site_name' => 'My_Site_NAME_HERE',
'short_url' => true, 'short_url' => true,
'default_project' => 'home', 'default_project' => 'home',

@ -3,85 +3,85 @@
/* /*
* This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration! * This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration!
*/ */
/* Contents of : on_email.php */ /* Contents of : on_email.php */
\main_tts\configure::set('email', array( \main_tts\configure::set('email', array(
// 'host' => '', // SMTP Hosts - seperated by ; // 'host' => '', // SMTP Hosts - seperated by ;
// 'username' => '', // 'username' => '',
// 'password' => '', // 'password' => '',
'send_emails' => false, // Enable emails 'send_emails' => false, // Enable emails
'email_on_errors' => false, 'email_on_errors' => false,
'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localhost'), // Email Admins on error 'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localhost'), // Email Admins on error
)); ));
/* Contents of : on_html.php */ /* Contents of : on_html.php */
\main_tts\configure::set('html', array( \main_tts\configure::set('html', array(
'title' => 'In Mockup...', 'title' => 'In Mockup...',
'author' => 'Robert Strutts', 'author' => 'Robert Strutts',
'javascript' => array('js/tts.min.js'=>'assets'), //'js/analytics.js'=>'project' 'javascript' => array('js/tts.min.js'=>'assets'), //'js/analytics.js'=>'project'
'css' => array('css/style.css'=>'project'), 'css' => array('css/style.css'=>'project'),
'robots' => 'noindex', 'robots' => 'noindex',
'keywords' => '', 'keywords' => '',
'description' => '', 'description' => '',
)); ));
/* Contents of : on_http_request.php */ /* Contents of : on_http_request.php */
\main_tts\configure::set('http_request', array( \main_tts\configure::set('http_request', array(
'use' => 'sockets', // curl or sockets 'use' => 'sockets', // curl or sockets
)); ));
/* Contents of : on_security.php */ /* Contents of : on_security.php */
\main_tts\configure::set('security', array( \main_tts\configure::set('security', array(
'show_dumps' => true, 'show_dumps' => true,
'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==',
'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1',
'csrf_security_level' => 'high', // Stop Attacks at what cost?? 'csrf_security_level' => 'high', // Stop Attacks at what cost??
'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it... 'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it...
'throttling_login_seconds' => 20, // Seconds to deny more login attempts 'throttling_login_seconds' => 20, // Seconds to deny more login attempts
'pepper_pwd' => 'SZFJXX]7HcwJjS]av3q8cUR', 'pepper_pwd' => 'SZFJXX]7HcwJjS]av3q8cUR',
'salt_pwd' => 'fVN(P8nBNK3;tM88Kkku', 'salt_pwd' => 'fVN(P8nBNK3;tM88Kkku',
)); ));
/* Contents of : on_sessions.php */ /* Contents of : on_sessions.php */
\main_tts\configure::set('sessions', array( \main_tts\configure::set('sessions', array(
'engine' => 'php', // php, db 'engine' => 'php', // php, db
'type' => 'none', // Session Type: files, database, or cache 'type' => 'none', // Session Type: files, database, or cache
'session_variable' => 'ses_app_aaa_', // set session variable name for project 'session_variable' => 'ses_app_aaa_', // set session variable name for project
'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID 'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID
'session_table' => false, // DB PHP Session Table name, false = USE FILES 'session_table' => false, // DB PHP Session Table name, false = USE FILES
'session_security_level' => 'blaze', // Faster Reqests keep at: blaze 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze
'session_key' => '6cb0d56f2345917624f2c5473e4d32cd', 'session_key' => '6cb0d56f2345917624f2c5473e4d32cd',
)); ));
/* Contents of : on_tts.php */ /* Contents of : on_tts.php */
/** /**
* @todo REMOVE or CHANGE [set_local_site_domains] to your * @todo REMOVE or CHANGE [set_local_site_domains] to your
* PRIVATE or non-public accessible site domain name. * PRIVATE or non-public accessible site domain name.
* *
* Make sure the web-server only servers it on a * Make sure the web-server only servers it on a
* loop-back or non-routable IP address range, * loop-back or non-routable IP address range,
* otherwise people will be able to see lots of * otherwise people will be able to see lots of
* private DEBUG info. Also, make sure your HOST file has an * private DEBUG info. Also, make sure your HOST file has an
* entry to your web server's IP IG: 127.0.0.1 tts.home.local * entry to your web server's IP IG: 127.0.0.1 tts.home.local
* *
* When in Doubt, just make live false, below here!!! * When in Doubt, just make live false, below here!!!
*/ */
\bs_tts\site_helper::set_local_site_domains('tts.home.local'); \bs_tts\site_helper::set_local_site_domains('tts.home.local');
// \bs_tts\site_helper::set_allowed_Private_IPs(['192.168.32.2', '192.168.32.3']); // \bs_tts\site_helper::set_allowed_Private_IPs(['192.168.32.2', '192.168.32.3']);
// \bs_tts\site_helper::set_allowed_Public_IPs('12.x.x.x'); // \bs_tts\site_helper::set_allowed_Public_IPs('12.x.x.x');
\main_tts\configure::set('tts', array( \main_tts\configure::set('tts', array(
'site_name' => 'Testing', 'site_name' => 'Testing',
'short_url' => true, 'short_url' => true,
'default_project' => 'home', 'default_project' => 'home',
'check_HTML_tags' => true, 'check_HTML_tags' => true,
'live' => (\bs_tts\site_helper::remote_not_allowed_force_live()), 'live' => (\bs_tts\site_helper::remote_not_allowed_force_live()),
)); ));
/* Contents of : on_view_mode.php */ /* Contents of : on_view_mode.php */
\main_tts\configure::set('view_mode', array( \main_tts\configure::set('view_mode', array(
'default_paths' => array('json', 'common', 'flexbox', 'default') 'default_paths' => array('json', 'common', 'flexbox', 'default')
)); ));

@ -4,10 +4,11 @@ declare(strict_types=1);
namespace prj\ex\inputs\app; namespace prj\ex\inputs\app;
use \bs_tts\INPUTS; use \tts\enum\INPUTS;
use \bs_tts\FIELD_FILTER; use \tts\enum\FIELD_FILTER;
use \bs_tts\HTML_FLAG; use \tts\enum\HTML_FLAG;
use \bs_tts\DB_FILTER; use \tts\enum\DB_FILTER;
use \bs_tts\use_io as IO; use \bs_tts\use_io as IO;
class home_in { class home_in {

@ -0,0 +1,39 @@
<?php
declare(strict_types = 1);
/**
* @author Robert Strutts <Robert@TryingToScale.com>
* @copyright Copyright (c) 2022, Robert Strutts.
* @license https://mit-license.org/
*/
namespace prj\mockup\controllers\app;
/**
* Description of cookie_ctrl
*
* @author Robert Strutts <Robert@TryingToScale.com>
*/
class cookie_ctrl {
public function __construct() {
$key = "78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2";
$sc = new \tts\services\paragon_crypto\sodium_storage($key);
$handler = new \tts\services\sessions\cookie_sessions($sc);
session_set_save_handler($handler, true);
session_start();
}
public function save() {
$_SESSION['admin'] = "Bob";
$_SESSION['logged_in'] = true;
}
public function read() {
var_dump($_SESSION);
// var_dump($_SESSION['admin'] ?? "");
}
}

@ -29,7 +29,7 @@ class home_ctrl {
$view->render($this); $view->render($this);
} }
public function name_demo_post() { public function name_demo_post() {
$view = new \tts\view(); $view = new \tts\view();
$view->set('html', new \tts\html_document()); $view->set('html', new \tts\html_document());
$view->set('output', IOL::auto_wire("app", "home", "name_demo")); $view->set('output', IOL::auto_wire("app", "home", "name_demo"));

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Robert@TryingToScale.com>
* @copyright Copyright (c) 2022, Robert Strutts.
* @license https://mit-license.org/
*/
$protocol = "HTTP/1.0";
if ( "HTTP/1.1" == $_SERVER["SERVER_PROTOCOL"] ) {
$protocol = "HTTP/1.1";
}
header( "{$protocol} 404 Not Found", true, 404 );
header('Content-type: text/html; charset=utf-8');
if (defined("PROJECT_ASSETS_BASE_REF")) {
$base_ref = PROJECT_ASSETS_BASE_REF;
} else {
$base_ref = "";
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="<?= $base_ref ?>/">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="language" content="english">
<meta name="robots" content="no-follow">
<link rel="shortcut icon" href="<?= $base_ref ?>/favicon/favicon.ico">
<title>404 Page not found!</title>
<style>
@media only screen and (max-width: 600px) {
#nopage {
height: 150px;
width: 300px;
}
}
@media only screen and (min-width: 600px) {
#nopage {
height: 500px;
width: 1500px;
}
}
</style>
</head>
<body>
<div id="wrap">
<?php
$assets = \bs_tts\site_helper::get_asset("images/404page.jpg");
?>
<img src="<?= $assets ?>/images/404page.jpg" alt="Page not found." id="nopage"/>
<header><h1>404 Page not found!<h1></header>
<h3>Our apologies for the temporary inconvenience.</h3>
</div>
</body>
</html>
<?php
exit;

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
if (defined("PROJECT_ASSETS_BASE_REF")) {
$base_ref = PROJECT_ASSETS_BASE_REF;
} else {
$base_ref = "";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="<?= $base_ref ?>/">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="Robert Strutts">
<meta name="language" content="english">
<meta name="robots" content="">
<meta name="copyright" content="2014-<?= date('Y'); ?>">
<title>DEV ERROR!</title>
<link rel="shortcut icon" href="<?= $base_ref ?>/favicon/favicon.ico">
</head>
<body id="my-page">
<div id="wrap">
<div id="autosavemessage"></div>
<?= $local->page_output; ?>
</div> <!-- end wrap -->
</body>
</html>

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Robert@TryingToScale.com>
* @copyright Copyright (c) 2022, Robert Strutts.
* @license https://mit-license.org/
*/
define('PRODUCTION', 600);
define('MAINTENACE', 3600); // 1 hour = 3600 seconds
define('RETRY_AFTER', PRODUCTION);
if(! headers_sent()) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: ' . RETRY_AFTER);
}
if (defined("PROJECT_ASSETS_BASE_REF")) {
$base_ref = PROJECT_ASSETS_BASE_REF;
} else {
$base_ref = "";
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="<?= $base_ref ?>/">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Robert Strutts">
<meta name="language" content="english">
<meta name="robots" content="NOINDEX, NOFOLLOW">
<meta name="copyright" content="2014-<?php echo date('Y'); ?>">
<link rel="shortcut icon" href="<?= $base_ref ?>/favicon/favicon.ico">
<title>Sorry, we had an error...</title>
<style>
body { padding: 20px; background: #C00; color: white; font-size: 40px; }
</style>
</head>
<body>
<h1>Sorry, we had an error...</h1>
<p>We apologize for any inconvenience this may cause.<p>
</body>
</html>
<?php exit;
Loading…
Cancel
Save