Exemplo n.º 1
0
function setUpDatabase()
{
    $db = \BeeHub::getNoSQL();
    $collections = $db->listCollections();
    foreach ($collections as $collection) {
        $collection->drop();
    }
    // All the resources are stored
    $filesCollection = $db->createCollection('files');
    $filesCollection->ensureIndex(array('props.http://beehub%2Enl/ sponsor' => 1));
    $filesCollection->ensureIndex(array('props.DAV: owner' => 1));
    $filesCollection->ensureIndex(array('path' => 1), array('unique' => 1));
    $filesCollection->ensureIndex(array('depth' => 1, 'path' => 1));
    $files = array();
    $files[] = array('path' => 'home', 'depth' => 1);
    // Create 1 sponsor
    $collection = $db->createCollection('sponsors');
    $collection->ensureIndex(array('name' => 1), array('unique' => 1));
    $sponsors = array();
    $sponsorNames = array();
    $sponsors[] = array('name' => 'sponsor1', 'displayname' => 'sponsor1', 'admins' => array('user1'));
    $sponsorNames[] = 'sponsor1';
    $collection->batchInsert($sponsors);
    // Create 200 groepen
    $collection = $db->createCollection('groups');
    $collection->ensureIndex(array('name' => 1), array('unique' => 1));
    $groups = array();
    $groupNames = array();
    for ($counter = 1; $counter <= 500; $counter++) {
        $groups[] = array('name' => 'group' . $counter, 'displayname' => 'group' . $counter, 'admins' => array('user1'));
        $groupNames[] = 'group' . $counter;
        // Create the resources for this group; all for user1 who is in all groups
        $files[] = array('path' => 'group' . $counter, 'depth' => 1, 'props' => array('http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 1000; $resourceCounter++) {
            $files[] = array('path' => 'group' . $counter . '/5mb_' . $resourceCounter, 'depth' => 2, 'props' => array('DAV: owner' => 'user1', 'DAV: getcontentlength' => 5242880, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 500; $resourceCounter++) {
            $files[] = array('path' => 'group' . $counter . '/100gb_' . $resourceCounter, 'depth' => 2, 'props' => array('DAV: owner' => 'user1', 'DAV: getcontentlength' => 107374182400.0, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
    }
    $collection->batchInsert($groups);
    unset($groups);
    // 20 gebruikers
    $collection = $db->createCollection('users');
    $collection->ensureIndex(array('name' => 1), array('unique' => 1));
    $users = array();
    for ($counter = 1; $counter <= 20; $counter++) {
        $users[] = array('name' => 'user' . $counter, 'displayname' => 'user' . $counter, 'email' => 'user' . $counter . '@mailservice.com', 'password' => '$6$rounds=5000$126b519331f5189c$liGp7IWjOlsZ7wwYbobzsMC9y7bE9JYERiS4ts503HKNqIQUrvNM8IyxoGDSBo30XwrdyTzI6rNZRL5lSEPTr0', 'default_sponsor' => 'sponsor1', 'sponsors' => $sponsorNames);
        // And create user files
        //   /home/userXX/    200 bestanden van 500 Mb
        $files[] = array('path' => 'home/user' . $counter, 'depth' => 2, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 500; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/500mb_' . $resourceCounter, 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 524288000, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
    }
    $users[0]['groups'] = $groupNames;
    $users[0]['sponsors'] = $sponsorNames;
    $tb = 1073741824 * 1024;
    for ($counter = 21; $counter <= 40; $counter++) {
        $users[] = array('name' => 'user' . $counter, 'displayname' => 'user' . $counter, 'email' => 'user' . $counter . '@mailservice.com', 'password' => '$6$rounds=5000$126b519331f5189c$liGp7IWjOlsZ7wwYbobzsMC9y7bE9JYERiS4ts503HKNqIQUrvNM8IyxoGDSBo30XwrdyTzI6rNZRL5lSEPTr0', 'default_sponsor' => 'sponsor1', 'sponsors' => $sponsorNames);
        // And create user files
        //   /home/userXX/             10,000 bestanden van 1 Mb
        //   /home/userXX/dir1         1,000 bestanden van 1Gb
        //   /home/userXX/dir2/dir1    10 bestanden van 1 Tb
        $files[] = array('path' => 'home/user' . $counter, 'depth' => 2, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        $files[] = array('path' => 'home/user' . $counter . '/dir1', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        $files[] = array('path' => 'home/user' . $counter . '/dir2', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        $files[] = array('path' => 'home/user' . $counter . '/dir2/dir1', 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 10000; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/1mb_' . $resourceCounter, 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 1048576, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 1000; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir1/1gb_' . $resourceCounter, 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 1073741824, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 10; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir2/dir1/1tb_' . $resourceCounter, 'depth' => 5, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => $tb, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
    }
    for ($counter = 41; $counter <= 60; $counter++) {
        $users[] = array('name' => 'user' . $counter, 'displayname' => 'user' . $counter, 'email' => 'user' . $counter . '@mailservice.com', 'password' => '$6$rounds=5000$126b519331f5189c$liGp7IWjOlsZ7wwYbobzsMC9y7bE9JYERiS4ts503HKNqIQUrvNM8IyxoGDSBo30XwrdyTzI6rNZRL5lSEPTr0', 'default_sponsor' => 'sponsor1', 'sponsors' => $sponsorNames);
        // And create user files
        //   /home/userXX/        10 bestanden van 1 Tb
        //   /home/userXX/dir1    20 bestanden van 500 Gb
        $files[] = array('path' => 'home/user' . $counter, 'depth' => 2, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        $files[] = array('path' => 'home/user' . $counter . '/dir1', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 10; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/1tb_' . $resourceCounter, 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => $tb, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 20; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir1/500gb_' . $resourceCounter, 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 536870912000.0, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
    }
    for ($counter = 61; $counter <= 80; $counter++) {
        $users[] = array('name' => 'user' . $counter, 'displayname' => 'user' . $counter, 'email' => 'user' . $counter . '@mailservice.com', 'password' => '$6$rounds=5000$126b519331f5189c$liGp7IWjOlsZ7wwYbobzsMC9y7bE9JYERiS4ts503HKNqIQUrvNM8IyxoGDSBo30XwrdyTzI6rNZRL5lSEPTr0', 'default_sponsor' => 'sponsor1', 'sponsors' => $sponsorNames);
        // And create user files
        //   /home/userXX/        10 bestanden van 1 Tb, 10,000 bestanden van 1Kb
        //   /home/userXX/dir1    200 bestanden van 500 Gb, 1,000 bestanden van 1 Mb
        $files[] = array('path' => 'home/user' . $counter, 'depth' => 2, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        $files[] = array('path' => 'home/user' . $counter . '/dir1', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 10; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/1tb_' . $resourceCounter, 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => $tb, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 10000; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/1kb_' . $resourceCounter, 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 1024, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 200; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir1/500gb_' . $resourceCounter, 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 536870912000.0, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        for ($resourceCounter = 1; $resourceCounter <= 1000; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir1/1mb_' . $resourceCounter, 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 1048576, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
    }
    for ($counter = 81; $counter <= 100; $counter++) {
        $users[] = array('name' => 'user' . $counter, 'displayname' => 'user' . $counter, 'email' => 'user' . $counter . '@mailservice.com', 'password' => '$6$rounds=5000$126b519331f5189c$liGp7IWjOlsZ7wwYbobzsMC9y7bE9JYERiS4ts503HKNqIQUrvNM8IyxoGDSBo30XwrdyTzI6rNZRL5lSEPTr0', 'default_sponsor' => 'sponsor1', 'sponsors' => $sponsorNames);
        // And create user files
        //   /home/userXX/                       10 bestanden van 10 Mb
        //   /home/userXX/dir1                   10 bestanden van 10 Mb
        //   /home/userXX/dir2                   100 bestanden van 1 Gb
        //   /home/userXX/dir2/dir1              150 bestanden van 20 Mb
        //   /home/userXX/dir2/dir1/../dir50/    150 bestanden van 20 Mb in tussenliggende dirs
        //   /home/userXX/dir3/dir1/../dir20/    150 bestanden van 20 Mb in tussenliggende dirs
        $files[] = array('path' => 'home/user' . $counter, 'depth' => 2, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 10; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/10mb_' . $resourceCounter, 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 10485760, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        $files[] = array('path' => 'home/user' . $counter . '/dir1', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 10; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir1/10mb_' . $resourceCounter, 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 10485760, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        $files[] = array('path' => 'home/user' . $counter . '/dir2', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        for ($resourceCounter = 1; $resourceCounter <= 100; $resourceCounter++) {
            $files[] = array('path' => 'home/user' . $counter . '/dir2/1gb_' . $resourceCounter, 'depth' => 4, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 1073741824, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
        }
        $filesCollection->batchInsert($files);
        $files = array();
        $path = 'home/user' . $counter . '/dir2';
        for ($dirCounter = 1; $dirCounter <= 50; $dirCounter++) {
            $path .= '/dir' . $dirCounter;
            $files[] = array('path' => $path, 'depth' => 3 + $dirCounter, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
            for ($resourceCounter = 1; $resourceCounter <= 150; $resourceCounter++) {
                $files[] = array('path' => $path . '/20mb_' . $resourceCounter, 'depth' => 3 + $dirCounter + 1, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 20971520, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
            }
            $filesCollection->batchInsert($files);
            $files = array();
        }
        $files[] = array('path' => 'home/user' . $counter . '/dir3', 'depth' => 3, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
        $path = 'home/user' . $counter . '/dir3';
        for ($dirCounter = 1; $dirCounter <= 20; $dirCounter++) {
            $path .= '/dir' . $dirCounter;
            $files[] = array('path' => $path, 'depth' => 3 + $dirCounter, 'props' => array('DAV: owner' => 'user' . $counter, 'http://beehub%2Enl/ sponsor' => 'sponsor1'), 'collection' => true);
            for ($resourceCounter = 1; $resourceCounter <= 150; $resourceCounter++) {
                $files[] = array('path' => $path . '/20mb_' . $resourceCounter, 'depth' => 3 + $dirCounter + 1, 'props' => array('DAV: owner' => 'user' . $counter, 'DAV: getcontentlength' => 20971520, 'http://beehub%2Enl/ sponsor' => 'sponsor1'));
            }
            $filesCollection->batchInsert($files);
            $files = array();
        }
    }
    $collection->batchInsert($users);
    unset($users);
    unset($files);
    \BeeHub_Principal::update_principals_json();
}
Exemplo n.º 2
0
}
$result = $mysql->query('SHOW TABLES');
if ($result->num_rows > 0) {
    print "MySQL database already contains tables. Skipping initialisation of database.\n";
} else {
    print "Creating database structure...";
    if (\BeeHub_DB::createDbTables() === false) {
        \header('HTTP/1.1 500 Internal Server Error');
        \ob_end_flush();
        print "\nUnable to create database structure\n";
        exit;
    }
    print "ok\n";
}
// Create principals.js with displaynames of all principals
\BeeHub_Principal::update_principals_json();
// Let 'them' know everything went well
print "\nDone configuring webserver\n";
\ob_end_flush();
/**
 * Checks whether a PHP configuration value is correct
 * 
 * @param   string  $key    The configuration item to check
 * @param   mixed   $value  The value it should have
 * @return  boolean         True if the configuration is correct, false otherwise
 */
function test_config($key, $value)
{
    print $key . ' should be ' . \strval($value) . '...';
    if (\ini_get($key) == $value) {
        print "ok\n";
Exemplo n.º 3
0
function setUpDatabase()
{
    $db = \BeeHub::getNoSQL();
    $collections = $db->listCollections();
    foreach ($collections as $collection) {
        $collection->drop();
    }
    $newCollections = \json_decode(\file_get_contents(\dirname(__FILE__) . \DIRECTORY_SEPARATOR . 'dbtests_data' . \DIRECTORY_SEPARATOR . 'basicDataset.json'), true);
    foreach ($newCollections as $collectionName => $documents) {
        $collection = $db->createCollection($collectionName);
        $collection->batchInsert($documents);
    }
    $filesCollection = $db->selectCollection('files');
    $filesCollection->ensureIndex(array('props.http://beehub%2Enl/ sponsor' => 1));
    $filesCollection->ensureIndex(array('props.DAV: owner' => 1));
    $filesCollection->ensureIndex(array('path' => 1), array('unique' => 1));
    $filesCollection->ensureIndex(array('depth' => 1, 'path' => 1));
    $locksCollection = $db->selectCollection('locks');
    $locksCollection->ensureIndex(array('path' => 1), array('unique' => 1));
    $groupsCollection = $db->selectCollection('groups');
    $groupsCollection->ensureIndex(array('name' => 1), array('unique' => 1));
    $sponsorsCollection = $db->selectCollection('sponsors');
    $sponsorsCollection->ensureIndex(array('name' => 1), array('unique' => 1));
    $usersCollection = $db->selectCollection('users');
    $usersCollection->ensureIndex(array('name' => 1), array('unique' => 1));
    \BeeHub_Principal::update_principals_json();
}