Esempio n. 1
0
 public function post()
 {
     $sess_admin_user = $this->session->userdata('admin_user');
     session_write_close();
     $result = jsonSrc();
     $createPage['catid'] = $this->input->post('catid');
     $createPage['author'] = $sess_admin_user;
     $createPage['date'] = time();
     $createPage['update'] = time();
     $createPage['title'] = $this->input->post('title');
     $createPage['url'] = $this->input->post('url');
     $createPage['title_en'] = $this->input->post('title_en');
     $createPage['excerpt'] = $this->input->post('excerpt');
     $createPage['excerpt_en'] = $this->input->post('excerpt_en');
     $createPage['content'] = $this->input->post('content');
     $createPage['content_en'] = $this->input->post('content_en');
     $createPage['meta_key'] = $this->input->post('meta_key');
     $createPage['meta_key_en'] = $this->input->post('meta_key_en');
     $createPage['meta_desc'] = $this->input->post('meta_desc');
     $createPage['meta_desc_en'] = $this->input->post('meta_desc_en');
     $createPage['template'] = $this->input->post('template');
     $createPage['type'] = 'blog';
     $page_id = db_create('page', $createPage);
     $result['resultCode'] = 1000;
     $result['resultMsg'] = "Success !!";
     $result['resultData']['id'] = $page_id;
     return $result;
 }
Esempio n. 2
0
 public function post()
 {
     $sess_admin_user = $this->session->userdata('admin_user');
     session_write_close();
     $result = jsonSrc();
     $createPage['catid'] = false;
     $createPage['author'] = $sess_admin_user;
     $createPage['date'] = time();
     $createPage['title'] = $this->input->post('title');
     if ($this->input->post('url')) {
         $createPage['url'] = $this->input->post('url');
     } else {
         $createPage['url'] = preg_replace('[\\ ]', '-', preg_replace('[^a-z0-9\\ ]', '', strtolower($this->input->post('title'))));
     }
     $createPage['title_en'] = $this->input->post('title_en');
     $createPage['excerpt'] = $this->input->post('excerpt');
     $createPage['excerpt_en'] = $this->input->post('excerpt_en');
     $createPage['content'] = $this->input->post('content');
     $createPage['content_en'] = $this->input->post('content_en');
     $createPage['meta_key'] = $this->input->post('meta_key');
     $createPage['meta_key_en'] = $this->input->post('meta_key_en');
     $createPage['meta_desc'] = $this->input->post('meta_desc');
     $createPage['meta_desc_en'] = $this->input->post('meta_desc_en');
     $createPage['template'] = $this->input->post('template');
     $createPage['type'] = 'page';
     $page_id = db_create('page', $createPage);
     $result['resultCode'] = 1000;
     $result['resultMsg'] = "Success !!";
     $result['resultData']['id'] = $page_id;
     return $result;
 }
Esempio n. 3
0
function db_connection()
{
    global $connection;
    $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    if (mysqli_connect_errno($connection)) {
        echo json_encode("Could not connect to database");
        exit;
    } else {
        echo json_encode("Connected");
    }
    db_create();
}
Esempio n. 4
0
 function scan()
 {
     $templates = scandir(docroot('templates/' . $this->config->item('theme') . '/page'));
     $theme = $this->config->item('theme');
     if (is_array($templates)) {
         db_delete('templates', array('theme' => $theme));
         foreach ($templates as $templateRow) {
             if (!preg_match('#^[\\.]|^[_]#', $templateRow)) {
                 $insert = false;
                 $insert['theme'] = $theme;
                 $insert['name'] = preg_replace('#\\.php$#', '', $templateRow);
                 db_create('templates', $insert);
             }
         }
     }
 }
Esempio n. 5
0
 function add($type = false)
 {
     if (empty($_POST)) {
         $view['type'] = $type;
         $this->load->view(tpldir('admin/extension/footer/add_view'), $view);
     } else {
         $result = jsonSrc();
         $id = $this->input->post('id');
         $createFooter['url'] = $this->input->post('url');
         $createFooter['name'] = $this->input->post('name');
         $createFooter['type'] = $this->input->post('type');
         db_create('mod_footer', $createFooter);
         $result['resultCode'] = 1000;
         $result['resultMsg'] = "Footer Created";
         $result['resultData']['openUrl'] = base_url('admin/footer');
         echo json_encode($result);
     }
 }
