Example #1
0
function createDatabaseIfNotExists()
{
    if (!is_file('f2.sqlite')) {
        $db = new PDO('sqlite:f2.sqlite');
        $db->exec("CREATE TABLE files ( id INTEGER PRIMARY KEY,\n\t\t                                      filename VARCHAR(255), \n\t\t                                      randname VARCHAR(50),\n\t\t                                      password VARCHAR(255),\n\t\t                                      validuntil datetime,\n\t\t                                      owner VARCHAR(50));");
        $db->exec("CREATE TABLE user ( id INTEGER PRIMARY KEY,\n\t\t                                      username VARCHAR(50), \n\t\t\t\t\t\t      password VARCHAR(255),\n\t\t\t\t\t\t      adminuser BOOLEAN NOT NULL DEFAULT 0,\n\t\t\t\t\t\t      email VARCHAR(100));");
        $password = genRandName();
        $db->exec("INSERT INTO user (username,password,adminuser,email) VALUES ('admin','" . password_hash($password, PASSWORD_BCRYPT) . "',1,'*****@*****.**');");
        $_SESSION['message']['type'] = "success";
        $_SESSION['message']['message'] = "Die Datenbank wurde erfolgreich angelegt. Zugangsdaten sind: <ul> <li>User: admin</li><li>Pass: "******"</li></ul><br/><a href=\"upload.php\">Backend</a>";
    }
}
Example #2
0
 }
 // TODO: CANCEL UPLOAD HERE
 if (isset($_POST[''])) {
     $key = ini_get("session.upload_progress.prefix") . "fileUpload";
     $_SESSION[$key]["cancel_upload"] = TRUE;
     $_SESSION['message']['type'] = "success";
     $_SESSION['message']['message'] = "Successfully canceled the file upload.";
     header('Location: ' . basename($_SERVER['HTTP_REFERER']));
 } else {
     // get name for url
     if (isset($_POST['ownname']) && $_POST['ownname'] != "") {
         // make sure only some chars are included if own name is given
         $randname = preg_replace('/[^A-Za-z0-9\\-]/', '', $_POST['ownname']);
     } else {
         // otherwise generate random string
         $randname = genRandName();
     }
     // check if chosen randname is uniq
     if (checkRandName($randname) == FALSE) {
         $_SESSION['message']['type'] = "danger";
         $_SESSION['message']['message'] = "The chosen or the random generated download name already exists.";
         header('Location: ' . basename($_SERVER['HTTP_REFERER']));
         exit;
     }
     // original filename
     $filename = $_FILES['file']['name'];
     // password if set
     $password = NULL;
     if (isset($_POST['password']) && !empty($_POST['password'])) {
         $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
     }