<commit_before>#!/usr/bin/env php
<?php

// connect to the database
// should replace parameters with getenv()
echo "[*] Connecting to database\n";
$guser = getenv('DBUSER');
$gpass = getenv('DBPASS');
$gconn = getenv('DBCONN');
if (!$guser || !$gpass || !$gconn) {
    die("[!] Need to set environment variables: DBUSER, DBPASS, DBCONN\n");
}

$connection = oci_connect($username = $guser,
                          $password = $g<PASSWORD>,
                          $connection_string = $gconn);

// check if the connection failed
// may need to connect to the vpn if it did
if (! $connection) {
    $err = oci_error();
    die("[!] oci_connect failed: ".$err."\n");
}

// check for command line arg about deleting
if ($argc >= 2 && $argv[1] == "delete") {
    $statement = oci_parse($connection, "delete from account");
    oci_execute($statement);
    echo "[*] Database deleted\n";
    oci_free_statement($statement);
    oci_close($connection);
    exit();
}

// insert the administrator into the database first
echo "[*] Inserting admin\n";
$admin_pwd = password_hash("<PASSWORD>", PASSWORD_DEFAULT);
$admin_insert = "insert into account values('admin', '".$admin_pwd."', 'administrator', '000-00-0000', '1-JAN-2017', '1-JAN-2017', 0, 'a', 1, 0, 'genderless')";
$statement = oci_parse($connection, $admin_insert);
oci_execute($statement);
oci_free_statement($statement);

// generate accounts from the names file
echo "[*] Inserting users\n";
$count = 0;
$name_file = fopen("scripts/data/male_names.txt", "r") or die("Unable to open file!\n");
while ((list ($fname, $lname) = fscanf($name_file, "%s %s")) != false) {
    echo "\r\t[*] Insert #".(++$count);
    $insert_cmd = "insert into account values('".$fname.".".$<EMAIL>."<EMAIL>', '";
    $insert_cmd = $insert_cmd.password_hash($fname, PASSWORD_DEFAULT)."', '";
    $insert_cmd = $insert_cmd.$fname." ".$lname."', '";
    $insert_cmd = $insert_cmd.mt_rand(100,999)."-".mt_rand(10,99)."-".mt_rand(1000,9999)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(1950,2000)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(2015,2017)."', ";
    $insert_cmd = $insert_cmd."0, '";
    $insert_cmd = $insert_cmd."address', ";
    $insert_cmd = $insert_cmd."0, ";
    $insert_cmd = $insert_cmd.mt_rand(1000000000,9999999999).", '";
    $insert_cmd = $insert_cmd."male')";
    // echo $insert_cmd."\n";
    $statement = oci_parse($connection, $insert_cmd);
    oci_execute($statement);
    oci_free_statement($statement);
}
fclose($name_file);
// female names
$name_file = fopen("scripts/data/female_names.txt", "r") or die("Unable to open file!\n");
while ((list ($fname, $lname) = fscanf($name_file, "%s %s")) != false) {
    echo "\r\t[*] Insert #".(++$count);
    $insert_cmd = "insert into account values('".$fname.".".$<EMAIL>."<EMAIL>', '";
    $insert_cmd = $insert_cmd.password_hash($fname, PASSWORD_DEFAULT)."', '";
    $insert_cmd = $insert_cmd.$fname." ".$lname."', '";
    $insert_cmd = $insert_cmd.mt_rand(100,999)."-".mt_rand(10,99)."-".mt_rand(1000,9999)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(1950,2000)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(2015,2017)."', ";
    $insert_cmd = $insert_cmd."0, '";
    $insert_cmd = $insert_cmd."address', ";
    $insert_cmd = $insert_cmd."0, ";
    $insert_cmd = $insert_cmd.mt_rand(1000000000,9999999999).", '";
    $insert_cmd = $insert_cmd."female')";
    // echo $insert_cmd."\n";
    $statement = oci_parse($connection, $insert_cmd);
    oci_execute($statement);
    oci_free_statement($statement);
}
fclose($name_file);
echo "\n";

// check to see what is in the database
$statement = oci_parse($connection, "select * from account");
oci_execute($statement);
$aftercount = -1;
while (($row = oci_fetch_object($statement)) != false) {
    ++$aftercount;
}
oci_free_statement($statement);

// make sure everything checks out
if ($aftercount != $count) {
    echo "[!] Database build failed\n";
} else {
    echo "[+] Database build complete\n";
}
<commit_msg>small modifications to database<commit_after>#!/usr/bin/env php
<?php

// connect to the database
// should replace parameters with getenv()
echo "[*] Connecting to database\n";
$guser = getenv('DBUSER');
$gpass = getenv('DBPASS');
$gconn = getenv('DBCONN');
if (!$guser || !$gpass || !$gconn) {
    die("[!] Need to set environment variables: DBUSER, DBPASS, DBCONN\n");
}

