Files
nexusphp/public/fields.php

56 lines
1.6 KiB
PHP
Raw Normal View History

2021-03-02 21:03:02 +08:00
<?php
require "../include/bittorrent.php";
dbconn();
require_once(get_langfile_path());
loggedinorreturn();
if (get_user_class() < UC_ADMINISTRATOR) {
permissiondenied();
}
$field = new \Nexus\Field\Field();
$action = $_GET['action'] ?? 'view';
if ($action == 'view') {
stdhead($lang_fields['field_management']." - ".$lang_fields['text_field']);
begin_main_frame();
2021-03-03 00:23:08 +08:00
$r = $field->buildFieldTable();
echo $r;
stdfoot();
2021-03-02 21:03:02 +08:00
} elseif ($action == 'add') {
stdhead($lang_fields['field_management']." - ".$lang_fields['text_add']);
begin_main_frame();
echo $field->buildFieldForm();
} elseif ($action == 'submit') {
try {
$result = $field->save($_REQUEST);
2021-03-18 02:01:12 +08:00
redirect('fields.php?action=view');
2021-03-02 21:03:02 +08:00
} catch (\Exception $e) {
2021-03-18 20:32:35 +08:00
stderr($lang_fields['field_management'], $e->getMessage());
2021-03-02 21:03:02 +08:00
}
} elseif ($action == 'edit') {
$id = intval($_GET['id'] ?? 0);
if ($id == 0) {
2021-03-18 02:01:12 +08:00
stderr($lang_fields['field_management'], "Invalid id");
2021-03-02 21:03:02 +08:00
}
$sql = "select * from torrents_custom_fields where id = $id";
$res = sql_query($sql);
$row = mysql_fetch_assoc($res);
if (empty($row)) {
2021-03-18 02:01:12 +08:00
stderr('', 'Invalid id');
2021-03-02 21:03:02 +08:00
}
stdhead($lang_fields['field_management']." - ".$lang_fields['text_edit']);
begin_main_frame();
echo $field->buildFieldForm($row);
2021-03-03 01:56:07 +08:00
} elseif ($action == 'del') {
$id = intval($_GET['id'] ?? 0);
if ($id == 0) {
2021-03-18 02:01:12 +08:00
stderr($lang_fields['field_management'], "Invalid id");
2021-03-03 01:56:07 +08:00
}
$sql = "delete from torrents_custom_fields where id = $id";
$res = sql_query($sql);
2021-03-18 02:01:12 +08:00
redirect('fields.php?action=view');
2021-03-02 21:03:02 +08:00
}