summaryrefslogtreecommitdiff
path: root/bin/auth.php
diff options
context:
space:
mode:
Diffstat (limited to 'bin/auth.php')
-rw-r--r--bin/auth.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/auth.php b/bin/auth.php
new file mode 100644
index 0000000..7e6eace
--- /dev/null
+++ b/bin/auth.php
@@ -0,0 +1,36 @@
+<?php
+
+global $user, $pass;
+
+session_start();
+
+if (isset($_COOKIE['istreamdev']))
+{
+ if(sha1($pass) == $_COOKIE['istreamdev'] ) {
+ setcookie ("istream", sha1($pass), time()+60*60*24*30);
+ $authorized = true;
+ } else {
+ $authorised = false;
+ }
+}
+
+# checkup login and password
+if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))
+{
+ if (($user == $_SERVER['PHP_AUTH_USER']) && ($pass == ($_SERVER['PHP_AUTH_PW'])) )
+ {
+ setcookie ("istreamdev", sha1($pass), time()+60*60*24*30);
+ $authorized = true;
+ }
+}
+
+# login
+if (!$authorized)
+{
+ header('WWW-Authenticate: Basic Realm="Login please"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo "Login";
+ exit;
+}
+
+?>