function drop_procedure($name)
{
    global $dbhandle, $ib_error, $s_procedures;
    $lsql = 'DROP PROCEDURE ' . $name;
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
    } else {
        unset($s_procedures[$name]);
    }
}
function drop_trigger($name)
{
    global $s_triggers, $dbhandle, $ib_error;
    global $lsql;
    $lsql = 'DROP TRIGGER ' . $name;
    if (DEBUG) {
        add_debug('lsql', __FILE__, __LINE__);
    }
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
    } else {
        unset($s_triggers[$name]);
    }
}
function drop_view($name)
{
    global $dbhandle, $s_tables;
    global $ib_error, $lsql;
    $lsql = 'DROP VIEW ' . $name;
    if (DEBUG) {
        add_debug('lsql', __FILE__, __LINE__);
    }
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
        return FALSE;
    } else {
        unset($s_tables[$name]);
        return TRUE;
    }
}
function revoke_role_from_user($role, $user)
{
    global $dbhandle, $roles;
    global $ib_error, $lsql;
    $user = strtoupper($user);
    $lsql = 'REVOKE ' . $role . ' FROM ' . $user;
    if (DEBUG) {
        add_debug('lsql', __FILE__, __LINE__);
    }
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
    }
    if (empty($ib_error) && ($idx = array_search($user, $roles[$role]['members'])) !== FALSE) {
        unset($roles[$role]['members'][$idx]);
        return TRUE;
    } else {
        return FALSE;
    }
}
function drop_user($uname, $s_sysdba_pw)
{
    global $s_login, $ib_error;
    if (($service = fbird_service_attach($s_login['host'], 'SYSDBA', $s_sysdba_pw)) == FALSE) {
        $ib_error = fbird_errmsg();
    } elseif (fbird_delete_user($service, $uname) == FALSE) {
        $ib_error = fbird_errmsg();
    } else {
        fbird_service_detach($service);
    }
    return empty($ib_error);
}
 function _handleerror()
 {
     $this->_errorMsg = fbird_errmsg();
 }
