print "<input name='db' value='".HEURIST_DBNAME."' type='hidden'>";
        if(!$is_h2){
        print "<input name='h2' value='1' type='hidden'>";
        }
        print "<input type='submit' value='Switch to H".($is_h2?"3":"2")." databases' /><br/>";
        print "</form>";
        */
print "<form name='selectdb' action='compareStructure.php' method='get'>";
//  We have to use 'get', 'post' fails to transfer target database to step 2
print "<input name='mode' value='2' type='hidden'>";
// calls the form to select mappings, step 2
print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>";
print "<input name='h2' value='" . ($is_h2 ? 1 : 0) . "' type='hidden'>";
// print "Enter source database name (prefix added automatically): <input type='text' name='sourcedbname' />";
print "Choose source database: <select id='db' name='sourcedbname'>";
$list = mysql__getdatabases();
foreach ($list as $name) {
    print "<option value='{$name}' " . ($sourcedbname == $name ? "selected='selected'" : "") . ">{$name}</option>";
}
print "</select>";
print "<input type='checkbox' name='useoid' value='1' " . ($useOriginalID ? "checked='checked'" : "") . "/>Use Concept ID&nbsp;&nbsp;";
print "<input type='submit' value='Continue' />";
print "</form>";
if ($sourcedbname == null) {
    exit;
}
// ----FORM 2 - MAPPINGS FORM ----------------------------------------------------------------------------------------
$sourcedbname = $_REQUEST['sourcedbname'];
createMappingForm(null);
// ---- Create mapping form -----------------------------------------------------------------
function getPresetId($config, $id)
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @version     3.2
*/
/*
* Licensed under the GNU License, Version 3.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at http://www.gnu.org/licenses/gpl-3.0.txt
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
* See the License for the specific language governing permissions and limitations under the License.
*/
require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php';
if (isForAdminOnly("to get information on all databases on this server")) {
    return;
}
mysql_connection_select();
$dbs = mysql__getdatabases(true);
function mysql__select_val($query)
{
    $res = mysql_query($query);
    if (!$res) {
        return 0;
    }
    $row = mysql_fetch_array($res);
    if ($row) {
        return $row[0];
    } else {
        0;
    }
}
function dirsize($dir)
{
Esempio n. 3
0
            </div>

            <div align="left" style="margin-left: 20px;">
                <h2><?php 
echo $msg;
?>
</h2>
                <br>Please select a database from the list. For further information on Heurist please visit
                <b> <a href="http://HeuristNetwork.org" target="_blank">http://HeuristNetwork.org</a></b>
            </div>

            <div id="loginDiv" style="height:auto; margin-top:44px; overflow-y:auto;text-align:left;">
                <ul class='dbList'>
                    <?php 
// Step 1 - mode not set - normally just list databases and select database
$list = mysql__getdatabases(false);
$i = 0;
foreach ($list as $name) {
    print "<li><a href='" . HEURIST_BASE_URL . "?db={$name}'>{$name}</a></li>";
    $i++;
}
// but check to see if any databases have been listed.
// if not it's an initialised instance, need to create sandpit db.
// Note: sandpit no longer needed or used from late 2015
if ($i == 0) {
    // no database can be created until sandpit db exists, so this is an adequate test. Note: sandpit no longer needed or used from late 2015
    $res = buildSandpitDB($sandpitDB);
    // TODO: supply prefix from code rather than hardcoded
    //if ($res != 0 ) { //error
    //    print "<h2>Unable to create $sandpitDB example database<h2> SQL error:".$res.
    //   "Query: ".$query_create." <p>Please contact Heurist developers for help";
Esempio n. 4
0
/**
* exit to page with error information for the user
* @param    int [$critical] level of criticality 1- unable to proceed 2-possible misname of db 0-db connection problem
* @param    string [$msg] error message
*/
function returnErrorMsgPage($critical, $msg = null)
{
    $redirect = null;
    if ($critical == 1) {
        // bad connection to MySQL server
        echo "<p>&nbsp;Heurist initialisation error<p> " . $msg ? $msg : "" . " <p><i>Please consult your sysadmin for help, or email: info - a t - heuristscholar.org </i></p>";
    } else {
        if ($critical == 2) {
            //database not defined or can not connect to it
            $redirect = HEURIST_BASE_URL . "common/connect/selectDatabase.php";
            error_log("redirectURL = " . print_r($redirect, true));
            if ($msg) {
                $redirect .= "?msg=" . rawurlencode($msg);
            }
        } else {
            // gets to here if database not specified properly. This is an error if set up properly, but not at first initialisaiton of the system
            // Test for existence of databases, if none then Heurist has not been set up yet
            // Placed here rather than up-front test to avoid having to test this in every script
            $list = mysql__getdatabases();
            if (count($list) > 0) {
                $msg2 = "<p>&nbsp;Cannot open database<p><br><br>" . $msg ? $msg : "" . "<p><br><br><i>Please consult your sysadmin for help, or email: info - a t - heuristscholar.org </i></p>";
                $msg2 = rawurlencode($msg2);
                $redirect = HEURIST_BASE_URL . "common/html/msgErrorMsg.html?msg=" . $msg2;
            }
        }
    }
    if ($redirect) {
        if (defined('ISSERVICE')) {
            echo "/*DEBUG: it happens in " . $_SERVER['PHP_SELF'] . " */ location.replace(\"" . $redirect . "\");";
        } else {
            header("Location: " . $redirect);
        }
    }
    exit;
    // it will drop through to here without an error message if the system has not been set up yet
}
Esempio n. 5
0
/**
* exit to page with error information for the user
* @param    int [$critical] level of criticality 1- unable to proceed 2-possible misname of db 0-db connection problem
* @param    string [$msg] error message
*/
function returnErrorMsgPage($critical, $msg = null)
{
    $redirect = null;
    if ($critical == 1) {
        // bad connection to MySQL server
        $msg2 = "<p>&nbsp;Heurist initialisation error<p> " . $msg ? $msg : "" . " <p><i>Please consult your system administrator for help, or email: info - a t - HeuristNetwork.org </i></p>";
        $msg2 = rawurlencode($msg2);
        $redirect = HEURIST_BASE_URL . "common/html/msgErrorMsg.html?msg=" . $msg2;
    } else {
        if ($critical == 2) {
            //database not defined or cannot connect to it
            $redirect = HEURIST_BASE_URL . "common/connect/selectDatabase.php";
            if ($msg) {
                $redirect .= "?msg=" . rawurlencode($msg);
            }
        } else {
            if ($critical == 3) {
                // db required upgrade
                $redirect = HEURIST_BASE_URL . "admin/setup/dbupgrade/upgradeDatabase.php?db=" . HEURIST_DBNAME;
            } else {
                // gets to here if database not specified properly. This is an error if the system is set up properly, but not at
                // first initialisaiton of the system, so test for existence of databases, if none then Heurist has not been set up yet.
                // Placed here rather than up-front test to avoid having to test this in every script
                $list = mysql__getdatabases();
                if (count($list) > 0) {
                    $msg2 = "<p>&nbsp;Cannot open database, but cause of error unknown.<p><br><br>" . $msg ? $msg : "" . "<p><br><br><i>Please consult your system administrator for help, or email: info - a t - HeuristNetwork.org </i></p>";
                    $msg2 = rawurlencode($msg2);
                    $redirect = HEURIST_BASE_URL . "common/html/msgErrorMsg.html?msg=" . $msg2;
                }
            }
        }
    }
    if ($redirect) {
        if (defined('ISSERVICE')) {
            // ISSERVICE set by files (~27) which include initialise.php. 0 if returns html, otherwise 1
            echo "/* Info: it happens in " . $_SERVER['PHP_SELF'] . " */ location.replace(\"" . $redirect . "\");";
        } else {
            header("Location: " . $redirect);
        }
    }
    exit;
    // it will drop through to here without an error message if the system has not been set up yet
}
 print "<form name='selectdbtype' action='getRecordsFromDB.php' method='get'>";
 print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>";
 if (!$is_h2) {
     print "<input name='h2' value='1' type='hidden'>";
 }
 print "<input type='submit' value='Switch to H" . ($is_h2 ? "3" : "2") . " databases' /><br/>";
 print "</form>";
 print "<form name='selectdb' action='getRecordsFromDB.php' method='post'>";
 //  We have to use 'get', 'post' fails to transfer target database to step 2
 print "<input name='mode' value='2' type='hidden'>";
 // calls the form to select mappings, step 2
 print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>";
 print "<input name='h2' value='" . ($is_h2 ? 1 : 0) . "' type='hidden'>";
 // print "Enter source database name (prefix added automatically): <input type='text' name='sourcedbname' />";
 print "<br/>Choose source database: <select id='db' name='sourcedbname'>";
 $list = mysql__getdatabases(false, null, null, $db_prefix);
 foreach ($list as $name) {
     print "<option value='{$name}'>{$name}</option>";
 }
 print "</select>";
 if (!$is_h2) {
     print "<div style=\"padding:5px;\">";
     print "Username:&nbsp;<input type='text' name='username' id='username' size='20' class='in'>&nbsp;&nbsp;";
     print "Password:&nbsp;<input type='password' name='password' size='20' class='in'>&nbsp;&nbsp;";
     print "Use the same as current:&nbsp;<input type='checkbox' checked='checked' name='samelogin' value='1'/>";
     if (@$_REQUEST['loginerror'] == '1') {
         print '<br/><font color="#ff0000">Incorrect Username / Password for source database</font>';
     }
     print "</div>";
 }
 print "&nbsp;&nbsp;<input type='submit' value='Continue'/>";
        }
    }
    if (array_key_exists('role', $_REQUEST)) {
        $role = $_REQUEST['role'];
    } else {
        if (@$_REQUEST['v'] != "4") {
            $role = 'user';
            // by default
        }
    }
}
if ($email) {
    if (!($role == 'user' || $role == 'admin')) {
        $role = null;
    }
    print "<div>Filter list: <select onchange='{document.location.href=\"getListOfDatabases.php?db=" . HEURIST_DBNAME . "&popup=" . @$_REQUEST['popup'] . "&v=" . @$_REQUEST['v'] . "&role=\"+this.value;}'>";
    print "<option " . ($role == null ? 'selected' : '') . " value='0'>All</option><option " . ($role == 'user' ? 'selected' : '') . " value='user'>User</option><option " . ($role == 'admin' ? 'selected' : '') . " value='admin'>Administrator</option></select></div>";
}
print "<br /><div>Click on the database name to open in a new tab. <br />" . "Databases are filtered by default to show only those to which you have access</div>";
print "<ul class='dbList'>";
$list = mysql__getdatabases(false, $email, $role);
foreach ($list as $name) {
    print "<li><a href=" . $url . "?db={$name} target=_blank>{$name}</a></li>";
}
print "</ul>";
?>
</div>
</body>
</html>

