]> Softwares of Agnibho - simpleipd.git/blob - adduser
minor
[simpleipd.git] / adduser
1 #! /usr/bin/env php
2 <?php
3 $db=new SQLite3("data/data.db");
4 if(!empty($_SERVER["argv"][1]) && !empty($_SERVER["argv"][2]) && !empty($_SERVER["argv"][3])){
5 $stmt=$db->prepare("SELECT * FROM users WHERE user=:user");
6 $stmt->bindValue(":user",$_SERVER["argv"][1]);
7 if($stmt->execute()->fetchArray()){
8 $stmt=$db->prepare("UPDATE users SET usergroup=:usergroup,hash=:hash WHERE user=:user");
9 $stmt->bindValue(":user", $_SERVER["argv"][1]);
10 $stmt->bindValue(":hash", password_hash($_SERVER["argv"][3], PASSWORD_DEFAULT));
11 $stmt->execute();
12 }
13 else{
14 $stmt=$db->prepare("INSERT INTO users (user,usergroup,hash) VALUES (:user,:usergroup,:hash)");
15 $stmt->bindValue(":user", $_SERVER["argv"][1]);
16 $stmt->bindValue(":usergroup", $_SERVER["argv"][2]);
17 $stmt->bindValue(":hash", password_hash($_SERVER["argv"][3], PASSWORD_DEFAULT));
18 $stmt->execute();
19 }
20 }
21 else{
22 echo "Plese enter an username and password for entry into the DB\n";
23 }
24 ?>