Ejemplo n.º 1
0
                $cond[] = PMA_bkq($_cols[$vi]) . " IN (" . $sq[$vi] . ")";
            }
            if ($fu == '16') {
                $cond[] = PMA_bkq($_cols[$vi]) . " NOT IN (" . $sq[$vi] . ")";
            }
            if ($fu == '17') {
                $cond[] = PMA_bkq($_cols[$vi]) . " BETWEEN " . str_replace(',', ' AND ', $sq[$vi]);
            }
            if ($fu == '18') {
                $cond[] = PMA_bkq($_cols[$vi]) . " NOT BETWEEN " . str_replace(',', ' AND ', $sq[$vi]);
            }
            if ($fu == '19') {
                $cond[] = PMA_bkq($_cols[$vi]) . " IS NULL ";
            }
            if ($fu == '20') {
                $cond[] = PMA_bkq($_cols[$vi]) . " IS NOT NULL ";
            }
        }
        ++$vi;
    }
    $query = @implode(" AND ", $cond);
    if (trim($query != '')) {
        $_SESSION['search'] = base64_encode($query);
        header("Location: tbl_browse.php?search2=1&{$_url}");
        exit;
    }
}
$pma->title = $lang->Search;
include $pma->tpl . "header.tpl";
include $pma->tpl . "tbl_search.tpl";
include $pma->tpl . "footer.tpl";
Ejemplo n.º 2
0
        if ($_POST['ok']) {
            $_q = "ALTER TABLE " . PMA_bkq($tb_name) . " ADD " . $_POST['todo'] . " (" . implode(',', $qq) . ");";
            if ($db->query($_q) !== TRUE) {
                $_err = $db->error;
            }
        }
    }
} else {
    // get all cols
    $_q = "SHOW FULL COLUMNS FROM " . PMA_bkq($tb_name) . " {$search};";
    if ($data = $db->query($_q)) {
        while ($_d = $data->fetch_object()) {
            if ($_d->Default != '') {
                $_d->Default = "default '" . htmlentities($_d->Default) . "'";
            }
            $_d->Null = $_d->Null == "NO" ? "not null" : "null";
            $col_data[] = $_d;
        }
    }
    // get all indexes
    $_q2 = "SHOW INDEXES FROM " . PMA_bkq($tb_name);
    if ($data = $db->query($_q2)) {
        while ($_d = $data->fetch_object()) {
            $ind_data[] = $_d;
        }
    }
}
$pma->title = $lang->Table;
include $pma->tpl . "header.tpl";
include $pma->tpl . "table.tpl";
include $pma->tpl . "footer.tpl";
Ejemplo n.º 3
0
 /**
  * Writes the selected database to file 
  */
 function doDump($doDB = false, $i = 1)
 {
     global $db, $pma;
     if (!$this->setDatabase($this->database)) {
         return false;
     }
     if ($this->utf8) {
         $encoding = $db->query("SET NAMES 'utf8'");
     }
     if ($i < 2) {
         $cur_time = date("Y-m-d H:i");
         $server_info = $db->get_server_info();
         $this->saveToFile($this->file, "-- Wap PhpMyAdmin {$pma->version}\n");
         $this->saveToFile($this->file, "-- http://master-land.net/phpmyadmin \n");
         $this->saveToFile($this->file, "-- Generation Time: {$cur_time}\n");
         $this->saveToFile($this->file, "-- MySQL Server Version: {$server_info}\n");
         $this->saveToFile($this->file, "-- PHP Version: " . phpversion() . "\n\n");
     }
     if ($doDB) {
         $this->saveToFile($this->file, "-- --------------------------------------------------------\n--\n-- Database: " . PMA_bkq($this->database) . "\n-- \n");
         $create_query = "CREATE DATABASE " . PMA_bkq($this->database);
         $collation = $db->query('SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'' . $db->real_escape_string($this->database) . '\' LIMIT 1')->fetch_row();
         $collation = $collation[0];
         if (strpos($collation, '_')) {
             $create_query .= ' DEFAULT CHARACTER SET ' . substr($collation, 0, strpos($collation, '_')) . ' COLLATE ' . $collation;
         } else {
             $create_query .= ' DEFAULT CHARACTER SET ' . $collation;
         }
         $create_query .= ";\nUSE " . PMA_bkq($this->database) . ";\n\n";
         $this->saveToFile($this->file, $create_query);
     } else {
         $this->saveToFile($this->file, "-- Database: " . PMA_bkq($this->database) . "\n\n");
     }
     if ($this->phpMyAdmin) {
         $this->getDatabaseStructureData($this->hexValue);
     } else {
         if ($this->createTable) {
             $this->getDatabaseStructure();
         }
         if ($this->tableData) {
             $this->getDatabaseData($this->hexValue);
         }
     }
     if ($this->outputTofile) {
         $this->closeFile($this->file);
         return true;
     } else {
         return $this->filestream;
     }
 }
