Archive: Namaste PHP AMQP framework v1.0 (2017-2020)

952 days continuous production uptime, 40k+ tp/s single node.
Original corpo Bitbucket history not included — clean archive commit.
This commit is contained in:
2026-04-05 09:49:30 -07:00
commit 373ebc8c93
1284 changed files with 409372 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
<?php
/**
* fetchSysData.php
*
* Stub program that's invoked by gaAdmin utility.
*
* This program stub connects to the admin mongo resource and pulls all (the whole one record) of system data from
* the system-data collection. (There should be either zero (edge case) or one record stored.)
*
* The program will store any user-level error messages in an array named $formErrors which will be displayed to the
* user in the next page load.
*
* There is an edge case to be accommodated -- when you request to edit a new Namaste installation and there is no
* data stored in the system-table.
*
* todo: write a program that populates the systemData collection during installation
*
* If data exists in the table, it's stored as an associative array in a variable called: $systemData.
* If data doesn't exist in the table, and if no errors were generated, we're going to assume it's a new (unpopulated)
* table. In both of the previous cases, a boolean value: $sysDataLoad is set to true.
*
*
* @author mike@givingassistant.org
* @version 1.0
*
* HISTORY:
* ========
* 08-07-18 mks CORE-1113: original coding
*
*/
$meta = [
META_TEMPLATE => TEMPLATE_CLASS_SYS_EVENTS,
META_CLIENT => CLIENT_SYSTEM,
META_CLIENT_IP => STRING_SESSION_HOME,
];
if (!isset($data['c'])) {
$systemMessage[] = 'Choice (C) data not loaded!';
return;
}
$whichConstant = intval($data['c']);
// this script may only execute locally on the namaste admin service
// todo -- remove the "true or" when done debugging
//if (true or intval(gasConfig::$settings[CONFIG_DATABASE][CONFIG_DATABASE_MONGODB][CONFIG_DATABASE_MONGODB_ADMIN][CONFIG_IS_LOCAL]) != 1) {
if (intval(gasConfig::$settings[CONFIG_DATABASE][CONFIG_DATABASE_MONGODB][CONFIG_DATABASE_MONGODB_ADMIN][CONFIG_IS_LOCAL]) != 1) {
$formErrors[] = ERROR_LOCAL_NOT_ADMIN;
return;
}
// instantiate the systemData class object
try {
$obj = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, basename(__FILE__) . AT . __LINE__, $formErrors);
} catch (TypeError $t) {
$formErrors[] = ERROR_TYPE_EXCEPTION . COLON . $t->getMessage();
return;
}
// ensure that the systemData class object successfully instantiated
if (!$obj->status) {
$formErrors = $obj->eventMessages;
if (is_object($obj->widget)) $obj->widget->__destruct();
if (is_object($obj)) $obj->__destruct();
unset($obj);
return;
}
// fetch the systemData
$query = [null];
$obj->widget->_fetchRecords([STRING_QUERY_DATA => $query]);
if (!$obj->status) {
$formErrors = $obj->widget->eventMessages;
if (is_object($obj->widget)) $obj->widget->__destruct();
if (is_object($obj)) $obj->__destruct();
unset($obj);
return;
}
// get the data array
$obj->widget->eventMessages = null;
$systemData = $obj->widget->getData();
if (is_array($systemData)) $systemData = $systemData[0];
$sysDataLoad = (empty($obj->widget->eventMessages)) ? true : false;
if (is_null($systemData) and $sysDataLoad) {
$systemMessage[] = 'The system data table has not been created yet; the table will be created when the new data is saved.';
} elseif (!$sysDataLoad) {
$formErrors[] = $obj->widget->eventMessages;
}
if (is_object($obj->widget)) $obj->widget->__destruct();
if (is_object($obj)) $obj->__destruct();
unset($obj);

View File

