Example #1
0
        foreach ($databases as $db_id => $database) {
            if ($database['path'] == $_GET['switchdb']) {
                $_SESSION[COOKIENAME . "currentDB"] = $database;
                break;
            }
        }
        $currentDB = $_SESSION[COOKIENAME . 'currentDB'];
    }
}
if (isset($_SESSION[COOKIENAME . 'currentDB']) && in_array($_SESSION[COOKIENAME . 'currentDB'], $databases)) {
    $currentDB = $_SESSION[COOKIENAME . 'currentDB'];
}
//- Open database (creates a Database object)
$db = new Database($currentDB);
//create the Database object
$db->registerUserFunction($custom_functions);
// collect parameters early, just once
$target_table = isset($_GET['table']) ? $_GET['table'] : null;
//- Switch on $_GET['action'] for operations without output
if (isset($_GET['action']) && isset($_GET['confirm'])) {
    switch ($_GET['action']) {
        //- Table actions
        //- Create table (=table_create)
        case "table_create":
            $num = intval($_POST['rows']);
            $name = $_POST['tablename'];
            $primary_keys = array();
            for ($i = 0; $i < $num; $i++) {
                if ($_POST[$i . '_field'] != "" && isset($_POST[$i . '_primarykey'])) {
                    $primary_keys[] = $_POST[$i . '_field'];
                }