function loadTables()
{
    $filename = dirname(__FILE__) . "/../database_desc.txt";
    if (!file_exists($filename)) {
        echo "<!DOCTYPE html><body>\n\t\t\t<div style='display:inline-block; color:red; font-weight:bold;'>Error:</div>\n\t\t\tfile\n\t\t\t<div style='display:inline-block; font-family:monospace;'>{$filename}</div>\n\t\t\tdescribing the tables does not exist!<br />\n\t\t\tPlease retrieve this file and try again.\n\t\t\t</body>";
        return;
    }
    $a_file_tables = unserialize(file_get_contents($filename));
    $a_file_tables = $a_file_tables["Tables"];
    $a_tables = getTables();
    updateTables($a_tables, $a_file_tables);
    echo "success";
}
Example #2
0
            try {
                $stmt = $dbh->prepare($sql);
                $stmt->bindParam(':timestp', $tmsp);
                $stmt->bindParam(':interaction', $interaction);
                $stmt->bindParam(':page', $page);
                $stmt->bindParam(':set', $set);
                $stmt->execute();
            } catch (PDOException $e) {
                echo 'SQL Query: ', $sql;
                echo 'Error: ' . $e->getMessage();
            }
        }
        if (isset($post_data["pages"])) {
            makeTables($dbh, $post_data);
        } else {
            updateTables($dbh, $post_data);
        }
    }
}
//e-mail data if e-mail is set up
if (isset($smtphost, $smtpport, $euser, $epass, $toaddr, $subject, $message)) {
    //variables of great social and political import
    $pid = $post_data["pid"];
    //check for directory and create if not exists
    if (!file_exists("../participants")) {
        mkdir("../participants", 0777, true);
    }
    //check for file and create with column headers if not exists
    $filepath = "../participants/p" . $pid . "_interactions.csv";
    if (!file_exists($filepath)) {
        $cols = "timestp, interaction, page, set\n";
Example #3
0
        if ($errors) {
            showForm($errors);
        } else {
            updateTables($version);
            $user = new User($name);
            $user->setName($fullname);
            $user->setPassword($password);
            $user->setAccess('admin');
            $user->setEmail($email);
            $user->save();
        }
    } else {
        showForm('');
    }
} else {
    updateTables($version);
}
function showForm($errors)
{
    $name = $_POST['name'];
    $fullname = $_POST['fullname'];
    $password = $_POST['password'];
    $password2 = $_POST['password2'];
    $email = $_POST['email'];
    print "<!DOCTYPE>\n<html>\n  <head>\n    <title>Initialize Database</title>\n  </head>\n  <body>\n    <h1>Initialize Database</h1>\n    <p>This page is displayed because the database for the Vacation Blog\n      has not yet been initialized. Please provide the information on this\n      page to initialize the database.</p>\n";
    if ($errors) {
        print "<ul style='color: red'>{$errors}</ul>\n";
    }
    print "\n    <form method='POST' action='CreateTables.php'>\n      <p>\n        <label for='name'>User Name:</label>\n        <input type='text' name='name' id='name' value='{$name}' size='32' maxlength='32'/>\n      </p>\n\n      <p>\n        <label for='fullname'>Full Name:</label>\n        <input type='text' name='fullname' id='fullname' value='{$fullname}' size='32' maxlength='64'/>\n      </p>\n\n      <p>\n        <label for='password'>Password:</label>\n        <input type='password' name='password' id='password' value='{$password}' size='32' maxlength='32'/>\n      </p>\n\n      <p>\n        <label for='password2'>Repeat Password:</label>\n        <input type='password' name='password2' id='password2' value='{$password2}' size='32' maxlength='32'/>\n      </p>\n\n      <p>\n        <label for='email'>Email:</label>\n        <input type='text' name='email' id='email' value='{$email}' size='32' maxlength='64'/>\n      </p>\n\n      <p>\n        <input type='submit' name='do' id='do' value='Initialize Database'/>\n        <input type='submit' name='cancel' id='cancel' value='Cancel'/>\n    </form>\n  </body>\n</html>\n";
    print "<!DOCTYPE html\n";
    print "<html>\n";