Ejemplo n.º 4
0
    } else {
        $_err = 1;
        $_msg = $lang->Empty;
    }
} elseif ($_GET['act'] == 'dropdb') {
    $db_nm = $_POST['i'];
    if (!$db_nm) {
        header("Location: ?");
    }
    foreach ($db_nm as $db_name) {
        if ($db_name != '') {
            if (!$_POST['ok']) {
                $_msg[0] .= "<i>" . htmlentities($db_name) . "</i><br/> ";
                $_msg[1] .= "<input type='hidden' name='i[]' value='" . htmlentities($db_name) . "'>\n";
            } else {
                if ($result = $db->query("DROP DATABASE IF EXISTS " . PMA_bkq($db_name))) {
                    $_msg .= htmlentities($db_name) . ", ";
                } else {
                    $_err = 1;
                    $_msg = $db->error;
                }
            }
        }
    }
} else {
    // get all dbs
    $_q = "SHOW DATABASES {$search};";
    if ($data = $db->query($_q)) {
        while ($_d = $data->fetch_array()) {
            $db_data[] = $_d;
        }
Ejemplo n.º 5
0
                    }
                }
                if ($_POST['do'] == 'optimize') {
                    if ($result = $db->query("OPTIMIZE TABLE " . PMA_bkq($tb_name))) {
                        $result = $result->fetch_object();
                        $_msg[$tb_name] = array($result->Msg_type, $result->Msg_text);
                    }
                }
                if ($_POST['do'] == 'repair') {
                    if ($result = $db->query("REPAIR TABLE " . PMA_bkq($tb_name))) {
                        $result = $result->fetch_object();
                        $_msg[$tb_name] = array($result->Msg_type, $result->Msg_text);
                    }
                }
                if ($_POST['do'] == 'analyze') {
                    if ($result = $db->query("ANALYZE TABLE " . PMA_bkq($tb_name))) {
                        $result = $result->fetch_object();
                        $_msg[$tb_name] = array($result->Msg_type, $result->Msg_text);
                    }
                }
            }
        }
    }
    // for export function
    if ($_SESSION['selected']) {
        header("Location: export.php?" . $_SERVER['QUERY_STRING']);
        exit;
    }
} else {
    // get all tbs
    $_q = "SHOW TABLE STATUS {$search};";
Ejemplo n.º 6
0
                $arr['type'] = substr($arr['type'], 0, $tmp - 1);
            }
            if ($arr['type'] == 'date' and $c['Default'] == '') {
                $c['Default'] = date("Y-m-d", time());
            }
            if ($arr['type'] == 'datetime' and $c['Default'] == '') {
                $c['Default'] = date("Y-m-d H:i:s", time());
            }
            $col[$c['Field']] = array_merge($arr, array('Default' => $c['Default']));
        }
    }
} else {
    $dat = $_POST['i'];
    $i = 0;
    while ($c = $cl->fetch_object()) {
        if (isSqlFunction($dat[$i])) {
            $tq[] = PMA_bkq($c->Field) . " = " . $dat[$i];
        } else {
            $tq[] = PMA_bkq($c->Field) . " = '" . $db->real_escape_string($dat[$i]) . "'";
        }
        ++$i;
    }
    $_q = "INSERT INTO " . PMA_bkq($tb_name) . " SET " . implode(',', $tq);
    if ($db->query($_q) !== TRUE) {
        $_err = $db->error;
    }
}
$pma->title = $lang->Insert;
include $pma->tpl . "header.tpl";
include $pma->tpl . "tbl_insert.tpl";
include $pma->tpl . "footer.tpl";
Ejemplo n.º 7
0
        $_url .= "&search={$search}";
        $search = "WHERE " . PMA_bkq($column) . " LIKE '%{$search}%'";
    }
    // total number of records and some pagination thingish
    $_q = "SELECT * FROM " . PMA_bkq($tb_name) . " {$search}";
    $data = $db->query($_q);
    $total_num_rows = $data->num_rows;
    $page = (int) $_GET['page'] == 0 ? 1 : (int) $_GET['page'];
    $perP = (int) $_SESSION['perp'] == 0 ? "10" : (int) $_SESSION['perp'];
    $sort = (int) $_SESSION['sort'] == 0 ? "ASC" : "DESC";
    $total_pages = ceil($total_num_rows / $perP);
    if ($page > $total_pages) {
        $page = $total_pages;
    }
    $start = $page * $perP - $perP;
    // just the ones we need on this page
    $_q = "SELECT * FROM " . PMA_bkq($tb_name) . " {$search} ORDER BY " . PMA_bkq($column) . " " . $sort . " LIMIT {$start},{$perP}";
    if ($data = $db->query($_q)) {
        while ($_d = $data->fetch_array()) {
            $tb_data[] = $_d;
            // let's see what makes the record unique
            $_unq[] = getUniqueCondition($data, $_d);
        }
    }
    if ($data->num_rows > 0) {
    }
}
$pma->title = $lang->Browse;
include $pma->tpl . "header.tpl";
include $pma->tpl . "tbl_browse.tpl";
include $pma->tpl . "footer.tpl";
Ejemplo n.º 8
0
     } elseif ($_POST['pos'] == 2) {
         $pos = "AFTER " . PMA_bkq($_POST['pos2']);
     }
     if (trim($_POST['comments']) != '') {
         $comments = "COMMENT  '" . $db->real_escape_string($_POST['comments']) . "'";
     }
     $_q = "ALTER TABLE " . PMA_bkq($tb_name) . " CHANGE " . PMA_bkq($col_name) . " " . PMA_bkq($_POST['name']) . " " . $_POST['type'] . "{$length} " . trim($_POST['attribute']) . " {$collation} {$null} {$default} {$auto} {$comments} {$pos}";
     if ($result = $db->query($_q)) {
         $_msg = htmlentities($_POST['name']);
     } else {
         $_err = 1;
         $_msg = $db->error;
     }
 } else {
     $col_data = $check_cl->fetch_array();
     $_q = "SHOW FULL COLUMNS FROM " . PMA_bkq($tb_name);
     if ($data = $db->query($_q)) {
         while ($_d = $data->fetch_object()) {
             $_cols[] = $_d->Field;
         }
     }
     //ok here we go :)
     //grab the type and lenght
     $extracted_fieldspec = PMA_extractFieldSpec($col_data['Type']);
     $type = $extracted_fieldspec['type'];
     if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
         $length = $extracted_fieldspec['spec_in_brackets'];
     } else {
         // strip the "BINARY" attribute, except if we find "BINARY(" because
         // this would be a BINARY or VARBINARY field type
         $type = preg_replace('@BINARY([^\\(])@i', '', $type);
Ejemplo n.º 9
0
function getUniqueCondition($result, $row)
{
    global $db;
    $fields = $result->fetch_fields();
    foreach ($fields as $k => $field) {
        if (defined('MYSQLI_PRI_KEY_FLAG') && defined('MYSQLI_UNIQUE_KEY_FLAG')) {
            $_primary_key = (int) (bool) ($field->flags & MYSQLI_PRI_KEY_FLAG);
            $_unique_key = (int) (bool) ($field->flags & MYSQLI_UNIQUE_KEY_FLAG);
        } else {
            $_primary_key = (int) (bool) $field->primary_key;
            $_unique_key = (int) (bool) $field->unique_key;
        }
        $c[] = "(" . PMA_bkq($field->name) . " = '" . $db->real_escape_string($row[$field->name]) . "')";
        if ($_primary_key) {
            $primary[] = "(" . PMA_bkq($field->name) . " = '" . $db->real_escape_string($row[$field->name]) . "')";
        } elseif ($_unique_key) {
            $unique[] = "(" . PMA_bkq($field->name) . " = '" . $db->real_escape_string($row[$field->name]) . "')";
        }
    }
    if ($primary) {
        $result = implode(" AND ", $primary);
    } elseif ($unique) {
        $result = implode(" AND ", $unique);
    } else {
        $result = implode(" AND ", $c);
    }
    return $result;
}