Ejemplo n.º 1
0
 // initial setup
 //
 // get some information about the database environment
 echo "<h2>Displaying databases</h2>";
 listDBTables($connection);
 // create tables
 foreach ($db_schema as $table => $keys) {
     $tableResult = addTable($connection, $table, $keys);
     // if there's an error, show it
     if ($tableResult) {
         echo $tableResult;
     }
 }
 // populate tables
 foreach ($db_data as $table => $items) {
     $tableResult = populateTable($connection, $table, $items);
     // if there's an error, show it
     if ($tableResult) {
         echo $tableResult;
     }
 }
 // display the tables on screen so we can see they were created
 echo "<h2>Showing script-created tables</h2>";
 if ($tables = getTableList($connection, $config["db"]["name"])) {
     foreach ($tables as $id => $table) {
         printTable($connection, $table);
     }
 }
 //
 // export and kill database
 //
    $db->query("DELETE FROM instances");
    // Populate table.
    $passboltInstances = Config::read('passbolt.instances');
    $seleniumInstances = Config::read('testserver.selenium.instances');
    foreach ($passboltInstances as $instance) {
        $instancesToSave[] = ['type' => 'passbolt', 'address' => $instance, 'locked' => 0];
    }
    foreach ($seleniumInstances as $instance) {
        $instancesToSave[] = ['type' => 'selenium', 'address' => $instance, 'locked' => 0];
    }
    foreach ($instancesToSave as $instance) {
        $db->query("INSERT INTO instances (type, address, locked) VALUES('{$instance['type']}', '{$instance['address']}', {$instance['locked']});");
    }
}
// Open or create DB.
$db = new mysqli(Config::read('database.host'), Config::read('database.username'), Config::read('database.password'), Config::read('database.name'));
// Check for errors
if (mysqli_connect_errno()) {
    echo mysqli_connect_error();
}
// Check if table exists.
$tableExists = checkTableExist($db);
// If table doesn't exist, create it and populate it with instances.
if (!$tableExists) {
    createTable($db);
}
populateTable($db);
$nbEntries = $db->query('SELECT COUNT(*) AS nbdata FROM instances');
$nbEntries = $nbEntries->fetch_array()['nbdata'];
echo "Database and table instances have been created, and populated with {$nbEntries} entries\n";
$db->close();
    <body>

    <?php 
$date = new DateTime();
$year = (int) date_format($date, 'Y');
$nextYear = $year + 1;
$date = new DateTime("01.01.{$year}");
$month = "";
$output = "";
echo '<h1>' . $year . "</h1>\n";
while ($year != $nextYear) {
    $currentMonth = date_format($date, 'F');
    $month = $currentMonth;
    $output = initializeMonth($output, $month);
    while ($currentMonth == $month) {
        $output = populateTable($output, $date);
        date_add($date, date_interval_create_from_date_string('1 days'));
        $currentMonth = date_format($date, 'F');
    }
    $output = encloseTable($output, $date);
    echo $output;
    $year = (int) date_format($date, 'Y');
}
// date_add($date, date_interval_create_from_date_string('10 days'));
?>

    <?php 
function initializeMonth($output, $month)
{
    $output = "<table>\n" . '<tr><th colspan="7">' . "{$month}</th></tr>" . "\n" . "<tr><td>Mon</td><td>Tue</td><td>Wed</td>" . "<td>Thu</td><td>Fri</td><td>Sat</td><td>Sun</td></tr>\n";
    return $output;