Esempio n. 6
0
 function add()
 {
     if (empty($_POST)) {
         $this->load->view(tpldir('admin/extension/video/add_view'));
     } else {
         $result = jsonSrc();
         $insertVid['url'] = $this->input->post('url');
         $insertVid['status'] = $this->input->post('status');
         $insertVid['text'] = $this->input->post('text');
         $insertVid['content'] = $this->input->post('content');
         $id = db_create('mod_video', $insertVid);
         if ($id) {
             $result['resultCode'] = 1000;
             $result['resultMsg'] = "Success !!";
             $result['resultData']['openUrl'] = base_url('admin/video');
         }
         echo json_encode($result);
     }
 }
Esempio n. 7
0
 function add()
 {
     if (empty($_POST)) {
         $view['categories'] = db_reads('category', array('type' => 'blog'));
         $this->load->view(tpldir('admin/category/add_view'), $view);
     } else {
         $result = jsonSrc();
         $insertcat['type'] = 'blog';
         $insertcat['name'] = $this->input->post('name');
         $id = db_create('category', $insertcat);
         if ($id) {
             $result['resultCode'] = 1000;
             $result['resultMsg'] = "Success!!";
             $result['resultData']['openUrl'] = base_url('admin/category/edit/' . $id);
         } else {
             $result['resultMsg'] = "Create Category Failed";
         }
         echo json_encode($result);
     }
 }
Esempio n. 8
0
 public function post()
 {
     $result = jsonSrc();
     $createMenu['title'] = $this->input->post('title');
     $createMenu['title_en'] = $this->input->post('title_en');
     if ($this->input->post('post_id')) {
         $createMenu['post_id'] = $this->input->post('post_id');
         $createMenu['link'] = false;
     } else {
         $createMenu['post_id'] = false;
         $createMenu['link'] = $this->input->post('link');
     }
     $createMenu['parent_id'] = $this->input->post('parent_id');
     $createMenu['position'] = $this->input->post('position');
     $createMenu['hide'] = $this->input->post('hide');
     $menu_item_id = db_create('menu_item', $createMenu);
     $result['resultCode'] = 1000;
     $result['resultMsg'] = "Success !!";
     $result['resultData']['id'] = $menu_item_id;
     return $result;
 }
