Working on Table ' . $_tab . ''; if ($content == 'none') { $lines = array(); $fd = fopen($docpath . $file, 'r'); if ($fd) { while (!feof($fd)) { $lines[] = fgets($fd, 4096); } } } else { $content = str_replace("\r\n", "\n", $content); $content = str_replace("\r", "\n", $content); $lines = explode("\n", $content); } if (isset($lines) && is_array($lines) && count($lines) > 0) { foreach ($lines AS $lkey => $line) { //echo '
' . $line . '
'; $inf = explode('|', $line); if (!empty($inf[1]) && strlen(trim($inf[1])) > 0) { $qry = ' INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . ' ( db_name, table_name, column_name, ' . PMA_backquote('comment') . ' ) VALUES ( \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\', \'' . PMA_sqlAddslashes(trim($tab)) . '\', \'' . PMA_sqlAddslashes(trim($inf[0])) . '\', \'' . PMA_sqlAddslashes(trim($inf[1])) . '\')'; if (PMA_query_as_cu($qry)) { echo '' . $GLOBALS['strAddedColumnComment'] . ' ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]) . '
'; } else { echo '' . $GLOBALS['strWritingCommentNotPossible'] . '
'; } echo "\n"; } // end inf[1] exists if (!empty($inf[2]) && strlen(trim($inf[2])) > 0) { $for = explode('->', $inf[2]); $qry = ' INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . ' ( master_db, master_table, master_field, foreign_db, foreign_table, foreign_field) VALUES ( \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\', \'' . PMA_sqlAddslashes(trim($tab)) . '\', \'' . PMA_sqlAddslashes(trim($inf[0])) . '\', \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\', \'' . PMA_sqlAddslashes(trim($for[0])) . '\', \'' . PMA_sqlAddslashes(trim($for[1])) . '\')'; if (PMA_query_as_cu($qry)) { echo '' . $GLOBALS['strAddedColumnRelation'] . ' ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]) . ' to ' . htmlspecialchars($inf[2]) . '
'; } else { echo '' . $GLOBALS['strWritingRelationNotPossible'] . '
'; } echo "\n"; } // end inf[2] exists } echo '' . sprintf($GLOBALS['strImportSuccessfullyFinished'], count($lines)) . '
' . "\n"; } else { echo '' . $GLOBALS['strFileCouldNotBeRead'] . '
' . "\n"; } return 1; } else { if ($content != 'none') { echo '' . sprintf($GLOBALS['strIgnoringFile'], ' ' . htmlspecialchars($file)) . '
' . "\n"; } else { // garvin: disabled. Shouldn't impose ANY non-submitted files ever. echo '' . sprintf($GLOBALS['strIgnoringFile'], ' ' . '...') . '
' . "\n"; } return 0; } // end working on table } /** * Executes import if required */ if (isset($do) && $do == 'import') { $orig_docpath = $docpath; if (empty($sql_file)) { $sql_file = 'none'; } // Get relation settings require_once('./libraries/relation.lib.php'); $cfgRelation = PMA_getRelationsParam(); // Gets the query from a file if required if ($sql_file != 'none') { if (file_exists($sql_file) && is_uploaded_file($sql_file)) { $open_basedir = @ini_get('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 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)) { $docsql_text = PMA_readFile($sql_file, $sql_file_compression); if ($docsql_text == FALSE) { echo $strFileCouldNotBeRead; exit(); } } else { $sql_file_new = $tmp_subdir . basename($sql_file); move_uploaded_file($sql_file, $sql_file_new); $docsql_text = PMA_readFile($sql_file_new, $sql_file_compression); unlink($sql_file_new); } } else { // read from the normal upload dir $docsql_text = PMA_readFile($sql_file, $sql_file_compression); } // Convert the file's charset if necessary if ($cfg['AllowAnywhereRecoding'] && $allow_recoding && isset($charset_of_file) && $charset_of_file != $charset) { $docsql_text = PMA_convert_string($charset_of_file, $charset, $docsql_text); } if (!isset($docsql_text) || $docsql_text == FALSE || $docsql_text == '') { echo '' . $GLOBALS['strFileCouldNotBeRead'] . '
' . "\n"; } else { docsql_check('', $sql_file_name, $sql_file_name, $docsql_text); } } // end uploaded file stuff } else { // echo 'Working on file ' . $filename . '
'; $matched_files += docsql_check($docpath, $file, $filename); } // end while } else { echo '' .$docpath . ': ' . $strThisNotDirectory . "
\n"; } } } /** * Displays the form */ ?>