Skip to content

Commit c755a25

Browse files
authored
Updates
1 parent 3c5786a commit c755a25

9 files changed

Lines changed: 44 additions & 282 deletions

File tree

config/var/www/admin/control-panel/api.php

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ function sanitizeLogInput($input) {
372372
'/services/status' => 15, // 15 seconds - service status should be fresh
373373
'/sites' => 120, // 2 minutes - site list rarely changes
374374
'/sites/count' => 120, // 2 minutes
375-
'/activity/recent' => 30, // 30 seconds
376-
'/alerts' => 30, // 30 seconds
377375
'/tools/filemanager/status' => 300, // 5 minutes - rarely changes
378376
'/monitoring/uptime' => 60, // 1 minute
379377
'/monitoring/uptime/monitors' => 60, // 1 minute
@@ -573,8 +571,6 @@ function outputCachedResponse($data, $ttl) {
573571
'/services/status',
574572
'/sites',
575573
'/sites/count',
576-
'/activity/recent',
577-
'/alerts',
578574
'/tools/filemanager/status',
579575
'/monitoring/uptime',
580576
'/monitoring/uptime/monitors',
@@ -657,12 +653,6 @@ function handleBatchRequest() {
657653
case '/sites/count':
658654
handleSitesCount();
659655
break;
660-
case '/activity/recent':
661-
handleRecentActivity();
662-
break;
663-
case '/alerts':
664-
handleAlerts();
665-
break;
666656
case '/tools/filemanager/status':
667657
handleFileManagerStatus();
668658
break;
@@ -784,14 +774,6 @@ function handleCacheClear() {
784774
handleSitesCount();
785775
break;
786776

787-
case '/activity/recent':
788-
handleRecentActivity();
789-
break;
790-
791-
case '/alerts':
792-
case '/alerts/':
793-
handleAlerts();
794-
break;
795777

796778
case '/tools/filemanager/status':
797779
handleFileManagerStatus();
@@ -948,25 +930,6 @@ function handleSitesCount() {
948930
}
949931
}
950932

951-
function handleRecentActivity() {
952-
try {
953-
echo json_encode(sanitizeOutput(getRecentActivity())); // codacy:ignore - echo required for JSON API response
954-
} catch (Exception $e) {
955-
http_response_code(500);
956-
logSecurityEvent('Recent activity error', $e->getMessage());
957-
echo json_encode(['error' => 'Unable to retrieve recent activity']); // codacy:ignore - echo required for JSON API response
958-
}
959-
}
960-
961-
function handleAlerts() {
962-
try {
963-
echo json_encode(sanitizeOutput(getSystemAlerts())); // codacy:ignore - echo required for JSON API response
964-
} catch (Exception $e) {
965-
http_response_code(500);
966-
logSecurityEvent('Alerts error', $e->getMessage());
967-
echo json_encode(['error' => 'Unable to retrieve alerts']); // codacy:ignore - echo required for JSON API response
968-
}
969-
}
970933

971934
function handleFileManagerStatus() {
972935
try {
@@ -1413,116 +1376,6 @@ function getWordPressVersion($document_root) {
14131376
}
14141377
}
14151378

1416-
// Recent activity helpers
1417-
function checkRecentSSHActivity() {
1418-
$auth_log = '/var/log/auth.log';
1419-
$real_auth_log = realpath($auth_log); // codacy:ignore - realpath() required for log file path validation in standalone API
1420-
1421-
if (!isValidLogFile($real_auth_log, $auth_log)) {
1422-
return null;
1423-
}
1424-
1425-
$handle = fopen($real_auth_log, 'r'); // codacy:ignore - fopen() required for log file reading in standalone API
1426-
if (!$handle) {
1427-
return null;
1428-
}
1429-
1430-
$ssh_activity = parseAuthLogForActivity($handle);
1431-
fclose($handle); // codacy:ignore - fclose() required for proper file handle cleanup in standalone API
1432-
1433-
return $ssh_activity;
1434-
}
1435-
1436-
function getRecentActivity() {
1437-
$activities = [];
1438-
1439-
try {
1440-
// Check for SSH login activity
1441-
$ssh_activity = checkRecentSSHActivity();
1442-
if ($ssh_activity) {
1443-
$activities[] = $ssh_activity;
1444-
}
1445-
1446-
// Add system status update
1447-
$activities[] = [
1448-
'message' => 'System status updated',
1449-
'time' => 'Just now',
1450-
'icon' => 'fa-sync-alt'
1451-
];
1452-
} catch (Exception $e) {
1453-
logSecurityEvent('Recent activity error', $e->getMessage());
1454-
// Add fallback activity
1455-
$activities[] = [
1456-
'message' => 'System monitoring active',
1457-
'time' => 'Just now',
1458-
'icon' => 'fa-shield-alt'
1459-
];
1460-
}
1461-
1462-
return $activities;
1463-
}
1464-
1465-
function isValidLogFile($real_path, $expected_path) {
1466-
return $real_path &&
1467-
$real_path === $expected_path &&
1468-
file_exists($real_path) && // codacy:ignore - file_exists() required for log file validation in standalone API
1469-
is_readable($real_path); // codacy:ignore - is_readable() required for log file validation in standalone API
1470-
}
1471-
1472-
function parseAuthLogForActivity($handle) {
1473-
$file_size = filesize('/var/log/auth.log'); // codacy:ignore - filesize() required for log file size checking in standalone API
1474-
if (!$file_size || $file_size <= 0) {
1475-
return null;
1476-
}
1477-
1478-
fseek($handle, max(0, $file_size - 1024), SEEK_SET); // codacy:ignore - fseek() required for log file positioning in standalone API
1479-
$content = fread($handle, 1024); // codacy:ignore - fread() required for log file reading in standalone API
1480-
1481-
if ($content && strpos($content, 'Accepted') !== false) {
1482-
return [
1483-
'message' => 'Recent SSH login detected',
1484-
'time' => '5 minutes ago',
1485-
'icon' => 'fa-sign-in-alt'
1486-
];
1487-
}
1488-
1489-
return null;
1490-
}
1491-
1492-
function getSystemAlerts() {
1493-
$alerts = [];
1494-
1495-
// Check disk usage
1496-
$disk_usage = (float)str_replace('%', '', getDiskUsage());
1497-
if ($disk_usage > 90) {
1498-
$alerts[] = [
1499-
'message' => 'High disk usage detected',
1500-
'time' => 'Now',
1501-
'type' => 'warning'
1502-
];
1503-
}
1504-
1505-
// Check memory usage
1506-
$memory_usage = (float)str_replace('%', '', getMemoryUsage());
1507-
if ($memory_usage > 85) {
1508-
$alerts[] = [
1509-
'message' => 'High memory usage detected',
1510-
'time' => 'Now',
1511-
'type' => 'warning'
1512-
];
1513-
}
1514-
1515-
// If no alerts, return success message
1516-
if (empty($alerts)) {
1517-
$alerts[] = [
1518-
'message' => 'All systems operational',
1519-
'time' => 'Just now',
1520-
'type' => 'info'
1521-
];
1522-
}
1523-
1524-
return $alerts;
1525-
}
15261379

15271380
// External services functions moved to external-services/external-services-api.php
15281381

config/var/www/admin/control-panel/dashboard.css

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -558,71 +558,6 @@ body {
558558
.service-item .service-status .offline { color: var(--error-color); }
559559
.service-item .service-status .warning { color: var(--warning-color); }
560560

561-
/* Activity Lists */
562-
.activity-list, .alert-list {
563-
max-height: 300px;
564-
overflow-y: auto;
565-
}
566-
567-
.activity-item, .alert-item {
568-
display: flex;
569-
align-items: flex-start;
570-
padding: 1rem;
571-
border-bottom: 1px solid var(--border-color);
572-
transition: var(--transition);
573-
}
574-
575-
.activity-item:hover, .alert-item:hover {
576-
background: rgba(255, 255, 255, 0.02);
577-
}
578-
579-
.activity-item:last-child, .alert-item:last-child {
580-
border-bottom: none;
581-
}
582-
583-
.activity-icon, .alert-icon {
584-
width: 40px;
585-
height: 40px;
586-
border-radius: 50%;
587-
display: flex;
588-
align-items: center;
589-
justify-content: center;
590-
margin-right: 1rem;
591-
flex-shrink: 0;
592-
}
593-
594-
.activity-icon {
595-
background: rgba(0, 212, 170, 0.1);
596-
color: var(--accent-color);
597-
}
598-
599-
.alert-icon.info {
600-
background: rgba(0, 168, 255, 0.1);
601-
color: var(--info-color);
602-
}
603-
604-
.alert-icon.warning {
605-
background: rgba(255, 184, 0, 0.1);
606-
color: var(--warning-color);
607-
}
608-
609-
.alert-icon.error {
610-
background: rgba(255, 68, 68, 0.1);
611-
color: var(--error-color);
612-
}
613-
614-
.activity-content, .alert-content {
615-
flex: 1;
616-
}
617-
618-
.activity-content p, .alert-content p {
619-
margin-bottom: 0.25rem;
620-
}
621-
622-
.activity-time, .alert-time {
623-
color: var(--text-muted);
624-
font-size: 0.75rem;
625-
}
626561

627562
/* Sites Grid */
628563
.sites-grid {

config/var/www/admin/control-panel/dashboard.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -786,45 +786,11 @@ class EngineScriptDashboard {
786786
}
787787
}
788788

789-
isValidActivity(activity) {
790-
return this.utils.isValidActivity(activity);
791-
}
792-
793-
isValidAlert(alert) {
794-
return this.utils.isValidAlert(alert);
795-
}
796789

797790
isValidSite(site) {
798791
return this.utils.isValidSite(site);
799792
}
800793

801-
createActivityElement(activity) {
802-
const iconClass = this.sanitizeInput(activity.icon) || "fa-info-circle";
803-
804-
return this.utils.createContentElement({
805-
containerClass: "activity-item",
806-
iconClass: "activity-icon",
807-
contentClass: "activity-content",
808-
messageText: activity.message,
809-
timeText: activity.time,
810-
timeClass: "activity-time",
811-
iconType: iconClass,
812-
});
813-
}
814-
815-
createAlertElement(alert) {
816-
const alertType = this.sanitizeInput(alert.type) || "info";
817-
818-
return this.utils.createContentElement({
819-
containerClass: `alert-item ${alertType}`,
820-
iconClass: `alert-icon ${alertType}`,
821-
contentClass: "alert-content",
822-
messageText: alert.message,
823-
timeText: alert.time,
824-
timeClass: "alert-time",
825-
iconType: this.getAlertIcon(alertType),
826-
});
827-
}
828794

829795
// Helper method to create site card structure - eliminates duplication
830796
createSiteCardStructure(titleText) {

config/var/www/admin/control-panel/external-services/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ The module is already integrated into the EngineScript admin dashboard:
2121

2222
```html
2323
<!-- In index.html -->
24-
<link rel="stylesheet" href="external-services/external-services.css?v=2025.11.21.09">
25-
<script type="module" src="external-services/external-services.js?v=2025.11.21.09"></script>
24+
<link rel="stylesheet" href="external-services/external-services.css?v=2025.11.25.3">
25+
<script type="module" src="external-services/external-services.js?v=2025.11.25.3"></script>
2626
```
2727

2828
```javascript
2929
// In dashboard.js
30-
import { ExternalServicesManager } from './external-services/external-services.js?v=2025.11.21.09';
30+
import { ExternalServicesManager } from './external-services/external-services.js?v=2025.11.25.3';
3131

3232
class EngineScriptDashboard {
3333
constructor() {

config/var/www/admin/control-panel/modules/utils.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -105,29 +105,6 @@ export class DashboardUtils {
105105
}
106106
}
107107

108-
isValidActivity(activity) {
109-
return (
110-
activity &&
111-
typeof activity === "object" &&
112-
typeof activity.message === "string" &&
113-
typeof activity.time === "string" &&
114-
activity.message.length > 0 &&
115-
activity.message.length < 500
116-
);
117-
}
118-
119-
isValidAlert(alert) {
120-
const validTypes = ["info", "warning", "error", "success"];
121-
return (
122-
alert &&
123-
typeof alert === "object" &&
124-
typeof alert.message === "string" &&
125-
typeof alert.time === "string" &&
126-
(!alert.type || validTypes.includes(alert.type)) &&
127-
alert.message.length > 0 &&
128-
alert.message.length < 500
129-
);
130-
}
131108

132109
isValidSite(site) {
133110
return (
@@ -140,16 +117,6 @@ export class DashboardUtils {
140117
); // Basic domain validation
141118
}
142119

143-
getAlertIcon(type) {
144-
const icons = {
145-
info: "fa-info-circle",
146-
warning: "fa-exclamation-triangle",
147-
error: "fa-exclamation-circle",
148-
success: "fa-check-circle",
149-
};
150-
return icons[type] || "fa-info-circle";
151-
}
152-
153120
showError(message) {
154121
// Sanitize error message
155122
const sanitizedMessage = this.sanitizeInput(message) || "An unknown error occurred";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
#----------------------------------------------------------------------------------
3+
# EngineScript - A High-Performance WordPress Server Built on Ubuntu and Cloudflare
4+
#----------------------------------------------------------------------------------
5+
# Website: https://EngineScript.com
6+
# GitHub: https://github.com/Enginescript/EngineScript
7+
# License: GPL v3.0
8+
#----------------------------------------------------------------------------------
9+
10+
# EngineScript Variables
11+
source /usr/local/bin/enginescript/enginescript-variables.txt
12+
source /home/EngineScript/enginescript-install-options.txt
13+
14+
# Source shared functions library
15+
source /usr/local/bin/enginescript/scripts/functions/shared/enginescript-common.sh
16+
17+
18+
#----------------------------------------------------------------------------
19+
# Start Main Script
20+
21+
# Directly remove JSON cache files from the API cache directory.
22+
CACHE_DIR="/var/cache/enginescript/api"
23+
24+
if [[ -d "${CACHE_DIR}" ]]; then
25+
# Remove cache files safely, suppress errors
26+
find "${CACHE_DIR}" -maxdepth 1 -type f -name '*.json' -exec rm -f {} \; 2>/dev/null || true
27+
fi

0 commit comments

Comments
 (0)