Esempio n. 9
0
function cloneDatabase($targetdbname)
{
    set_time_limit(0);
    $newname = HEURIST_DB_PREFIX . $targetdbname;
    //create new empty database
    if (!db_create($newname)) {
        return false;
    }
    echo_flush("<p>Create Database Structure (tables)</p>");
    if (db_script($newname, HEURIST_DIR . "admin/setup/dbcreate/blankDBStructure.sql")) {
        echo_flush('<p style="padding-left:20px">SUCCESS</p>');
    } else {
        db_drop($newname);
        return false;
    }
    // Remove initial values from empty database
    mysql_connection_insert($newname);
    mysql_query('delete from sysIdentification where 1');
    mysql_query('delete from sysTableLastUpdated where 1');
    mysql_query('delete from sysUsrGrpLinks where 1');
    mysql_query('delete from sysUGrps where ugr_ID>=0');
    mysql_query('delete from defLanguages where 1');
    echo_flush("<p>Copy data</p>");
    // db_clone function in /common/php/db_utils.php does all the work
    if (db_clone(DATABASE, $newname)) {
        echo_flush('<p style="padding-left:20px">SUCCESS</p>');
    } else {
        db_drop($newname);
        return false;
    }
    //cleanup database to avoid issues with addition of constraints
    //1. cleanup missed trm_InverseTermId
    mysql_query('update defTerms t1 left join defTerms t2 on t1.trm_InverseTermId=t2.trm_ID
        set t1.trm_InverseTermId=null
    where t1.trm_ID>0 and t2.trm_ID is NULL');
    //2. remove missed recent records
    mysql_query('delete FROM usrRecentRecords
        where rre_RecID is not null
    and rre_RecID not in (select rec_ID from Records)');
    //3. remove missed rrc_SourceRecID and rrc_TargetRecID
    mysql_query('delete FROM recRelationshipsCache
        where rrc_SourceRecID is not null
    and rrc_SourceRecID not in (select rec_ID from Records)');
    mysql_query('delete FROM recRelationshipsCache
        where rrc_TargetRecID is not null
    and rrc_TargetRecID not in (select rec_ID from Records)');
    //4. cleanup orphaned details
    mysql_query('delete FROM recDetails
        where dtl_RecID is not null
    and dtl_RecID not in (select rec_ID from Records)');
    //5. cleanup missed references to uploaded files
    mysql_query('delete FROM recDetails
        where dtl_UploadedFileID is not null
    and dtl_UploadedFileID not in (select ulf_ID from recUploadedFiles)');
    $sHighLoadWarning = "<p><h4>Note: </h4>Failure to clone a database may result from high server load. Please try again, and if the problem continues contact the Heurist developers at info heuristnetwork dot org</p>";
    // 4. add contrainsts, procedure and triggers
    echo_flush("<p>Addition of Referential Constraints</p>");
    if (db_script($newname, dirname(__FILE__) . "/../dbcreate/addReferentialConstraints.sql")) {
        echo_flush('<p style="padding-left:20px">SUCCESS</p>');
    } else {
        db_drop($newname);
        print $sHighLoadWarning;
        return false;
    }
    echo_flush("<p>Addition of Procedures and Triggers</p>");
    if (db_script($newname, dirname(__FILE__) . "/../dbcreate/addProceduresTriggers.sql")) {
        echo_flush('<p style="padding-left:20px">SUCCESS</p>');
    } else {
        db_drop($newname);
        print $sHighLoadWarning;
        return false;
    }
    // 5. remove registration info and assign originID for definitions
    mysql_connection_insert($newname);
    $sourceRegID = 0;
    $res = mysql_query('select sys_dbRegisteredID from sysIdentification where 1');
    if ($res) {
        $row = mysql_fetch_row($res);
        if ($row) {
            $sourceRegID = $row[0];
        }
    }
    //print "<p>".$sourceRegID."</p>";
    // RESET register db ID
    $query1 = "update sysIdentification set sys_dbRegisteredID=0, sys_hmlOutputDirectory=null, sys_htmlOutputDirectory=null, sys_SyncDefsWithDB=null, sys_MediaFolders=null where 1";
    $res1 = mysql_query($query1);
    if (mysql_error()) {
        //(mysql_num_rows($res1) == 0)
        print "<p><h4>Warning</h4><b>Unable to reset sys_dbRegisteredID in sysIdentification table. (" . mysql_error() . ")<br> Please reset the registration ID manually</b></p>";
    }
    //assign origin ID
    db_register($newname, $sourceRegID);
    // Index new database for Elasticsearch
    //TODO: Needs error report, trap error and warn or abort clone
    buildAllIndices($targetdbname);
    // Copy the images and the icons directories
    //TODO: Needs error report, trap error and warn or abort clone
    recurse_copy(HEURIST_UPLOAD_ROOT . HEURIST_DBNAME, HEURIST_UPLOAD_ROOT . $targetdbname);
    // Update file path in target database  with absolute paths
    $query1 = "update recUploadedFiles set ulf_FilePath='" . HEURIST_UPLOAD_ROOT . $targetdbname . "/' where ulf_FilePath='" . HEURIST_UPLOAD_ROOT . HEURIST_DBNAME . "/' and ulf_ID>0";
    $res1 = mysql_query($query1);
    if (mysql_error()) {
        //(mysql_num_rows($res1) == 0)
        print "<p><h4>Warning</h4><b>Unable to set database files path to new path</b>" . "<br>Query was:" . $query1 . "<br>Please get your system administrator to fix this problem BEFORE editing the database (your edits will affect the original database)</p>";
    }
    // Success!
    echo "<hr><p>&nbsp;</p><h2>New database '{$targetdbname}' created successfully</h2>";
    print "<p>Please access your new database through this link: <a href='" . HEURIST_BASE_URL . "?db=" . $targetdbname . "' title='' target=\"_new\"><strong>" . $targetdbname . "</strong></a></p>";
    return true;
}
Esempio n. 10
0
    $user->createdBy = $_SESSION['user_id'];
    $user->labConfigId = $lab_config_id;
    $user->langId = "default";
    add_user($user);
}
/*
# Create revamp DB instance for this lab
db_create($revamp_db_name);
# Populate
create_lab_config_revamp_tables($lab_config_id, $revamp_db_name);
# Copy selected test types and specimen types to this database
$lab_config->id = $lab_config_id;
add_lab_config_with_id($lab_config);
*/
# Create DB instance for this lab
db_create($db_name);
# Switch to this new instance and create data tables
db_change($db_name);
create_lab_config_tables($lab_config_id, $db_name);
# Generate initial worksheet configs if missing
$lab_config = LabConfig::getById($lab_config_id);
$lab_config->worksheetConfigGenerate();
# TODO:
$saved_id = $_SESSION['lab_config_id'];
$_SESSION['lab_config_id'] = $lab_config_id;
//db_change($GLOBAL_DB_NAME);
## Add new entry for infection (disease) report
# TODO:
/*
$site_settings = new DiseaseReport();
$site_settings->labConfigId = $lab_config_id;
Esempio n. 11
0
        if (@$row && $row[0] != 0 && $row[0] != get_user_id()) {
            echo "Definitions are already being modified or SQL failure on lock check.";
            header('Location: ' . HEURIST_BASE_URL . 'common/html/msgLockedByAdmin.html');
            // put up informative failure message
            die("Definitions are already being modified.<p> If this is not the case, you will need to remove the locks on the database.<br>Use Utilities > Clear database locks (administrators only)");
        }
    }
    // detect lock and shuffle out
    // Mark database definitions as being modified by administrator
    mysql_connection_insert(DATABASE);
    $query = "insert into sysLocks (lck_UGrpID, lck_Action) VALUES (" . (function_exists('get_user_id') ? get_user_id() : 0) . ", 'buildcrosswalks')";
    $res = mysql_query($query);
    // create sysLock
    // Create the Heurist structure for the temp database, using a shortened version of the new database template
    db_drop($tempDBName, false);
    if (!db_create($tempDBName) || !db_script($tempDBName, HEURIST_DIR . "admin/setup/dbcreate/blankDBStructureDefinitionsOnly.sql")) {
        unlockDatabase();
        exit;
    }
}
// existing database
mysql_connection_insert($tempDBName);
// Use temp database
// ------Find and set the source database-----------------------------------------------------------------------
// Query heurist.sydney.edu.au Heurist_Master_Index database to find the URL of the installation
// that you want to use as the source.
if ($isNewDB) {
    // minimal definitions from coreDefinitions.txt - returns same format as getDBStructureAsSQL
    $file = fopen($definitions_filename, "r");
    $output = "";
    while (!feof($file)) {
Esempio n. 12
0
             // apply some critical updates to the database for migration issues
             query('ALTER TABLE ' . $_zp_conf_vars['mysql_prefix'] . 'administrators' . ' ADD COLUMN `valid` int(1) default 1', false);
             query('ALTER TABLE ' . $_zp_conf_vars['mysql_prefix'] . 'administrators' . ' CHANGE `password` `pass` varchar(64)', false);
             query('ALTER TABLE ' . $_zp_conf_vars['mysql_prefix'] . 'administrators' . ' ADD COLUMN `loggedin` datetime', false);
             query('ALTER TABLE ' . $_zp_conf_vars['mysql_prefix'] . 'administrators' . ' ADD COLUMN `lastloggedin` datetime', false);
             query('ALTER TABLE ' . $_zp_conf_vars['mysql_prefix'] . 'administrators' . ' ADD COLUMN `challenge_phrase` TEXT', false);
         }
     }
     $environ = true;
     require_once dirname(dirname(__FILE__)) . '/admin-functions.php';
 } else {
     if ($_zp_DB_connection) {
         // there was a connection to the database handler but not to the database.
         if (!empty($_zp_conf_vars['mysql_database'])) {
             if (isset($_GET['Create_Database'])) {
                 $result = db_create();
                 if ($result && ($connection = db_connect($_zp_conf_vars, false))) {
                     $environ = true;
                     require_once dirname(dirname(__FILE__)) . '/admin-functions.php';
                 } else {
                     if ($result) {
                         $DBcreated = true;
                     } else {
                         $connectDBErr = db_error();
                     }
                 }
             } else {
                 $oktocreate = true;
             }
         }
     } else {
Esempio n. 13
0
 function contentadd($mid = false)
 {
     if (empty($_POST)) {
         if ($mid) {
             $view['mid'] = $mid;
             $this->load->view(tpldir('admin/extension/microsite/content/add_view'), $view);
         }
     } else {
         $result = jsonSrc();
         $insertContent['mid'] = $this->input->post('mid');
         $insertContent['background'] = $this->input->post('background');
         $insertContent['menu'] = $this->input->post('menu');
         $insertContent['anchor'] = preg_replace('/[^a-zA-Z0-9]/', '', $this->input->post('menu'));
         $insertContent['content'] = $this->input->post('content');
         db_create('mod_microsite_content', $insertContent);
         $result['resultCode'] = 1000;
         $result['resultMsg'] = "Content Created";
         $result['resultData']['openUrl'] = base_url('admin/microsite/edit/' . $mid);
         echo json_encode($result);
     }
 }
Esempio n. 14
0
 function add()
 {
     $result = jsonSrc();
     if (isset($_FILES["assetfile"]["name"]) && $this->input->post('dirid')) {
         $target_dir = $this->config->item('document_root') . 'assets/';
         $arrname = explode('.', $_FILES["assetfile"]["name"]);
         $ext = "." . $arrname[count($arrname) - 1];
         $origname = $arrname[0];
         $filename = preg_replace('/[^0-9a-zA-Z]/', '', $origname) . '-' . time() . $ext;
         $target_file = $target_dir . basename($filename);
         $uploadOk = 1;
         $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
         if (in_array($imageFileType, array('jpg', 'png'))) {
             if (move_uploaded_file($_FILES["assetfile"]["tmp_name"], $target_file)) {
                 $insertAsset['file'] = $filename;
                 $insertAsset['dirid'] = $this->input->post('dirid');
                 $id = db_create('mod_asset', $insertAsset);
                 if ($id) {
                     $result['resultCode'] = 1000;
                     $result['resultMsg'] = "File succesfully uploaded";
                     $result['resultData']['openUrl'] = base_url('admin/asset/detail/' . $this->input->post('dirid'));
                 }
             } else {
                 $result['resultMsg'] = "Fail to update the image";
             }
         } else {
             $result = "The file " . basename($_FILES["assetfile"]["name"]) . " Is not supported for upload";
         }
     } else {
         $result = "Invalid parameter";
     }
     echo json_encode($result);
 }
Esempio n. 15
0
File: base.php Progetto: efoft/studi
<?php

include 'config.php';
$db = new SQLite3(DBFILE);
db_create();
function db_create()
{
    global $db;
    try {
        $db->exec('CREATE TABLE IF NOT EXISTS students (
                        id INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,
                        lastname text NOT NULL,
                        firstname text NOT NULL,
                        email text,
                        phone text,
                        college text,
                        faculty text,
                        enabled boolean DEFAULT 1
                );');
        $db->exec('CREATE TABLE IF NOT EXISTS lectures (
                        id INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,
                        name text,
                        date text,
                        teacher text,
                        matelials text
                );');
        $db->exec('CREATE TABLE IF NOT EXISTS marks (
                        id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                        lecture_id INTEGER NOT NULL,
                        teacher_id INTEGER NOT NULL,
                        mark INTEGER,
Esempio n. 16
0
?>

<!-- Page Start -->
<div class='data'>
	<p>
	  <table>
	    <tr>
	    	<?php 
$input = $connection;
db_read($input);
?>
</table></td>
	    </tr>
	  </table>
	</p>	
</div>

<div class='data_input'>
	<a name='form'></a>
	<?php 
db_create($connection);
?>
</div>
  
<?php 
db_finish($connection);
?>
<!-- Page End -->	
	
<?php 
include "../includes/layouts/footer.php";
Esempio n. 17
0
        trigger_error('Cannot connect to the database host: ' . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
        $B->setup_error[] = 'Cannot connect to the database host: ' . __FILE__ . ' ' . __LINE__;
        return FALSE;
    }
    $sql = 'CREATE DATABASE IF NOT EXISTS ' . $_POST['dbname'];
    if (FALSE == @mysql_query($sql, $_conn)) {
        trigger_error('Cannot create database: ' . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
        $B->setup_error[] = 'Cannot create database: ' . __FILE__ . ' ' . __LINE__;
        return FALSE;
    }
    @mysql_close($_conn);
    return TRUE;
}
// create db on demande
if (isset($_POST['create_db'])) {
    if (FALSE == ($success = db_create($this->B))) {
        return FALSE;
    }
}
$this->B->dsn = array('phptype' => 'mysql', 'username' => $this->B->conf_val['db']['user'], 'password' => $this->B->conf_val['db']['passwd'], 'hostspec' => $this->B->conf_val['db']['host'], 'database' => $this->B->conf_val['db']['name']);
$this->B->dboptions = array('debug' => 2, 'portability' => DB_PORTABILITY_ALL);
// include PEAR DB class
include_once SF_BASE_DIR . 'modules/common/PEAR/DB.php';
$this->B->db =& DB::connect($this->B->dsn, $this->B->dboptions);
if (DB::isError($this->B->db)) {
    trigger_error($this->B->db->getMessage() . "\n" . $this->B->db->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
    $this->B->setup_error[] = 'Cannot connect to the database: ' . __FILE__ . ' ' . __LINE__;
    $success = FALSE;
    return FALSE;
}
// create table if it dosent exist
Esempio n. 18
0
function createDatabaseEmpty($newDBName)
{
    $newname = HEURIST_DB_PREFIX . $newDBName;
    if (!db_create($newname)) {
        return false;
    }
    //
    //echo_flush ("<p>Create Database Structure (tables) ".HEURIST_DIR." </p>");
    if (db_script($newname, HEURIST_DIR . "admin/setup/dbcreate/blankDBStructure.sql")) {
        // echo_flush ('OK');
        // echo_flush ("<p>Add Referential Constraints ");
        if (db_script($newname, HEURIST_DIR . "admin/setup/dbcreate/addReferentialConstraints.sql")) {
            // echo_flush ('OK');
            // echo_flush ("<p>Add Procedures and Triggers ");
            if (db_script($newname, HEURIST_DIR . "admin/setup/dbcreate/addProceduresTriggers.sql")) {
                // echo_flush ('OK');
                return true;
            }
        }
    }
    db_drop($newname);
    return false;
}
Esempio n. 19
0
function SQLEditor()
{
    extract($_SESSION);
    $conn = @mysql_connect($mhost . ":" . $mport, $muser, $mpass);
    if ($conn) {
        echo "Logged in as {$muser}@{$mhost} <a href='{$self}?act=logout'>[Logout]</a><center>";
        echo "<form method='POST' action='{$self}?'>\n            Quick SQL query: <input type='text' style='width: 300px' value='select * from users' name='sqlquery'>\n            <input type='hidden' name='db' value='{$_GET['db']}'>\n            <input type='submit' value='Go' name='sql'>\n            </form>";
        echo "<form action='{$self}?act=sqledit' method='post'>\n            <input type='submit' style='border: none;' value='[ List Processes ]' name='sql_list_proc'>\n            </form></center></br></br>";
        if (isset($_POST['sql_list_proc'])) {
            $res = mysql_list_processes();
            echo "<table style='margin: auto; text-align: center;'><tr>\n                <td>Proc ID</td><td>Host</td><td>DB</td><td>Command</td><td>Time</td>\n                </tr>";
            while ($r = mysql_fetch_assoc($res)) {
                echo "<tr><td>{$r['Id']}</td><td>{$r['Host']}</td><td>{$r['db']}</td><td>{$r['Command']}</td><td>{$r['Time']}</td></tr>";
            }
            mysql_free_result($res);
            echo "</table></br>";
        }
        if (!isset($_GET['db'])) {
            if (isset($_POST['dbc'])) {
                db_create();
            }
            if (isset($_GET['dropdb'])) {
                SQLDrop();
            }
            echo "<table style='margin: auto; text-align: center;'>\n            <tr><td>Database</td><td>Table count</td><td>Download</td><td>Drop</td></tr>";
            $all_your_base = mysql_list_dbs($conn);
            while ($your_base = mysql_fetch_assoc($all_your_base)) {
                $tbl = mysql_query("SHOW TABLES FROM {$your_base['Database']}");
                $tbl_count = mysql_num_rows($tbl);
                echo "<tr><td><a href='{$self}?act=sqledit&db={$your_base['Database']}'>{$your_base['Database']}</td><td>{$tbl_count}</td><td><a href='{$self}?act=download&db={$your_base['Database']}'>Download</a></td><td><a href='{$self}?act=sqledit&dropdb={$your_base['Database']}'>Drop</a></td></tr>";
            }
            echo "</table></br><center><form action='{$self}?act=sqledit' method='post'>New database name: <input type='text' value='new_database' name='db_name'><input type='submit' style='border: none;' value='[ Create Database ]' name='dbc'></form></center></br>";
        } elseif (isset($_GET['db']) && !isset($_GET['tbl'])) {
            if (isset($_POST['tblc'])) {
                table_create();
            }
            if (isset($_GET['droptbl'])) {
                SQLDrop();
            }
            echo "<table style='margin: auto; text-align: center;'>\n            <tr><td>Table</td><td>Column count</td><td>Dump</td><td>Drop</td></tr>";
            $tables = mysql_query("SHOW TABLES FROM {$_GET['db']}");
            while ($tblc = mysql_fetch_array($tables)) {
                $fCount = mysql_query("SHOW COLUMNS FROM {$_GET['db']}.{$tblc['0']}");
                $fc = mysql_num_rows($fCount);
                echo "<tr><td><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$tblc['0']}'>{$tblc['0']}</a></td><td>{$fc}</td><td><a href='{$self}?act=download&db={$_GET['db']}&tbl={$tblc['0']}'>Dump</td><td><a href='{$self}?act=sqledit&db={$_GET['db']}&droptbl={$tblc['0']}'>Drop</a></td></tr>";
            }
            echo "</table></br><center><form action='{$self}?act=sqledit&db={$_GET['db']}' method='post'>Create new table: <input type='text' value='new_table' name='table_name'><input type='hidden' value='{$_GET['db']}' name='db_current'> <input type='submit' style='border: none;' value='[ Create Table ]' name='tblc'></form></center>";
        } elseif (isset($_GET['field']) && isset($_POST['sqlsave'])) {
            $discard_values = mysql_query("SELECT * FROM {$_GET['db']}.{$_GET['tbl']} WHERE {$_GET['field']}='{$_GET['v']}'");
            $values = mysql_fetch_assoc($discard_values);
            $keys = array_keys($values);
            $values = array();
            foreach ($_POST as $k => $v) {
                if (in_array($k, $keys)) {
                    $values[] = $v;
                }
            }
            $query = "UPDATE {$_GET['db']}.{$_GET['tbl']} SET ";
            for ($y = 0; $y < count($values); $y++) {
                if ($y == count($values) - 1) {
                    $query .= "{$keys[$y]}='{$values[$y]}' ";
                } else {
                    $query .= "{$keys[$y]}='{$values[$y]}', ";
                }
            }
            $query .= "WHERE {$_GET['field']} = '{$_GET['v']}'";
            $try = mysql_query($query) or die(mysql_error());
            echo "<center>Table updated!<br>";
            echo "<a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}'>Go back</a><br><br>";
        } elseif (isset($_GET['field']) && isset($_GET['v']) && !isset($_GET['del'])) {
            echo "<center><form action='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&field={$_GET['field']}&v={$_GET['v']}' method='post'>";
            $sql_fields = array();
            $fields = mysql_query("SHOW COLUMNS FROM {$_GET['db']}.{$_GET['tbl']}");
            while ($field = mysql_fetch_assoc($fields)) {
                $sql_fields[] = $field['Field'];
            }
            $data = mysql_query("SELECT * FROM {$_GET['db']}.{$_GET['tbl']} WHERE {$_GET['field']}='{$_GET['v']}'");
            $d_piece = mysql_fetch_assoc($data);
            for ($m = 0; $m < count($sql_fields); $m++) {
                $point = $sql_fields[$m];
                echo "{$point}: <input type='text' value='{$d_piece[$point]}' name='{$sql_fields[$m]}'></br>";
            }
            echo "<input type='submit' value='Save' name='sqlsave'></form></center>";
        } elseif (isset($_GET['db']) && isset($_GET['tbl'])) {
            if (isset($_GET['insert'])) {
                SQLInsert();
            }
            if (isset($_GET['field']) && isset($_GET['v']) && isset($_GET['del'])) {
                echo "<center>";
                if (@mysql_query("DELETE FROM {$_GET['db']}.{$_GET['tbl']} WHERE {$_GET['field']}={$_GET['v']}")) {
                    echo "Row deleted</br>";
                } else {
                    echo "Failed to delete row</br>";
                }
                echo "</center>";
            }
            echo "<center><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&insert=1'>[Insert new row]</a></center>";
            echo "<table style='margin: auto; text-align: center;'><tr>";
            $cols = mysql_query("SHOW COLUMNS FROM {$_GET['db']}.{$_GET['tbl']}");
            $fields = array();
            while ($col = mysql_fetch_assoc($cols)) {
                array_push($fields, $col['Field']);
                echo "<td>{$col['Field']}</td>";
            }
            echo "</tr>";
            if (isset($_GET['s']) && is_numeric($_GET['s'])) {
                $selector = mysql_query("SELECT * FROM {$_GET['db']}.{$_GET['tbl']} LIMIT {$_GET['s']}, 250");
            } else {
                $selector = mysql_query("SELECT * FROM {$_GET['db']}.{$_GET['tbl']} LIMIT 0, 250");
            }
            while ($select = mysql_fetch_row($selector)) {
                echo "<tr>";
                for ($i = 0; $i < count($fields); $i++) {
                    echo "<td>" . htmlspecialchars($select[$i]) . "</td>";
                }
                echo "<td><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&field={$fields['0']}&v={$select['0']}'>Edit</a></td><td><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&field={$fields['0']}&v={$select['0']}&del=true'>Delete</a></td>";
                echo "</tr>";
            }
            echo "</table>";
            echo "<table style='margin: auto;'>";
            if (isset($_GET['s'])) {
                $prev = intval($_GET['s']) - 250;
                $next = intval($_GET['s']) + 250;
                if ($_GET['s'] > 0) {
                    echo "<tr><td><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&s={$prev}'>Previous</a></td>";
                }
                if (mysql_num_rows($selector) > 249) {
                    echo "<td><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&s={$next}'>Next</a></td></tr>";
                }
            } else {
                echo "<center><a href='{$self}?act=sqledit&db={$_GET['db']}&tbl={$_GET['tbl']}&s=250'>Next</a></center>";
            }
            echo "</table>";
        } else {
            $_SESSION = array();
            session_destroy();
            header("Location: {$self}?act=sql");
        }
    }
}
Esempio n. 20
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
}