return $ok;
}
+ public static function getnetworkAction()
+ {
+ $name = NULL;
+ $conf = '/etc/network/interfaces.d/uplink.conf';
+ if (file_exists($conf)) {
+ $dest = readlink($conf);
+ $name = substr($dest, 9, -5);
+ }
+
+ $upstream = [];
+ foreach (new DirectoryIterator(dirname($conf)) as $fileInfo) {
+ if (substr($fileInfo->getBasename(), 0, 9) != 'upstream_') continue;
+ $upstream[] = substr($fileInfo->getBasename('.conf'), 9);
+ }
+ sort($upstream);
+
+ $ip = NULL;
+ $lines = [];
+ $f = popen("ip -f inet addr show wlan0", 'r');
+ while (($line = fgets($f)) !== false)
+ $lines[] = rtrim($line);
+ pclose($f);
+ if (count($lines)) {
+ if (preg_match('/inet (\d+\.\d+\.\d+\.\d+)\/.*/', $lines[1], $matches))
+ $ip = $matches[1];
+ }
+
+ $networks = [];
+ $f = popen("(sudo iwlist wlan0 scan; sudo iwlist wlan1 scan)|sort -u", 'r');
+ while (($line = fgets($f)) !== false) {
+ if (preg_match('/ESSID:"(.*?)"/', $line, $matches))
+ if (strlen($matches[1]))
+ $networks[] = $matches[1];
+ }
+ pclose($f);
+ sort($networks);
+
+ return ['name' => $name,
+ 'ip' => $ip,
+ 'networks' => $networks,
+ 'upstream' => $upstream];
+ }
+
+ public static function networkAction()
+ {
+ $ok = self::callCommand("super musiikki-wlan", array($_POST['wlan']));
+
+ return $ok;
+ }
+
+ public static function essidAction()
+ {
+ if (!preg_match('/^[A-Za-z0-9_-]+$/', $_POST['name']))
+ return;
+
+ $ok = self::callCommand("super musiikki-essid", array($_POST['name'], $_POST['essid'], $_POST['psk']));
+
+ return $ok;
+ }
+
public static function getsharesAction()
{
return array('ro_name' => '\\\\' . $_SERVER['SERVER_ADDR'] .'\\'. Config::SHARE_READ,
public static function haltAction()
{
+ $ok = self::callCommand("super musiikki-wlan", array(''));
$ok = self::callCommand("super musiikki-halt");
return $ok;
{
$mtime = filemtime(Config::main()->get('cache'));
- return array('modified' => date ("d. F Y H:i:s", $mtime));
+ $result = array('modified' => date ("d. F Y H:i:s", $mtime),
+ 'running' => $mtime > time()-10,
+ );
+
+ return $result;
+ }
+
+ public static function rescanstatusAction()
+ {
+ $cmd = "tail -n 1 /var/log/minidlna.log 2>&1";
+
+ $file = '';
+ $line = shell_exec($cmd);
+ if ($line !== false && !is_null($line)) {
+ $search = "info: Scanning /media/music/music/";
+ $pos = strpos($line, $search);
+ if ($pos !== false)
+ $file = substr($line, $pos + strlen($search));
+ }
+
+ $mtime = filemtime(Config::main()->get('cache'));
+
+ $result = array('file' => $file,
+ 'end' => $mtime < time()-60);
+
+ return $result;
}
public static function rescanAction()