@@ -0,0 +1,71 @@
/**
* gaAdmin.js
*
* This is the javascript file for the Namaste admin web-program: gaAdmin.php.
*
*
* @author mike@givingassistant.org
* @version 1.0
*
*
* HISTORY:
* ========
* 08-06-18 CORE-1113: original coding
*
*/
/**
*
* This stub handles the click event when a user clicks on the side-nav bar (Edit Constants) and selects the option
* to edit either the STATE or STATUS constants. The stub evaluates which link was clicked and passes the result back
* to the server via AJAX which, in turn, should spawn the events to fetch the systemData record and display the
* appropriate data field on-screen.
*
*
* @author mike@givingassistant.org
* @version 1.0
*
* HISTORY:
* ========
* 08-06-18 mks CORE-1113: original coding
*
*/
$('.getSysD').on('click', function () {
var id = this.id;
var which = 0;
// console.log('id: ' + id);
switch (id) {
case 'stateConstants' :
which = 'c=1';
break;
case 'statusConstants' :
which = 'c=2';
break;
}
// console.log('which: ' + which);
event.preventDefault();
event.stopImmediatePropagation();
$.ajax({
type : "POST",
data : which,
success: function ( response ) {
$('body').html(response);
console.log(response);
}
});
return false;
});
// $( "#gaConstants" ).submit(function() {
// alert( "Handler for .submit() called." );
// // event.preventDefault();
// $.ajax({
// type : "POST",
// data : 'stateConstants=1',
// success: function () {
// }
// })
// });

View File

@@ -0,0 +1,81 @@
<?php
/**
* loadConstants.php
*
* This stub is called when a user selects the option to edit the state or status constants in namaste.
*
* We call this stub to generate the main panel (HTML) which is an editable table containing the data pulled from
* the systemData collection -- depending on which link was clicked on the main page, we'll load either state or
* status constants into the table.
*
* If there is no data in the system table, the system message will display that fact and we'll proc an empty table
* for the user to begin population.
*/
// state constants == 1
// status constants == 2
if (intval($data['c']) == 1) {
$whichConstant = VALID_STATES;
$constantTitle = 'States';
} elseif (intval($data['c']) == 2) {
$whichConstant = VALID_STATUS;
$constantTitle = 'Status';
} else {
$systemMessage = 'Invalid data (status) choice!';
return;
}
$htmlMain = '
<div class="col-md-5">
<!-- Panel Header -->
<div class="view view-cascade py-3 gradient-card-header info-color-dark">
<h5>' . $whichConstant . '</h5>
</div>
<!-- Panel Content -->
<div class="card-body card-body-cascade">
<!-- Grid Row -->
<div class="row">
<!-- Grid Column -->
<div class="col-md-auto mb-4">
<!-- Editable Table -->
<div class="card">
<h3 class="card-header text-center font-weight-bold text-uppercase py-4">' . $constantTitle . '</h3>
<div class="card-body">
<div id="constantTable" class="table-editable">
<span class="table-add float-right mb-3 mr-2"><a href="#!" class="text-success">
<i class="fa fa-plus fa-2x" aria-hidden="true"></i></a>
</span>
<table class="table table-bordered table-responsive-md table-striped text-center">
<tr>
<th class="text-center">Constant Key</th>
<th class="text-center">Constant Value</th>
<th class="text-center">Remove</th>
</tr>
';
if (isset($systemData) and is_array($systemData)) {
foreach ($systemData[$whichConstant] as $key => $value) {
$htmlMain .= '<tr>';
$htmlMain .= '<td class="pt-3-half" contenteditable="true">' . $key . '</td>';
$htmlMain .= '<td class="pt-3-half" contenteditable="true">' . $value . '</td>';
$htmlMain .= '<td><span class="table-remove"><button type="button" class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span></td>';
$htmlMain .= '</tr>';
}
}
$htmlMain .= '
</table>
</div>
</div>
</div>
<!-- !Editable Table -->
</div>
<!-- !Grid Column -->
</div>
<!-- !Grid Row -->
</div>
<!-- !Panel Content -->
';
?>