コード例 #1
0
ファイル: worker.php プロジェクト: dermidgen/moode
function wrk_sourcecfg($queueargs)
{
    $action = $queueargs['mount']['action'];
    unset($queueargs['mount']['action']);
    switch ($action) {
        case 'reset':
            $source = ConfigDB::read('cfg_source');
            foreach ($source as $mp) {
                sysCmd("umount -f '/mnt/NAS/" . $mp['name'] . "'");
                sysCmd("rmdir '/mnt/NAS/" . $mp['name'] . "'");
            }
            $return = ConfigDB::delete('cfg_source') ? 1 : 0;
            break;
        case 'add':
            print_r($queueargs);
            unset($queueargs['mount']['id']);
            // write new entry
            $newmountID = ConfigDB::write('cfg_source', array_values($queueargs['mount']));
            $return = wrk_sourcemount('mount', $newmountID) ? 1 : 0;
            break;
        case 'edit':
            $mp = ConfigDB::read('cfg_source', '', $queueargs['mount']['id']);
            ConfigDB::update('cfg_source', '', $queueargs['mount']);
            sysCmd("umount -f '/mnt/NAS/" . $mp[0]['name'] . "'");
            if ($mp[0]['name'] != $queueargs['mount']['name']) {
                sysCmd("rmdir '/mnt/NAS/" . $mp[0]['name'] . "'");
                sysCmd("mkdir '/mnt/NAS/" . $queueargs['mount']['name'] . "'");
            }
            $return = wrk_sourcemount('mount', $queueargs['mount']['id']) ? 1 : 0;
            break;
        case 'delete':
            $mp = ConfigDB::read('cfg_source', '', $queueargs['mount']['id']);
            sysCmd("umount -f '/mnt/NAS/" . $mp[0]['name'] . "'");
            sysCmd("rmdir '/mnt/NAS/" . $mp[0]['name'] . "'");
            $return = ConfigDB::delete('cfg_source', $queueargs['mount']['id']) ? 1 : 0;
            break;
    }
    return $return;
}