$connection = oci_connect($username = $guser,
                          $password = $g<PASSWORD>,
                          $connection_string = $gconn);

// check if the connection failed
// may need to connect to the vpn if it did
if (! $connection) {
    $err = oci_error();
    die("[!] oci_connect failed: ".$err."\n");
}

// check for command line arg about deleting
if ($argc >= 2 && $argv[1] == "delete") {
    $statement = oci_parse($connection, "delete from account");
    oci_execute($statement);
    echo "[*] Database deleted\n";
    oci_free_statement($statement);
    oci_close($connection);
    exit();
}

// insert the administrator into the database first
echo "[*] Inserting admin\n";
$admin_pwd = password_hash("<PASSWORD>", PASSWORD_DEFAULT);
$admin_insert = "insert into account values('admin', '".$admin_pwd."', 'administrator', '000-00-0000', '1-JAN-2017', '1-JAN-2017', 0, 's', 'c', 'ST', 1, 0, 'genderless')";
$statement = oci_parse($connection, $admin_insert);
oci_execute($statement);
oci_free_statement($statement);

// generate accounts from the names file
echo "[*] Inserting users\n";
$count = 0;
$name_file = fopen("scripts/data/male_names.txt", "r") or die("Unable to open file!\n");
while ((list ($fname, $lname) = fscanf($name_file, "%s %s")) != false) {
    echo "\r\t[*] Insert #".(++$count);
    $insert_cmd = "insert into account values('".$fname.".".$lname."<EMAIL>', '";
    $insert_cmd = $insert_cmd.password_hash($fname, PASSWORD_DEFAULT)."', '";
    $insert_cmd = $insert_cmd.$fname." ".$lname."', '";
    $insert_cmd = $insert_cmd.mt_rand(100,999)."-".mt_rand(10,99)."-".mt_rand(1000,9999)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(1950,2000)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(2015,2017)."', ";
    $insert_cmd = $insert_cmd."0, '";
    $insert_cmd = $insert_cmd."street', '";
    $insert_cmd = $insert_cmd."city', '";
    $insert_cmd = $insert_cmd."ST', ";
    $insert_cmd = $insert_cmd."0, ";
    $insert_cmd = $insert_cmd.mt_rand(1000000000,9999999999).", '";
    $insert_cmd = $insert_cmd."male')";
    // echo $insert_cmd."\n";
    $statement = oci_parse($connection, $insert_cmd);
    oci_execute($statement);
    oci_free_statement($statement);
}
fclose($name_file);
// female names
$name_file = fopen("scripts/data/female_names.txt", "r") or die("Unable to open file!\n");
while ((list ($fname, $lname) = fscanf($name_file, "%s %s")) != false) {
    echo "\r\t[*] Insert #".(++$count);
    $insert_cmd = "insert into account values('".$fname.".".$<EMAIL>."<EMAIL>', '";
    $insert_cmd = $insert_cmd.password_hash($fname, PASSWORD_DEFAULT)."', '";
    $insert_cmd = $insert_cmd.$fname." ".$lname."', '";
    $insert_cmd = $insert_cmd.mt_rand(100,999)."-".mt_rand(10,99)."-".mt_rand(1000,9999)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(1950,2000)."', '";
    $insert_cmd = $insert_cmd.mt_rand(1,31)."-JAN-".mt_rand(2015,2017)."', ";
    $insert_cmd = $insert_cmd."0, '";
    $insert_cmd = $insert_cmd."street', '";
    $insert_cmd = $insert_cmd."city', '";
    $insert_cmd = $insert_cmd."ST', ";
    $insert_cmd = $insert_cmd."0, ";
    $insert_cmd = $insert_cmd.mt_rand(1000000000,9999999999).", '";
    $insert_cmd = $insert_cmd."female')";
    // echo $insert_cmd."\n";
    $statement = oci_parse($connection, $insert_cmd);
    oci_execute($statement);
    oci_free_statement($statement);
}
fclose($name_file);
echo "\n";

// check to see what is in the database
$statement = oci_parse($connection, "select * from account");
oci_execute($statement);
$aftercount = -1;
while (($row = oci_fetch_object($statement)) != false) {
    ++$aftercount;
}
oci_free_statement($statement);

// make sure everything checks out
if ($aftercount != $count) {
    echo "[!] Database build failed\n";
} else {
    echo "[+] Database build complete\n";
}

{'fraction_non_alphanumeric': 0.21185523626307562, 'fraction_numerical': 0.036070698569195626, 'mean_word_length': 4.257901390644753, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2717359', 'n_tokens_mistral': 3238, 'n_tokens_neox': 2989, 'n_words': 585}