public function log() { $id = $this->input->get('history_id'); $import_id = $this->input->get('id'); $wp_uploads = wp_upload_dir(); $log_file = pmxi_secure_file($wp_uploads['basedir'] . "/wpallimport/logs", 'logs', $id) . '/' . $id . '.html'; if (file_exists($log_file)) { PMXI_download::xml($log_file); } else { wp_redirect(add_query_arg(array('id' => $import_id, 'pmxi_nt' => urlencode(__('Log file does not exists.', 'pmxi_plugin'))), $this->baseUrl)); die; } }
public function log() { $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : ''; if (!wp_verify_nonce($nonce, '_wpnonce-download_log')) { die(__('Security check', 'wp_all_import_plugin')); } else { $id = $this->input->get('history_id'); $import_id = $this->input->get('id'); $wp_uploads = wp_upload_dir(); $log_file = wp_all_import_secure_file($wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $id) . DIRECTORY_SEPARATOR . $id . '.html'; if (file_exists($log_file)) { PMXI_download::xml($log_file); } else { wp_redirect(add_query_arg(array('id' => $import_id, 'pmxi_nt' => urlencode(__('Log file does not exists.', 'wp_all_import_plugin'))), $this->baseUrl)); die; } } }
public function feed() { $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : ''; if (!wp_verify_nonce($nonce, '_wpnonce-download_feed')) { die(__('Security check', 'wp_all_import_plugin')); } else { $import_id = $this->input->get('id'); $path = ''; $import = new PMXI_Import_Record(); $import->getbyId($import_id); if (!$import->isEmpty()) { $path = wp_all_import_get_absolute_path($import->path); } if (file_exists($path)) { if (preg_match('%\\W(zip)$%i', trim(basename($path)))) { PMXI_download::zip($path); } elseif (preg_match('%\\W(xml)$%i', trim(basename($path)))) { PMXI_download::xml($path); } else { PMXI_download::csv($path); } } else { wp_redirect(add_query_arg(array('pmxi_nt' => urlencode(__('File does not exists.', 'wp_all_import_plugin'))), $this->baseUrl)); die; } } }
public function index() { $this->data['post'] = $post = $this->input->post(PMXI_Plugin::getInstance()->getOption()); /*$addons = new PMXI_Admin_Addons(); $this->data['addons'] = $addons->get_premium_addons();*/ $this->data['addons']['PMXI_Plugin'] = array('title' => __('WP All Import', 'wp_all_import_plugin'), 'active' => class_exists('PMXI_Plugin') and defined('PMXI_EDITION') and PMXI_EDITION == 'paid'); $this->data['addons'] = array_reverse($this->data['addons']); if ($this->input->post('is_settings_submitted')) { // save settings form check_admin_referer('edit-settings', '_wpnonce_edit-settings'); if (!preg_match('%^\\d+$%', $post['history_file_count'])) { $this->errors->add('form-validation', __('History File Count must be a non-negative integer', 'wp_all_import_plugin')); } if (!preg_match('%^\\d+$%', $post['history_file_age'])) { $this->errors->add('form-validation', __('History Age must be a non-negative integer', 'wp_all_import_plugin')); } if (empty($post['html_entities'])) { $post['html_entities'] = 0; } if (empty($post['utf8_decode'])) { $post['utf8_decode'] = 0; } if (!$this->errors->get_error_codes()) { // no validation errors detected PMXI_Plugin::getInstance()->updateOption($post); if (empty($_POST['pmxi_license_activate']) and empty($_POST['pmxi_license_deactivate'])) { foreach ($this->data['addons'] as $class => $addon) { $post['statuses'][$class] = $this->check_license($class); } PMXI_Plugin::getInstance()->updateOption($post); } isset($_POST['pmxi_license_activate']) and $this->activate_licenses(); $files = new PMXI_File_List(); $files->sweepHistory(); // adjust file history to new settings specified wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Settings saved', 'wp_all_import_plugin')), $this->baseUrl)); die; } } /*else{ foreach ($this->data['addons'] as $class => $addon) { $post['statuses'][$class] = $this->check_license($class); } PMXI_Plugin::getInstance()->updateOption($post); }*/ if ($this->input->post('is_templates_submitted')) { // delete templates form check_admin_referer('delete-templates', '_wpnonce_delete-templates'); if ($this->input->post('import_templates')) { if (!empty($_FILES)) { $file_name = $_FILES['template_file']['name']; $file_size = $_FILES['template_file']['size']; $tmp_name = $_FILES['template_file']['tmp_name']; if (isset($file_name)) { $filename = stripslashes($file_name); $extension = strtolower(pmxi_getExtension($filename)); if ($extension != "txt") { $this->errors->add('form-validation', __('Unknown File extension. Only txt files are permitted', 'wp_all_import_plugin')); } else { $import_data = @file_get_contents($tmp_name); if (!empty($import_data)) { $templates_data = json_decode($import_data, true); if (!empty($templates_data)) { $template = new PMXI_Template_Record(); foreach ($templates_data as $template_data) { unset($template_data['id']); $template->clear()->set($template_data)->insert(); } wp_redirect(add_query_arg('pmxi_nt', urlencode(sprintf(_n('%d template imported', '%d templates imported', count($templates_data), 'wp_all_import_plugin'), count($templates_data))), $this->baseUrl)); die; } else { $this->errors->add('form-validation', __('Wrong imported data format', 'wp_all_import_plugin')); } } else { $this->errors->add('form-validation', __('File is empty or doesn\'t exests', 'wp_all_import_plugin')); } } } else { $this->errors->add('form-validation', __('Undefined entry!', 'wp_all_import_plugin')); } } else { $this->errors->add('form-validation', __('Please select file.', 'wp_all_import_plugin')); } } else { $templates_ids = $this->input->post('templates', array()); if (empty($templates_ids)) { $this->errors->add('form-validation', __('Templates must be selected', 'wp_all_import_plugin')); } if (!$this->errors->get_error_codes()) { // no validation errors detected if ($this->input->post('delete_templates')) { $template = new PMXI_Template_Record(); foreach ($templates_ids as $template_id) { $template->clear()->set('id', $template_id)->delete(); } wp_redirect(add_query_arg('pmxi_nt', urlencode(sprintf(_n('%d template deleted', '%d templates deleted', count($templates_ids), 'wp_all_import_plugin'), count($templates_ids))), $this->baseUrl)); die; } if ($this->input->post('export_templates')) { $export_data = array(); $template = new PMXI_Template_Record(); foreach ($templates_ids as $template_id) { $export_data[] = $template->clear()->getBy('id', $template_id)->toArray(TRUE); } $uploads = wp_upload_dir(); $targetDir = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY; $export_file_name = "templates_" . uniqid() . ".txt"; file_put_contents($targetDir . DIRECTORY_SEPARATOR . $export_file_name, json_encode($export_data)); PMXI_download::csv($targetDir . DIRECTORY_SEPARATOR . $export_file_name); } } } } $this->render(); }
public function get_template() { $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : ''; if (!wp_verify_nonce($nonce, '_wpnonce-download_template')) { die(__('Security check', 'wp_all_export_plugin')); } else { $id = $this->input->get('id'); $export = new PMXE_Export_Record(); $filepath = ''; $export_data = array(); if (!$export->getById($id)->isEmpty()) { $export_data[] = $export->options['tpl_data']; $uploads = wp_upload_dir(); $targetDir = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY; $export_file_name = "WP All Import Template - " . sanitize_file_name($export->friendly_name) . ".txt"; file_put_contents($targetDir . DIRECTORY_SEPARATOR . $export_file_name, json_encode($export_data)); PMXI_download::csv($targetDir . DIRECTORY_SEPARATOR . $export_file_name); } } }
public function download() { PMXI_download::csv(PMXI_Plugin::ROOT_DIR . '/logs/' . $_GET['file'] . '.txt'); }
public function log() { $id = $this->input->get('id'); $wp_uploads = wp_upload_dir(); PMXI_download::csv($wp_uploads['basedir'] . '/wpallimport_logs/' . $id . '.html'); }