summaryrefslogtreecommitdiff
path: root/www/setup.php
diff options
context:
space:
mode:
authorroot2014-02-17 20:32:33 +0100
committerroot2014-02-17 20:32:33 +0100
commit5b9069e5d3f77f0148e1c867a14f9e1d44c229d4 (patch)
tree91d1095651d1ba0f308c7f3da7287cd7b03d8752 /www/setup.php
parent90719f4deb17c8d89d74a7b9872764c1df081f6d (diff)
downloadfiles.iamfabulous.de-5b9069e5d3f77f0148e1c867a14f9e1d44c229d4.tar.gz
setup
Diffstat (limited to 'www/setup.php')
-rw-r--r--www/setup.php52
1 files changed, 40 insertions, 12 deletions
diff --git a/www/setup.php b/www/setup.php
index 2ff5f52..00aa9ed 100644
--- a/www/setup.php
+++ b/www/setup.php
@@ -1,20 +1,48 @@
<?
-$cleartext_password="password";
-$salt = uniqid(mt_rand(), true);
-$password = "$salt"."$cleartext_password";
-$hash_password = md5($password);
-for($i=0;$i<15000;$i++)
- $hash_password = md5($hash_password);
+
+/*Sets up the database with the user table. Add ?drop to drop _everything_*/
$db = new SQLite3("../database/sqlite.db");
-if($db->exec("CREATE TABLE IF NOT EXISTS user (id INTEGER PRIMARY KEY, name TEXT UIQUE, senpai INTEGER, key TEXT, status INTEGER, invites INTEGER, salt TEXT, password TEXT, email TEXT UNIQUE);") && $db->exec("BEGIN TRANSACTION; INSERT INTO user (id, name, senpai, key, status, invites, salt, password, email) VALUES (NULL, 'admin', 0, '11111', 1, 5, '$salt', '$hash_password', 'admin@iamfabulous.de'); COMMIT;")) {
- echo "Success!";
-} else {
- echo "Failure! :( <br>";
- echo "Salt: $salt, password: $hash_password";
+foreach ($_GET as $name => $value) {
+ if(preg_match("/drop(ped)?/i",$name)){
+ $bool=true;
+ }
}
+if($bool){
+ if($db->exec("
+ BEGIN TRANSACTION;
+ PRAGMA writable_schema = 1;
+ delete from sqlite_master where type = 'table';
+ PRAGMA writable_schema = 0;
+ COMMIT;
+ VACUUM;")
+ ){
+ echo "dropped everything";
+ } else {
+ echo "error with database";
+ }
+} else {
+ $cleartext_password="password";
+ $salt = uniqid(mt_rand(), true);
+ $password = "$salt"."$cleartext_password";
+ $hash_password = md5($password);
+ for($i=0;$i<15000;$i++)
+ $hash_password = md5($hash_password);
+
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ CREATE TABLE IF NOT EXISTS user (id INTEGER PRIMARY KEY, name TEXT UIQUE, senpai INTEGER, key TEXT, status INTEGER, invites INTEGER, salt TEXT, password TEXT, email TEXT UNIQUE);
+ INSERT INTO user (id, name, senpai, key, status, invites, salt, password, email) VALUES (NULL, 'admin', 0, '11111', 1, 5, '$salt', '$hash_password', 'admin@iamfabulous.de');
+ COMMIT;")
+ ) {
+ echo "Success!";
+ } else {
+ echo "Failure! :( <br>";
+ echo "Salt: $salt, password: $hash_password";
+ }
+}
// INSERT INT0 user (id, name, salt, password, status, invites, email, senpai, key) VALUES (NULL, 'admin', '$salt', '$hash_password', 1, 5, 'admin@iamfabulous.de', 0, '11111');
-// COMMIT;")