mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 09:18:54 +00:00
1aae452c2a
[ci skip] [skip ci]
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
|
|
|
|
use nntmux\Regexes;
|
|
use App\Models\Category;
|
|
|
|
$page = new AdminPage();
|
|
$regexes = new Regexes(['Settings' => $page->pdo, 'Table_Name' => 'collection_regexes']);
|
|
$error = '';
|
|
$regex = ['id' => '', 'regex' => '', 'description' => '', 'group_regex' => '', 'ordinal' => '', 'status' => 1];
|
|
|
|
switch ($_REQUEST['action'] ?? 'view') {
|
|
case 'submit':
|
|
if ($_POST['group_regex'] === '') {
|
|
$error = 'Group regex must not be empty!';
|
|
break;
|
|
}
|
|
|
|
if ($_POST['regex'] === '') {
|
|
$error = 'Regex cannot be empty';
|
|
break;
|
|
}
|
|
|
|
if ($_POST['description'] === '') {
|
|
$_POST['description'] = '';
|
|
}
|
|
|
|
if (! is_numeric($_POST['ordinal']) || $_POST['ordinal'] < 0) {
|
|
$error = 'Ordinal must be a number, 0 or higher.';
|
|
break;
|
|
}
|
|
|
|
if ($_POST['id'] === '') {
|
|
$regexes->addRegex($_POST);
|
|
} else {
|
|
$regexes->updateRegex($_POST);
|
|
}
|
|
|
|
header('Location:'.WWW_TOP.'/collection_regexes-list.php');
|
|
break;
|
|
|
|
case 'view':
|
|
default:
|
|
if (isset($_GET['id'])) {
|
|
$page->title = 'Collections Regex Edit';
|
|
$regex = $regexes->getRegexByID($_GET['id']);
|
|
} else {
|
|
$page->title = 'Collections Regex Add';
|
|
$regex += ['status' => 1];
|
|
}
|
|
break;
|
|
}
|
|
|
|
$page->smarty->assign('regex', $regex);
|
|
$page->smarty->assign('error', $error);
|
|
$page->smarty->assign('status_ids', [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE]);
|
|
$page->smarty->assign('status_names', ['Yes', 'No']);
|
|
|
|
$page->content = $page->smarty->fetch('collection_regexes-edit.tpl');
|
|
$page->render();
|