예제 #1
0
function wrk_sourcecfg($db, $queueargs)
{
    $action = $queueargs['mount']['action'];
    unset($queueargs['mount']['action']);
    switch ($action) {
        case 'reset':
            $dbh = cfgdb_connect($db);
            $source = cfgdb_read('cfg_source', $dbh);
            foreach ($source as $mp) {
                sysCmd("umount -f \"/mnt/NAS/" . $mp['name'] . "\"");
                sysCmd("rmdir \"/mnt/NAS/" . $mp['name'] . "\"");
            }
            if (cfgdb_delete('cfg_source', $dbh)) {
                $return = 1;
            } else {
                $return = 0;
            }
            $dbh = null;
            break;
        case 'add':
            $dbh = cfgdb_connect($db);
            print_r($queueargs);
            unset($queueargs['mount']['id']);
            // format values string
            foreach ($queueargs['mount'] as $key => $value) {
                if ($key == 'error') {
                    $values .= "'" . SQLite3::escapeString($value) . "'";
                    error_log(">>>>> values on line 1014 >>>>> " . $values, 0);
                } else {
                    $values .= "'" . SQLite3::escapeString($value) . "',";
                    error_log(">>>>> values on line 1016 >>>>> " . $values, 0);
                }
            }
            error_log(">>>>> values on line 1019 >>>>> " . $values, 0);
            // write new entry
            cfgdb_write('cfg_source', $dbh, $values);
            $newmountID = $dbh->lastInsertId();
            $dbh = null;
            if (wrk_sourcemount($db, 'mount', $newmountID)) {
                $return = 1;
            } else {
                $return = 0;
            }
            break;
        case 'edit':
            $dbh = cfgdb_connect($db);
            $mp = cfgdb_read('cfg_source', $dbh, '', $queueargs['mount']['id']);
            cfgdb_update('cfg_source', $dbh, '', $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'] . "\"");
            }
            if (wrk_sourcemount($db, 'mount', $queueargs['mount']['id'])) {
                $return = 1;
            } else {
                $return = 0;
            }
            error_log(">>>>> wrk_sourcecfg(edit) exit status = >>>>> " . $return, 0);
            $dbh = null;
            break;
        case 'delete':
            $dbh = cfgdb_connect($db);
            $mp = cfgdb_read('cfg_source', $dbh, '', $queueargs['mount']['id']);
            sysCmd("umount -f \"/mnt/NAS/" . $mp[0]['name'] . "\"");
            sysCmd("rmdir \"/mnt/NAS/" . $mp[0]['name'] . "\"");
            if (cfgdb_delete('cfg_source', $dbh, $queueargs['mount']['id'])) {
                $return = 1;
            } else {
                $return = 0;
            }
            $dbh = null;
            break;
    }
    return $return;
}
예제 #2
0
     if (!empty($ip_wlan0[0])) {
         $_SESSION['netconf']['wlan0']['ip'] = $ip_wlan0[0];
     } else {
         if (wrk_checkStrSysfile('/proc/net/wireless', 'wlan0')) {
             $_SESSION['netconf']['wlan0']['ip'] = '--- NO IP ASSIGNED ---';
         } else {
             $_SESSION['netconf']['wlan0']['ip'] = '--- NO INTERFACE PRESENT ---';
         }
     }
 }
 sysCmd('service networking restart');
 // reset sourcecfg to defaults
 wrk_sourcecfg($db, 'reset');
 sendMpdCommand($mpd, 'update');
 // reset mpdconf to defaults
 $mpdconfdefault = cfgdb_read('', $dbh, 'mpdconfdefault');
 foreach ($mpdconfdefault as $element) {
     cfgdb_update('cfg_mpd', $dbh, $element['param'], $element['value_default']);
 }
 // tell worker to write new MPD config
 wrk_mpdconf('/etc', $db);
 // update hash
 $hash = md5_file('/etc/mpd.conf');
 playerSession('write', $db, 'mpdconfhash', $hash);
 sysCmd('service mpd restart');
 $dbh = null;
 // disable minidlna / samba / MPD startup
 sysCmd("update-rc.d -f minidlna remove");
 sysCmd("update-rc.d -f ntp remove");
 sysCmd("update-rc.d -f smbd remove");
 sysCmd("update-rc.d -f nmbd remove");
