Skip to content

Commit

Permalink
Merge branch 'CSS_FIX'
Browse files Browse the repository at this point in the history
# Conflicts:
#	public/css/admin.css
#	public/themes/default_admin/green/admin.php
  • Loading branch information
trongate committed Mar 23, 2021
2 parents 9d7ca81 + bc98ba7 commit 12d0ac5
Show file tree
Hide file tree
Showing 57 changed files with 2,044 additions and 2,401 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
PLEASE GIVE THE TRONGATE FRAMEWORK
A STAR ON GITHUB. IT'S ALL I ASK. (David)

GitHub URL:
https://github.com/davidjconnelly/trongate-framework


~ Together, we SHALL make PHP great again! ~
Every time somebody gives the Trongate framework a star on Github, middle managers and self appointed PHP aficionados start crying like babies. Do something amazing today. Give Trongate a star on GitHub and together we SHALL make PHP great again! https://github.com/davidjconnelly/trongate-framework
17 changes: 16 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
<?php
/*
*** PLEASE GIVE TRONGATE A STAR ON GITHUB ***
https://github.com/davidjconnelly/trongate-framework
Trongate is on a mission to keep the doors of web development
open! Please do something amazing and give the Trongate
Framework a star on GitHub. Here's a YouTube video
explaining why this is so important:
https://youtu.be/e8ZLCE4h_aA
Thank you! Together, we SHALL make PHP great again!
-DC
*/

//The main config file
define('BASE_URL', 'http://localhost/tg-pre-launch-test/');
define('ENV', 'dev');
define('ENV', 'live');
define('DEFAULT_MODULE', 'welcome');
define('DEFAULT_CONTROLLER', 'Welcome');
define('DEFAULT_METHOD', 'index');
Expand Down
4 changes: 2 additions & 2 deletions config/custom_routing.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$routes = [
'tg-admin/logout' => 'tg_administrators/logout',
'tg-admin' => 'tg_administrators/manage'
'tg-admin/logout' => 'trongate_administrators/logout',
'tg-admin' => 'trongate_administrators/manage'
];
define('CUSTOM_ROUTES', $routes);
2 changes: 1 addition & 1 deletion config/themes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$admin_theme = [
"dir" => "default_admin/green",
"dir" => "default_admin/blue",
"template" => "admin.php",
];

