-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocumentation.html
More file actions
667 lines (514 loc) · 20.2 KB
/
Copy pathdocumentation.html
File metadata and controls
667 lines (514 loc) · 20.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>EEQ Framework from EEQSOFT Documentation</title>
<meta name="description" content="Documentation of the EEQ Framework application created by EEQSOFT. Please read carefully before use.">
<meta name="keywords" content="eeq framework documentation">
<meta name="robots" content="all">
<style>
body {
margin: 40px 20px 40px 20px;
font-family: Arial, Helvetica, sans-serif;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
p {
text-align: justify;
}
blockquote {
margin-left: 20px;
margin-right: 0;
padding: 10px;
border-left: 4px solid #aaa;
background: #eee;
font-style: italic;
white-space: nowrap;
overflow-x: auto;
}
code {
white-space: pre;
}
.code {
padding: 0 15px;
border-radius: 5px;
background: #eee;
overflow-x: auto;
}
.container {
max-width: 770px;
margin-left: auto;
margin-right: auto;
}
@media (min-width: 2500px) {
body {
margin: 80px 40px 80px 40px;
font-size: 32px;
}
h1 {
margin: 40px 0 40px 0;
font-size: 72px;
}
h2 {
margin: 40px 0 40px 0;
font-size: 56px;
}
h3 {
margin: 40px 0 40px 0;
font-size: 38px;
}
p {
margin-top: 30px;
margin-bottom: 30px;
line-height: 36px;
}
blockquote {
margin-left: 40px;
padding: 20px;
border-left: 8px solid #aaa;
}
.container {
width: 1540px;
max-width: 1540px;
margin-bottom: 40px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>EEQ Framework from EEQSOFT Documentation</h1>
<span id="introduction"></span>
<h2>Introduction</h2>
<p>
This application is a PHP framework.
It uses the MVC design pattern.
All you need is a personal computer with XAMPP or Docker Desktop.
The application requires PHP and, for example, MySQL.
</p>
<h3>More Information</h3>
<ol>
<li><a href="#installation">Installation</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#development">Development</a></li>
<li><a href="#upgrade">Upgrade</a></li>
<li><a href="#change-logs">Change Logs</a></li>
</ol>
<span id="installation"></span>
<h2>1. Installation</h2>
<h3>Server Requirements</h3>
<p>
This application requires at least <strong>PHP 8.4</strong> and <strong>MySQL 5.x-8.x</strong>.
Please ensure your hosting service or personal computer meets these requirements.
</p>
<h3>Hosting Configuration</h3>
<p>
Set the root directory of the php files to "public".
Set the path for your hosting:
</p>
<blockquote><path to project>/public</blockquote>
<p>
Create a database with full user permissions.
Use the database name as in your config:
</p>
<blockquote>for example: "framework"</blockquote>
<h3>Application Configuration</h3>
<p>
Change the settings in the "database.php" file.
Set as in the "database.php.dist" file (check "config"):
</p>
<blockquote>
'db_host' => 'localhost'<br>
'db_port' => 3306<br>
'db_user' => '<user>'<br>
'db_password' => '<password>'<br>
'db_database' => 'framework'
</blockquote>
<p>
If necessary, set these permissions.
Change the permissions of the "settings.php" file to 666:
</p>
<blockquote><path to project>/config/settings.php</blockquote>
<h3>Application Installation</h3>
<p>
If you want to use a database, use the SQL commands from the "framework.sql" file for your database:
</p>
<blockquote><path to project>/data/framework.sql</blockquote>
<p>
Run this web application in your browser.
Open the url below:
</p>
<blockquote>https://<domain.com></blockquote>
<span id="usage"></span>
<h2>2. Usage</h2>
<p>
Below you can find the <strong>Directory Structure</strong> of this framework.
Let's see what files the directories contain.
</p>
<h3>Config</h3>
<p>The "config" directory contains all the configuration files:</p>
<blockquote>
<path to project>/config/actions.php<br>
<path to project>/config/config.php<br>
<path to project>/config/database.php<br>
<path to project>/config/database.php.dist<br>
<path to project>/config/redirects.php<br>
<path to project>/config/settings.php<br>
<path to project>/config/settings.php.dist
</blockquote>
<h4>actions.php</h4>
<div class="code"><code>
return [
'main_page' => [
'role' => 'none',
'option' => 'page',
'name' => 'MainPage'
]
];
</code></div>
<h4>database.php</h4>
<div class="code"><code>
return [
'mysql' => [
'db_host' => 'fwe-mysql',
'db_port' => 3306,
'db_user' => 'framework',
'db_password' => '1234567890',
'db_database' => 'framework',
'db_names' => 'utf8mb4',
'db_collate' => 'utf8mb4_unicode_ci'
]
];
</code></div>
<h4>settings.php</h4>
<div class="code"><code>
return [
'app_version' => '0.4.0',
'admin_email' => 'contact@framework.eeq'
];
</code></div>
<h3>Data</h3>
<p>The "data" directory contains the "framework.sql" file with an example structure of database tables:</p>
<blockquote><path to project>/data/framework.sql</blockquote>
<h3>Include</h3>
<p>The "inc" directory contains included files that are not classes:</p>
<blockquote>
<path to project>/inc/core/core.php<br>
<path to project>/inc/core/data.php<br>
<path to project>/inc/public/error.php<br>
<path to project>/inc/public/index.php<br>
<path to project>/inc/public/info.php
</blockquote>
<h3>Public</h3>
<p>The "public" directory contains files displayed by the browser to users:</p>
<blockquote>
<path to project>/public/css/default.css<br>
<path to project>/public/css/rwd.css<br>
<path to project>/public/images/favicon.ico<br>
<path to project>/public/js/default.js<br>
<path to project>/public/.htaccess<br>
<path to project>/public/error.php<br>
<path to project>/public/index.php<br>
<path to project>/public/robots.txt
</blockquote>
<h4>.htaccess</h4>
<div class="code"><code>
ErrorDocument 403 /error.php?code=403
ErrorDocument 404 /error.php?code=404
ErrorDocument 500 /error.php?code=500
DirectoryIndex index.html index.php /error.php?code=403
AddHandler application/x-httpd-ea-php84 .php
# php_flag register_globals off
# php_value default_charset utf-8
# php_value date.timezone UTC
# php_value max_execution_time 180
# php_value memory_limit 1024M
# php_value post_max_size 200M
# php_value upload_max_filesize 100M
RewriteEngine on
RewriteBase /
# RewriteCond %{HTTPS} !^on$
# RewriteCond %{HTTP_HOST} !^127\.0\.0\.9$
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# RewriteCond %{HTTP_HOST} !^framework\.eeq$
# RewriteCond %{HTTP_HOST} !^127\.0\.0\.9$
# RewriteRule ^(.*)$ https://framework.eeq/$1 [R=301,L]
# RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?framework\.eeq/ [NC]
# RewriteCond %{HTTP_REFERER} !^http(s)?://127\.0\.0\.9/ [NC]
# RewriteRule \.(jpeg|jpg|gif|png|bmp)$ - [NC,F,L]
RewriteRule ^((pl)/)?$ /index.php?action=main_page&lang=$2 [L]
</code></div>
<h3>Source</h3>
<p>The "src" directory contains source files that are classes:</p>
<blockquote>
<path to project>/src/Controller/MainPageController.php<br>
<path to project>/src/Core/*<br>
<path to project>/src/Repository/UserRepository.php<br>
<path to project>/src/Service/MainPageService.php<br>
<path to project>/src/Validator/MainPageValidator.php<br>
<path to project>/src/autoload.php
</blockquote>
<p>
The "src/Core/*" directory contains all the core files of this framework.
Add or edit the contents of the "Controller," "Repository," "Service," and "Validator" directories.
Use the "autoload.php" file in "config.php" (check "config") if you don't plan to use <strong>Composer</strong>.
</p>
<h4>MainPageController.php</h4>
<div class="code"><code>
declare(strict_types=1);
namespace App\Controller;
use App\Core\Controller;
use App\Service\MainPageService;
use App\Validator\MainPageValidator;
class MainPageController extends Controller
{
public function mainPageAction(array $request): array
{
$mainPageValidator = new MainPageValidator($this->csrfToken);
$mainPageService = new MainPageService(
$this->getManager(),
$this->html,
$this->csrfToken,
$mainPageValidator
);
return $mainPageService->mainPageAction(
(string) ($request['lang'] ?? ''),
(string) ($request['name'] ?? ''),
(bool) ($request['submit'] ?? false),
(string) ($request['token'] ?? '')
);
}
}
</code></div>
<h4>UserRepository.php</h4>
<div class="code"><code>
declare(strict_types=1);
namespace App\Repository;
use App\Core\Repository;
class UserRepository extends Repository
{
public function setCookieLoginUserLoged(
int $user,
string $ip,
string $date
): bool {
$this->manager->prepare(
'UPDATE `user` u
SET u.`user_ip_loged` = :ip, u.`user_date_loged` = :date
WHERE u.`user_id` = :user'
)
->setParameter('user', $user)
->setParameter('ip', $ip)
->setParameter('date', $date)
->getResult();
return $this->manager->execute();
}
public function getCookieLoginUserData(
string $login,
string $password
): array {
$array = [];
$stmt = $this->manager->prepare(
'SELECT u.`user_id`, u.`user_admin`, u.`user_active`,
u.`user_login` FROM `user` u
WHERE u.`user_login_canonical` = :login_canonical
AND u.`user_password` = :password'
)
->setParameter('login_canonical', strtolower($login))
->setParameter('password', $password)
->getResult();
$this->manager->execute();
foreach ($stmt as $row) {
$array['user_id'] = (int) $row['user_id'];
$array['user_admin'] = (bool) $row['user_admin'];
$array['user_active'] = (bool) $row['user_active'];
$array['user_login'] = $row['user_login'];
}
return $array;
}
}
</code></div>
<h4>MainPageService.php</h4>
<div class="code"><code>
declare(strict_types=1);
namespace App\Service;
use App\Core\{CsrfToken, Html, Manager};
use App\Repository\UserRepository;
use App\Validator\MainPageValidator;
class MainPageService
{
public function __construct(
protected readonly Manager $rm,
protected readonly Html $html,
protected readonly CsrfToken $csrfToken,
protected readonly MainPageValidator $mainPageValidator
) {}
public function mainPageAction(
string $lang,
string $name,
bool $submit,
string $token
): array {
$ur = $this->rm->getRepository(UserRepository::class);
if ($submit) {
$this->mainPageValidator->validate([$name, $token]);
if ($this->mainPageValidator->isValid()) {
$userData = $ur->getCookieLoginUserData($name, '');
return [
'content' => 'main_page/name_info.php',
'active_menu' => 'main_page',
'title' => PAGE_INFO_TITLE,
'language' => LANGUAGE_NAME[LANGUAGE_ID[$lang]],
'name' => $userData['user_login'] ?? $name
];
}
}
return [
'content' => 'main_page/main_page.php',
'active_menu' => 'main_page',
'title' => PAGE_MAIN_PAGE_TITLE,
'desc' => WEBSITE_DESC,
'keywords' => WEBSITE_KEYWORDS,
'error' => $this->html->prepareError(
$this->mainPageValidator->getError()
),
'name' => $name,
'token' => $this->csrfToken->generateToken()
];
}
}
</code></div>
<h4>MainPageValidator.php</h4>
<div class="code"><code>
declare(strict_types=1);
namespace App\Validator;
use App\Core\{CsrfToken, ErrorValidator};
class MainPageValidator extends ErrorValidator
{
public function __construct(
protected readonly CsrfToken $csrfToken
) {
parent::__construct();
}
public function validate(array $array): void
{
list($name, $token) = $array;
if ($name === '') {
$this->addError(FORM_MAIN_PAGE_NAME_MIN_MESSAGE);
} elseif (strlen($name) > 20) {
$this->addError(FORM_MAIN_PAGE_NAME_MAX_MESSAGE);
}
if ($token !== $this->csrfToken->receiveToken()) {
$this->addError(FORM_TOKEN_INVALID);
}
}
}
</code></div>
<h3>Templates</h3>
<p>
The "templates" directory contains all the design files for this framework.
You can add multiple layouts and additional pages:
</p>
<blockquote>
<path to project>/templates/layout/main/*.php<br>
<path to project>/templates/layout/*<br>
<path to project>/templates/main_page/main_page.php<br>
<path to project>/templates/main_page/name_info.php
</blockquote>
<h3>Tests</h3>
<p>
The "tests" directory contains the framework's test files.
You can modify its contents:
</p>
<blockquote>
<path to project>/tests/Browser/MainPageBrowserTest.php<br>
<path to project>/tests/Repository/UserRepositoryTest.php<br>
<path to project>/tests/Validator/MainPageValidatorTest.php<br>
<path to project>/tests/bootstrap.php
</blockquote>
<h3>Translations</h3>
<p>The "translations" directory contains all translation files:</p>
<blockquote>
<path to project>/translations/languages.php<br>
<path to project>/translations/languages.en.php<br>
<path to project>/translations/languages.pl.php<br>
<path to project>/translations/messages.en.php<br>
<path to project>/translations/messages.pl.php<br>
<path to project>/translations/validators.en.php<br>
<path to project>/translations/validators.pl.php
</blockquote>
<h3>Vendor</h3>
<p>The "vendor" directory contains all libraries added by <strong>Composer</strong>:</p>
<blockquote>
<path to project>/vendor/*<br>
<path to project>/vendor/autoload.php
</blockquote>
<span id="development"></span>
<h2>3. Development</h2>
<p>
The easiest way to develop this software is to use <strong>Docker Desktop</strong>.
To do so, follow the instructions below.
</p>
<p>Go to the application directory:</p>
<blockquote>cd <path to project></blockquote>
<p>Start the application stack defined in "docker-compose.yml":</p>
<blockquote>docker-compose up -d</blockquote>
<p>Set the permissions and access for the "fwe-php-apache" container:</p>
<blockquote>
docker exec -it fwe-php-apache bash<br>
cd /var/www<br>
ls -l<br>
chmod 777 /var/www/html<br>
chown -R www-data:www-data /var/www/html<br>
ls -l<br>
exit
</blockquote>
<p>Use <strong>Composer</strong> to install the needed dependencies from the "composer.json" file:</p>
<blockquote>
docker exec -it fwe-php-apache bash<br>
cd /var/www/html<br>
composer install
</blockquote>
<p>Run the <strong>PHPUnit Tests</strong>:</p>
<blockquote>docker exec -it fwe-php-apache vendor/bin/phpunit tests</blockquote>
<p>Open this web application and/or <strong>phpMyAdmin</strong> in your browser:</p>
<blockquote>
http://localhost:8000<br>
http://localhost:8001
</blockquote>
<p>Stop the application stack:</p>
<blockquote>docker-compose down</blockquote>
<span id="upgrade"></span>
<h2>4. Upgrade</h2>
<p>
These EEQ Framework core classes are located in the "src/Core/*" directory.
You'll need to copy the new ones to the updated project and fix any inconsistencies in other application files.
</p>
<span id="change-logs"></span>
<h2>5. Change Logs</h2>
<h3>v0.4.0 - 26 November 2025</h3>
<p>
- Update: Core classes changed<br>
- Fix: MyPDO class fixed
</p>
<h3>v0.3.0 - 30 June 2025</h3>
<p>
- Add: MyPDO class added<br>
- Update: Core classes changed<br>
- Fix: Database security improvements
</p>
<h3>v0.2.0 - 11 June 2025</h3>
<p>
- Update: Many classes changed<br>
- Fix: Many security improvements
</p>
<h3>v0.1.0 - 20 February 2025</h3>
<p>- Initial release</p>
</div>
</body>
</html>