if ($result['result'] == 2) { $text = new HAW_text($file . ' - OK'); } else { $text = new HAW_text($file . ' - KO - ' . $result['sql'], HAW_TEXTFORMAT_BOLD); } $page->add_text($text); } } closedir($dh); } } if (is_dir(CAMILA_TABLES_DIR)) { if ($dh = opendir(CAMILA_TABLES_DIR)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..' && substr($file, -3) == 'csv') { $result = CSV_import(CAMILA_TABLES_DIR . '/' . $file, CAMILA_APPLICATION_PREFIX . substr($file, 0, -4), $db); if ($result['result'] == 2) { $text = new HAW_text($file . ' - inserted: ' . $result['processed']); } else { $text = new HAW_text($file . ' - error: ' . $result['error'] . ', failed: ' . $result['failed'] . ', inserted: ' . $result['processed'], HAW_TEXTFORMAT_BOLD); } $page->add_text($text); } } closedir($dh); } } function listdir($dir = '.') { if (!is_dir($dir)) { return false;
You should have received a copy of the GNU General Public License along with Camila PHP Framework; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once CAMILA_DIR . '/datagrid/form.class.php'; require_once CAMILA_DIR . '/datagrid/elements/form/static_listbox.php'; $options = ''; if (is_dir(CAMILA_TABLES_DIR)) { if ($dh = opendir(CAMILA_TABLES_DIR)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..' && substr($file, -3) == 'csv') { $options .= $file . ','; } } closedir($dh); } } $form = new phpform('table', basename($_SERVER['PHP_SELF']) . '?dbimport'); new form_static_listbox($form, 'file', 'CSV file', $options, true); //new form_static_listbox($form, 'prefix', 'Prefix', CAMILA_APP_DB_.','.CAMILA_DB_,'test_', true); if ($form->process()) { $file = CAMILA_TABLES_DIR . '/' . $form->fields['file']->value; require_once CAMILA_DIR . 'db/import.inc.php'; $result = CSV_import($file, substr($form->fields['file']->value, 0, -4), $_CAMILA['db']); ob_start(); print_r($result); $sql_r = ob_get_contents(); ob_end_clean(); camila_information_text('DATA IMPORT ' . $sql_r); } $form->draw();