'; echo PHP_EOL.'

'.PHP_EOL; echo PHP_EOL.'

'.__('Import a list\'s settings','amr-ical-events-list').'

'; // 201602 check if we are allowed to upload text file types $mimes = get_allowed_mime_types(); $filetypeok = false; foreach ($mimes as $type => $mime) { if (strpos($type, 'txt') !== false) { $filetypeok = true; } } if (!$filetypeok) { echo '

!! '.__('This site does not allow filetype .txt to be uploaded.','amr-ical-events-list'). ' ' .__('Please contact your wordpress administrator to request that it be added.','amr-ical-events-list').' ' .__('Alternatively, change the file suffix to an allowed type eg: .odt in order to upload it.','amr-ical-events-list').'

'; } echo '

'.__('Imported settings must be from a compatible system.','amr-ical-events-list'); echo ' '.__('Ensure any fields used by the list are in your database and have been "found".','amr-ical-events-list').'

'; echo '

' .'' .'

'; if (WP_DEBUG and !$filetypeok) { echo '

'.__('Allowed mimetypes: ', 'amr-ical-events-list').'

'; echo '

'; foreach ($mimes as $type => $mime) { echo $type.', '; } echo '

'; } } function amr_ical_list_export_form () { global $amain; global $aopt; global $ausersadminurl; if (isset ($amain['names'])) { echo PHP_EOL.'

'; echo PHP_EOL.'

'.PHP_EOL; echo '

'; _e("Export a list's settings", 'amr-ical-events-list'); echo '

'; echo PHP_EOL.'
'; echo PHP_EOL.wp_nonce_field('amr-meta','amr-meta',true,false); echo PHP_EOL."

".PHP_EOL; echo '

'; } } function amr_ical_main_to_export () { // define the list of overview settings to export return array( // we have a historically weird structure so we have to do it this way until we risk updating 'sortable', 'names', 'html_type', 'public' , 'list_avatar_size', 'list_rows_per_page', 'show_search', 'show_perpage', 'show_pagination', 'show_headings', 'show_csv', 'filterable', 'show_refresh', 'customnav' ); } function amr_ical_build_export($list) { global $amain, $aopt; if (empty ($aopt)) $aopt = ausers_get_option('amr-ical-events-list'); $data = array(); $data ['version'] = $amain['version']; // $toexport = amr_main_to_export (); foreach ($toexport as $text) { if (isset($amain[$text][$list])) $data[$text] = $amain[$text][$list]; } if (isset ($aopt['list'])) $data['list'] = $aopt['list'][$list]; $content = serialize($data); return($content); } function amr_ical_handle_export() { if ( isset( $_POST['export-list'] ) and isset( $_POST['export-list-text'] ) ) { check_admin_referer('amr-meta','amr-meta'); $filename = sanitize_title(get_bloginfo('name'))."-amr-users-list.txt"; if (amr_is_network_admin()) $filename = 'network-'.$filename; $content = htmlspecialchars_decode($_POST['export-list-text']); header("Content-Description: File Transfer"); header("Content-type: application/txt"); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Pragma: no-cache"); header("Expires: 0"); echo $content; die(); } } function amr_ical_handle_import() { global $amain, $aopt; if ( isset( $_POST['import-list'] ) ) { // require_once(ABSPATH . 'wp-admin/includes/admin.php'); if (empty($_FILES) ) { amr_users_message('No file specified','amr-ical-events-list'); return; } if (empty($_FILES['importfile'])) { amr_users_message('Problem in upload','amr-ical-events-list'); return; } $file = $_FILES['importfile']; $uploaded = wp_handle_upload($file, array('test_form' => FALSE)); if ( is_wp_error($uploaded) ) { $errors['upload_error'] = $uploaded['error']; } if (!empty($errors)) { amr_users_message('There was an error uploading your file.','amr-ical-events-list'); return; } if (empty($uploaded['file'])) { amr_users_message('There was an error uploading your file.','amr-ical-events-list'); // could be file mime type is not allowed 20160207 return; } $content = file_get_contents($uploaded['file']); $data = unserialize(stripslashes($content)); //$data = unserialize($content); if ((!is_array($data)) or (!isset($data['version']) )) { echo '

'; _e('Invalid data in settings file','amr-ical-events-list'); echo '

$name) { if ($name == 'justimported' ) { $thisindex = $index; } } foreach ($toimport as $setting) { if (isset($data[$setting])) $amain[$setting][$thisindex] = $data[$setting]; } if (isset($data['list'])) $aopt ['list'][$thisindex] = $data['list']; // do we need this?? ausers_update_option('amr-ical-events-list',$aopt); ausers_update_option('amr-users-main',$amain); amr_users_message(sprintf(__('List %s will be saved with imported data','amr-ical-events-list'),$thisindex)); } }