$part = urldecode($_POST['part']); $cmd = urldecode($_POST['command']); set_config($serial, "command_bg.{$part}", urldecode($_POST['background'])); echo json_encode(array('result' => set_config($serial, "command.{$part}", $cmd))); break; case 'remove_config': $serial = urldecode($_POST['serial']); echo json_encode(array('result' => remove_config_disk($serial))); break; case 'toggle_share': $info = json_decode(html_entity_decode($_POST['info']), true); $status = urldecode($_POST['status']); $result = toggle_share($info['serial'], $info['part'], $status); echo json_encode(array('result' => $result)); if ($result && strlen($info['target'])) { add_smb_share($info['mountpoint'], $info['label']); } else { rm_smb_share($info['mountpoint'], $info['label']); } break; case 'list_samba_shares': $ip = urldecode($_POST['IP']); $user = isset($_POST['USER']) ? urlencode($_POST['USER']) : NULL; $pass = isset($_POST['PASS']) ? urlencode($_POST['PASS']) : NULL; $login = $user ? $pass ? "-U '{$user}%{$pass}'" : "-U '{$user}' -N" : "-U%"; echo shell_exec("smbclient -g -L {$ip} {$login} 2>&1|awk -F'|' '/Disk/{print \$2}'|sort"); break; case 'add_samba_mount': $ip = urldecode($_POST['IP']); $user = isset($_POST['USER']) ? urldecode($_POST['USER']) : ""; $pass = isset($_POST['PASS']) ? urldecode($_POST['PASS']) : "";
function reload_shares() { // Disk mounts foreach (get_unasigned_disks() as $name => $disk) { foreach ($disk['partitions'] as $p) { if (is_mounted(realpath($p), true)) { $info = get_partition_info($p); $attrs = isset($_ENV['DEVTYPE']) ? get_udev_info($device, $_ENV, $reload) : get_udev_info($device, NULL, $reload); if (config_shared($info['serial'], $info['part'], strpos($attrs['DEVPATH'], "usb"))) { unassigned_log("Reloading shared dir '{$info[target]}'."); unassigned_log("Removing old config..."); rm_smb_share($info['target'], $info['label']); rm_nfs_share($info['target']); unassigned_log("Adding new config..."); add_smb_share($info['mountpoint'], $info['label']); add_nfs_share($info['mountpoint']); } } } } // SMB Mounts foreach (get_samba_mounts() as $name => $info) { if (is_mounted($info['device'])) { unassigned_log("Reloading shared dir '{$info[mountpoint]}'."); unassigned_log("Removing old config..."); rm_smb_share($info['mountpoint'], $info['device']); add_smb_share($info['mountpoint'], $info['device']); } } // Iso File Mounts foreach (get_iso_mounts() as $name => $info) { if (is_mounted($info['device'])) { unassigned_log("Reloading shared dir '{$info[mountpoint]}'."); unassigned_log("Removing old config..."); rm_smb_share($info['mountpoint'], $info['device']); rm_nfs_share($info['mountpoint']); add_smb_share($info['mountpoint'], $info['device']); add_nfs_share($info['mountpoint']); } } }