]> git.treefish.org Git - banana.git/blobdiff - admin/password.php
...
[banana.git] / admin / password.php
diff --git a/admin/password.php b/admin/password.php
new file mode 100644 (file)
index 0000000..6459c94
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+  require 'include/head.inc';
+  require 'include/common.inc';
+
+  if(isset($_POST['submit']) && $_POST['password']!="") {
+
+    $fh_pass = fopen(".htpasswd", 'w');
+    fwrite($fh_pass, "admin:" . crypt($_POST['password'], base64_encode($_POST['password'])) . "\n");
+    fclose($fh_pass);
+
+    $fh_access = fopen(".htaccess", 'w');
+    fwrite($fh_access, "AuthUserFile " . getcwd() . "/.htpasswd\n");
+    fwrite($fh_access, "AuthGroupFile /dev/null\n");
+    fwrite($fh_access, "AuthName \"Banana Admin\"\n");
+    fwrite($fh_access, "AuthType Basic\n");
+    fwrite($fh_access, "require user admin\n");
+    fclose($fh_access);
+
+    block("lightgreen", "admin password set");
+    break;
+  }
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+  <table bgcolor="black">
+    <tr><th><b><font color="white">set admin password</font></b></th><tr>
+  </table>
+
+  <table>
+    <tr>  
+      <th align="left">Password:</th> <th><input type="text" name="password"></th>
+    </tr>
+  
+    <tr>
+      <th></th><th align="right" columnspan=2><input type="submit" name="submit" value="Set"></th>
+    </tr>
+  </table>
+</form>