yf_manage_servers admin module

Core servers management.

Fileplugins/sys/admin_modules/yf_manage_servers.class.php
Useadmin URL ?object=manage_servers

Public properties

PropertyDefaultDescription
None declared in this class.

Constants

table'core_servers'

Public methods 5

active

public function active()
    public function active()
    {
        return _class('admin_methods')->active(['table' => self::table]);
    }

add

public function add()
    public function add()
    {
        $a = $_POST;
        return form($a)
            ->validate(['ip' => 'trim|required|valid_ip|is_unique[core_servers.ip]'])
            ->db_insert_if_ok(self::table, ['ip', 'role', 'name', 'hostname', 'comment'], [])
            ->on_after_update(function () {
                cache_del(['servers', 'server_roles']);
                common()->admin_wall_add(['server added: ' . ($_POST['ip'] ?? null) . '', db()->insert_id()]);
            })
            ->text('ip')
            ->text('role')
            ->text('name')
            ->text('hostname')
            ->textarea('comment')
            ->active_box()
            ->save_and_back();
    }

delete

public function delete()
    public function delete()
    {
        return _class('admin_methods')->delete(['table' => self::table]);
    }

edit

public function edit()
    public function edit()
    {
        $a = db()->query_fetch('SELECT * FROM ' . db(self::table) . ' WHERE id=' . (int) (($_GET['id'] ?? null)));
        if ( ! $a['id']) {
            return _e('No id!');
        }
        $a = $_POST ? $a + $_POST : $a;
        return form($a)
            ->validate(['ip' => 'trim|required|valid_ip'])
            ->db_update_if_ok(self::table, ['ip', 'role', 'name', 'hostname', 'comment'], 'id=' . $a['id'])
            ->on_after_update(function () use ($a) {
                cache_del(['servers', 'server_roles']);
                common()->admin_wall_add(['server updated: ' . ($_POST['ip'] ?? null) . '', $a['id']]);
            })
            ->text('ip')
            ->text('role')
            ->text('name')
            ->text('hostname')
            ->textarea('comment')
            ->active_box()
            ->save_and_back();
    }

show

public function show()
    public function show()
    {
        return table('SELECT * FROM ' . db(self::table))
            ->text('ip')
            ->text('role')
            ->text('name')
            ->text('hostname')
            ->text('comment')
            ->btn_active()
            ->btn_edit()
            ->btn_delete()
            ->footer_add();
    }