Files
nexusphp/public/fields.php

58 lines
1.8 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());
2022-09-19 16:27:04 +08:00
require_once(get_langfile_path('catmanage.php'));
2021-03-02 21:03:02 +08:00
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') {
die("This method is deprecated! This method is no longer available in 1.10, it does not save data correctly, please go to the management system!");
2021-03-02 21:03:02 +08:00
try {
$result = $field->save($_REQUEST);
2021-04-21 00:07:32 +08:00
nexus_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-04-21 00:07:32 +08:00
nexus_redirect('fields.php?action=view');
2021-03-02 21:03:02 +08:00
}