function drop_generator($name)
{
    global $generators, $dbhandle, $ib_error;
    $lsql = 'DELETE FROM RDB$GENERATORS WHERE RDB$GENERATOR_NAME=\'' . fb_escape_string($name) . "'";
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
    } else {
        // remove the dropped generator from the array
        $idx = get_generator_idx($name);
        array_splice($generators, $idx, 1);
    }
}
function drop_udf($name)
{
    global $s_udfs, $dbhandle;
    global $ib_error, $lsql;
    $lsql = 'DROP EXTERNAL FUNCTION ' . $name;
    if (DEBUG) {
        add_debug('lsql', __FILE__, __LINE__);
    }
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
        return FALSE;
    } else {
        unset($s_udfs[$name]);
        return TRUE;
    }
}
function ib_error($file = '', $line = '', $sql = '')
{
    echo '<pre><b>Firebird Error</b><br>' . 'file: ' . $file . ', line: ' . $line . '<br>' . 'statement: ' . $sql . '<br>' . 'fbird_errmsg: ' . fbird_errmsg() . '</pre>';
    exit;
}
function drop_index($name)
{
    global $indices, $dbhandle, $ib_error, $lsql;
    $lsql = 'DROP INDEX ' . $name;
    if (DEBUG) {
        add_debug('lsql', __FILE__, __LINE__);
    }
    if (!@fbird_query($dbhandle, $lsql)) {
        $ib_error = fbird_errmsg();
        return TRUE;
    } else {
        unset($indices[$name]);
        return TRUE;
    }
}
    $where = get_request_data('del', 'GET');
    $quote = identifier_quote($s_login['dialect']);
    $sql = 'DELETE FROM ' . $quote . $s_wt['table'] . $quote . ' ' . $where;
    if ($s_cust['askdel'] == TRUE) {
        $s_delete_idx = $s_delete_idx > 0 ? get_max_key($s_confirmations['row']) + 1 : 1;
        $target_panels = get_panel_array($s_referer);
        $pname = 'dt_delete' . $s_delete_idx;
        $ptitle = 'Delete';
        $ptitle .= $s_delete_idx > 1 ? " ({$s_delete_idx}) " : ' ';
        $ptitle .= 'from table ' . $s_wt['table'];
        ${$target_panels}[] = array($pname, $ptitle, 'open');
        $pos = get_panel_index(${$target_panels}, $pname);
        ${$target_panels} = array_moveto_top(${$target_panels}, $pos);
        $s_confirmations['row'][$s_delete_idx] = array('msg' => sprintf($MESSAGES['CONFIRM_ROW_DELETE'], $s_wt['table'], $where), 'sql' => $sql);
    } else {
        fbird_query($dbhandle, $sql) or $ib_error = fbird_errmsg();
        // cleanup the watchtable output buffer
        $s_watch_buffer = '';
    }
}
// cleanup the watchtable output buffer
if (isset($_GET['go']) || isset($_GET['order'])) {
    $s_watch_buffer = '';
    $s_cust['wt'][$s_login['database']] = array('table' => $s_wt['table'], 'start' => $s_wt['start'], 'order' => $s_wt['order'], 'dir' => $s_wt['direction']);
    set_customize_cookie($s_cust);
}
globalize_session_vars();
if (!empty($dbhandle)) {
    fbird_close($dbhandle);
}
header('Location: ' . url_session($s_referer));
function print_rows_sp($wt)
{
    global $dbhandle, $ib_error;
    $types = get_column_types($wt['table'], $wt['columns']);
    $col_count = count($wt['columns']);
    $class = 'wttr2';
    $sql = 'SELECT * FROM ' . SP_LIMIT_NAME;
    $res = fbird_query($dbhandle, $sql) or $ib_error = fbird_errmsg();
    while ($row = fbird_fetch_row($res)) {
        unset($obj);
        foreach ($wt['columns'] as $idx => $colname) {
            $obj[$colname] = isset($row[$idx]) ? $row[$idx] : '';
        }
        settype($obj, 'object');
        $class = $class == 'wttr1' ? 'wttr2' : 'wttr1';
        echo '<tr class="wttr ' . $class . '">';
        for ($k = 0; $k < $col_count; $k++) {
            if (!isset($row[$k])) {
                print_value($wt, NULL, NULL);
            } else {
                print_value($wt, $row[$k], $types[$wt['columns'][$k]], $wt['columns'][$k], $obj);
            }
        }
        // get parameter for the edit and/or del link
        if ($wt['edit'] == TRUE || $wt['delete'] == TRUE) {
            build_editdel_links($obj, $wt['edit'], $wt['delete']);
            echo "</tr>\n";
        }
    }
    fbird_free_result($res);
}
function modify_domain($olddef, $domdef)
{
    global $dbhandle, $ib_error;
    $lsql = array();
    if ($domdef['name'] != $olddef['name']) {
        $lsql[] = 'ALTER DOMAIN ' . $olddef['name'] . ' TO ' . $domdef['name'];
    }
    if (datatype_is_modified($olddef, $domdef)) {
        $lsql[] = 'ALTER DOMAIN ' . $domdef['name'] . ' TYPE ' . build_datatype($domdef);
    }
    if (isset($olddef['default']) && $olddef['default'] != '' && $domdef['default'] == '') {
        $lsql[] = 'ALTER DOMAIN ' . $domdef['name'] . ' DROP DEFAULT';
    }
    if (isset($olddef['default']) && $domdef['default'] != '' && $olddef['default'] != $domdef['default']) {
        $lsql[] = 'ALTER DOMAIN ' . $domdef['name'] . ' SET DEFAULT ' . $domdef['default'];
    }
    if (isset($olddef['check']) && !empty($olddef['check']) && (empty($domdef['check']) || $olddef['check'] != $domdef['check'])) {
        $lsql[] = 'ALTER DOMAIN ' . $domdef['name'] . ' DROP CONSTRAINT';
    }
    if (isset($olddef['check']) && $olddef['check'] != $domdef['check']) {
        $lsql[] = 'ALTER DOMAIN ' . $domdef['name'] . ' ADD CHECK ' . $domdef['check'];
    }
    foreach ($lsql as $sql) {
        if (DEBUG) {
            add_debug($sql, __FILE__, __LINE__);
        }
        if (!@fbird_query($dbhandle, $sql)) {
            $ib_error = fbird_errmsg() . "<br>\n>";
            return FALSE;
        }
    }
    return TRUE;
}
function get_tables()
{
    global $dbhandle, $ib_error, $s_tables, $s_fields, $s_foreigns, $s_primaries, $s_uniques, $s_login;
    global $s_charsets, $s_tables_counts, $s_views_counts, $s_tables_def, $s_tables_comp;
    $previous = $s_tables;
    $s_tables = array();
    $s_fields = array();
    // get the tablenames, owner and view flag
    $sql = 'SELECT RDB$RELATION_NAME AS RNAME,' . ' RDB$VIEW_BLR AS VBLR,' . ' RDB$OWNER_NAME AS OWNER' . ' FROM RDB$RELATIONS' . ' WHERE RDB$SYSTEM_FLAG=0' . ' ORDER BY RDB$RELATION_NAME';
    $res = @fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    if (!is_resource($res)) {
        return FALSE;
    }
    // initialize $s_tables[]
    while ($row = fbird_fetch_object($res)) {
        $tablename = trim($row->RNAME);
        $s_tables[$tablename]['status'] = isset($previous[$tablename]) ? $previous[$tablename]['status'] : 'close';
        $s_tables[$tablename]['is_view'] = isset($row->VBLR) && $row->VBLR !== NULL ? TRUE : FALSE;
        $s_tables[$tablename]['owner'] = trim($row->OWNER);
        $s_tables[$tablename]['privileges'] = array();
    }
    fbird_free_result($res);
    unset($previous);
    // get privileges on tables for the current user and for the role used at login
    $sql = 'SELECT R.RDB$RELATION_NAME AS RNAME,' . ' P1.RDB$PRIVILEGE AS PRIV' . ' FROM RDB$RELATIONS R' . ' INNER JOIN RDB$USER_PRIVILEGES P1' . ' ON R.RDB$RELATION_NAME=P1.RDB$RELATION_NAME' . ' WHERE R.RDB$SYSTEM_FLAG=0' . " AND (P1.RDB\$USER='******'user'] . "' OR P1.RDB\$USER='******')";
    if (!empty($s_login['role'])) {
        $sql .= ' UNION' . ' SELECT R.RDB$RELATION_NAME AS RNAME,' . ' P2.RDB$PRIVILEGE AS PRIV' . ' FROM RDB$USER_PRIVILEGES P1' . ' INNER JOIN RDB$USER_PRIVILEGES P2 ON P1.RDB$RELATION_NAME=P2.RDB$USER' . ' INNER JOIN RDB$RELATIONS R ON R.RDB$RELATION_NAME=P2.RDB$RELATION_NAME' . " WHERE P1.RDB\$PRIVILEGE='M'" . ' AND R.RDB$SYSTEM_FLAG=0' . " AND P1.RDB\$RELATION_NAME='" . $s_login['role'] . "'" . " AND (P1.RDB\$USER='******'user'] . "' OR P1.RDB\$USER='******')";
    }
    $res = @fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    while ($row = fbird_fetch_object($res)) {
        $s_tables[trim($row->RNAME)]['privileges'][] = trim($row->PRIV);
    }
    fbird_free_result($res);
    // find the check, not null, unique, pk and fk and  constraints
    $sql = 'SELECT RC.RDB$RELATION_NAME TNAME,' . ' RC.RDB$CONSTRAINT_TYPE RTYPE,' . ' RC.RDB$CONSTRAINT_NAME CNAME,' . ' RC.RDB$INDEX_NAME INAME,' . ' CC.RDB$TRIGGER_NAME TRIGNAME,' . ' SE.RDB$FIELD_NAME SENAME,' . ' SE.RDB$FIELD_POSITION POS,' . ' DP.RDB$FIELD_NAME DPNAME' . ' FROM RDB$RELATION_CONSTRAINTS RC' . ' LEFT JOIN RDB$CHECK_CONSTRAINTS CC' . ' ON RC.RDB$CONSTRAINT_NAME=CC.RDB$CONSTRAINT_NAME' . " AND RC.RDB\$CONSTRAINT_TYPE='CHECK'" . ' LEFT JOIN RDB$INDEX_SEGMENTS SE' . ' ON RC.RDB$INDEX_NAME=SE.RDB$INDEX_NAME' . ' LEFT JOIN RDB$DEPENDENCIES DP' . ' ON CC.RDB$TRIGGER_NAME=DP.RDB$DEPENDENT_NAME' . ' ORDER BY RC.RDB$RELATION_NAME';
    $res = @fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    // reset the index infos
    $s_foreigns = array();
    $s_primaries = array();
    $s_uniques = array();
    $constraints = array();
    while ($row = fbird_fetch_object($res)) {
        $cname = trim($row->CNAME);
        switch (trim($row->RTYPE)) {
            case 'CHECK':
                $constraints[trim($row->TNAME)][trim($row->DPNAME)]['check'] = $cname;
                break;
            case 'UNIQUE':
                $constraints[trim($row->TNAME)][trim($row->SENAME)]['unique'] = $cname;
                $s_uniques[$cname]['index'] = trim($row->INAME);
                $s_uniques[$cname]['cols'] = isset($s_uniques[$cname]['cols']) ? $s_uniques[$cname]['cols']++ : 1;
                break;
            case 'FOREIGN KEY':
                $constraints[trim($row->TNAME)][trim($row->SENAME)]['foreign'] = $cname;
                $s_foreigns[$cname]['index'] = trim($row->INAME);
                $s_foreigns[$cname]['cols'] = isset($s_foreigns[$cname]['cols']) ? $s_foreigns[$cname]['cols']++ : 1;
                break;
            case 'PRIMARY KEY':
                $constraints[trim($row->TNAME)][trim($row->SENAME)]['primary'] = $cname;
                $s_primaries[$cname]['index'] = trim($row->INAME);
                $s_primaries[$cname]['cols'] = isset($s_primaries[$cname]['cols']) ? $s_primaries[$cname]['cols']++ : 1;
                break;
        }
    }
    fbird_free_result($res);
    //     debug_var($sql);
    //     debug_var($constraints);
    //     debug_var($s_foreigns);
    //     debug_var($s_primaries);
    // find the field properties for all non-system tables
    $sql = 'SELECT DISTINCT R.RDB$FIELD_NAME AS FNAME,' . ' R.RDB$NULL_FLAG AS NFLAG,' . ' R.RDB$DEFAULT_SOURCE AS DSOURCE,' . ' R.RDB$FIELD_POSITION,' . ' R.RDB$RELATION_NAME AS TNAME,' . ' R.RDB$COLLATION_ID AS COLLID,' . ' F.RDB$FIELD_NAME AS DNAME,' . ' F.RDB$FIELD_TYPE AS FTYPE,' . ' F.RDB$FIELD_SUB_TYPE AS STYPE,' . ' F.RDB$FIELD_LENGTH AS FLEN,' . ' F.RDB$COMPUTED_SOURCE AS CSOURCE,' . ' F.RDB$FIELD_PRECISION AS FPREC,' . ' F.RDB$FIELD_SCALE AS FSCALE,' . ' F.RDB$SEGMENT_LENGTH AS SEGLEN,' . ' F.RDB$CHARACTER_SET_ID AS CHARID,' . ' D.RDB$LOWER_BOUND AS LBOUND,' . ' D.RDB$UPPER_BOUND AS UBOUND' . ' FROM RDB$RELATION_FIELDS R ' . ' JOIN RDB$FIELDS F ON R.RDB$FIELD_SOURCE=F.RDB$FIELD_NAME' . ' LEFT JOIN RDB$FIELD_DIMENSIONS D ON R.RDB$FIELD_SOURCE=D.RDB$FIELD_NAME' . ' WHERE F.RDB$SYSTEM_FLAG=0' . ' ORDER BY R.RDB$FIELD_POSITION';
    $res = @fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    //initialize $s_fields[]
    $idx = 0;
    while ($row = fbird_fetch_object($res)) {
        $tname = trim($row->TNAME);
        $field = $s_fields[$tname][$idx]['name'] = trim($row->FNAME);
        if (strpos($row->DNAME, 'RDB$') !== 0) {
            $s_fields[$tname][$idx]['domain'] = 'Yes';
            $s_fields[$tname][$idx]['type'] = trim($row->DNAME);
        } else {
            $s_fields[$tname][$idx]['stype'] = isset($row->STYPE) ? $row->STYPE : NULL;
            $s_fields[$tname][$idx]['type'] = get_datatype($row->FTYPE, $s_fields[$tname][$idx]['stype']);
        }
        if ($s_fields[$tname][$idx]['type'] == 'VARCHAR' || $s_fields[$tname][$idx]['type'] == 'CHARACTER') {
            $s_fields[$tname][$idx]['size'] = $row->FLEN;
        }
        // field is defined as NOT NULL
        if (!empty($row->NFLAG)) {
            $s_fields[$tname][$idx]['notnull'] = 'Yes';
        }
        // this field is computed
        if (isset($row->CSOURCE)) {
            $s_fields[$tname][$idx]['comp'] = 'Yes';
            $s_fields[$tname][$idx]['csource'] = FALSE;
        }
        // this field has a default value
        if (isset($row->DSOURCE)) {
            $s_fields[$tname][$idx]['default'] = 'Yes';
            $s_fields[$tname][$idx]['dsource'] = FALSE;
        }
        if ($s_fields[$tname][$idx]['type'] == 'DECIMAL' or $s_fields[$tname][$idx]['type'] == 'NUMERIC') {
            $s_fields[$tname][$idx]['prec'] = $row->FPREC;
            $s_fields[$tname][$idx]['scale'] = -$row->FSCALE;
        }
        if ($s_fields[$tname][$idx]['type'] == 'BLOB') {
            $s_fields[$tname][$idx]['segsize'] = $row->SEGLEN;
        }
        $s_fields[$tname][$idx]['charset'] = isset($row->CHARID) ? $s_charsets[$row->CHARID]['name'] : NULL;
        $s_fields[$tname][$idx]['collate'] = isset($row->COLLID) && $row->COLLID != 0 && isset($s_charsets[$row->CHARID]['collations'][$row->COLLID]) ? $s_charsets[$row->CHARID]['collations'][$row->COLLID] : NULL;
        // optional array dimensions
        if (isset($row->LBOUND)) {
            $s_fields[$tname][$idx]['lower_bound'] = $row->LBOUND;
            $s_fields[$tname][$idx]['upper_bound'] = $row->UBOUND;
        }
        // column constraints
        foreach (array('check', 'unique', 'foreign', 'primary') as $ctype) {
            if (isset($constraints[$tname][$field][$ctype])) {
                $s_fields[$tname][$idx][$ctype] = $constraints[$tname][$field][$ctype];
            }
        }
        $idx++;
    }
    //     debug_var($s_fields);
    $quote = identifier_quote($s_login['dialect']);
    foreach ($s_tables as $name => $properties) {
        if ($s_tables_def == TRUE) {
            $s_fields = get_table_defaults_sources($name, $s_fields);
        }
        if ($s_tables_comp == TRUE) {
            $s_fields = get_table_computed_sources($name, $s_fields);
        }
        if (!in_array('S', $properties['privileges'])) {
            continue;
        }
        if ($properties['is_view'] == FALSE && $s_tables_counts == TRUE || $properties['is_view'] == TRUE && $s_views_counts == TRUE) {
            $sql = 'SELECT COUNT(*) AS CNT FROM ' . $quote . $name . $quote;
            $res = fbird_query($dbhandle, $sql) or $ib_error .= fbird_errmsg() . "<br>\n";
            if (is_resource($res)) {
                $row = fbird_fetch_object($res);
                $s_tables[$name]['count'] = $row->CNT;
                fbird_free_result($res);
            }
        }
    }
    return TRUE;
}
Exemple #15
0
 // execute command/script by isql
 if (isset($isql_flag) && empty($error)) {
     list($binary_output, $binary_error) = isql_execute($sql_script);
     $s_sql['buffer'] = '';
     array_shift($binary_output);
     // discard the first line
     foreach ($binary_output as $line) {
         $s_sql['buffer'] .= nl2br(str_replace(' ', '&nbsp;', $line)) . "<br>\n";
     }
 } elseif ($s_connected == TRUE && empty($error)) {
     $s_sql['more'] = FALSE;
     $results = array();
     foreach ($lines as $lnr => $cmd) {
         $cnt = 0;
         $trans = fbird_trans(TRANS_WRITE, $dbhandle);
         $res = @fbird_query($trans, $cmd) or $ib_error = fbird_errmsg();
         // if sql_output-panel is open
         $idx = get_panel_index($s_sql_panels, 'sql_output');
         if ($s_sql_panels[$idx][2] == 'open') {
             // if the query have result rows
             if (is_resource($res) && @fbird_num_fields($res) > 0) {
                 $fieldinfo[$lnr] = get_field_info($res);
                 // save the rows for the output in the sql_output panel
                 while ($row = fbird_fetch_object($res)) {
                     $results[$lnr][] = get_object_vars($row);
                     $cnt++;
                     if ($cnt >= SHOW_OUTPUT_ROWS && !isset($_POST['sql_display_all'])) {
                         $s_sql['more'] = TRUE;
                         break;
                     }
                 }
        } else {
            $options |= IBASE_RES_CREATE;
        }
        if (empty($error)) {
            $source_file = defined('BACKUP_DIR') && BACKUP_DIR !== '' ? BACKUP_DIR . $s_restore['source'] : $s_restore['source'];
            if ($s_restore['verbose']) {
                // remove pending backup-jobs from session
                $s_iframejobs = array_filter($s_iframejobs, create_function('$a', '$a["job"]!="restore";'));
                $iframekey_restore = md5(uniqid('restore'));
                $s_iframejobs[$iframekey_restore] = array('job' => 'restore', 'source' => $source_file, 'target' => $s_restore['target'], 'options' => $options, 'connect' => $s_restore['connect'], 'timestamp' => time());
            } elseif (($service = fbird_service_attach($s_login['host'], $s_login['user'], $s_login['password'])) != FALSE) {
                fbird_restore($service, $source_file, $s_restore['target'], $options, $s_restore['verbose']);
                $message = 'restore started';
                fbird_service_detach($service);
            } else {
                $ib_error = fbird_errmsg();
            }
        }
    }
}
// print out all the panels
//
$s_page = 'Admin';
$panels = $s_admin_panels;
require './inc/script_end.inc.php';
function get_backup_filename($pname)
{
    return defined('BACKUP_DIR') && BACKUP_DIR !== '' ? BACKUP_DIR . basename($pname) : $pname;
}
//
// return the options for the database statistics selectlist
function export_data($export)
{
    global $s_fields, $warning;
    ini_set('ibase.dateformat', $export['general']['date']);
    ini_set('ibase.timeformat', $export['general']['time']);
    ini_set('ibase.timestampformat', $export['general']['date'] . ' ' . $export['general']['time']);
    if ($export['format'] == 'sql' && $export['sql']['info']) {
        echo sql_export_info($export, replace_escape_sequences($export['sql']['lineend']));
    }
    foreach (export_queries($export) as $query) {
        if (DEBUG) {
            add_debug($query, __FILE__, __LINE__);
        }
        $trans = fbird_trans(TRANS_READ, $dbhandle);
        $res = @fbird_query($trans, $query);
        if ($res === FALSE) {
            $ib_error = fbird_errmsg();
            $warning = '';
            return FALSE;
        }
        $columns = $col_types = $num_fields = array();
        $num = fbird_num_fields($res);
        for ($idx = 0; $idx < $num; $idx++) {
            $info = fbird_field_info($res, $idx);
            $columns[] = $info['name'];
            $col_types[] = $info['type'];
            $num_fields[] = is_number_type(substr($info['type'], 0, strcspn($info['type'], '(')));
        }
        $tablename = $info['relation'];
        $export['query'] = array('source' => $query, 'columns' => $columns, 'col_types' => $col_types, 'num_fields' => $num_fields, 'result' => $res);
        switch ($export['format']) {
            case 'csv':
                export_csv_data($export);
                break;
            case 'sql':
                export_sql_data($export, $tablename);
                break;
            case 'ext':
                printf('Export data to %s is still not implemented!', $export['format']);
                break;
            default:
                echo 'Unsupported export format!';
        }
        fbird_free_result($res);
        fbird_commit($trans);
    }
}
function drop_database($db, $login)
{
    $success = '';
    // make a connection to the selected database
    // or use the global dbhandle if it is the one firebirdwebadmin is currently connected to
    if ($db['database'] == $login['database'] && $db['host'] == $login['host']) {
        $dbh = $GLOBALS['dbhandle'];
    } else {
        $db_path = $db['host'] == '' ? $db['database'] : $db['host'] . ':' . $db['database'];
        if (($dbh = fbird_connect($db_path, $db['user'], $db['password'])) == FALSE) {
            $success = fbird_errmsg();
        }
    }
    // drop it if we got a handle
    if (is_resource($dbh) && fbird_drop_db($dbh) == FALSE) {
        $success = fbird_errmsg();
        fbird_close($dbh);
    }
    return $success;
}