4 protected static function callCommand($cmd, array $data=array())
6 if (($pipe = popen($cmd, 'w')) === false)
9 foreach ($data as $value)
10 fwrite($pipe, $value . "\n");
16 public static function getdatetimeAction()
18 return array('year' => date('Y'),
22 'minute' => date('i'),
23 'second' => date('s'));
26 public static function datetimeAction()
28 $date = sprintf("%04d-%02d-%02d", $_POST['year'], $_POST['month'], $_POST['day']);
29 $time = sprintf("%02d:%02d:%02d", $_POST['hour'], $_POST['minute'], $_POST['second']);
31 $ok = self::callCommand("super musiikki-datetime", array($date, $time));
36 public static function getwifiAction()
38 if (!file_exists('/etc/hostapd/hostapd.conf'))
41 if (($f = fopen('/etc/hostapd/hostapd.conf', 'r')) === false)
47 while (($line = fgets($f)) !== false) {
49 if (substr($line,0,1) == '#') continue;
50 if (!strlen($line)) continue;
52 $parts = explode('=', $line, 2);
53 if ($parts[0] == 'ssid')
55 elseif ($parts[0] == 'wpa_passphrase')
56 $password = $parts[1];
61 return array('essid' => $essid,
62 'password' => $password);
65 public static function wifiAction()
67 $ok = self::callCommand("super musiikki-wifi", array($_POST['essid'], $_POST['password']));
72 public static function getsharesAction()
74 return array('ro_name' => '\\\\' . $_SERVER['SERVER_ADDR'] .'\\'. Config::SHARE_READ,
75 'ro_user' => Config::SHARE_READ,
77 'rw_name' => '\\\\' . $_SERVER['SERVER_ADDR'] .'\\'. Config::SHARE_WRITE,
78 'rw_user' => Config::SHARE_WRITE,
82 public static function sharesAction()
84 $ok = self::callCommand("super musiikki-shares", array($_POST['ro_password'], $_POST['rw_password']));
89 public static function getadminAction()
94 public static function adminAction()
96 if (!strlen($_POST['password'])) return false;
98 if (($f = fopen(Config::main()->get('password'), 'w')) === false) return false;
100 fwrite($f, sprintf("admin:%s\n", $_POST['password']));
106 public static function gethaltAction()
111 public static function haltAction()
113 $ok = self::callCommand("super musiikki-halt");
118 public static function getrescanAction()
120 $mtime = filemtime(Config::main()->get('cache'));
122 return array('modified' => date ("d. F Y H:i:s", $mtime));
125 public static function rescanAction()
127 $mtime = filemtime(Config::main()->get('cache'));
128 if ($mtime > time()-10)
129 return array('info' => 'Rescan läuft gerade und kann nicht erneut getriggert werden.');
131 if (($f = fopen(Config::main()->get('rescan_file'), 'w')) !== false) {