Skip to content

Commit 3ef42ae

Browse files
authored
v0.7.6 - Working on guiCore, adding core functionality.
-Adding & refining functions in guiCore.php. -I want to have widgets, apps, and files on the homepage similar to HRCloud2, but with seamless iframes that scroll to the side similar to Netflix. -Maybe smaller than netflix. -Maybe put two side by side? -User can re-arrange widgets and apps and anything else. -Make a cache file to store the order in which items are displayed. -Update this cache file when the user changes their display options. -Iframes sidescroll, only one object tall. -Iframes should be outputted via PHP functions and contained in widgets. -Authentication levels for widgets are coded into the widget themselves. -That way widgets can be made for unauthenticated users for things that don't need auth. Like converting one-time files or outputting server analytics or marketing. -Refactored getFiles() in guiCore.php pretty heavily. -Add Applications and Widgets folders to verifyInstallation() in core.php. -Need to add code in core.php to create a cache file to store the order that guiElements are displayed in. -This code should probably go in the same area as notifications file generation. -Maybe tuck it inside the generateUserCache() function? -Cleanup lingering files from last nights big GUI / HTML file move.
1 parent f5ea474 commit 3ef42ae

File tree

4 files changed

+84
-9
lines changed

4 files changed

+84
-9
lines changed

compatibilityCore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
// / ----------------------------------------------------------------------------------
2525
// / Specify the engine version.
26-
$EngineVersion = 'v0.7.5';
26+
$EngineVersion = 'v0.7.6';
2727
// / ----------------------------------------------------------------------------------
2828

2929
// / ----------------------------------------------------------------------------------

