Blob upload via pre-uploaded (FTP) files in $cfg['UploadDir'].
This commit is contained in:
@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2003-03-19 Garvin Hicking <me@supergarv.de>
|
||||
* tbl_change.php3, tbl_query_box.php3, tbl_replace_fields.php3:
|
||||
Display select box for stored files on Server ($cfg['UploadDir']) in every SQL
|
||||
input area (SQL window, table properties) AND in the 'Insert/Update field' display
|
||||
where you can upload files to blob fields. Experimental.
|
||||
|
||||
2003-03-19 Alexander M. Turek <rabus@users.sourceforge.net>
|
||||
* lang/german-*.inc.php3: Updates.
|
||||
|
||||
|
@@ -611,6 +611,32 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
if ($is_upload && $is_blob) {
|
||||
echo '<input type="file" name="fields_upload_' . urlencode($field) . '" class="textfield" id="field_' . $i . '_3" />';
|
||||
}
|
||||
|
||||
if ($cfg['UploadDir'] != '') {
|
||||
if ($handle = @opendir($cfg['UploadDir'])) {
|
||||
$is_first = 0;
|
||||
while ($file = @readdir($handle)) {
|
||||
if (is_file($cfg['UploadDir'] . $file) && substr($file, -4) != '.sql') {
|
||||
if ($is_first == 0) {
|
||||
echo "<br />\n";
|
||||
echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ' :<br />' . "\n";
|
||||
echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . '">' . "\n";
|
||||
echo ' <option value="" selected="selected"></option>' . "\n";
|
||||
} // end if (is_first)
|
||||
echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
|
||||
$is_first++;
|
||||
} // end if (is_file)
|
||||
} // end while
|
||||
if ($is_first > 0) {
|
||||
echo ' </select>' . "\n";
|
||||
} // end if (isfirst > 0)
|
||||
@closedir($handle);
|
||||
} else {
|
||||
echo ' <font color="red">' . $strError . '</font><br />' . "\n";
|
||||
echo ' ' . $strWebServerUploadDirectoryError . "\n";
|
||||
}
|
||||
} // end if (web-server upload directory)
|
||||
|
||||
echo '</td>';
|
||||
|
||||
} // end else if ( binary or blob)
|
||||
|
@@ -175,6 +175,40 @@ if ($is_upload && (!isset($is_inside_querywindow) ||
|
||||
} // end if
|
||||
echo "\n";
|
||||
|
||||
// web-server upload directory
|
||||
// (TODO: display the charset selection, even if is_upload == FALSE)
|
||||
if ($cfg['UploadDir'] != '' && !isset($is_inside_querywindow) ||
|
||||
($cfg['UploadDir'] != '' && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'full'))) {
|
||||
|
||||
if ($handle = @opendir($cfg['UploadDir'])) {
|
||||
$is_first = 0;
|
||||
while ($file = @readdir($handle)) {
|
||||
if (is_file($cfg['UploadDir'] . $file) && substr($file, -4) == '.sql') {
|
||||
if ($is_first == 0) {
|
||||
echo "\n";
|
||||
echo ' ' . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') || !isset($is_inside_querywindow) ? '<i>' . $strOr . '</i>' : '') . ' ' . $strWebServerUploadDirectory . ' :<br />' . "\n";
|
||||
echo ' <div style="margin-bottom: 5px">' . "\n";
|
||||
echo ' <select size="1" name="sql_localfile">' . "\n";
|
||||
echo ' <option value="" selected="selected"></option>' . "\n";
|
||||
} // end if (is_first)
|
||||
echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
|
||||
$is_first++;
|
||||
} // end if (is_file)
|
||||
} // end while
|
||||
if ($is_first > 0) {
|
||||
echo ' </select>' . "\n"
|
||||
. ' </div>' . "\n\n";
|
||||
} // end if (isfirst > 0)
|
||||
@closedir($handle);
|
||||
} else {
|
||||
echo ' <div style="margin-bottom: 5px">' . "\n";
|
||||
echo ' <font color="red">' . $strError . '</font><br />' . "\n";
|
||||
echo ' ' . $strWebServerUploadDirectoryError . "\n";
|
||||
echo ' </div>' . "\n";
|
||||
}
|
||||
} // end if (web-server upload directory)
|
||||
echo "\n";
|
||||
|
||||
// Encoding setting form appended by Y.Kawada
|
||||
if (function_exists('PMA_set_enc_form')) {
|
||||
echo PMA_set_enc_form(' ');
|
||||
|
@@ -49,6 +49,58 @@ if (isset(${"fields_upload_" . $key}) && ${"fields_upload_" . $key} != 'none'){
|
||||
// void
|
||||
}
|
||||
|
||||
} elseif (!empty(${'fields_uploadlocal_' . $key})) {
|
||||
$file_to_upload = $cfg['UploadDir'] . eregi_replace('\.\.*', '.', ${'fields_uploadlocal_' . $key});
|
||||
|
||||
// A local file will be uploaded.
|
||||
$open_basedir = '';
|
||||
if (PMA_PHP_INT_VERSION >= 40000) {
|
||||
$open_basedir = @ini_get('open_basedir');
|
||||
}
|
||||
if (empty($open_basedir)) {
|
||||
$open_basedir = @get_cfg_var('open_basedir');
|
||||
}
|
||||
|
||||
// If we are on a server with open_basedir, we must move the file
|
||||
// before opening it. The doc explains how to create the "./tmp"
|
||||
// directory
|
||||
|
||||
$unlink = false;
|
||||
if (!empty($open_basedir)) {
|
||||
|
||||
$tmp_subdir = (PMA_IS_WINDOWS ? '.\\tmp\\' : './tmp/');
|
||||
|
||||
// function is_writeable() is valid on PHP3 and 4
|
||||
if (!is_writeable($tmp_subdir)) {
|
||||
// if we cannot move the file don't change blob fields
|
||||
$file_to_upload = '';
|
||||
} else {
|
||||
$new_file_to_upload = $tmp_subdir . basename($file_to_upload);
|
||||
if (PMA_PHP_INT_VERSION < 40003) {
|
||||
copy($file_to_upload, $new_file_to_upload);
|
||||
} else {
|
||||
move_uploaded_file($file_to_upload, $new_file_to_upload);
|
||||
}
|
||||
|
||||
$file_to_upload = $new_file_to_upload;
|
||||
$unlink = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($file_to_upload != '') {
|
||||
|
||||
$val = fread(fopen($file_to_upload, "rb"), filesize($file_to_upload));
|
||||
if (!empty($val)) {
|
||||
$val = '0x' . bin2hex($val);
|
||||
$seen_binary = TRUE;
|
||||
$check_stop = TRUE;
|
||||
}
|
||||
|
||||
if ($unlink == TRUE) {
|
||||
unlink($file_to_upload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// garvin: else: Post-field contains no data. Blob-fields are preserved, see below. ($protected$)
|
||||
|
||||
|
Reference in New Issue
Block a user