admin_head.php
4 years ago
admin_init.php
5 years ago
admin_menu.php
4 years ago
admin_notices.php
4 years ago
init.php
8 years ago
pmxe_after_export.php
8 years ago
pmxe_before_export.php
8 years ago
pmxe_exported_post.php
10 years ago
wp_ajax_dismiss_export_warnings.php
9 years ago
wp_ajax_dismiss_review_modal.php
4 years ago
wp_ajax_dismiss_warnings.php
4 years ago
wp_ajax_generate_zapier_api_key.php
10 years ago
wp_ajax_redirect_after_addon_installed.php
6 years ago
wp_ajax_save_scheduling.php
8 years ago
wp_ajax_scheduling_dialog_content.php
4 years ago
wp_ajax_send_feedback.php
4 years ago
wp_ajax_wpae_available_rules.php
4 years ago
wp_ajax_wpae_filtering.php
4 years ago
wp_ajax_wpae_filtering_count.php
4 years ago
wp_ajax_wpae_preview.php
4 years ago
wp_ajax_wpae_upgrade_notice.php
4 years ago
wp_ajax_wpallexport.php
4 years ago
wp_loaded.php
4 years ago
wpmu_new_blog.php
10 years ago
wp_loaded.php
132 lines
| 1 | <?php |
| 2 | |
| 3 | function pmxe_wp_loaded() { |
| 4 | |
| 5 | @ini_set("max_input_time", PMXE_Plugin::getInstance()->getOption('max_input_time')); |
| 6 | |
| 7 | if ( ! empty($_GET['action']) && ! empty($_GET['export_id']) && (!empty($_GET['export_hash']) || !empty($_GET['security_token']))) |
| 8 | { |
| 9 | pmxe_set_max_execution_time(); |
| 10 | |
| 11 | if(empty($_GET['export_hash'])) { |
| 12 | $securityToken = $_GET['security_token']; |
| 13 | } else { |
| 14 | $securityToken = $_GET['export_hash']; |
| 15 | } |
| 16 | |
| 17 | $cron_job_key = PMXE_Plugin::getInstance()->getOption('cron_job_key'); |
| 18 | |
| 19 | if ( $securityToken == substr(md5($cron_job_key . $_GET['export_id']), 0, 16) ) |
| 20 | { |
| 21 | $export = new PMXE_Export_Record(); |
| 22 | |
| 23 | $export->getById($_GET['export_id']); |
| 24 | |
| 25 | if ( ! $export->isEmpty()) |
| 26 | { |
| 27 | switch ($_GET['action']) |
| 28 | { |
| 29 | case 'get_data': |
| 30 | |
| 31 | if ( ! empty($export->options['current_filepath']) and @file_exists($export->options['current_filepath'])) |
| 32 | { |
| 33 | $filepath = $export->options['current_filepath']; |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure'); |
| 38 | |
| 39 | if ( ! $is_secure_import) |
| 40 | { |
| 41 | $filepath = get_attached_file($export->attch_id); |
| 42 | } |
| 43 | else |
| 44 | { |
| 45 | $filepath = wp_all_export_get_absolute_path($export->options['filepath']); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if ( ! empty($_GET['part']) and is_numeric($_GET['part'])) $filepath = str_replace(basename($filepath), str_replace('.' . $export->options['export_to'], '', basename($filepath)) . '-' . $_GET['part'] . '.' . $export->options['export_to'], $filepath); |
| 50 | |
| 51 | break; |
| 52 | |
| 53 | case 'get_bundle': |
| 54 | |
| 55 | $filepath = wp_all_export_get_absolute_path($export->options['bundlepath']); |
| 56 | |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | if (file_exists($filepath)) |
| 61 | { |
| 62 | $uploads = wp_upload_dir(); |
| 63 | $fileurl = $uploads['baseurl'] . str_replace($uploads['basedir'], '', str_replace(basename($filepath), rawurlencode(basename($filepath)), $filepath)); |
| 64 | |
| 65 | if($export['options']['export_to'] == XmlExportEngine::EXPORT_TYPE_XML && $export['options']['xml_template_type'] == XmlExportEngine::EXPORT_TYPE_GOOLE_MERCHANTS) { |
| 66 | |
| 67 | // If we are doing a google merchants export, send the file as a download. |
| 68 | header("Content-type: text/plain"); |
| 69 | header("Content-Disposition: attachment; filename=".basename($filepath)); |
| 70 | readfile($filepath); |
| 71 | |
| 72 | die; |
| 73 | } |
| 74 | |
| 75 | if(apply_filters('wp_all_export_no_cache', false)) { |
| 76 | |
| 77 | // If we are doing a google merchants export, send the file as a download. |
| 78 | header("Content-type: " . mime_content_type($filepath)); |
| 79 | header("Content-Disposition: attachment; filename=" . basename($filepath)); |
| 80 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
| 81 | header("Cache-Control: post-check=0, pre-check=0", false); |
| 82 | header("Pragma: no-cache"); |
| 83 | |
| 84 | readfile($filepath); |
| 85 | |
| 86 | die; |
| 87 | } |
| 88 | |
| 89 | $fileurl = str_replace( "\\", "/", $fileurl ); |
| 90 | |
| 91 | wp_redirect($fileurl); |
| 92 | } |
| 93 | else |
| 94 | { |
| 95 | wp_send_json(array( |
| 96 | 'status' => 403, |
| 97 | 'message' => __('File doesn\'t exist', 'wp_all_export_plugin') |
| 98 | )); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | wp_send_json(array( |
| 105 | 'status' => 403, |
| 106 | 'message' => __('Export hash is not valid.', 'wp_all_export_plugin') |
| 107 | )); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | if(isset($_GET['action']) && $_GET['action'] == 'wpae_public_api') { |
| 112 | |
| 113 | pmxe_set_max_execution_time(); |
| 114 | |
| 115 | $router = new \Wpae\Http\Router(); |
| 116 | $router->route($_GET['q'], false); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if(!function_exists('pmxe_set_max_execution_time')) { |
| 121 | function pmxe_set_max_execution_time() |
| 122 | { |
| 123 | @ini_set("max_input_time", PMXE_Plugin::getInstance()->getOption('max_input_time')); |
| 124 | |
| 125 | $maxExecutionTime = PMXE_Plugin::getInstance()->getOption('max_execution_time'); |
| 126 | if ($maxExecutionTime == -1) { |
| 127 | $maxExecutionTime = 0; |
| 128 | } |
| 129 | |
| 130 | @ini_set("max_execution_time", $maxExecutionTime); |
| 131 | } |
| 132 | } |