core.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
https://www.gnu.org/licenses/gpl-3.0.html
99
1010
Author: Justin Grimes
11-
Date: 3/10/2021
11+
Date: 3/12/2021
1212
<3 Open-Source
1313
1414
This is the primary Core file for the Diablo Web Application Engine.
@@ -113,7 +113,7 @@ function verifyInstallation() {
113113
// / Set variables.
114114
global $Date, $Time, $Salts, $RootPath;
115115
$dirCheck = $indexCheck = $dirExists = $indexExists = $logCheck = $cacheCheck = TRUE;
116-
$requiredDirs = array('Logs', 'Data', 'Cache', 'Cache'.DIRECTORY_SEPARATOR.'Data');
116+
$requiredDirs = array('Applications', 'Widgets', 'Logs', 'Data', 'Cache', 'Cache'.DIRECTORY_SEPARATOR.'Data');
117117
$InstallationIsVerified = FALSE;
118118
// / For servers with unprotected directory roots, we must verify (at minimum) that a local index file exists to catch unwanted traversal.
119119
if (!file_exists('index.html')) $indexCheck = FALSE;

guiCore.php

+80-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
https://www.gnu.org/licenses/gpl-3.0.html
99
1010
Author: Justin Grimes
11-
Date: 3/11/2021
11+
Date: 3/12/2021
1212
<3 Open-Source
1313
1414
The GUI Core provides resources for the user interfaces & decides which interface to use.
@@ -61,15 +61,22 @@ function getCurrentURL() {
6161
// / Set $includeDangerousFiles to TRUE to have dangerous files appear in the array of results.
6262
// / Set $includeDangerousFiles to FALSE to have dangerous files removed from the array of results.
6363
// / The $DangerousFiles array defined in config.php contains the global list of dangerous file extensions.
64-
function getFiles($pathToFiles, $includeIndexFiles, $includeDangerousFiles) {
64+
// / Set $includeDirectories to TRUE to have directories appear in the array of results.
65+
// / Set $includeDirectories to FALSE to have directories removed from the array of results.
66+
function getFiles($pathToFiles, $includeIndexFiles, $includeDangerousFiles, $includeDirectories) {
6567
global $DangerousFiles;
66-
$dirtyFileArr = $dirtyFileArr = FALSE;
68+
$dirtyFileArr = $OperationSuccessful = FALSE;
69+
$dirtyFileArr = array();
6770
$dirtyFileArr = scandir($Files);
6871
foreach ($dirtyFileArr as $dirtyFile) {
72+
if ($dirtyFile === '.' or $dirtyFile === '..') continue;
6973
$dirtyExt = pathinfo($pathToFiles.DIRECTORY_SEPARATOR.$dirtyFile, PATHINFO_EXTENSION);
7074
if (!$includeDangerousFiles && in_array($dirtyExt, $DangerousFiles)) continue;
7175
if (!$includeIndexFiles && $dirtyFile == 'index.html') continue;
76+
if (!$includeDirectories && is_dir($pathToFiles)) continue;
7277
array_push($Files, $dirtyFile); }
78+
// / Check that the operation returned some files.
79+
if (count($Files) > 0) $OperationSuccessful = TRUE;
7380
$dirtyFileArr = $dirtyFile = $dirtyExt = $pathToFiles = $includeDangerousFiles = $includeIndexFiles = NULL;
7481
unset($dirtyFileArr, $dirtyFile, $dirtyExt, $pathToFiles, $includeDangerousFiles, $includeIndexFiles);
7582
return ($Files); }
@@ -109,15 +116,83 @@ function setColorScheme() {
109116
if ($ColorScheme == '5') {
110117
echo ('<link rel="stylesheet" type="text/css" href="'.$CD.'Styles/iframeStyleBLACK.css">'); } }
111118

112-
function getPageElement($htmlFile) {
119+
function outputPageElement($htmlFile) {
113120
global $DefaultTheme;
114121

122+
return ($HtmlElement);
123+
}
115124

125+
// / A function to initialize installed widgets.
126+
// / Widgets are small macros for adding standalone functionality to the GUI.
127+
function initializeWidgets() {
128+
global $WidgetsArrayCache;
129+
$wac = $wid = $widget = $widgets = $WidgetsAreLoaded = $key = $keyCheck = $keyWac = $widgetArrayCountRaw = $widgetArrayCountRaw = $widgetArrayCheck = FALSE;
130+
$widgetsArray = $newWidgetsArray = array();
131+
// / Scan the Widgets directory and build an array of installed Widgets.
132+
$widgetsArray = getFiles('Widgets', FALSE, TRUE);
133+
// / Iterate through all installed widgets and
134+
foreach ($widgetsArray as $widget) if (!is_dir($widget) && !($widget === '.' or $widget === '..' or $widget === 'index.html')) array_push($WidgetsArrayCache, $widget);
135+
$WidgetArrayCountRaw = count($WidgetsArrayCache);
136+
$widgetArrayCountRaw = count($WidgetsArrayCache);
137+
// / Validate the Widget cache is accurate.
138+
// / The cahce is not for improving performance, but rather to store the order that the user has arranged their Widgets.
139+
// / Detects when Widgets are added or removed and updates the cache accordingly.
140+
foreach ($widgetsArray as $keyCheck => $widgetArrayCheck) {
141+
// / Detect if a Widget needs to be removed from the Widget cache.
142+
if (!in_array($widgetArrayCheck, $widgetsArray)) {
143+
// / Remove the Widget from the cache array.
144+
$WidgetsArrayCache[$keyCheck] = NULL;
145+
unset ($WidgetsArrayCache[$keyCheck]); } }
146+
// / Consolidate the WidgetsArrayCache but keep the order of array elements intact.
147+
foreach ($WidgetsArrayCache as $keyWac => $wac) {
148+
// / Add the current array index to a new array, but in the same order as the original array.
149+
// / This way new array keys will be generated in-order, but the order of the array will be preserved.
150+
// / This is required to keep the number of array keys down.
151+
// / Otherwise our array keys would become orphaned and the our index would grow arbitrarily.
152+
$newWidgetsArray = array_push($newWidgetsArray, $wac);
153+
// / Erase the current array index from the original WidgetsArrayCache array.
154+
$WidgetsArrayCache[$keyWac] = NULL;
155+
unset ($WidgetsArrayCache[$keyWac]); }
156+
// / Redefine the WidgetsArrayCache with data from the newWidgetsArray.
157+
$WidgetsArrayCache = $newWidgetsArray;
158+
// / Clean up unneeded memory.
159+
$wac = $wid = $widget = $widgets = $WidgetsAreLoaded = $key = $keyCheck = $keyWac = $widgetArrayCountRaw = $widgetArrayCountRaw = $widgetArrayCheck = $widgetsArray = $newWidgetsArray = NULL;
160+
unset($wac, $wid, $widget, $widgets, $WidgetsAreLoaded, $key, $keyCheck, $keyWac, $widgetArrayCountRaw, $widgetArrayCountRaw, $widgetArrayCheck, $widgetsArray, $newWidgetsArray);
161+
return (array($WidgetsArrayCache, $WidgetsAreLoaded)); }
162+
163+
function updateWidgetOrder() {
164+
116165

166+
return ($WidgetOrder);
117167
}
118168

169+
function outputWidgets($StyleToUse) {
170+
171+
return ($WidgetsElement);
172+
}
119173

174+
function initializeApplications() {
175+
$app = $application = $applications = $ApplicationsAreLoaded = $key = FALSE;
176+
$ApplicationsArray = $applicationArray = array();
177+
$applicationsArray = scandir('Widgets');
178+
foreach ($applicationsArray as $application) if (is_dir($application) && !($application === '.' or $application === '..')) array_push($ApplicationsArray, $application);
179+
foreach ($ApplicationsArray as $key => $application) { }
180+
$applicationsArray = $applications = NULL;
181+
unset($applicationsArray, $applications);
182+
return (array($ApplicationArray, $applicationsAreLoaded)); }
183+
184+
function updateApplicationOrder() {
185+
186+
return ($ApplicationOrder);
187+
}
120188

189+
function outputApplications($StyleToUse) {
190+
191+
return ($ApplicationsElement);
192+
}
121193

122-
194+
function outputLogs($StyleToUse, $LogSource) {
195+
196+
return ($LogsElement);
197+
}
123198
// / -----------------------------------------------------------------------------------

versionInfo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
// / ----------------------------------------------------------------------------------
1818
// / Specify the engine version.
19-
$EngineVersionInfo = 'v0.7.5';
19+
$EngineVersionInfo = 'v0.7.6';
2020
// / ----------------------------------------------------------------------------------

0 commit comments

Comments
 (0)