get_error_message(); else if($result) $message = $result; unset($files); libxml_use_internal_errors( $set_err ); libxml_disable_entity_loader( $loader ); } public static function route() { $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; $action = FrmAppHelper::get_param($action); if($action == 'import_xml') { return self::import_xml(); } else if($action == 'export_xml') { return self::export_xml(); } else { if ( apply_filters('frm_xml_route', true, $action) ){ return self::form(); } } } public static function form($errors = array(), $message = '') { //wp_enqueue_script('jquery-chosen'); //wp_enqueue_style('formidable'); $frm_form = new FrmForm(); $forms = $frm_form->getAll("status is NULL OR status = '' OR status = 'published'", ' ORDER BY name'); unset($frm_form); $export_types = apply_filters('frm_xml_export_types', array('forms' => __('Forms', 'formidable')) ); $export_format = apply_filters('frm_export_formats', array( 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple'), )); global $frmpro_settings; $csv_format = $frmpro_settings ? $frmpro_settings->csv_format : 'UTF-8'; include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php'); } public static function import_xml() { $errors = array(); $message = ''; if ( !current_user_can('frm_edit_forms') || ! isset($_POST['import-xml']) || ! wp_verify_nonce($_POST['import-xml'], 'import-xml-nonce') ) { global $frm_settings; $errors[] = $frm_settings->admin_permission; self::form($errors); return; } if ( !isset($_FILES) || !isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int)$_FILES['frm_import_file']['size'] < 1) { $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); self::form($errors); return; } $file = $_FILES['frm_import_file']['tmp_name']; if ( !is_uploaded_file($file) ) { unset($file); $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); self::form($errors); return; } //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); $export_format = apply_filters('frm_export_formats', array( 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple'), )); $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); if ( $file_type != 'xml' && isset($export_format[$file_type]) ) { // allow other file types to be imported do_action('frm_before_import_'. $file_type ); return; } unset($file_type); //$media_id = FrmProAppHelper::upload_file('frm_import_file'); //if(is_numeric($media_id)){ if ( !function_exists( 'libxml_disable_entity_loader' ) ) { $errors[] = __('XML import is not enabled on your server.', 'formidable'); self::form($errors); return; } include_once(FrmAppHelper::plugin_path() .'/classes/helpers/FrmXMLHelper.php'); $set_err = libxml_use_internal_errors(true); $loader = libxml_disable_entity_loader( true ); $result = FrmXMLHelper::import_xml($file); if ( is_wp_error($result) ) { $errors[] = $result->get_error_message(); } else if ( $result ) { if ( is_array($result) ) { $t_strings = array( 'imported' => __('Imported', 'formidable'), 'updated' => __('Updated', 'formidable'), ); $message = '