aaronhurt / zfs-replicate

POSIX compliant shell script to manage ZFS snapshot replication locally, or between hosts.
72 stars 17 forks source link

PHP page for XigmaNAS? #20

Closed tschettervictor closed 2 months ago

tschettervictor commented 2 months ago

This isn’t really an issue, but I’m looking to code a php page to work with xigmanas.

inhabe the overall layout pretty well set up, but since I do not know php too well, I was wondering if anyone could assist in a simple task.

I want each of the checkboxes to update the respective values in the config file, as well as the text boxes. Here is the starting php file


// zfs-replicate.php

require_once 'auth.inc';
require_once 'guiconfig.inc';

// Initialize the page
$pgtitle = [gtext("Extensions"), gtext('ZFS Replicate')];
include 'fbegin.inc';
?>

<style>
    .file-chooser-btn {
        margin: 5px 0;
        padding: 5px 10px;
        border: 1px solid #007bff;
        border-radius: 5px;
        background-color: #007bff;
        color: #fff;
        cursor: pointer;
    }

    .file-chooser-btn:hover {
        background-color: #0056b3;
    }
</style>

<table id="area_data">
    <tbody>
        <tr>
            <td id="area_data_frame">
                <table class="area_data_settings">
                    <colgroup>
                        <col class="area_data_settings_col_tag">
                        <col class="area_data_settings_col_data">
                    </colgroup>
                    <thead>
                        <?php html_titleline2(gettext('Settings')); ?>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="celltag"><?= gtext('Hostname or IP of Remote Server'); ?></td>
                            <td class="celldata">
                                <input type="text" name="remote_server" id="remote_server" placeholder="<?= gtext('IP or Hostname'); ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Recursive Snapshots'); ?></td>
                            <td class="celldata">
                                <input type="checkbox" name="recurse_children" id="recurse_children" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Allow Replicate from Scratch'); ?></td>
                            <td class="celldata">
                                <input type="checkbox" name="allow_replicate_from_scratch" id="allow_replicate_from_scratch" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Allow Root Datasets'); ?></td>
                            <td class="celldata">
                                <input type="checkbox" name="allow_root_datasets" id="allow_root_datasets" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Snapshot Keep'); ?></td>
                            <td class="celldata">
                                <input type="number" name="snapshot_keep" id="snapshot_keep" min="0" value="2" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Log Keep'); ?></td>
                            <td class="celldata">
                                <input type="number" name="log_keep" id="log_keep" min="0" value="5" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Replication Type'); ?></td>
                            <td class="celldata">
                                <select name="local_remote" id="local_remote">
                                    <option value="local"><?= gtext('REMOTE'); ?></option>
                                    <option value="remote"><?= gtext('LOCAL'); ?></option>
                                </select>
                            </td>
                        </tr>
            <tr>
                            <td class="celltag"><?= gtext('Replication Mode'); ?></td>
                            <td class="celldata">
                                <select name="replication_direction" id="replication_direction">
                                    <option value="push"><?= gtext('PULL'); ?></option>
                                    <option value="pull"><?= gtext('PUSH'); ?></option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Local Dataset'); ?></td>
                            <td class="celldata">
                                <input type="text" name="local_file" id="local_file" placeholder="<?= gtext('Enter Local Dataset'); ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td class="celltag"><?= gtext('Remote Dataset'); ?></td>
                            <td class="celldata">
                                <input type="text" name="remote_file" id="remote_file" placeholder="<?= gtext('Enter Remote Dataset'); ?>" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>

<?php
include 'fend.inc';
?>```