Skip to content

Commit 8bdd06a

Browse files
committed
optimizations
1 parent f116c9f commit 8bdd06a

13 files changed

Lines changed: 5302 additions & 6 deletions

File tree

.htaccess

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# PHP Terminal - Security Configuration
2+
# Apache .htaccess file for enhanced security
3+
4+
# Disable server signature
5+
ServerSignature Off
6+
7+
# Hide Apache version
8+
<IfModule mod_headers.c>
9+
Header unset Server
10+
Header always unset X-Powered-By
11+
Header unset X-Powered-By
12+
Header unset X-CF-Powered-By
13+
Header unset X-Mod-Pagespeed
14+
Header unset X-Pingback
15+
</IfModule>
16+
17+
# Security Headers
18+
<IfModule mod_headers.c>
19+
# Prevent MIME type sniffing
20+
Header always set X-Content-Type-Options nosniff
21+
22+
# Enable XSS filtering
23+
Header always set X-XSS-Protection "1; mode=block"
24+
25+
# Prevent clickjacking
26+
Header always set X-Frame-Options DENY
27+
28+
# Strict Transport Security (HTTPS only)
29+
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
30+
31+
# Content Security Policy
32+
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; frame-ancestors 'none';"
33+
34+
# Referrer Policy
35+
Header always set Referrer-Policy "strict-origin-when-cross-origin"
36+
37+
# Permissions Policy
38+
Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
39+
</IfModule>
40+
41+
# Disable directory browsing
42+
Options -Indexes
43+
44+
# Follow symbolic links
45+
Options +FollowSymLinks
46+
47+
# Disable server signature
48+
ServerTokens Prod
49+
50+
# Prevent access to sensitive files
51+
<FilesMatch "\.(env|log|sql|bak|backup|old|orig|tmp)$">
52+
Order allow,deny
53+
Deny from all
54+
</FilesMatch>
55+
56+
# Protect configuration files
57+
<FilesMatch "^(config|\.env|\.htaccess|\.htpasswd)">
58+
Order allow,deny
59+
Deny from all
60+
</FilesMatch>
61+
62+
# Protect cache and logs directories
63+
<DirectoryMatch "^(cache|logs|uploads)/">
64+
Order allow,deny
65+
Deny from all
66+
</DirectoryMatch>
67+
68+
# Prevent access to PHP files in media directory
69+
<Directory "media/">
70+
<Files "*.php">
71+
Order allow,deny
72+
Deny from all
73+
</Files>
74+
</Directory>
75+
76+
# Limit file upload size
77+
php_value upload_max_filesize 10M
78+
php_value post_max_size 20M
79+
php_value max_execution_time 30
80+
php_value max_input_time 30
81+
php_value memory_limit 128M
82+
83+
# Disable dangerous PHP functions
84+
php_value disable_functions "exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source"
85+
86+
# Enable error logging
87+
php_value log_errors On
88+
php_value error_log /var/log/phpterminal.log
89+
90+
# Disable display of errors in production
91+
php_value display_errors Off
92+
php_value display_startup_errors Off
93+
94+
# Enable session security
95+
php_value session.cookie_httponly 1
96+
php_value session.cookie_secure 1
97+
php_value session.use_only_cookies 1
98+
php_value session.cookie_samesite Strict
99+
100+
# Prevent access to version control files
101+
<FilesMatch "\.(git|svn|hg)">
102+
Order allow,deny
103+
Deny from all
104+
</FilesMatch>
105+
106+
# Rate limiting (if mod_evasive is available)
107+
<IfModule mod_evasive24.c>
108+
DOSHashTableSize 2048
109+
DOSPageCount 3
110+
DOSPageInterval 1
111+
DOSSiteCount 50
112+
DOSSiteInterval 1
113+
DOSBlockingPeriod 600
114+
</IfModule>
115+
116+
# Compression for better performance
117+
<IfModule mod_deflate.c>
118+
AddOutputFilterByType DEFLATE text/plain
119+
AddOutputFilterByType DEFLATE text/html
120+
AddOutputFilterByType DEFLATE text/xml
121+
AddOutputFilterByType DEFLATE text/css
122+
AddOutputFilterByType DEFLATE application/xml
123+
AddOutputFilterByType DEFLATE application/xhtml+xml
124+
AddOutputFilterByType DEFLATE application/rss+xml
125+
AddOutputFilterByType DEFLATE application/javascript
126+
AddOutputFilterByType DEFLATE application/x-javascript
127+
</IfModule>
128+
129+
# Browser caching
130+
<IfModule mod_expires.c>
131+
ExpiresActive On
132+
ExpiresByType text/css "access plus 1 month"
133+
ExpiresByType application/javascript "access plus 1 month"
134+
ExpiresByType image/png "access plus 1 month"
135+
ExpiresByType image/jpg "access plus 1 month"
136+
ExpiresByType image/jpeg "access plus 1 month"
137+
ExpiresByType image/gif "access plus 1 month"
138+
ExpiresByType image/svg+xml "access plus 1 month"
139+
ExpiresByType font/woff "access plus 1 month"
140+
ExpiresByType font/woff2 "access plus 1 month"
141+
</IfModule>
142+
143+
# Force HTTPS (uncomment in production)
144+
# RewriteEngine On
145+
# RewriteCond %{HTTPS} off
146+
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
147+
148+
# Custom error pages
149+
ErrorDocument 404 /phpterminal.php
150+
ErrorDocument 403 /phpterminal.php
151+
ErrorDocument 500 /phpterminal.php

