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("iwlist wlan0 scan", '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;
return false;
}
+
+ public static function getsearchAction()
+ {
+ return array();
+ }
+
+ public static function searchAction()
+ {
+ $cache = new Cache();
+
+ $list = $cache->findTitles($_POST['keyword']);
+
+ return ['results' => $list,
+ 'playlist' => $_SESSION['playlist']];
+ }
+
+ public static function getresultsAction()
+ {
+ return array();
+ }
+
+ public static function playlistSelectAction()
+ {
+ $_SESSION['playlist'] = $_POST['name'];
+ }
+
+ public static function getplaylistsAction()
+ {
+ $playlists = new Playlists();
+ $selected = null;
+ if (array_key_exists('playlist', $_SESSION))
+ $selected = $_SESSION['playlist'];
+
+ return ['list' => $playlists->getList(),
+ 'selected' => $selected];
+ }
+
+ public static function playlistAction()
+ {
+ $playlists = new Playlists();
+
+ return ['title' => $_POST['name'],
+ 'list' => $playlists->getContents($_POST['name'])];
+ }
+
+ public function playlistNewAction()
+ {
+ $playlists = new Playlists();
+ $playlists->create($_POST['name']);
+ }
+
+ public function playlistAddAction()
+ {
+ $cache = new Cache();
+ $playlists = new Playlists();
+
+ if (!array_key_exists('playlist', $_SESSION))
+ return;
+
+ $playlists->add($_SESSION['playlist'], $cache->getRelativePath($_POST['id']));
+ }
}