date('Y'), 'month' => date('m'), 'day' => date('d'), 'hour' => date('H'), 'minute' => date('i'), 'second' => date('s')); } public static function datetimeAction() { $date = sprintf("%04d-%02d-%02d", $_POST['year'], $_POST['month'], $_POST['day']); $time = sprintf("%02d:%02d:%02d", $_POST['hour'], $_POST['minute'], $_POST['second']); $ok = self::callCommand("super musiikki-datetime", array($date, $time)); return $ok; } public static function getwifiAction() { if (!file_exists('/etc/hostapd/hostapd.conf')) return array(); if (($f = fopen('/etc/hostapd/hostapd.conf', 'r')) === false) return array(); $essid = ''; $password = ''; while (($line = fgets($f)) !== false) { $line = trim($line); if (substr($line,0,1) == '#') continue; if (!strlen($line)) continue; $parts = explode('=', $line, 2); if ($parts[0] == 'ssid') $essid = $parts[1]; elseif ($parts[0] == 'wpa_passphrase') $password = $parts[1]; } fclose($f); return array('essid' => $essid, 'password' => $password); } public static function wifiAction() { $ok = self::callCommand("super musiikki-wifi", array($_POST['essid'], $_POST['password'])); return $ok; } public static function getsharesAction() { return array('ro_name' => '\\\\' . $_SERVER['SERVER_ADDR'] .'\\'. Config::SHARE_READ, 'ro_user' => Config::SHARE_READ, 'ro_password' => '', 'rw_name' => '\\\\' . $_SERVER['SERVER_ADDR'] .'\\'. Config::SHARE_WRITE, 'rw_user' => Config::SHARE_WRITE, 'rw_password' => ''); } public static function sharesAction() { $ok = self::callCommand("super musiikki-shares", array($_POST['ro_password'], $_POST['rw_password'])); return $ok; } public static function getadminAction() { return array(); } public static function adminAction() { if (!strlen($_POST['password'])) return false; if (($f = fopen(Config::main()->get('password'), 'w')) === false) return false; fwrite($f, sprintf("admin:%s\n", $_POST['password'])); fclose($f); return true; } public static function gethaltAction() { return array(); } public static function haltAction() { $ok = self::callCommand("super musiikki-halt"); return $ok; } }