README.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,73 @@ A **secure**, **modern**, and **feature-rich** web-based terminal emulator built
6363
php install.php
6464
```
6565

66-
3. **Follow the guided setup process**
66+
3. **Deploy to production:**
67+
```bash
68+
php deploy.php
69+
```
70+
71+
4. **Follow the guided setup process**
6772

68-
4. **Configure your environment:**
73+
5. **Configure your environment:**
6974
```bash
7075
# Edit .env file
7176
PHPTERM_USERNAME=your_username
7277
PHPTERM_PASSWORD=your_secure_password
7378
PHPTERM_SESSION_TIMEOUT=3600
7479
```
7580

76-
5. **Access the terminal:**
77-
```
78-
http://your-domain/phpterminal.php
79-
```
81+
6. **Access the terminal:**
82+
- Open your browser and navigate to `http://your-domain.com/phpterminal.php`
83+
- Login with your credentials
84+
- Start using the terminal!
85+
86+
7. **Access admin dashboard:**
87+
- Navigate to `http://your-domain.com/phpterminal/admin/dashboard.php`
88+
- Monitor system health, security, and performance
8089

8190
### **Default Credentials**
8291
```
8392
Username: admin
8493
Password: admin
8594
```
95+
96+
## 📡 **API Documentation**
97+
98+
The PHP Terminal includes a comprehensive REST API for system management and monitoring.
99+
100+
### **Available Endpoints**
101+
102+
| Endpoint | Method | Description |
103+
|----------|--------|-------------|
104+
| `/api/health` | GET | System health check |
105+
| `/api/security` | GET | Security report |
106+
| `/api/performance` | GET | Performance metrics |
107+
| `/api/backups` | GET/POST | List/create backups |
108+
| `/api/backups/restore` | POST | Restore backup |
109+
| `/api/maintenance` | POST | Run maintenance |
110+
| `/api/status` | GET | System status |
111+
| `/api/logs` | GET | System logs |
112+
| `/api/config` | GET | Configuration |
113+
| `/api/commands` | GET | Available commands |
114+
| `/api/metrics` | GET | System metrics |
115+
116+
### **Example API Usage**
117+
118+
```bash
119+
# Get system health
120+
curl -X GET http://your-domain.com/phpterminal/api/health
121+
122+
# Get security report
123+
curl -X GET http://your-domain.com/phpterminal/api/security?days=7
124+
125+
# Create backup
126+
curl -X POST http://your-domain.com/phpterminal/api/backups \
127+
-H "Content-Type: application/json" \
128+
-d '{"description": "Manual backup"}'
129+
130+
# Run maintenance
131+
curl -X POST http://your-domain.com/phpterminal/api/maintenance
132+
```
86133
⚠️ **Change these immediately after installation!**
87134

88135
## 📁 Project Structure

0 commit comments

Comments
 (0)