$status = urldecode($_POST['status']);
        echo json_encode(array('automount' => toggle_samba_automount($device, $status)));
        break;
    case 'set_samba_command':
        $device = urldecode($_POST['device']);
        $cmd = urldecode($_POST['command']);
        set_samba_config($device, "command_bg", urldecode($_POST['background']));
        echo json_encode(array('result' => set_samba_config($device, "command", $cmd)));
        break;
    case 'get_preclear':
        $device = urldecode($_POST['device']);
        if (is_file("/tmp/preclear_stat_{$device}")) {
            $preclear = explode("|", file_get_contents("/tmp/preclear_stat_{$device}"));
            $status = count($preclear) > 3 ? file_exists("/proc/" . trim($preclear[3])) ? "<span style='color:#478406;'>{$preclear[2]}</span>" : "<span style='color:#CC0000;'>{$preclear[2]} <a class='exec' style='color:#CC0000;font-weight:bold;' onclick='rm_preclear(\"{$device}\");' title='Clear stats'> <i class='glyphicon glyphicon-remove hdd'></i></a></span>" : $preclear[2] . " <a class='exec' style='color:#CC0000;font-weight:bold;' onclick='rm_preclear(\"{$device}\");' title='Clear stats'> <i class='glyphicon glyphicon-remove hdd'></i></a>";
            $status = str_replace("^n", "<br>", $status);
            if (tmux_is_session("preclear_disk_{$device}") && is_file("plugins/preclear.disk/Preclear.php")) {
                $status = "{$status}<a class='openPreclear exec' onclick='openPreclear(\"{$device}\");' title='Preview'><i class='glyphicon glyphicon-eye-open'></i></a>";
            }
            echo json_encode(array('preclear' => "<i class='glyphicon glyphicon-dashboard hdd'></i><span style='margin:4px;'></span>" . $status));
        } else {
            echo json_encode(array('preclear' => " "));
        }
        break;
    case 'rm_preclear':
        $device = urldecode($_POST['device']);
        @unlink("/tmp/preclear_stat_{$device}");
        break;
}
switch ($_GET['action']) {
    case 'change_mountpoint':
        $serial = urldecode($_GET['serial']);
Beispiel #2
0
function tmux_kill_window($name) {
  if (tmux_is_session($name)) {
    exec("/usr/bin/tmux kill-window -t '${name}' 2>/dev/null");
  }
}