1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace FreenetRouter\Controllers; |
4 | | | |
5 | | | use FreenetRouter\Models\System\System; |
6 | | | use Phem\Environment\EnvironmentManager; |
7 | | | |
8 | | | /** |
9 | | | * @author Jakub PetrĹžĂlka <petrzilka@czweb.net> |
10 | | | */ |
11 | | | class HomeController extends Controller |
12 | | | { |
13 | | | public function showPage() |
14 | | | { |
15 | | | $this->getModel()->put("system", System::getInstance()); |
16 | | | } |
17 | | | |
18 | | | public function login($jmeno,$heslo) |
19 | | | { |
20 | | | $loginResult = null; |
21 | | | $output = null; |
22 | | | $session = EnvironmentManager::getSession(); |
23 | | | |
24 | | | //exec('sudo web-auth '.$jmeno.' '.$heslo,$output,$loginResult); |
25 | | | |
26 | | | if ($jmeno == "root" && $heslo == "voyage") $loginResult = 0; |
27 | | | |
28 | | | if ($loginResult === 0) |
29 | | | { |
30 | | | $session->setVar("loggedUser", $jmeno); |
31 | | | } |
32 | | | else |
33 | | | { |
34 | | | $session->setVar("loggedUser", null); |
35 | | | } |
36 | | | |
37 | | | $this->redirectToController = "Home"; |
38 | | | $this->redirectToTask = "showPage"; |
39 | | | } |
40 | | | |
41 | | | public function logout() |
42 | | | { |
43 | | | $session = EnvironmentManager::getSession(); |
44 | | | $session->setVar("loggedUser", null); |
45 | | | |
46 | | | $this->redirectToController = "Home"; |
47 | | | $this->redirectToTask = "showPage"; |
48 | | | } |
49 | | | |
50 | | | public function saveConfig() |
51 | | | { |
52 | | | $this->redirectToController = "Home"; |
53 | | | $this->redirectToTask = "showPage"; |
54 | | | } |
55 | | | |
56 | | | public function setWritable($writable) |
57 | | | { |
58 | | | System::getInstance()->setWriteEnabled($writable); |
59 | | | |
60 | | | $this->redirectToController = "Home"; |
61 | | | $this->redirectToTask = "showPage"; |
62 | | | } |
63 | | | } |