Toolvana: production-ready media tools platform (CodeIgniter 4)

- 134-tool registry with programmatic SEO (unique titles/H1/descriptions,
  JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter)
- DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD),
  Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG)
- Security: SSRF guard, MIME validation, rate limits, API-key auth,
  bcrypt admin login, security headers
- Admin panel: dashboard, tools/categories/guides CRUD, SEO audit,
  analytics, job inspector with retry, system health, feature flags
- Docker deployment (nginx + web/api FPM pools + scalable workers),
  PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
This commit is contained in:
deepseek
2026-08-23 07:10:30 +00:00
commit beaf0e1f37
217 changed files with 19619 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace App\Libraries\Pipeline;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
/**
* Renders QR codes server-side (PNG) via chillerlan/php-qrcode.
* Text-kind tool: input is `content`, options: size, level, margin.
*/
final class Qr implements DriverInterface
{
public function handle(array $job, array $tool = [], ?callable $update = null): array
{
$update ??= static function (int $p, string $stage): void {
};
$params = json_decode($job['params'] ?? '{}', true) ?: [];
$content = trim((string) ($params['content'] ?? ''));
if ($content === '') {
throw new \RuntimeException('Enter the text or URL to encode.');
}
if (mb_strlen($content) > 1000) {
throw new \RuntimeException('Content too long for a QR code (max 1000 characters).');
}
// error-correction: L ~7%, M ~15%, Q ~25%, H ~30%
$level = strtoupper((string) ($params['level'] ?? 'M'));
if (! in_array($level, ['L', 'M', 'Q', 'H'], true)) {
$level = 'M';
}
$size = (int) ($params['size'] ?? 300);
$size = min(1000, max(120, $size));
$options = new QROptions([
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
'eccLevel' => constant(QRCode::class . '::ECC_' . $level),
'scale' => max(3, (int) round($size / 33)),
'imageBase64' => false,
'quality' => 90,
]);
[, $out] = self::output($job, 'png');
$png = (new QRCode($options))->render($content);
if (! str_starts_with((string) $png, "\x89PNG")) {
throw new \RuntimeException('QR rendering failed.');
}
file_put_contents($out, $png);
return ['file' => basename($out), 'name' => 'qr-code.png', 'ext' => 'png'];
}
private static function output(array $job, string $ext): array
{
$dir = \App\Libraries\Pipeline::storageDir();
$file = \App\Libraries\Pipeline::safeName($job['id'], $ext);
return [$file, $dir . '/' . $file];
}
}