Expand Down
20 changes: 10 additions & 10 deletions engine/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ function _extract_connective($where_left_side) {
function submit_bypass_auth() {
$post = file_get_contents('php://input');
$decoded = json_decode($post, true);
$this->module('tg_tokens');
$this->tg_tokens->_attempt_generate_bypass_token();
$this->module('trongate_tokens');
$this->trongate_tokens->_attempt_generate_bypass_token();
}

function _not_allowed_msg() {
Expand All @@ -180,10 +180,10 @@ function _not_allowed_msg() {

function _validate_token($token_validation_data) {

$this->module('tg_tokens');
$this->module('trongate_tokens');

extract($token_validation_data);
$endpoint_auth_rules = $this->tg_tokens->_fetch_endpoint_auth_rules($endpoint, $module_endpoints);
$endpoint_auth_rules = $this->trongate_tokens->_fetch_endpoint_auth_rules($endpoint, $module_endpoints);
$authorization_rules = $endpoint_auth_rules['authorization_rules'];

if (!isset($_SERVER['HTTP_TRONGATETOKEN'])) {
Expand All @@ -199,7 +199,7 @@ function _validate_token($token_validation_data) {

$token_validation_data['token'] = $token;
$token_validation_data['authorization_rules'] = $authorization_rules;
$valid = $this->tg_tokens->_is_token_valid($token_validation_data);
$valid = $this->trongate_tokens->_is_token_valid($token_validation_data);

if ($valid == false) {
$this->_not_allowed_msg();
Expand Down Expand Up @@ -491,19 +491,19 @@ function explorer() {
die();
}

$this->module('tg_security');
$this->module('trongate_security');
$target_module = segment(3);
$this->_make_sure_table_exists($target_module);
$this->module('tg_tokens');
$this->module('trongate_tokens');

$token_data['user_id'] = $this->tg_security->_get_user_id();
$token_data['user_id'] = $this->trongate_security->_get_user_id();
$token_data['code'] = 'aaa';

$sql = 'delete from tg_tokens where user_id = :user_id and code = :code';
$sql = 'delete from trongate_tokens where user_id = :user_id and code = :code';
$this->model->query_bind($sql, $token_data);

$token_data['expiry_date'] = time() + 7200; //two hours
$data['golden_token'] = $this->tg_tokens->_generate_token($token_data);
$data['golden_token'] = $this->trongate_tokens->_generate_token($token_data);
$data['endpoints'] = $this->_fetch_endpoints($target_module);
$data['endpoint_settings_location'] = '/modules/'.$target_module.'/assets/api.json';
$columns = $this->_get_all_columns($target_module);
Expand Down
2 changes: 1 addition & 1 deletion engine/views/api_explorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ function clearContent(){document.getElementById("params").value="",setTimeout(fu
.set-token-btn {border: 1px #33C3F0 solid; top:-1px !important; position: relative;}
</style>
<script>
function generateNewGoldenToken(e){var t=new Date;t.setHours(t.getHours()+4),expiryDate=Date.parse(t)/1e3;const n=new XMLHttpRequest;n.open("POST","<?= BASE_URL ?>tg_tokens/regenerate/"+e+"/"+expiryDate),n.setRequestHeader("Content-type","application/json"),n.send(JSON.stringify(params)),n.onload=function(){"false"==n.responseText?expiredGoldenToken():golden_token=n.responseText}}function submitRequest(){var e=document.getElementById("params").value;document.getElementById("endpointUrl").innerHTML=initialSegments,setTimeout(function(){document.getElementById("bypass").checked=!1,token==golden_token&&(token="",generateNewGoldenToken(golden_token))},600);var t="<?= BASE_URL ?>"+document.getElementById("endpointUrl").innerHTML;if(""!=e&&(isValidJson=validateJson(e),0==isValidJson))return void alert("Invalid JSON");if("GET"==requestType&&""!=e){e=(e=(e=(e=e.replace(/>/g,"*!gt!*")).replace(/</g,"*!lt!*")).replace(/=/g,"*!equalto!*")).replace(/_/g,"*!underscore!*"),e=JSON.parse(e);var n="/?"+fromObject(e);n=n.replace(/ /gi,"%20"),t=t.concat(n)}if(t=t.replace(/<(.|\n)*?>/g,""),0==(t=replacePlaceholders(t)))return;const d=new XMLHttpRequest;d.open(requestType,t),d.setRequestHeader("Content-type","application/json"),d.setRequestHeader("trongateToken",token),d.send(e),d.onload=function(){document.getElementById("endpointUrl").innerHTML=t.replace("<?= BASE_URL ?>",""),responseHeaders=d.getAllResponseHeaders(),responseHeaders=responseHeaders.replace(/(?:\r\n|\r|\n)/g,"<br>"),headerInfo='<p style="font-weight: bold;">HTTP Header Values </p><span style="font-size: 0.8em;">'+responseHeaders+"</span>",1==document.getElementById("display-headers-checkbox").checked&&(document.getElementById("header-info").innerHTML=headerInfo),200==d.status?document.getElementById("http-status-code").style.color="green":document.getElementById("http-status-code").style.color="purple",document.getElementById("http-status-code").innerHTML=d.status+" "+HTTP_STATUS_CODES["CODE_"+d.status],document.getElementById("serverResponse").disabled=!1,document.getElementById("serverResponse").value=d.responseText}}function drawRequiredFields(e){extraFieldsHtml="";for(var t=0;t<e.length;t++){var n=e[t].name,d=e[t].label;extraFieldsHtml=extraFieldsHtml.concat('<label for="text_field">'+d+"</label>"),extraFieldsHtml=extraFieldsHtml.concat('<input type="text" name="'+n+'" id="extra-required-field-'+n+'" class="u-full-width" placeholder="Enter '+d+' here">');var a={name:n,label:d};extraRequiredFields.push(a)}document.getElementById("extra-required-fields").innerHTML=extraFieldsHtml}var endpoint_settings="",initialSegments="";function openModal(e,t){t = t.replace(/{\$id}/g, '{id}');document.getElementById("serverResponse").value="",document.getElementById("http-status-code").innerHTML="",document.getElementById("header-info").innerHTML="",document.getElementById("extra-required-fields").innerHTML="",document.getElementById("bypass").checked=!1,extraRequiredFields=[],endpoint_data=JSON.parse(t),endpoint_settings=t,1==endpoint_data.enableParams?(document.getElementById("params").disabled=!1,document.getElementById("params").style.backgroundColor="#fff",document.getElementById("params").style.minHeight="200px",document.getElementById("clearParamsBox").style.display="inline"):(document.getElementById("params").value="",document.getElementById("params").disabled=!0,document.getElementById("params").style.backgroundColor="#ddd",document.getElementById("params").style.minHeight="118px",document.getElementById("clearParamsBox").style.display="none"),endpoint_data.required_fields&&setTimeout(drawRequiredFields,100,endpoint_data.required_fields),url_segments=endpoint_data.url_segments.replace(/{/g,'<span class="alt-font">{</span>'),url_segments=url_segments.replace(/}/g,'<span class="alt-font">}</span>'),initialSegments=url_segments,requestType=endpoint_data.request_type;endpoint_data.description;"POST"==requestType&&(document.getElementById("modal-header").className="w3-container theme-a white-text",document.getElementById("modal-footer").className="w3-container theme-a white-text",document.getElementById("modal-content").className="w3-container modal-content"),"GET"==requestType&&(document.getElementById("modal-header").className="w3-container theme-b white-text",document.getElementById("modal-footer").className="w3-container theme-b white-text",document.getElementById("modal-content").className="w3-container modal-content-get"),"PUT"==requestType&&(document.getElementById("modal-header").className="w3-container theme-c white-text",document.getElementById("modal-footer").className="w3-container theme-c white-text",document.getElementById("modal-content").className="w3-container modal-content-put"),"DELETE"==requestType&&(document.getElementById("modal-header").className="w3-container theme-d white-text",document.getElementById("modal-footer").className="w3-container theme-d white-text",document.getElementById("modal-content").className="w3-container modal-content-delete"),document.getElementById("id01").style.display="block",document.getElementById("endpointName").innerHTML=e,document.getElementById("requestType").innerHTML=requestType,document.getElementById("endpointUrl").innerHTML=url_segments}function viewSettings(){alert(endpoint_settings)}function copyText(){var e=document.getElementById("serverResponse");e.select(),document.execCommand("copy"),alert("Copied the text: "+e.value)}var modal=document.getElementById("id01");window.onclick=function(e){e.target==modal&&(modal.style.display="none")};var headerInfo="";function initBypassAuth(){if(isChecked=document.getElementById("bypass").checked,1==isChecked){token=golden_token;var e=new Date;e.setHours(e.getHours()+4),expiryDate=Date.parse(e)/1e3;const t=new XMLHttpRequest;t.open("POST","<?= BASE_URL ?>tg_tokens/regenerate/"+token+"/"+expiryDate),t.setRequestHeader("Content-type","application/json"),t.send(JSON.stringify(params)),t.onload=function(){"false"==t.responseText?expiredGoldenToken():(token=t.responseText,golden_token=token,document.getElementById("input-token").value=token,document.getElementById("token-value").innerHTML=token)}}}function displayHeaders(){isChecked=document.getElementById("display-headers-checkbox").checked,1==isChecked?document.getElementById("header-info").innerHTML=headerInfo:document.getElementById("header-info").innerHTML=""}function validateJson(e){return!!function(e){try{return"string"==typeof e&&(JSON.parse(e),!0)}catch(e){return!1}}(e)}
function generateNewGoldenToken(e){var t=new Date;t.setHours(t.getHours()+4),expiryDate=Date.parse(t)/1e3;const n=new XMLHttpRequest;n.open("POST","<?= BASE_URL ?>trongate_tokens/regenerate/"+e+"/"+expiryDate),n.setRequestHeader("Content-type","application/json"),n.send(JSON.stringify(params)),n.onload=function(){"false"==n.responseText?expiredGoldenToken():golden_token=n.responseText}}function submitRequest(){var e=document.getElementById("params").value;document.getElementById("endpointUrl").innerHTML=initialSegments,setTimeout(function(){document.getElementById("bypass").checked=!1,token==golden_token&&(token="",generateNewGoldenToken(golden_token))},600);var t="<?= BASE_URL ?>"+document.getElementById("endpointUrl").innerHTML;if(""!=e&&(isValidJson=validateJson(e),0==isValidJson))return void alert("Invalid JSON");if("GET"==requestType&&""!=e){e=(e=(e=(e=e.replace(/>/g,"*!gt!*")).replace(/</g,"*!lt!*")).replace(/=/g,"*!equalto!*")).replace(/_/g,"*!underscore!*"),e=JSON.parse(e);var n="/?"+fromObject(e);n=n.replace(/ /gi,"%20"),t=t.concat(n)}if(t=t.replace(/<(.|\n)*?>/g,""),0==(t=replacePlaceholders(t)))return;const d=new XMLHttpRequest;d.open(requestType,t),d.setRequestHeader("Content-type","application/json"),d.setRequestHeader("trongateToken",token),d.send(e),d.onload=function(){document.getElementById("endpointUrl").innerHTML=t.replace("<?= BASE_URL ?>",""),responseHeaders=d.getAllResponseHeaders(),responseHeaders=responseHeaders.replace(/(?:\r\n|\r|\n)/g,"<br>"),headerInfo='<p style="font-weight: bold;">HTTP Header Values </p><span style="font-size: 0.8em;">'+responseHeaders+"</span>",1==document.getElementById("display-headers-checkbox").checked&&(document.getElementById("header-info").innerHTML=headerInfo),200==d.status?document.getElementById("http-status-code").style.color="green":document.getElementById("http-status-code").style.color="purple",document.getElementById("http-status-code").innerHTML=d.status+" "+HTTP_STATUS_CODES["CODE_"+d.status],document.getElementById("serverResponse").disabled=!1,document.getElementById("serverResponse").value=d.responseText}}function drawRequiredFields(e){extraFieldsHtml="";for(var t=0;t<e.length;t++){var n=e[t].name,d=e[t].label;extraFieldsHtml=extraFieldsHtml.concat('<label for="text_field">'+d+"</label>"),extraFieldsHtml=extraFieldsHtml.concat('<input type="text" name="'+n+'" id="extra-required-field-'+n+'" class="u-full-width" placeholder="Enter '+d+' here">');var a={name:n,label:d};extraRequiredFields.push(a)}document.getElementById("extra-required-fields").innerHTML=extraFieldsHtml}var endpoint_settings="",initialSegments="";function openModal(e,t){t = t.replace(/{\$id}/g, '{id}');document.getElementById("serverResponse").value="",document.getElementById("http-status-code").innerHTML="",document.getElementById("header-info").innerHTML="",document.getElementById("extra-required-fields").innerHTML="",document.getElementById("bypass").checked=!1,extraRequiredFields=[],endpoint_data=JSON.parse(t),endpoint_settings=t,1==endpoint_data.enableParams?(document.getElementById("params").disabled=!1,document.getElementById("params").style.backgroundColor="#fff",document.getElementById("params").style.minHeight="200px",document.getElementById("clearParamsBox").style.display="inline"):(document.getElementById("params").value="",document.getElementById("params").disabled=!0,document.getElementById("params").style.backgroundColor="#ddd",document.getElementById("params").style.minHeight="118px",document.getElementById("clearParamsBox").style.display="none"),endpoint_data.required_fields&&setTimeout(drawRequiredFields,100,endpoint_data.required_fields),url_segments=endpoint_data.url_segments.replace(/{/g,'<span class="alt-font">{</span>'),url_segments=url_segments.replace(/}/g,'<span class="alt-font">}</span>'),initialSegments=url_segments,requestType=endpoint_data.request_type;endpoint_data.description;"POST"==requestType&&(document.getElementById("modal-header").className="w3-container theme-a white-text",document.getElementById("modal-footer").className="w3-container theme-a white-text",document.getElementById("modal-content").className="w3-container modal-content"),"GET"==requestType&&(document.getElementById("modal-header").className="w3-container theme-b white-text",document.getElementById("modal-footer").className="w3-container theme-b white-text",document.getElementById("modal-content").className="w3-container modal-content-get"),"PUT"==requestType&&(document.getElementById("modal-header").className="w3-container theme-c white-text",document.getElementById("modal-footer").className="w3-container theme-c white-text",document.getElementById("modal-content").className="w3-container modal-content-put"),"DELETE"==requestType&&(document.getElementById("modal-header").className="w3-container theme-d white-text",document.getElementById("modal-footer").className="w3-container theme-d white-text",document.getElementById("modal-content").className="w3-container modal-content-delete"),document.getElementById("id01").style.display="block",document.getElementById("endpointName").innerHTML=e,document.getElementById("requestType").innerHTML=requestType,document.getElementById("endpointUrl").innerHTML=url_segments}function viewSettings(){alert(endpoint_settings)}function copyText(){var e=document.getElementById("serverResponse");e.select(),document.execCommand("copy"),alert("Copied the text: "+e.value)}var modal=document.getElementById("id01");window.onclick=function(e){e.target==modal&&(modal.style.display="none")};var headerInfo="";function initBypassAuth(){if(isChecked=document.getElementById("bypass").checked,1==isChecked){token=golden_token;var e=new Date;e.setHours(e.getHours()+4),expiryDate=Date.parse(e)/1e3;const t=new XMLHttpRequest;t.open("POST","<?= BASE_URL ?>trongate_tokens/regenerate/"+token+"/"+expiryDate),t.setRequestHeader("Content-type","application/json"),t.send(JSON.stringify(params)),t.onload=function(){"false"==t.responseText?expiredGoldenToken():(token=t.responseText,golden_token=token,document.getElementById("input-token").value=token,document.getElementById("token-value").innerHTML=token)}}}function displayHeaders(){isChecked=document.getElementById("display-headers-checkbox").checked,1==isChecked?document.getElementById("header-info").innerHTML=headerInfo:document.getElementById("header-info").innerHTML=""}function validateJson(e){return!!function(e){try{return"string"==typeof e&&(JSON.parse(e),!0)}catch(e){return!1}}(e)}

function prePopulate() {

Expand Down
Loading

0 comments on commit 12d0ac5

Please sign in to comment.