예제 #3
0
파일: sources.php 프로젝트: norrest/test
		$_SESSION['w_active'] = 1;
		// set UI notify
		$_SESSION['notify']['title'] = 'auto.nas modified';
		$_SESSION['notify']['msg'] = 'remount shares in progress...';
		session_write_close();
		} else {
		session_start();
		$_SESSION['notify']['title'] = 'Job Failed';
		$_SESSION['notify']['msg'] = 'background worker is busy.';
		session_write_close();
		}
} */
// wait for worker output if $_SESSION['w_active'] = 1
waitWorker(5, 'sources');
$dbh = cfgdb_connect($db);
$source = cfgdb_read('cfg_source', $dbh);
$dbh = null;
// set normal config template
$tpl = "sources.html";
// unlock session files
playerSession('unlock', $db, '', '');
foreach ($source as $mp) {
    if (wrk_checkStrSysfile('/proc/mounts', $mp['name'])) {
        $icon = "<i class='fa fa-check green sx'></i>";
    } else {
        $icon = "<i class='fa fa-remove red sx'></i>";
    }
    $_mounts .= "<p><a href=\"sources.php?p=edit&id=" . $mp['id'] . "\" class='btn btn-large btn-block'> " . $icon . " NAS/" . $mp['name'] . "&nbsp;&nbsp;&nbsp;&nbsp;//" . $mp['address'] . "/" . $mp['remotedir'] . " </a></p>";
}
?>
예제 #4
0
    } else {
        session_start();
        $_SESSION['notify']['title'] = 'Job Failed';
        $_SESSION['notify']['msg'] = 'Background worker is busy.';
        session_write_close();
    }
}
// wait for worker output if $_SESSION['w_active'] = 1
waitWorker(1);
// check integrity of /etc/network/interfaces
if (!hashCFG('check_mpd', $db)) {
    $_mpdconf = file_get_contents('/etc/mpd.conf');
    // set manual config template
    $tpl = "mpd-config-manual.html";
} else {
    $mpdconf = cfgdb_read('', $dbh, 'mpdconf');
    // prepare array
    $_mpd = array('port' => '', 'gapless_mp3_playback' => '', 'auto_update' => '', 'samplerate_converter' => '', 'auto_update_depth' => '', 'zeroconf_enabled' => '', 'zeroconf_name' => '', 'audio_output_format' => '', 'mixer_type' => '', 'audio_buffer_size' => '', 'buffer_before_play' => '', 'dop' => '', 'device' => '', 'volume_normalization' => '');
    //debug($mpdconf);
    // parse output for template $_mpdconf
    foreach ($mpdconf as $key => $value) {
        foreach ($_mpd as $key2 => $value2) {
            if ($value['param'] == $key2) {
                $_mpd[$key2] = $value['value_player'];
            }
        }
    }
    // setup select dropdown menu for template
    // gapeless_mp3_playback
    $_mpd_select['gapless_mp3_playback'] .= "<option value=\"yes\" " . ($_mpd['gapless_mp3_playback'] == 'yes' ? "selected" : "") . " >yes</option>\n";
    $_mpd_select['gapless_mp3_playback'] .= "<option value=\"no\" " . ($_mpd['gapless_mp3_playback'] == 'no' ? "selected" : "") . " >no</option>\n";
예제 #5
0
        $_SESSION['notify']['msg'] = 'Background worker busy';
    }
    // unlock session file
    playerSession('unlock');
}
// wait for worker output if $_SESSION['w_active'] = 1
waitWorker(1);
// check integrity of /etc/network/interfaces
if (!hashCFG('check_net', $db)) {
    $_netconf = file_get_contents('/etc/network/interfaces');
    // set manual config template
    $tpl = "net-config-manual.html";
} else {
    $dbh = cfgdb_connect($db);
    $net = cfgdb_read('cfg_lan', $dbh);
    $wifisec = cfgdb_read('cfg_wifisec', $dbh);
    $dbh = null;
    $ipe = "ip addr list eth0 |grep \"inet \" |cut -d' ' -f6|cut -d/ -f1";
    $ipw = "ip addr list wlan0 |grep \"inet \" |cut -d' ' -f6|cut -d/ -f1";
    $ipeth0 = exec($ipe);
    $ipwlan0 = exec($ipw);
    $spe = "ethtool eth0 | grep -i speed | tr -d 'Speed:'";
    $speth0 = exec($spe);
    //getting signal quality percentage
    $quw = "iwconfig wlan0 | grep 'Link Quality' | awk '{print \$2}' | tr -d 'Quality=' |  cut -c 1-2";
    $quwg = exec($quw);
    $quwlan0 = round($quwg / 70 * 100);
    $bitr = "iwconfig wlan0 | grep 'Bit Rate' | awk '{print \$2}' | tr -d 'Bit Rate='";
    $bitrate = exec($bitr);
    if (!empty($ipeth0)) {
        $statuset = 'Connected <i class="icon-ok green sx"></i>';