Esempio n. 8
0
function makeDatabase()
{
    global $newDBName, $isNewDB, $done, $isDefineNewDatabase, $dbTemplateName, $errorCreatingTables;
    $isTemplateDB = $dbTemplateName != null && $dbTemplateName != '0';
    $dataInsertionSQLFile = null;
    $error = false;
    $warning = false;
    if (isset($_REQUEST['dbname'])) {
        // Check that there is a current administrative user who can be made the owner of the new database
        $message = "MySQL username and password have not been set in configIni.php " . "or heuristConfigIni.php<br/> - Please do so before trying to create a new database.<br>";
        if (ADMIN_DBUSERNAME == "" || ADMIN_DBUSERPSWD == "") {
            errorOut($message);
            return false;
        }
        // checking for current administrative user
        if (!is_logged_in()) {
            //this is creation+registration
            $captcha_code = getUsrField('ugr_Captcha');
            //check capture
            if (@$_SESSION["captcha_code"] && $_SESSION["captcha_code"] != $captcha_code) {
                errorOut('Are you a bot? Please enter the correct answer to the challenge question');
                print '<script type="text/javascript">isRegdataEntered=false;</script>';
                $isDefineNewDatabase = true;
                return false;
            }
            if (@$_SESSION["captcha_code"]) {
                unset($_SESSION["captcha_code"]);
            }
            $firstName = getUsrField('ugr_FirstName');
            $lastName = getUsrField('ugr_LastName');
            $eMail = getUsrField('ugr_eMail');
            $name = getUsrField('ugr_Name');
            $password = getUsrField('ugr_Password');
            if ($firstName == '' || $lastName == '' || $eMail == '' || $name == '' || $password == '') {
                errorOut('Mandatory data for your registration profile (first and last name, email, password) are not completed. Please fill out registration form');
                print '<script type="text/javascript">isRegdataEntered=false;</script>';
                $isDefineNewDatabase = true;
                return false;
            }
        }
        // Create a new blank database
        $newDBName = trim($_REQUEST['uname']) . '_';
        if ($newDBName == '_') {
            $newDBName = '';
        }
        // don't double up underscore if no user prefix
        $newDBName = $newDBName . trim($_REQUEST['dbname']);
        $newname = HEURIST_DB_PREFIX . $newDBName;
        // all databases have common prefix then user prefix
        $list = mysql__getdatabases();
        $list = array_map("arraytolower", $list);
        if (false && in_array(strtolower($newDBName), $list)) {
            errorOut('Warning: database "' . $newname . '" already exists. Please choose a different name');
            $isDefineNewDatabase = true;
            return false;
        }
        //get path to registered db template and download coreDefinitions.txt
        $reg_url = @$_REQUEST['url_template'];
        $exemplar_db = @$_REQUEST['exemplar'];
        $name = '';
        //user name
        if (true) {
            // For debugging: set to false to avoid real database creation
            if ($exemplar_db != null) {
                //from example db
                //1a. verify that sample dump exists
                $templateFoldersContent = HEURIST_DIR . "admin/setup/exemplars/" . $exemplar_db . '.zip';
                if (!file_exists($templateFoldersContent) || filesize($templateFoldersContent) < 1) {
                    errorOut('Sorry, unable to find the exemplar zip file (' . $templateFoldersContent . ')containing the database folders and SQL script.');
                    return false;
                }
                //1b. verify that sample dump can be extracted
                $exemplar_dir = HEURIST_DIR . "admin/setup/exemplars/";
                $exemplar_dir = str_replace('//', '/', $exemplar_dir);
                $dataInsertionSQLFile = HEURIST_FILESTORE_DIR . 'scratch/' . $exemplar_db . ".sql";
                if (!file_exists($dataInsertionSQLFile) || filesize($templateFoldersContent) < 0) {
                    //extract dump from archive
                    unzip($templateFoldersContent, HEURIST_FILESTORE_DIR . 'scratch/', $exemplar_db . '.sql');
                    if (!file_exists($dataInsertionSQLFile) || filesize($dataInsertionSQLFile) < 0) {
                        errorOut('Sorry, unable to extract the database script "' . $exemplar_db . '.sql" from the zipped file "' . $templateFoldersContent . '". This may be due to incorrect permissions on the program code - please consult your system administrator.');
                        return false;
                    }
                }
                //2. create empty database
                if (!db_create($newname)) {
                    errorOut('Sorry, unable to create new database ' . $newname);
                    return false;
                }
                //3. restore from dump
                if (!db_script($newname, $dataInsertionSQLFile)) {
                    errorOut('Error importing sample data from ' . $dataInsertionSQLFile);
                    cleanupNewDB($newname);
                    return false;
                }
                $dataInsertionSQLFile = null;
            } else {
                //$exemplar_db
                // this is global variable that is used in buildCrosswalks.php
                $templateFileName = "NOT DEFINED";
                $templateFoldersContent = "NOT DEFINED";
                if ($reg_url) {
                    // getting definitions from an external registered database
                    $nouse_proxy = true;
                    $isTemplateDB = true;
                    $data = loadRemoteURLContent($reg_url, $nouse_proxy);
                    //without proxy
                    $resval = isDefinitionsInvalid($data);
                    if ($resval) {
                        if (defined("HEURIST_HTTP_PROXY")) {
                            $nouse_proxy = false;
                            $data = loadRemoteURLContent($reg_url, $nouse_proxy);
                            //with proxy
                            $resval = isDefinitionsInvalid($data);
                            if ($resval) {
                                $data = null;
                            }
                        } else {
                            $data = null;
                        }
                    }
                    if ($resval) {
                        errorOut("Error importing core definitions from template database {$reg_url} for database {$newname}<br>" . $resval . '<br>Please check whether this database is valid; consult Heurist support if needed');
                        return false;
                    }
                    //save data into file
                    if (defined('HEURIST_SETTING_DIR')) {
                        $templateFileName = HEURIST_SETTING_DIR . get_user_id() . '_dbtemplate.txt';
                    } else {
                        $templateFileName = HEURIST_UPLOAD_ROOT . '0_dbtemplate.txt';
                    }
                    $res = file_put_contents($templateFileName, $data);
                    if (!$res) {
                        errorOut('Error: cannot save definitions from template database into local file.' . ' Please verify that folder ' . (defined('HEURIST_SETTING_DIR') ? HEURIST_SETTING_DIR : HEURIST_UPLOAD_ROOT) . ' is writeable');
                        return false;
                    }
                    //download content of some folder from template database ======================
                    $reg_url = str_replace("getDBStructureAsSQL", "getDBFoldersForNewDB", $reg_url);
                    //replace to other script
                    $data = loadRemoteURLContent($reg_url, $nouse_proxy);
                    //with proxy
                    if ($data) {
                        if (defined('HEURIST_SETTING_DIR')) {
                            $templateFoldersContent = HEURIST_SETTING_DIR . get_user_id() . '_dbfolders.zip';
                        } else {
                            $templateFoldersContent = HEURIST_UPLOAD_ROOT . '0_dbfolders.zip';
                        }
                        $res = file_put_contents($templateFoldersContent, $data);
                        if (!$res) {
                            errorOut('Warning: cannot save content of settings folders from template database into local file. ' . ' Please verify that folder ' . (defined('HEURIST_SETTING_DIR') ? HEURIST_SETTING_DIR : HEURIST_UPLOAD_ROOT) . ' is writeable');
                            return false;
                        }
                    } else {
                        errorOut('Warning: server does not return the content of settings folders from template database. ' . 'Please ask system adminstrator to verify that zip extension on remote server is installed and that upload folder is writeable');
                        return false;
                    }
                    // Example database: download data to insert into new database =================================
                    if ($dbTemplateName != '1') {
                        // TODO: Artem: correct way is the donwloading data from sample database, however at the moment it is included into code. Ian: NASAT - would exposes databases to easy harvesting, but potentially OK as long as data marked public
                        // $dbTemplateNsme is the name of the database which is used to populate the example database, the corresponding data file has the same name with _data.sql appended
                        $dataInsertionSQLFile = HEURIST_DIR . "admin/setup/dbcreate/" . $dbTemplateName . "_data.sql";
                        if (!file_exists($dataInsertionSQLFile)) {
                            errorOut('Warning: cannot find sample data file in code ' . $dataInsertionSQLFile);
                            return false;
                        }
                    }
                } else {
                    if ($isTemplateDB) {
                        errorOut('Wrong parameters: Template database is not defined.');
                        return false;
                    } else {
                        $templateFileName = HEURIST_DIR . "admin/setup/dbcreate/coreDefinitions.txt";
                    }
                }
                if (!file_exists($templateFileName)) {
                    errorOut('Error: template database structure file ' . $templateFileName . ' not found');
                    return false;
                }
                if (!createDatabaseEmpty($newDBName)) {
                    $isDefineNewDatabase = true;
                    return false;
                }
                // Run buildCrosswalks to import minimal definitions from coreDefinitions.txt into the new DB
                // yes, this is badly structured, but it works - if it ain't broke ...
                $isNewDB = true;
                // flag of context for buildCrosswalks, tells it to use coreDefinitions.txt
                require_once dirname(__FILE__) . '/../../structure/import/buildCrosswalks.php';
                // errorCreatingTables is set to true by buildCrosswalks if an error occurred
                if ($errorCreatingTables) {
                    errorOut('Error importing core definitions from ' . ($isTemplateDB ? "template database" : "coreDefinitions.txt") . ' for database ' . $newname . '<br>' . 'Please check whether this file or database is valid; consult Heurist support if needed');
                    cleanupNewDB($newname);
                    return false;
                }
            }
            //not $exemplar_db
            // Get and clean information for the user creating the database
            if (!is_logged_in()) {
                // getUsrField sanitises data entered
                $longName = "";
                $firstName = getUsrField('ugr_FirstName');
                $lastName = getUsrField('ugr_LastName');
                $eMail = getUsrField('ugr_eMail');
                $name = getUsrField('ugr_Name');
                $password = getUsrField('ugr_Password');
                $department = getUsrField('ugr_Department');
                $organisation = getUsrField('ugr_Organisation');
                $city = getUsrField('ugr_City');
                $state = getUsrField('ugr_State');
                $postcode = getUsrField('ugr_Postcode');
                $interests = getUsrField('ugr_Interests');
                $ugr_IncomingEmailAddresses = getUsrField('ugr_IncomingEmailAddresses');
                $ugr_TargetEmailAddresses = getUsrField('ugr_TargetEmailAddresses');
                $ugr_URLs = getUsrField('ugr_URLs');
                $s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./';
                $salt = $s[rand(0, strlen($s) - 1)] . $s[rand(0, strlen($s) - 1)];
                $password = crypt($password, $salt);
            } else {
                mysql_connection_insert(DATABASE);
                $query = mysql_query('SELECT ugr_LongName, ugr_FirstName, ugr_LastName, ugr_eMail, ugr_Name, ugr_Password, ' . 'ugr_Department, ugr_Organisation, ugr_City, ugr_State, ugr_Postcode, ugr_Interests, ' . 'ugr_IncomingEmailAddresses, ugr_TargetEmailAddresses, ugr_URLs ' . 'FROM sysUGrps WHERE ugr_ID=' . get_user_id());
                $details = mysql_fetch_row($query);
                $longName = mysql_real_escape_string($details[0]);
                $firstName = mysql_real_escape_string($details[1]);
                $lastName = mysql_real_escape_string($details[2]);
                $eMail = mysql_real_escape_string($details[3]);
                $name = mysql_real_escape_string($details[4]);
                $password = mysql_real_escape_string($details[5]);
                $department = mysql_real_escape_string($details[6]);
                $organisation = mysql_real_escape_string($details[7]);
                $city = mysql_real_escape_string($details[8]);
                $state = mysql_real_escape_string($details[9]);
                $postcode = mysql_real_escape_string($details[10]);
                $interests = mysql_real_escape_string($details[11]);
                $ugr_IncomingEmailAddresses = mysql_real_escape_string($details[12]);
                $ugr_TargetEmailAddresses = mysql_real_escape_string($details[13]);
                $ugr_URLs = mysql_real_escape_string($details[14]);
            }
            //	 todo: code location of upload directory into sysIdentification, remove from edit form (should not be changed)
            //	 todo: might wish to control ownership rather than leaving it to the O/S, although this works well at present
            createDatabaseFolders($newDBName);
            if (file_exists($templateFoldersContent) && filesize($templateFoldersContent) > 0) {
                //override content of setting folders with template database files - rectype icons, smarty templates etc
                unzip($templateFoldersContent, HEURIST_UPLOAD_ROOT . $newDBName . "/");
            }
            // Prepare to write to the newly created database
            mysql_connection_insert($newname);
            // Make the current user the owner and admin of the new database
            $res = mysql_query('UPDATE sysUGrps SET ugr_Enabled="Y", ugr_LongName="' . $longName . '", ugr_FirstName="' . $firstName . '",
                            ugr_LastName="' . $lastName . '", ugr_eMail="' . $eMail . '", ugr_Name="' . $name . '",
                            ugr_Password="******", ugr_Department="' . $department . '", ugr_Organisation="' . $organisation . '",
                            ugr_City="' . $city . '", ugr_State="' . $state . '", ugr_Postcode="' . $postcode . '",
                            ugr_IncomingEmailAddresses="' . $ugr_IncomingEmailAddresses . '",
                            ugr_TargetEmailAddresses="' . $ugr_TargetEmailAddresses . '",
                            ugr_URLs="' . $ugr_URLs . '",
                            ugr_interests="' . $interests . '" WHERE ugr_ID=2');
            if (!$res) {
                ?>
                            <b>Warning: Failed to make the current user the owner and admin of the new database, error:</b>
                            <?php 
                print mysql_error();
            }
            // Add the default navigation tree for the DATABASE MANAGERS group (user #1). This is copied from the Heurist_Core_Definitions database}
            $navTree = '{"expanded":true,"key":"root_3","title":"root","children":[{"expanded":true,"folder":true,"key":"_6","title":"Recent changes","children":[{"folder":false,"key":"19","title":"Recent changes (last week)","data":{"isfaceted":false}},{"folder":false,"key":"20","title":"Recent changes (last month)","data":{"isfaceted":false}},{"folder":false,"key":"21","title":"Recent changes (last year)","data":{"isfaceted":false}},{"folder":false,"key":"14","title":"All (most recent first)","data":{"isfaceted":false}}]},{"expanded":true,"folder":true,"key":"_1","title":"Specific types","children":[{"key":"27","title":"Bibliographic records","data":{"isfaceted":false}},{"key":"28","title":"Organisations","data":{"isfaceted":false}},{"key":"29","title":"People","data":{"isfaceted":false}},{"key":"30","title":"Media items","data":{"isfaceted":false}},{"expanded":true,"folder":true,"key":"_5","title":"Facet searches","children":[{"key":"25","title":"Persons","data":{"isfaceted":true}},{"key":"26","title":"Organisations","data":{"isfaceted":true}},{"expanded":true,"folder":true,"key":"_1","title":"Facet searches with rules","children":[{"key":"31","title":"Persons with related recs","data":{"isfaceted":true}}]}]}]},{"expanded":true,"folder":true,"key":"_5","title":"Experiments","children":[{"key":"24","title":"Mapping (layers, data sources)","data":{"isfaceted":false}}]}]}';
            $res = mysql__insertupdate($newname, 'sysUGrps', 'ugr', array('ugr_ID' => 1, 'ugr_NavigationTree' => $navTree));
            if (!is_int($res)) {
                print '<b>Warning: Failed to copy navigation tree for user (group) 1 (DB Managers) to new database, error:</b>' . $res;
            }
            // Add the default navigation tree for the DATABASE OWNER (user #2). This is copied from the Heurist_Core_Definitions database}
            $navTree = '"bookmark":{"expanded":true,"key":"root_1","title":"root","children":[{"folder":false,"key":"_1","title":"Recent changes","data":{"url":"?w=bookmark&q=sortby:-m after:\\"1 week ago\\"&label=Recent changes"}},{"folder":false,"key":"_2","title":"All (date order)","data":{"url":"?w=bookmark&q=sortby:-m&label=All records"}}]},"all":{"expanded":true,"key":"root_2","title":"root","children":[{"folder":false,"key":"_3","title":"Recent changes","data":{"url":"?w=all&q=sortby:-m after:\\"1 week ago\\"&label=Recent changes"}},{"folder":false,"key":"_4","title":"All (date order)","data":{"url":"?w=all&q=sortby:-m&label=All records"}},{"folder":true,"key":"_5","title":"Rules","children":[{"folder":false,"key":"12","title":"Person > anything they created","data":{"isfaceted":false}},{"folder":false,"key":"13","title":"Organisation > Assoc. places","data":{"isfaceted":false}}]}]}';
            $res = mysql__insertupdate($newname, 'sysUGrps', 'ugr', array('ugr_ID' => 2, 'ugr_NavigationTree' => $navTree));
            if (!is_int($res)) {
                print '<b>Warning: Failed to copy navigation tree for user 2 (DB Owner) to new database, error:</b>' . $res;
            }
            // email the system administrator to tell them a new database has been created
            user_EmailAboutNewDatabase($name, $firstName . ' ' . $lastName, $organisation, $eMail, $newDBName, $interests);
        }
        if ($dataInsertionSQLFile != null && file_exists($dataInsertionSQLFile)) {
            if (!db_script($newname, $dataInsertionSQLFile)) {
                errorOut('Error importing sample data from ' . $dataInsertionSQLFile);
            }
        }
        ?>
                    <div  style='padding:0px 0 10px 0; font-size:larger;'>
                        <h2 style='padding-bottom:10px'>Congratulations, your new database  [ <?php 
        echo $newDBName;
        ?>
  ]  has been created</h2>
                        <?php 
        if (@$_REQUEST['db'] != '' && @$_REQUEST['db'] != null) {
            ?>
                            <p style="padding-left:10px"><strong>Admin username:</strong> <?php 
            echo $name;
            ?>
</p>
                            <p style="padding-left:10px"><strong>Admin password:</strong> &#60;<i>same as the account you are currently logged in as</i>&#62;</p>
                            <?php 
        }
        ?>
                        <p style="padding-left:10px">Log into your new database with the following link:</p>
                        <p style="padding-left:6em"><b><a href="<?php 
        echo HEURIST_BASE_URL . "?db=" . $newDBName;
        ?>
"
                                    title="" onclick="{closeDialog()}" target="blank">
                                    <?php 
        echo HEURIST_BASE_URL . "?db=" . $newDBName;
        ?>
                                </a></b>&nbsp;&nbsp;&nbsp;&nbsp; <i>(we suggest bookmarking this link)</i></p>

                        <p style="padding-left:6em">
                            After logging in to your new database, we suggest you import some additional entity types from one of the<br />
                            curated Heurist databases, or from one of the other databases listed in the central database catalogue,<br />
                            using Database &gt; Structure &gt; Acquire from Databases 
                            <!--or Database &gt; Structure &gt; Acquire from Templates -->
                        </p>
                    </div>
                    <?php 
        // TODO: automatically redirect to the new database in a new window
        // this is a point at which people tend to get lost
        return false;
    }
    // isset
}