diff options
author | Christian Pointner <equinox@ffgraz.net> | 2009-02-08 04:48:53 +0000 |
---|---|---|
committer | Christian Pointner <equinox@ffgraz.net> | 2009-02-08 04:48:53 +0000 |
commit | f6be9edd401664d95e60ae3c81aeaf36723ba891 (patch) | |
tree | 86f2127f51f0f16053c1b593c722cf0a5eeecba4 /login.php | |
parent | 0c420c393dba896e14972ecb5181904f1a1342a4 (diff) |
added login capability
Diffstat (limited to 'login.php')
-rw-r--r-- | login.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/login.php b/login.php new file mode 100644 index 0000000..02015e7 --- /dev/null +++ b/login.php @@ -0,0 +1,40 @@ +<?php +session_start(); + +header("Content-Type: text/xml"); +header("Cache-Control: no-cache, must-revalidate"); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + +require_once('check_user.php'); + +echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; +echo "<root>\n"; + +if (isset($_POST['login'])) +{ + if(check_user($_POST['username'], $_POST['password'])) + { + $_SESSION['logged_in'] = true; + $_SESSION['username'] = $_POST['username']; + } + else + { + echo '<error string="'.'Ihre Anmeldedaten waren nicht korrekt!'.'" />'."\n"; + } +} +else if (isset($_POST['logout'])) +{ + session_destroy(); + $_SESSION['logged_in'] = false; +} + +if (isset($_SESSION['logged_in']) && $_SESSION['logged_in']) +{ + echo '<status code="'.'logged_in'.'" />'."\n"; + echo '<username name="'.$_SESSION['username'].'" />'."\n"; +} +else +{ + echo '<status code="'.'logged_out'.'" />'."\n"; +} +echo "</root>"; |