Compare commits

..

3 commits

6 changed files with 67 additions and 21 deletions

1
.gitignore vendored
View file

@ -2,4 +2,3 @@ sessions/*
conf/conf.local.php conf/conf.local.php
ignore ignore
.pi-tasks .pi-tasks
docs/framework_review.md

View file

@ -1,48 +1,50 @@
ZAP is a refactorment of the Zap Machine V0.3.2 from ApFab
It's more like a framework now.
todo ZAP
- add .htaccess file
# ZAP # ZAP
0.5.0 Continued developing with the way better structured ZAPV
- updated the search engines removed Yahoo, added Bing
## 0.9.0
- updated the search engines removed Yahoo and Bing, switched to Brave search
- optimized and updated the framework to work with PHP 8.5
# ZAPV # ZAPV
0.1.0 ZAP is a refactorment of the Zap Machine V0.3.2 from ApFab
It's more like a framework now.
## 0.1.0
- new public release of ZAP - new public release of ZAP
0.0.9 ## 0.0.9
- made logging dependent - made logging dependent
- made adult searches config dependent - made adult searches config dependent
0.0.8 ## 0.0.8
- refactored the ImgProcess class and removed code to two other classes - refactored the ImgProcess class and removed code to two other classes
- added ImgIOTools and ImgTools. They contain static functions - added ImgIOTools and ImgTools. They contain static functions
0.0.7 ## 0.0.7
- refactored the whole search engine part - refactored the whole search engine part
- made an interface for future implementations of other search engines - made an interface for future implementations of other search engines
0.0.6 ## 0.0.6
- added a Config class - added a Config class
0.0.5 ## 0.0.5
- split the search code to separate functions - split the search code to separate functions
- added ZAPCurl util class - added ZAPCurl util class
0.0.4 ## 0.0.4
- split the zap code to separate functions - split the zap code to separate functions
0.0.3 ## 0.0.3
- refactored all classes to more readable code - refactored all classes to more readable code
- created Session utils class - created Session utils class
0.0.2 ## 0.0.2
- created new index.php and front controller - created new index.php and front controller
- added conf.php and init.php - added conf.php and init.php
0.0.1 ## 0.0.1
- reworked frontend to separate html and js - reworked frontend to separate html and js

39
docs/framework_review.md Normal file
View file

@ -0,0 +1,39 @@
# ZAP Framework Review
Task #10 — *“Check if the framework is the optimal, most simple and flexible way to go. If not: suggest some changes.”*
This review audits the internal ZapMachine PHP framework (documented in `docs/framework_guide.md`) against three criteria — **optimal**, **simple**, and **flexible** — based on a full read of the current source on branch `optimize-framework` (commit `d971512`).
**Scope:** audit + recommendations only. **No source files are modified in this deliverable.** Every recommendation below is a proposal that should get its own kanban task and separate approval before implementation.
---
## Verdict
The frameworks **architecture is genuinely simple and flexible** for its scope. Adding a new page (`?mode=`) is a one-class + one-template operation with zero registration. Adding a new search engine is a one-class operation behind a clean interface. PHP-native templating means no build step and no engine dependency. These are real strengths and should be preserved.
It is **not optimal**, however, because:
1. **Three P0 correctness bugs** silently degrade the core search pipeline (Brave `size`/`offset` params never sent; query double-URL-encoded; autoloader path split hardcodes `':'`).
2. **Unsafe / committed config defaults** (`ZAP_DEBUG=true`, placeholder API key in git-tracked `conf/conf.php`, `chmod 777`).
3. **Several loose abstraction boundaries** make the “framework contract” described in the guide looser than the code actually enforces (no `ZAPHandler` interface, inconsistent `extract()` template pattern, raw `$_SESSION` access beside a `Session` wrapper).
None of these require replacing the architecture. They are bug fixes, a config-hygiene pass, and a few small interface tightenings. Recommended effort: a handful of small, well-scoped tasks — **not** a rewrite.
---
## Strengths worth preserving
| Aspect | Why its good |
|---|---|
| Front-controller + naming convention (`ZAP` + ucfirst(mode)) | Zero-config routing. A new mode = one class in `lib/` + one `.tpl`. No route table, no registration. Very flexible, very simple. (`lib/ZAPController.class.php`) |
| `spl_autoload_register` over the include path | No manual `require_once` for library classes; drop a `.class.php` in the right dir and it loads. (`conf/init.php`) |
| `Search` interface plugin system | Engines are interchangeable behind a 3-method contract and a universal result-array shape. Adding `Pixabay`/`Pexels` (tasks #1/#2) is a clean drop-in. (`resource/Search.interface.php`, `resource/Brave.class.php`) |
| PHP-native templates (`ob_start`/`include`/`extract`/`ob_get_clean`) | No template engine, no compilation step, no extra dependency. Simplest possible rendering. |
| `Config` singleton | Decouples runtime config (e.g. registered engines) from individual classes. (`conf/Config.class.php`) |
| Clear layering | routing / handlers / search / imaging / utils are in separate dirs with single responsibilities. |
These answer the “simple and flexible” part of the brief affirmatively. The rest of this document is about getting to “optimal.”
---

View file

@ -91,3 +91,5 @@
{"timestamp":"2026-07-20T01:09:23.947300407+02:00","action":"edit","task_id":19,"detail":"Single source of truth for word count + cleanup handleWords"} {"timestamp":"2026-07-20T01:09:23.947300407+02:00","action":"edit","task_id":19,"detail":"Single source of truth for word count + cleanup handleWords"}
{"timestamp":"2026-07-20T01:09:23.947430566+02:00","action":"claim","task_id":19,"detail":"rain-raven"} {"timestamp":"2026-07-20T01:09:23.947430566+02:00","action":"claim","task_id":19,"detail":"rain-raven"}
{"timestamp":"2026-07-20T01:09:23.97076796+02:00","action":"move","task_id":19,"detail":"todo -\u003e done"} {"timestamp":"2026-07-20T01:09:23.97076796+02:00","action":"move","task_id":19,"detail":"todo -\u003e done"}
{"timestamp":"2026-07-20T14:15:55.814485137+02:00","action":"move","task_id":12,"detail":"review -\u003e done"}
{"timestamp":"2026-07-20T14:15:59.830512648+02:00","action":"move","task_id":11,"detail":"review -\u003e done"}

View file

@ -1,10 +1,12 @@
--- ---
id: 11 id: 11
title: 'Fix Brave request building: lazy URL + single encode' title: 'Fix Brave request building: lazy URL + single encode'
status: review status: done
priority: high priority: high
created: 2026-07-17T03:57:00.444816503+02:00 created: 2026-07-17T03:57:00.444816503+02:00
updated: 2026-07-17T12:26:38.759875442+02:00 updated: 2026-07-20T14:15:59.825243496+02:00
started: 2026-07-20T14:15:59.830054903+02:00
completed: 2026-07-20T14:15:59.830054903+02:00
tags: tags:
- search - search
- bug - bug

View file

@ -1,10 +1,12 @@
--- ---
id: 12 id: 12
title: 'Fix autoloader: use PATH_SEPARATOR instead of hardcoded '':''' title: 'Fix autoloader: use PATH_SEPARATOR instead of hardcoded '':'''
status: review status: done
priority: high priority: high
created: 2026-07-17T03:57:06.82901804+02:00 created: 2026-07-17T03:57:06.82901804+02:00
updated: 2026-07-17T12:27:53.056263524+02:00 updated: 2026-07-20T14:15:55.809367918+02:00
started: 2026-07-20T14:15:55.814059562+02:00
completed: 2026-07-20T14:15:55.814059562+02:00
tags: tags:
- framework - framework
- bug - bug