- Created separate MoneyFlix project directory - Copied Node.js redirector from production server - Added CRM PHP code (Redirects module, Core classes, Config, Routes, Views) - Created comprehensive documentation (README_MONEYFLIX.md) - Added sync script to keep CRM code updated (sync-from-crm.sh) - Configured .gitignore for Node.js and PHP - Set up proper project structure for multi-client isolation This separates MoneyFlix from the main CRM to avoid confusion between different client systems and provides a dedicated environment for MoneyFlix-specific development and maintenance.
71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Core;
|
|
|
|
class CrontabTask
|
|
{
|
|
public string $id;
|
|
public string $schedule;
|
|
public string $command;
|
|
public ?string $args = null;
|
|
public ?string $redirect = null;
|
|
public ?string $raw = null;
|
|
public array $comments = [];
|
|
public ?string $special = null; // @reboot, @hourly, etc.
|
|
|
|
public function __construct(string $rawLine, array $comments = [])
|
|
{
|
|
$this->raw = $rawLine;
|
|
$this->comments = $comments;
|
|
$this->parse($rawLine);
|
|
$this->id = md5(trim($rawLine));
|
|
}
|
|
|
|
private function parse(string $line): void
|
|
{
|
|
// Remove inline comments (mas guarda para display)
|
|
$line = preg_replace('/\s+#.*/', '', $line);
|
|
|
|
// Suporte a @reboot, @hourly, etc.
|
|
if (preg_match('/^(@\w+)\s+(.*)$/', $line, $matches)) {
|
|
$this->special = $matches[1];
|
|
$this->schedule = $matches[1];
|
|
$rest = $matches[2];
|
|
} else {
|
|
// Split schedule (5 campos) + comando
|
|
$parts = preg_split('/\s+/', $line, 6);
|
|
if (count($parts) < 6) {
|
|
$this->schedule = '';
|
|
$this->command = '';
|
|
return;
|
|
}
|
|
[$min, $hour, $dom, $mon, $dow, $rest] = $parts;
|
|
$this->schedule = "$min $hour $dom $mon $dow";
|
|
}
|
|
|
|
// Separa comando, args e redirecionamentos
|
|
if (preg_match('/^([^\s]+)(.*?)(\s+>\s*.+)?$/', $rest, $matches)) {
|
|
$this->command = trim($matches[1]);
|
|
$this->args = isset($matches[2]) ? trim($matches[2]) : null;
|
|
$this->redirect = isset($matches[3]) ? trim($matches[3]) : null;
|
|
} else {
|
|
$this->command = trim($rest);
|
|
}
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'schedule' => $this->schedule,
|
|
'command' => $this->command,
|
|
'args' => $this->args,
|
|
'redirect' => $this->redirect,
|
|
'raw' => $this->raw,
|
|
'comments' => $this->comments,
|
|
'special' => $this->special,
|
|
];
|
|
}
|
|
}
|