binary field upload
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2003-02-01 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* tbl_change.php3, tbl_replace.php3, (new)tbl_replace_fields.php3,
|
||||
db_details.php3, tbl_query_box.php3, libraries/common.lib.php3:
|
||||
new Feature: BLOB field upload
|
||||
|
||||
2003-01-31 Alexander M. Turek <rabus@users.sourceforge.net>
|
||||
* config.inc.php3, Documentation.html, libraries/common.lib.php3,
|
||||
libraries/config_import.lib.php3: Added experimental support for
|
||||
|
@@ -43,10 +43,7 @@ if ($num_tables == 0 && empty($db_query_force)) {
|
||||
}
|
||||
|
||||
// loic1: defines wether file upload is available or not
|
||||
$is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
|
||||
? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
|
||||
// loic1: php 3.0.15 and lower bug -> always enabled
|
||||
: (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
|
||||
// (now defined in common.lib.php3)
|
||||
|
||||
$auto_sel = ($cfg['TextareaAutoSelect'])
|
||||
? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
|
||||
|
@@ -153,6 +153,14 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
*/
|
||||
include('./libraries/defines_php.lib.php3');
|
||||
|
||||
/**
|
||||
* Define $is_upload
|
||||
*/
|
||||
$is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
|
||||
? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
|
||||
// loic1: php 3.0.15 and lower bug -> always enabled
|
||||
: (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
|
||||
|
||||
/**
|
||||
* Charset conversion.
|
||||
*/
|
||||
|
@@ -148,7 +148,7 @@ document.onkeydown = onKeyDownArrowsHandler;
|
||||
</script>
|
||||
|
||||
<!-- Change table properties form -->
|
||||
<form method="post" action="tbl_replace.php3" name="insertForm">
|
||||
<form method="post" action="tbl_replace.php3" name="insertForm" enctype="multipart/form-data">
|
||||
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
|
||||
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
|
||||
<input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
|
||||
@@ -524,6 +524,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
?>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php echo $strBinaryDoNotEdit . "\n"; ?>
|
||||
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$protected$" />
|
||||
</td>
|
||||
<?php
|
||||
} else if ($is_blob) {
|
||||
@@ -535,6 +536,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
|
||||
</td>
|
||||
<?php
|
||||
|
||||
} else {
|
||||
if ($len < 4) {
|
||||
$fieldsize = $maxlength = 4;
|
||||
@@ -550,7 +552,16 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
</td>
|
||||
<?php
|
||||
} // end if...elseif...else
|
||||
} // end else if
|
||||
|
||||
// Upload choice
|
||||
// (displayed whatever value the ProtectBinary has)
|
||||
// TODO: check if uploads are allowed by PHP
|
||||
|
||||
if ($is_upload) {
|
||||
echo '<td><input type="file" name="fields_upload_' . urlencode($field) . '" class="textfield" /></td>';
|
||||
}
|
||||
|
||||
} // end else if ( binary or blob)
|
||||
else {
|
||||
// For char or varchar, respect the maximum length (M); for other
|
||||
// types (int or float), the length is not a limit on the values that
|
||||
|
@@ -45,13 +45,7 @@ else {
|
||||
* Work on the table
|
||||
*/
|
||||
// loic1: defines wether file upload is available or not
|
||||
// lem9: we should check if PHP 4.0.0 really implements the "file_uploads"
|
||||
// variable, because I got a support request and his 4.0.0 did not have it
|
||||
|
||||
$is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
|
||||
? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
|
||||
// loic1: php 3.0.15 and lower bug -> always enabled
|
||||
: (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
|
||||
// ($is_upload now defined in common.lib.php3)
|
||||
|
||||
$auto_sel = ($cfg['TextareaAutoSelect'])
|
||||
? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
|
||||
|
125
tbl_replace.php3
125
tbl_replace.php3
@@ -80,67 +80,12 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
|
||||
|
||||
// Defines the SET part of the sql query
|
||||
$valuelist = '';
|
||||
|
||||
while (list($key, $val) = each($fields)) {
|
||||
$encoded_key = $key;
|
||||
$key = urldecode($key);
|
||||
|
||||
switch (strtolower($val)) {
|
||||
case 'null':
|
||||
break;
|
||||
case '$enum$':
|
||||
// if we have an enum, then construct the value
|
||||
$f = 'field_' . md5($key);
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
if ($val == 'null') {
|
||||
// void
|
||||
} else {
|
||||
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||
}
|
||||
} else {
|
||||
$val = "''";
|
||||
}
|
||||
break;
|
||||
case '$set$':
|
||||
// if we have a set, then construct the value
|
||||
$f = 'field_' . md5($key);
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||
} else {
|
||||
$val = "''";
|
||||
}
|
||||
break;
|
||||
case '$foreign$':
|
||||
// if we have a foreign key, then construct the value
|
||||
$f = 'field_' . md5($key);
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
if ($val == 'null') {
|
||||
// void
|
||||
} else {
|
||||
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||
}
|
||||
} else {
|
||||
$val = "''";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$val = "'" . str_replace('\\"', '"', $val) . "'";
|
||||
} else {
|
||||
$val = "'" . PMA_sqlAddslashes($val) . "'";
|
||||
}
|
||||
break;
|
||||
} // end switch
|
||||
|
||||
// Was the Null checkbox checked for this field?
|
||||
// (if there is a value, we ignore the Null checkbox: this could
|
||||
// be possible if Javascript is disabled in the browser)
|
||||
if (isset($fields_null) && isset($fields_null[$encoded_key])
|
||||
&& $val=="''") {
|
||||
$val = 'NULL';
|
||||
}
|
||||
include('./tbl_replace_fields.php3');
|
||||
|
||||
// No change for this column and no MySQL function is used -> next column
|
||||
if (empty($funcs[$encoded_key])
|
||||
@@ -193,63 +138,7 @@ else {
|
||||
$key = urldecode($key);
|
||||
$fieldlist .= PMA_backquote($key) . ', ';
|
||||
|
||||
switch (strtolower($val)) {
|
||||
case 'null':
|
||||
break;
|
||||
case '$enum$':
|
||||
// if we have a set, then construct the value
|
||||
$f = 'field_' . md5($key);
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
if ($val == 'null') {
|
||||
// void
|
||||
} else {
|
||||
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||
}
|
||||
} else {
|
||||
$val = "''";
|
||||
}
|
||||
break;
|
||||
case '$set$':
|
||||
// if we have a set, then construct the value
|
||||
$f = 'field_' . md5($key);
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||
} else {
|
||||
$val = "''";
|
||||
}
|
||||
break;
|
||||
case '$foreign$':
|
||||
// if we have a foreign key, then construct the value
|
||||
$f = 'field_' . md5($key);
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
if ($val == 'null') {
|
||||
// void
|
||||
} else {
|
||||
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
|
||||
}
|
||||
} else {
|
||||
$val = "''";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$val = "'" . str_replace('\\"', '"', $val) . "'";
|
||||
} else {
|
||||
$val = "'" . PMA_sqlAddslashes($val) . "'";
|
||||
}
|
||||
break;
|
||||
} // end switch
|
||||
|
||||
// Was the Null checkbox checked for this field?
|
||||
// (if there is a value, we ignore the Null checkbox: this could
|
||||
// be possible if Javascript is disabled in the browser)
|
||||
if (isset($fields_null) && isset($fields_null[$encoded_key])
|
||||
&& $val=="''") {
|
||||
$val = 'NULL';
|
||||
}
|
||||
include('./tbl_replace_fields.php3');
|
||||
|
||||
if (empty($funcs[$encoded_key])) {
|
||||
$valuelist .= $val . ', ';
|
||||
@@ -277,7 +166,6 @@ else {
|
||||
PMA_mysql_select_db($db);
|
||||
$sql_query = $query . ';';
|
||||
$result = PMA_mysql_query($query);
|
||||
|
||||
if (!$result) {
|
||||
$error = PMA_mysql_error();
|
||||
include('./header.inc.php3');
|
||||
@@ -298,7 +186,12 @@ if (!$result) {
|
||||
} else {
|
||||
// I don't understand this one:
|
||||
//$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : '');
|
||||
$add_query = '&disp_query=' . urlencode($sql_query);
|
||||
|
||||
// if the sql_query was too long (for example because of an upload)
|
||||
// we do not append the query to the Location
|
||||
// why 100? well, tell me a better value... - lem9
|
||||
|
||||
$add_query = (strlen($sql_query) < 100 ? '&disp_query=' . urlencode($sql_query) : '');
|
||||
header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . $add_query);
|
||||
}
|
||||
exit();
|
||||
|
Reference in New Issue
Block a user