Version Description
Download this release
Release Info
Developer | soflyy |
Plugin | ![]() |
Version | 0.9.0 |
Comparing to | |
See all releases |
Version 0.9.0
- actions/admin_init.php +5 -0
- actions/admin_menu.php +20 -0
- actions/admin_notices.php +30 -0
- actions/plugins_loaded.php +9 -0
- actions/wp.php +7 -0
- actions/wp_ajax_export.php +403 -0
- actions/wp_loaded.php +6 -0
- actions/wp_session_garbage_collection.php +65 -0
- banner-772x250.png +0 -0
- classes/arrayaccess.php +141 -0
- classes/config.php +91 -0
- classes/download.php +39 -0
- classes/helper.php +139 -0
- classes/input.php +72 -0
- classes/session.php +371 -0
- config/options.php +11 -0
- controllers/admin/export.php +161 -0
- controllers/admin/help.php +12 -0
- controllers/admin/settings.php +30 -0
- controllers/controller.php +102 -0
- controllers/controller/admin.php +104 -0
- helpers/backward.php +40 -0
- helpers/pmxe_functions.php +80 -0
- helpers/str_getcsv.php +18 -0
- helpers/wp_redirect_or_javascript.php +17 -0
- models/export/list.php +8 -0
- models/export/record.php +36 -0
- models/model.php +198 -0
- models/model/list.php +149 -0
- models/model/record.php +176 -0
- plugin.php +498 -0
- readme.txt +41 -0
- schema.php +27 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- static/css/admin-ie.css +13 -0
- static/css/admin-wp-3.8.css +0 -0
- static/css/admin.css +1332 -0
- static/img/add-ons/acf-thumb.jpg +0 -0
- static/img/add-ons/woo-commerce-thumb.jpg +0 -0
- static/img/date-picker.gif +0 -0
- static/img/down.gif +0 -0
- static/img/drag.png +0 -0
- static/img/help.png +0 -0
- static/img/ico-add-new.png +0 -0
- static/img/ico-remove.png +0 -0
- static/img/loading.png +0 -0
- static/img/progress_animated.gif +0 -0
- static/img/screen-options-right-up.gif +0 -0
- static/img/screen-options-right.gif +0 -0
- static/img/stars.png +0 -0
- static/img/xmlicon.png +0 -0
- static/js/admin.js +143 -0
- static/js/jquery/css/redmond/images/animated-overlay.gif +0 -0
- static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_flat_0_aaaaaa_40x100_1.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_217bc0_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_469bdd_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
- static/js/jquery/css/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
- static/js/jquery/css/redmond/jquery-ui.css +1177 -0
- static/js/jquery/css/select2/select2-bootstrap.css +87 -0
- static/js/jquery/css/select2/select2-spinner.gif +0 -0
- static/js/jquery/css/select2/select2.css +617 -0
- static/js/jquery/css/select2/select2.png +0 -0
- static/js/jquery/css/smoothness/images/tipsy.gif +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- static/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- static/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- static/js/jquery/css/smoothness/jquery-ui.css +405 -0
- static/js/jquery/css/smoothness/jquery.tipsy.css +11 -0
- static/js/jquery/jquery.mjs.nestedSortable.js +426 -0
- static/js/jquery/jquery.tipsy.js +198 -0
- static/js/jquery/moment.js +6 -0
- static/js/jquery/select2.min.js +22 -0
- static/js/jquery/ui.autocomplete.js +606 -0
- static/js/jquery/ui.datepicker.js +1636 -0
- static/js/pmxe.js +14 -0
- views/admin/export/element.php +183 -0
- views/admin/export/index.php +61 -0
- views/admin/export/process.php +58 -0
- views/admin/help/index.php +13 -0
- views/admin/settings/index.php +25 -0
- views/controller/error.php +3 -0
actions/admin_init.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_admin_init(){
|
4 |
+
wp_enqueue_script('pmxe-script', PMXE_ROOT_URL . '/static/js/pmxe.js', array('jquery'), PMXE_VERSION);
|
5 |
+
}
|
actions/admin_menu.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Register plugin specific admin menu
|
4 |
+
*/
|
5 |
+
|
6 |
+
function pmxe_admin_menu() {
|
7 |
+
global $menu, $submenu;
|
8 |
+
|
9 |
+
if (current_user_can('manage_options')) { // admin management options
|
10 |
+
|
11 |
+
add_menu_page(__('WP All Export', 'pmxe_plugin'), __('All Export', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-home', array(PMXE_Plugin::getInstance(), 'adminDispatcher'), PMXE_Plugin::ROOT_URL . '/static/img/xmlicon.png');
|
12 |
+
// workaround to rename 1st option to `Home`
|
13 |
+
$submenu['pmxe-admin-home'] = array();
|
14 |
+
add_submenu_page('pmxe-admin-home', __('Export to XML', 'pmxe_plugin') . ' ‹ ' . __('WP All Export', 'pmxe_plugin'), __('New Export', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-export', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
|
15 |
+
add_submenu_page('pmxe-admin-home', __('Settings', 'pmxe_plugin') . ' ‹ ' . __('WP All Export', 'pmxe_plugin'), __('Settings', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-settings', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
|
16 |
+
add_submenu_page('pmxe-admin-home', __('Support', 'pmxe_plugin') . ' ‹ ' . __('WP All Export', 'pmxe_plugin'), __('Support', 'pmxe_plugin'), 'manage_options', 'pmxe-admin-help', array(PMXE_Plugin::getInstance(), 'adminDispatcher'));
|
17 |
+
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
actions/admin_notices.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_admin_notices() {
|
4 |
+
|
5 |
+
// notify user if history folder is not writable
|
6 |
+
$uploads = wp_upload_dir();
|
7 |
+
|
8 |
+
// notify user
|
9 |
+
if (!PMXE_Plugin::getInstance()->getOption('dismiss') and strpos($_SERVER['REQUEST_URI'], 'pmxe-admin') !== false) {
|
10 |
+
?>
|
11 |
+
<div class="updated"><p>
|
12 |
+
<?php printf(
|
13 |
+
__('Welcome to WP All Export. We hope you like it. Please send all support requests and feedback to <a href="mailto:support@soflyy.com">support@soflyy.com</a>.<br/><br/><a href="javascript:void(0);" id="dismiss">dismiss</a>', 'pmxe_plugin')
|
14 |
+
) ?>
|
15 |
+
</p></div>
|
16 |
+
<?php
|
17 |
+
}
|
18 |
+
|
19 |
+
$input = new PMXE_Input();
|
20 |
+
$messages = $input->get('pmxe_nt', array());
|
21 |
+
if ($messages) {
|
22 |
+
is_array($messages) or $messages = array($messages);
|
23 |
+
foreach ($messages as $type => $m) {
|
24 |
+
in_array((string)$type, array('updated', 'error')) or $type = 'updated';
|
25 |
+
?>
|
26 |
+
<div class="<?php echo $type ?>"><p><?php echo $m ?></p></div>
|
27 |
+
<?php
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
actions/plugins_loaded.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_plugins_loaded() {
|
4 |
+
|
5 |
+
PMXE_Plugin::$session = PMXE_Session::get_instance();
|
6 |
+
do_action( 'pmxe_session_start' );
|
7 |
+
|
8 |
+
return PMXE_Plugin::$session->session_started();
|
9 |
+
}
|
actions/wp.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_wp() {
|
4 |
+
if ( ! wp_next_scheduled( 'wp_session_garbage_collection' ) ) {
|
5 |
+
wp_schedule_event( time(), 'twicedaily', 'wp_session_garbage_collection' );
|
6 |
+
}
|
7 |
+
}
|
actions/wp_ajax_export.php
ADDED
@@ -0,0 +1,403 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_wp_ajax_export(){
|
4 |
+
|
5 |
+
$wp_uploads = wp_upload_dir();
|
6 |
+
|
7 |
+
$default = PMXE_Plugin::get_default_import_options();
|
8 |
+
$exportOptions = (isset(PMXE_Plugin::$session->data['pmxe_export']) ? PMXE_Plugin::$session->data['pmxe_export'] : array()) + $default;
|
9 |
+
|
10 |
+
wp_reset_postdata();
|
11 |
+
|
12 |
+
$exportQuery = new WP_Query( array( 'post_type' => $exportOptions['cpt'], 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => -1 ));
|
13 |
+
|
14 |
+
ob_start();
|
15 |
+
|
16 |
+
switch ($exportOptions['export_to']) {
|
17 |
+
case 'xml':
|
18 |
+
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
19 |
+
|
20 |
+
?>
|
21 |
+
<data>
|
22 |
+
<?php
|
23 |
+
// The Loop
|
24 |
+
while ( $exportQuery->have_posts() ) :
|
25 |
+
|
26 |
+
$exportQuery->the_post();
|
27 |
+
|
28 |
+
$record = get_post( get_the_ID() );
|
29 |
+
|
30 |
+
?>
|
31 |
+
<post>
|
32 |
+
<post_type><?php echo get_post_type(); ?></post_type>
|
33 |
+
<?php if ($exportOptions['is_export_title']): ?><title><?php the_title(); ?></title><?php endif; ?>
|
34 |
+
|
35 |
+
<?php if ($exportOptions['is_export_content']): ?>
|
36 |
+
<content><?php echo '<![CDATA['; the_content(); echo ']]>'; ?></content>
|
37 |
+
<?php endif; ?>
|
38 |
+
|
39 |
+
<?php if ($exportOptions['is_export_custom_fields']): ?>
|
40 |
+
<custom_fields>
|
41 |
+
<?php foreach (get_post_custom($record->ID) as $cur_meta_key => $cur_meta_val): ?>
|
42 |
+
<?php if ( $exportOptions['export_custom_fields_logic'] == 'full_export' or ($exportOptions['export_custom_fields_logic'] == 'only' and in_array($cur_meta_key, $exportOptions['custom_fields_list']))): ?>
|
43 |
+
<<?php echo $cur_meta_key; ?>><?php echo '<![CDATA[' . ((!empty($cur_meta_val) and is_array($cur_meta_val) and count($cur_meta_val) == 1) ? $cur_meta_val[0] : serialize($cur_meta_val)) . ']]>'; ?></<?php echo $cur_meta_key;?>>
|
44 |
+
<?php endif; ?>
|
45 |
+
<?php endforeach; ?>
|
46 |
+
</custom_fields>
|
47 |
+
<?php endif; ?>
|
48 |
+
|
49 |
+
<?php if ($exportOptions['is_export_categories']): ?>
|
50 |
+
<taxonomies>
|
51 |
+
<?php
|
52 |
+
|
53 |
+
global $wp_taxonomies;
|
54 |
+
|
55 |
+
foreach ($wp_taxonomies as $key => $obj) {
|
56 |
+
|
57 |
+
if ($exportOptions['export_categories_logic'] == 'full_export' or ($exportOptions['export_categories_logic'] == 'only' and in_array($obj->name, $exportOptions['taxonomies_list'])))
|
58 |
+
{
|
59 |
+
$txes_list = get_the_terms($record->ID, $obj->name);
|
60 |
+
|
61 |
+
if ( ! is_wp_error($txes_list)) {
|
62 |
+
$txes_new = array();
|
63 |
+
if (!empty($txes_list)):
|
64 |
+
foreach ($txes_list as $t) {
|
65 |
+
$txes_new[] = $t->slug;
|
66 |
+
}
|
67 |
+
?>
|
68 |
+
<<?php echo $obj->name; ?>><?php echo implode(', ', $txes_new); ?></<?php echo $obj->name; ?>>
|
69 |
+
<?php
|
70 |
+
endif;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
?>
|
75 |
+
</taxonomies>
|
76 |
+
<?php endif; ?>
|
77 |
+
|
78 |
+
<?php if ($exportOptions['is_export_images'] and ! empty($exportOptions['export_images_logic'])): ?>
|
79 |
+
|
80 |
+
<media_gallery>
|
81 |
+
<?php
|
82 |
+
|
83 |
+
$attachment_imgs = get_posts( array(
|
84 |
+
'post_type' => 'attachment',
|
85 |
+
'posts_per_page' => -1,
|
86 |
+
'post_parent' => $record->ID,
|
87 |
+
) );
|
88 |
+
|
89 |
+
if ( ! empty($attachment_imgs)):
|
90 |
+
|
91 |
+
foreach ($attachment_imgs as $attach) {
|
92 |
+
if ( wp_attachment_is_image( $attach->ID ) ){
|
93 |
+
?>
|
94 |
+
<image>
|
95 |
+
<?php if (in_array('urls', $exportOptions['export_images_logic'])): ?><url><?php echo wp_get_attachment_url( $attach->ID ); ?></url><?php endif;?>
|
96 |
+
|
97 |
+
<?php if (in_array('meta_data', $exportOptions['export_images_logic'])): ?>
|
98 |
+
<title><?php echo esc_html($attach->post_title); ?></title>
|
99 |
+
<caption><?php echo esc_html($attach->post_excerpt); ?></caption>
|
100 |
+
<description><?php echo $attach->post_content;?></description>
|
101 |
+
<alt><?php echo get_post_meta($record->ID, '_wp_attachment_image_alt'); ?></alt>
|
102 |
+
<?php endif; ?>
|
103 |
+
</image>
|
104 |
+
<?php
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
endif;
|
109 |
+
|
110 |
+
?>
|
111 |
+
</media_gallery>
|
112 |
+
|
113 |
+
<?php endif; ?>
|
114 |
+
|
115 |
+
<?php if ($exportOptions['is_export_other']): ?>
|
116 |
+
|
117 |
+
<other_stuff>
|
118 |
+
|
119 |
+
<?php if ($exportOptions['is_export_dates']): ?><date><?php echo get_post_time('U', true); ?></date><?php endif; ?>
|
120 |
+
<?php if ($exportOptions['is_export_parent']): ?><parent><?php echo $record->post_parent; ?></parent><?php endif; ?>
|
121 |
+
<?php if ($exportOptions['is_export_template']): ?><template><?php echo get_post_meta($record->ID, '_wp_page_template', true); ?></template><?php endif; ?>
|
122 |
+
<?php if ($exportOptions['is_export_menu_order']): ?><menu_order><?php echo $record->menu_order; ?></menu_order><?php endif; ?>
|
123 |
+
<?php if ($exportOptions['is_export_status']): ?><status><?php echo $record->post_status; ?></status><?php endif; ?>
|
124 |
+
<?php if ($exportOptions['is_export_format']): ?><format><?php echo get_post_format($record->ID); ?></format><?php endif; ?>
|
125 |
+
<?php if ($exportOptions['is_export_author']): ?><author><?php echo $record->post_author; ?></author><?php endif; ?>
|
126 |
+
<?php if ($exportOptions['is_export_slug']): ?><slug><?php echo $record->guid; ?></slug><?php endif; ?>
|
127 |
+
<?php if ($exportOptions['is_export_excerpt']): ?><excerpt><?php echo $record->post_excerpt; ?></excerpt><?php endif; ?>
|
128 |
+
<?php if ($exportOptions['is_export_attachments']): ?>
|
129 |
+
<attachments>
|
130 |
+
<?php
|
131 |
+
|
132 |
+
$attachment_imgs = get_posts( array(
|
133 |
+
'post_type' => 'attachment',
|
134 |
+
'posts_per_page' => -1,
|
135 |
+
'post_parent' => $record->ID,
|
136 |
+
) );
|
137 |
+
|
138 |
+
if ( ! empty($attachment_imgs)):
|
139 |
+
|
140 |
+
foreach ($attachment_imgs as $attach) {
|
141 |
+
if ( ! wp_attachment_is_image( $attach->ID ) ){
|
142 |
+
?>
|
143 |
+
<attach>
|
144 |
+
<url><?php echo wp_get_attachment_url( $attach->ID ); ?></url>
|
145 |
+
</attach>
|
146 |
+
<?php
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
endif;
|
151 |
+
|
152 |
+
?>
|
153 |
+
</attachments>
|
154 |
+
<?php endif; ?>
|
155 |
+
|
156 |
+
</other_stuff>
|
157 |
+
|
158 |
+
<?php endif; ?>
|
159 |
+
|
160 |
+
</post>
|
161 |
+
|
162 |
+
<?php
|
163 |
+
endwhile;
|
164 |
+
?>
|
165 |
+
|
166 |
+
</data>
|
167 |
+
<?php
|
168 |
+
|
169 |
+
break;
|
170 |
+
case 'csv':
|
171 |
+
|
172 |
+
// Prepare headers
|
173 |
+
|
174 |
+
$headers = array();
|
175 |
+
|
176 |
+
$stream = fopen("php://output", 'w');
|
177 |
+
|
178 |
+
$max_attach_count = 0;
|
179 |
+
$max_images_count = 0;
|
180 |
+
|
181 |
+
$cf = array();
|
182 |
+
$taxes = array();
|
183 |
+
|
184 |
+
$articles = array();
|
185 |
+
|
186 |
+
while ( $exportQuery->have_posts() ) :
|
187 |
+
|
188 |
+
$attach_count = 0;
|
189 |
+
$images_count = 0;
|
190 |
+
|
191 |
+
$exportQuery->the_post();
|
192 |
+
|
193 |
+
$record = get_post( get_the_ID() );
|
194 |
+
|
195 |
+
$article = array();
|
196 |
+
|
197 |
+
$article['post_type'] = $record->post_type;
|
198 |
+
|
199 |
+
if ($exportOptions['is_export_title']) $article['title'] = get_the_title();
|
200 |
+
if ($exportOptions['is_export_content']) $article['content'] = get_the_content();
|
201 |
+
|
202 |
+
if ($exportOptions['is_export_other']):
|
203 |
+
if ($exportOptions['is_export_dates']) $article['date'] = get_post_time('U', true);
|
204 |
+
if ($exportOptions['is_export_parent']) $article['parent'] = $record->post_parent;
|
205 |
+
if ($exportOptions['is_export_template']) $article['template'] = get_post_meta($record->ID, '_wp_page_template', true);
|
206 |
+
if ($exportOptions['is_export_menu_order']) $article['menu_order'] = $record->menu_order;
|
207 |
+
if ($exportOptions['is_export_status']) $article['status'] = $record->post_status;
|
208 |
+
if ($exportOptions['is_export_format']) $article['format'] = get_post_format($record->ID);
|
209 |
+
if ($exportOptions['is_export_author']) $article['author'] = $record->post_author;
|
210 |
+
if ($exportOptions['is_export_slug']) $article['slug'] = $record->guid;
|
211 |
+
if ($exportOptions['is_export_excerpt']) $article['excerpt'] = $record->post_excerpt;
|
212 |
+
if ($exportOptions['is_export_attachments']):
|
213 |
+
$attachment_imgs = get_posts( array(
|
214 |
+
'post_type' => 'attachment',
|
215 |
+
'posts_per_page' => -1,
|
216 |
+
'post_parent' => $record->ID,
|
217 |
+
) );
|
218 |
+
|
219 |
+
if ( ! empty($attachment_imgs)):
|
220 |
+
|
221 |
+
foreach ($attachment_imgs as $key => $attach) {
|
222 |
+
if ( ! wp_attachment_is_image( $attach->ID ) ){
|
223 |
+
$article['attach_' . ($key + 1)] = wp_get_attachment_url( $attach->ID );
|
224 |
+
$attach_count++;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
if ($attach_count > $max_attach_count) $max_attach_count = $attach_count;
|
229 |
+
|
230 |
+
endif;
|
231 |
+
endif;
|
232 |
+
endif;
|
233 |
+
|
234 |
+
if ($exportOptions['is_export_custom_fields']):
|
235 |
+
|
236 |
+
foreach (get_post_custom($record->ID) as $cur_meta_key => $cur_meta_val):
|
237 |
+
if ( $exportOptions['export_custom_fields_logic'] == 'full_export' or ($exportOptions['export_custom_fields_logic'] == 'only' and in_array($cur_meta_key, $exportOptions['custom_fields_list']))):
|
238 |
+
$article['CF_' . $cur_meta_key] = ((!empty($cur_meta_val) and is_array($cur_meta_val) and count($cur_meta_val) == 1) ? $cur_meta_val[0] : serialize($cur_meta_val));
|
239 |
+
|
240 |
+
if (!in_array('CF_' . $cur_meta_key, $cf)) $cf[] = 'CF_' . $cur_meta_key;
|
241 |
+
|
242 |
+
endif;
|
243 |
+
endforeach;
|
244 |
+
|
245 |
+
endif;
|
246 |
+
|
247 |
+
if ($exportOptions['is_export_categories']):
|
248 |
+
|
249 |
+
global $wp_taxonomies;
|
250 |
+
|
251 |
+
foreach ($wp_taxonomies as $key => $obj) {
|
252 |
+
|
253 |
+
if ($exportOptions['export_categories_logic'] == 'full_export' or ($exportOptions['export_categories_logic'] == 'only' and in_array($obj->name, $exportOptions['taxonomies_list'])))
|
254 |
+
{
|
255 |
+
$txes_list = get_the_terms($record->ID, $obj->name);
|
256 |
+
|
257 |
+
if ( ! is_wp_error($txes_list)) {
|
258 |
+
$txes_new = array();
|
259 |
+
if (!empty($txes_list)):
|
260 |
+
foreach ($txes_list as $t) {
|
261 |
+
$txes_new[] = $t->slug;
|
262 |
+
}
|
263 |
+
$article['TX_' . $obj->name] = implode('|', $txes_new);
|
264 |
+
|
265 |
+
if (!in_array('TX_' . $obj->name, $taxes)) $taxes[] = 'TX_' . $obj->name;
|
266 |
+
|
267 |
+
endif;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
endif;
|
273 |
+
|
274 |
+
if ($exportOptions['is_export_images'] and ! empty($exportOptions['export_images_logic'])):
|
275 |
+
|
276 |
+
$attachment_imgs = get_posts( array(
|
277 |
+
'post_type' => 'attachment',
|
278 |
+
'posts_per_page' => -1,
|
279 |
+
'post_parent' => $record->ID,
|
280 |
+
) );
|
281 |
+
|
282 |
+
if ( ! empty($attachment_imgs)):
|
283 |
+
|
284 |
+
foreach ($attachment_imgs as $key => $attach) {
|
285 |
+
if ( wp_attachment_is_image( $attach->ID ) ){
|
286 |
+
if (in_array('urls', $exportOptions['export_images_logic'])) $article['image_url_' . ($key + 1)] = wp_get_attachment_url( $attach->ID );
|
287 |
+
|
288 |
+
if (in_array('meta_data', $exportOptions['export_images_logic'])):
|
289 |
+
$article['image_title_' . ($key + 1)] = $attach->post_title;
|
290 |
+
$article['image_caption_' . ($key + 1)] = $attach->post_excerpt;
|
291 |
+
$article['image_description_' . ($key + 1)] = $attach->post_content;
|
292 |
+
$article['image_alt_' . ($key + 1)] = get_post_meta($record->ID, '_wp_attachment_image_alt');
|
293 |
+
endif;
|
294 |
+
|
295 |
+
$images_count++;
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
if ($max_images_count > $images_count) $max_images_count = $images_count;
|
300 |
+
|
301 |
+
endif;
|
302 |
+
|
303 |
+
endif;
|
304 |
+
|
305 |
+
$articles[] = $article;
|
306 |
+
|
307 |
+
//fputcsv($stream, $article);
|
308 |
+
|
309 |
+
endwhile;
|
310 |
+
|
311 |
+
$headers[] = 'post_type';
|
312 |
+
|
313 |
+
if ($exportOptions['is_export_title']) $headers[] = 'title';
|
314 |
+
if ($exportOptions['is_export_content']) $headers[] = 'content';
|
315 |
+
|
316 |
+
if ($exportOptions['is_export_other']):
|
317 |
+
if ($exportOptions['is_export_dates']) $headers[] = 'date';
|
318 |
+
if ($exportOptions['is_export_parent']) $headers[] = 'parent';
|
319 |
+
if ($exportOptions['is_export_template']) $headers[] = 'template';
|
320 |
+
if ($exportOptions['is_export_menu_order']) $headers[] = 'menu_order';
|
321 |
+
if ($exportOptions['is_export_status']) $headers[] = 'status';
|
322 |
+
if ($exportOptions['is_export_format']) $headers[] = 'format';
|
323 |
+
if ($exportOptions['is_export_author']) $headers[] = 'author';
|
324 |
+
if ($exportOptions['is_export_slug']) $headers[] = 'slug';
|
325 |
+
if ($exportOptions['is_export_excerpt']) $headers[] = 'excerpt';
|
326 |
+
|
327 |
+
for ($i = 0; $i < $max_attach_count; $i++){
|
328 |
+
$headers[] = 'attach_' . ($i + 1);
|
329 |
+
}
|
330 |
+
|
331 |
+
endif;
|
332 |
+
|
333 |
+
if (!empty($cf)){
|
334 |
+
foreach ($cf as $cf_key) {
|
335 |
+
$headers[] = $cf_key;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
if (!empty($taxes)){
|
340 |
+
foreach ($taxes as $tx) {
|
341 |
+
$headers[] = $tx;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
for ($i = 0; $i < $max_images_count; $i++){
|
346 |
+
|
347 |
+
if (in_array('urls', $exportOptions['export_images_logic'])) $headers[] = 'image_url_' . ($i + 1);
|
348 |
+
|
349 |
+
if (in_array('meta_data', $exportOptions['export_images_logic'])):
|
350 |
+
$headers[] = 'image_title_' . ($i + 1);
|
351 |
+
$headers[] = 'image_caption_' . ($i + 1);
|
352 |
+
$headers[] = 'image_description_' . ($i + 1);
|
353 |
+
$headers[] = 'image_alt_' . ($i + 1);
|
354 |
+
endif;
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
fputcsv($stream, $headers);
|
359 |
+
|
360 |
+
foreach ($articles as $article) {
|
361 |
+
$line = array();
|
362 |
+
foreach ($headers as $header) {
|
363 |
+
$line[$header] = (!empty($article[$header])) ? $article[$header] : '';
|
364 |
+
}
|
365 |
+
fputcsv($stream, $line);
|
366 |
+
}
|
367 |
+
|
368 |
+
break;
|
369 |
+
|
370 |
+
default:
|
371 |
+
# code...
|
372 |
+
break;
|
373 |
+
}
|
374 |
+
|
375 |
+
wp_reset_postdata();
|
376 |
+
|
377 |
+
$export_file = $wp_uploads['path'] . '/' . time() . '.' . $exportOptions['export_to'];
|
378 |
+
|
379 |
+
if (@file_exists($export_file)) @unlink($export_file);
|
380 |
+
|
381 |
+
file_put_contents($export_file, ob_get_clean());
|
382 |
+
|
383 |
+
if ( file_exists($export_file)){
|
384 |
+
$wp_filetype = wp_check_filetype(basename($export_file), null );
|
385 |
+
$attachment_data = array(
|
386 |
+
'guid' => $wp_uploads['baseurl'] . '/' . _wp_relative_upload_path( $export_file ),
|
387 |
+
'post_mime_type' => $wp_filetype['type'],
|
388 |
+
'post_title' => preg_replace('/\.[^.]+$/', '', basename($export_file)),
|
389 |
+
'post_content' => '',
|
390 |
+
'post_status' => 'inherit'
|
391 |
+
);
|
392 |
+
$attach_id = wp_insert_attachment( $attachment_data, $export_file );
|
393 |
+
}
|
394 |
+
|
395 |
+
PMXE_Plugin::$session['pmxe_export']['export_file'] = $export_file;
|
396 |
+
|
397 |
+
pmxe_session_commit();
|
398 |
+
|
399 |
+
exit(json_encode(array('file' => $export_file))); die;
|
400 |
+
|
401 |
+
}
|
402 |
+
|
403 |
+
?>
|
actions/wp_loaded.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_wp_loaded() {
|
4 |
+
|
5 |
+
|
6 |
+
}
|
actions/wp_session_garbage_collection.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function pmxe_wp_session_garbage_collection() {
|
4 |
+
global $wpdb;
|
5 |
+
|
6 |
+
if ( defined( 'WP_SETUP_CONFIG' ) ) {
|
7 |
+
return;
|
8 |
+
}
|
9 |
+
|
10 |
+
$session_mode = PMXE_Plugin::getInstance()->getOption('session_mode');
|
11 |
+
|
12 |
+
if ( ! defined( 'WP_INSTALLING' ) ) {
|
13 |
+
if ($session_mode == 'database'){
|
14 |
+
$expiration_keys = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE '_pmxe_session_expires_%'" );
|
15 |
+
|
16 |
+
$now = time();
|
17 |
+
$expired_sessions = array();
|
18 |
+
|
19 |
+
foreach( $expiration_keys as $expiration ) {
|
20 |
+
// If the session has expired
|
21 |
+
if ( $now > intval( $expiration->option_value ) ) {
|
22 |
+
// Get the session ID by parsing the option_name
|
23 |
+
$session_id = str_replace("_PMXE_session_expires_", "", $expiration->option_name);
|
24 |
+
|
25 |
+
$expired_sessions[] = $expiration->option_name;
|
26 |
+
$expired_sessions[] = "_PMXE_session_$session_id";
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
// Delete all expired sessions in a single query
|
31 |
+
if ( ! empty( $expired_sessions ) ) {
|
32 |
+
$option_names = implode( "','", $expired_sessions );
|
33 |
+
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name IN ('$option_names')" );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
elseif ($session_mode == 'files'){
|
37 |
+
$session_files = scandir( PMXE_ROOT_DIR . '/sessions');
|
38 |
+
|
39 |
+
if (!empty($session_files)){
|
40 |
+
$now = time();
|
41 |
+
$expired_sessions = array();
|
42 |
+
foreach ($session_files as $key => $file) {
|
43 |
+
if ( strpos($file, "_pmxe_session_expires_") !== false){
|
44 |
+
$expiration_value = @file_get_contents( PMXE_ROOT_DIR . "/sessions/" . $file );
|
45 |
+
|
46 |
+
if ($now > intval($expiration_value)){
|
47 |
+
$session_id = str_replace("_pmxe_session_expires_", "", $file);
|
48 |
+
$expired_sessions[] = $file;
|
49 |
+
$expired_sessions[] = "_pmxe_session_$session_id";
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
// Delete all expired sessions in a single query
|
54 |
+
if ( ! empty( $expired_sessions ) ) {
|
55 |
+
foreach ($expired_sessions as $key => $file) {
|
56 |
+
@unlink( PMXE_ROOT_DIR . "/sessions/" . $file );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
// Allow other plugins to hook in to the garbage collection process.
|
64 |
+
do_action( 'PMXE_session_cleanup' );
|
65 |
+
}
|
banner-772x250.png
ADDED
Binary file
|
classes/arrayaccess.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Multidimensional ArrayAccess
|
4 |
+
*
|
5 |
+
* Allows ArrayAccess-like functionality with multidimensional arrays. Fully supports
|
6 |
+
* both sets and unsets.
|
7 |
+
*
|
8 |
+
* @package WordPress
|
9 |
+
* @subpackage Session
|
10 |
+
* @since 3.7.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Recursive array class to allow multidimensional array access.
|
15 |
+
*
|
16 |
+
* @package WordPress
|
17 |
+
* @since 3.7.0
|
18 |
+
*/
|
19 |
+
class PMXE_ArrayAccess implements ArrayAccess {
|
20 |
+
/**
|
21 |
+
* Internal data collection.
|
22 |
+
*
|
23 |
+
* @var array
|
24 |
+
*/
|
25 |
+
public $container = array();
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Flag whether or not the internal collection has been changed.
|
29 |
+
*
|
30 |
+
* @var bool
|
31 |
+
*/
|
32 |
+
protected $dirty = false;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Default object constructor.
|
36 |
+
*
|
37 |
+
* @param array $data
|
38 |
+
*/
|
39 |
+
protected function __construct( $data = array() ) {
|
40 |
+
foreach ( $data as $key => $value ) {
|
41 |
+
$this[ $key ] = $value;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Allow deep copies of objects
|
47 |
+
*/
|
48 |
+
public function __clone() {
|
49 |
+
foreach ( $this->container as $key => $value ) {
|
50 |
+
if ( $value instanceof self ) {
|
51 |
+
$this[ $key ] = clone $value;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Output the data container as a multidimensional array.
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function toArray() {
|
62 |
+
$data = $this->container;
|
63 |
+
if (!empty($data)){
|
64 |
+
foreach ( $data as $key => $value ) {
|
65 |
+
if ( $value instanceof self ) {
|
66 |
+
$data[ $key ] = $value->toArray();
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return $data;
|
71 |
+
}
|
72 |
+
|
73 |
+
/*****************************************************************/
|
74 |
+
/* ArrayAccess Implementation */
|
75 |
+
/*****************************************************************/
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Whether a offset exists
|
79 |
+
*
|
80 |
+
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
81 |
+
*
|
82 |
+
* @param mixed $offset An offset to check for.
|
83 |
+
*
|
84 |
+
* @return boolean true on success or false on failure.
|
85 |
+
*/
|
86 |
+
public function offsetExists( $offset ) {
|
87 |
+
return isset( $this->container[ $offset ]) ;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Offset to retrieve
|
92 |
+
*
|
93 |
+
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
94 |
+
*
|
95 |
+
* @param mixed $offset The offset to retrieve.
|
96 |
+
*
|
97 |
+
* @return mixed Can return all value types.
|
98 |
+
*/
|
99 |
+
public function offsetGet( $offset ) {
|
100 |
+
return isset( $this->container[ $offset ] ) ? $this->container[ $offset ] : null;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Offset to set
|
105 |
+
*
|
106 |
+
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
107 |
+
*
|
108 |
+
* @param mixed $offset The offset to assign the value to.
|
109 |
+
* @param mixed $value The value to set.
|
110 |
+
*
|
111 |
+
* @return void
|
112 |
+
*/
|
113 |
+
public function offsetSet( $offset, $data ) {
|
114 |
+
if ( is_array( $data ) ) {
|
115 |
+
$data = new self( $data );
|
116 |
+
}
|
117 |
+
if ( $offset === null ) { // don't forget this!
|
118 |
+
$this->container[] = $data;
|
119 |
+
} else {
|
120 |
+
$this->container[ $offset ] = $data;
|
121 |
+
}
|
122 |
+
|
123 |
+
$this->dirty = true;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Offset to unset
|
128 |
+
*
|
129 |
+
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
130 |
+
*
|
131 |
+
* @param mixed $offset The offset to unset.
|
132 |
+
*
|
133 |
+
* @return void
|
134 |
+
*/
|
135 |
+
public function offsetUnset( $offset ) {
|
136 |
+
unset( $this->container[ $offset ] );
|
137 |
+
|
138 |
+
$this->dirty = true;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
?>
|
classes/config.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class to load config files
|
4 |
+
*
|
5 |
+
* @author Pavel Kulbakin <p.kulbakin@gmail.com>
|
6 |
+
*/
|
7 |
+
class PMXE_Config implements IteratorAggregate {
|
8 |
+
/**
|
9 |
+
* Config variables stored
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
protected $config = array();
|
13 |
+
/**
|
14 |
+
* List of loaded files in order to avoid loading same file several times
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
protected $loaded = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Static method to create config instance from file on disc
|
21 |
+
* @param string $filePath
|
22 |
+
* @param string[optional] $section
|
23 |
+
* @return PMXE_Config
|
24 |
+
*/
|
25 |
+
public static function createFromFile($filePath, $section = NULL) {
|
26 |
+
$config = new self();
|
27 |
+
return $config->loadFromFile($filePath, $section);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Load config file
|
32 |
+
* @param string $filePath
|
33 |
+
* @param string[optional] $section
|
34 |
+
* @return PMXE_Config
|
35 |
+
*/
|
36 |
+
public function loadFromFile($filePath, $section = NULL) {
|
37 |
+
if ( ! is_null($section)) {
|
38 |
+
$this->config[$section] = self::createFromFile($filePath);
|
39 |
+
} else {
|
40 |
+
$filePath = realpath($filePath);
|
41 |
+
if ($filePath and ! in_array($filePath, $this->loaded)) {
|
42 |
+
require $filePath;
|
43 |
+
|
44 |
+
$sandbox = create_function('', "require '$filePath'; if(array_keys(get_defined_vars()) != array('config')) return array(); return \$config;");
|
45 |
+
$config = $sandbox();
|
46 |
+
$this->loaded[] = $filePath;
|
47 |
+
$this->config = array_merge($this->config, $config);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* Return value of setting with specified name
|
54 |
+
* @param string $field Setting name
|
55 |
+
* @param string[optional] $section Section name to look setting in
|
56 |
+
* @return mixed
|
57 |
+
*/
|
58 |
+
public function get($field, $section = NULL) {
|
59 |
+
return ! is_null($section) ? $this->config[$section]->get($field) : $this->config[$field];
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Magic method for checking whether some config option are set
|
64 |
+
* @param string $field
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function __isset($field) {
|
68 |
+
return isset($this->config[$field]);
|
69 |
+
}
|
70 |
+
/**
|
71 |
+
* Magic method to implement object-like access to config parameters
|
72 |
+
* @param string $field
|
73 |
+
* @return mixed
|
74 |
+
*/
|
75 |
+
public function __get($field) {
|
76 |
+
return $this->config[$field];
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Return all config options as array
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function toArray($section = NULL) {
|
84 |
+
return ! is_null($section) ? $this->config[$section]->toArray() : $this->config;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getIterator() {
|
88 |
+
return new ArrayIterator($this->config);
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
classes/download.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class PMXE_Download
|
4 |
+
{
|
5 |
+
|
6 |
+
static public function zip($file_name)
|
7 |
+
{
|
8 |
+
|
9 |
+
header('Content-type: application/zip');
|
10 |
+
header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");
|
11 |
+
readfile($file_name);
|
12 |
+
die;
|
13 |
+
}
|
14 |
+
|
15 |
+
static public function xls($file_name)
|
16 |
+
{
|
17 |
+
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
|
18 |
+
header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");
|
19 |
+
readfile($file_name);
|
20 |
+
die;
|
21 |
+
}
|
22 |
+
|
23 |
+
static public function csv($file_name)
|
24 |
+
{
|
25 |
+
header("Content-Type: text/plain; charset=UTF-8");
|
26 |
+
header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");
|
27 |
+
readfile($file_name);
|
28 |
+
die;
|
29 |
+
}
|
30 |
+
|
31 |
+
static public function xml($file_name)
|
32 |
+
{
|
33 |
+
header("Content-Type: application/xhtml+xml; charset=UTF-8");
|
34 |
+
header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");
|
35 |
+
readfile($file_name);
|
36 |
+
die;
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
classes/helper.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Helper class which defnes a namespace for some commonly used functions
|
4 |
+
*
|
5 |
+
* @author Pavel Kulbakin <p.kulbakin@gmail.com>
|
6 |
+
*/
|
7 |
+
class PMXE_Helper {
|
8 |
+
const GLOB_MARK = 1;
|
9 |
+
const GLOB_NOSORT = 2;
|
10 |
+
const GLOB_ONLYDIR = 4;
|
11 |
+
|
12 |
+
const GLOB_NODIR = 256;
|
13 |
+
const GLOB_PATH = 512;
|
14 |
+
const GLOB_NODOTS = 1024;
|
15 |
+
const GLOB_RECURSE = 2048;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* A safe empowered glob().
|
19 |
+
*
|
20 |
+
* Function glob() is prohibited on some server (probably in safe mode)
|
21 |
+
* (Message "Warning: glob() has been disabled for security reasons in
|
22 |
+
* (script) on line (line)") for security reasons as stated on:
|
23 |
+
* http://seclists.org/fulldisclosure/2005/Sep/0001.html
|
24 |
+
*
|
25 |
+
* safe_glob() intends to replace glob() using readdir() & fnmatch() instead.
|
26 |
+
* Supported flags: self::GLOB_MARK, self::GLOB_NOSORT, self::GLOB_ONLYDIR
|
27 |
+
* Additional flags: self::GLOB_NODIR, self::GLOB_PATH, self::GLOB_NODOTS, self::GLOB_RECURSE
|
28 |
+
* (not original glob() flags)
|
29 |
+
* @author BigueNique AT yahoo DOT ca
|
30 |
+
* @updates
|
31 |
+
* - 080324 Added support for additional flags: self::GLOB_NODIR, self::GLOB_PATH,
|
32 |
+
* self::GLOB_NODOTS, self::GLOB_RECURSE
|
33 |
+
* - 100607 Recurse is_dir check fixed by Pavel Kulbakin <p.kulbakin@gmail.com>
|
34 |
+
*/
|
35 |
+
public static function safe_glob($pattern, $flags=0) {
|
36 |
+
$split = explode('/', str_replace('\\', '/', $pattern));
|
37 |
+
$mask = array_pop($split);
|
38 |
+
$path = implode('/', $split);
|
39 |
+
|
40 |
+
if (($dir = @opendir($path . '/')) !== false or ($dir = @opendir($path)) !== false) {
|
41 |
+
$glob = array();
|
42 |
+
while(($file = readdir($dir)) !== false) {
|
43 |
+
// Recurse subdirectories (self::GLOB_RECURSE)
|
44 |
+
if (($flags & self::GLOB_RECURSE) && is_dir($path . '/' . $file) && ( ! in_array($file, array('.', '..')))) {
|
45 |
+
$glob = array_merge($glob, self::array_prepend(self::safe_glob($path . '/' . $file . '/' . $mask, $flags), ($flags & self::GLOB_PATH ? '' : $file . '/')));
|
46 |
+
}
|
47 |
+
// Match file mask
|
48 |
+
if (self::fnmatch($mask, $file, FNM_CASEFOLD)) {
|
49 |
+
if ((( ! ($flags & self::GLOB_ONLYDIR)) || is_dir("$path/$file"))
|
50 |
+
&& (( ! ($flags & self::GLOB_NODIR)) || ( ! is_dir($path . '/' . $file)))
|
51 |
+
&& (( ! ($flags & self::GLOB_NODOTS)) || ( ! in_array($file, array('.', '..'))))
|
52 |
+
) {
|
53 |
+
$glob[] = ($flags & self::GLOB_PATH ? $path . '/' : '') . $file . ($flags & self::GLOB_MARK ? '/' : '');
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
closedir($dir);
|
58 |
+
if ( ! ($flags & self::GLOB_NOSORT)) sort($glob);
|
59 |
+
return $glob;
|
60 |
+
} else {
|
61 |
+
return (strpos($pattern, "*") === false) ? array($pattern) : false;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Prepends $string to each element of $array
|
67 |
+
* If $deep is true, will indeed also apply to sub-arrays
|
68 |
+
* @author BigueNique AT yahoo DOT ca
|
69 |
+
* @since 080324
|
70 |
+
*/
|
71 |
+
public static function array_prepend($array, $string, $deep=false) {
|
72 |
+
if(empty($array)||empty($string)) {
|
73 |
+
return $array;
|
74 |
+
}
|
75 |
+
foreach ($array as $key => $element) {
|
76 |
+
if (is_array($element)) {
|
77 |
+
if ($deep) {
|
78 |
+
$array[$key] = self::array_prepend($element,$string,$deep);
|
79 |
+
} else {
|
80 |
+
trigger_error(__METHOD__ . ': array element', E_USER_WARNING);
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
$array[$key] = $string.$element;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $array;
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
const FNM_PATHNAME = 1;
|
91 |
+
const FNM_NOESCAPE = 2;
|
92 |
+
const FNM_PERIOD = 4;
|
93 |
+
const FNM_CASEFOLD = 16;
|
94 |
+
|
95 |
+
/**
|
96 |
+
* non-POSIX complient remplacement for the fnmatch
|
97 |
+
*/
|
98 |
+
public static function fnmatch($pattern, $string, $flags = 0) {
|
99 |
+
|
100 |
+
$modifiers = null;
|
101 |
+
$transforms = array(
|
102 |
+
'\*' => '.*',
|
103 |
+
'\?' => '.',
|
104 |
+
'\[\!' => '[^',
|
105 |
+
'\[' => '[',
|
106 |
+
'\]' => ']',
|
107 |
+
'\.' => '\.',
|
108 |
+
'\\' => '\\\\',
|
109 |
+
'\-' => '-',
|
110 |
+
);
|
111 |
+
|
112 |
+
// Forward slash in string must be in pattern:
|
113 |
+
if ($flags & FNM_PATHNAME) {
|
114 |
+
$transforms['\*'] = '[^/]*';
|
115 |
+
}
|
116 |
+
|
117 |
+
// Back slash should not be escaped:
|
118 |
+
if ($flags & FNM_NOESCAPE) {
|
119 |
+
unset($transforms['\\']);
|
120 |
+
}
|
121 |
+
|
122 |
+
// Perform case insensitive match:
|
123 |
+
if ($flags & FNM_CASEFOLD) {
|
124 |
+
$modifiers .= 'i';
|
125 |
+
}
|
126 |
+
|
127 |
+
// Period at start must be the same as pattern:
|
128 |
+
if ($flags & FNM_PERIOD) {
|
129 |
+
if (strpos($string, '.') === 0 && strpos($pattern, '.') !== 0) return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
$pattern = '#^'
|
133 |
+
.strtr(preg_quote($pattern, '#'), $transforms)
|
134 |
+
.'$#'
|
135 |
+
.$modifiers;
|
136 |
+
|
137 |
+
return (boolean)preg_match($pattern, $string);
|
138 |
+
}
|
139 |
+
}
|
classes/input.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PMXE_Input {
|
3 |
+
protected $filters = array('stripslashes');
|
4 |
+
|
5 |
+
public function read($inputArray, $paramName, $default = NULL) {
|
6 |
+
if (is_array($paramName) and ! is_null($default)) {
|
7 |
+
throw new Exception('Either array of parameter names with default values as the only argument or param name and default value as seperate arguments are expected.');
|
8 |
+
}
|
9 |
+
if (is_array($paramName)) {
|
10 |
+
foreach ($paramName as $param => $def) {
|
11 |
+
if (isset($inputArray[$param])) {
|
12 |
+
$paramName[$param] = $this->applyFilters($inputArray[$param]);
|
13 |
+
}
|
14 |
+
}
|
15 |
+
return $paramName;
|
16 |
+
} else {
|
17 |
+
return isset($inputArray[$paramName]) ? $this->applyFilters($inputArray[$paramName]) : $default;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
public function get($paramName, $default = NULL) {
|
22 |
+
return $this->read($_GET, $paramName, $default);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function post($paramName, $default = NULL) {
|
26 |
+
return $this->read($_POST, $paramName, $default);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function cookie($paramName, $default = NULL) {
|
30 |
+
return $this->read($_COOKIE, $paramName, $default);
|
31 |
+
}
|
32 |
+
|
33 |
+
public function request($paramName, $default = NULL) {
|
34 |
+
return $this->read($_GET + $_POST + $_COOKIE, $paramName, $default);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getpost($paramName, $default = NULL) {
|
38 |
+
return $this->read($_GET + $_POST, $paramName, $default);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function server($paramName, $default = NULL) {
|
42 |
+
return $this->read($_SERVER, $paramName, $default);
|
43 |
+
}
|
44 |
+
|
45 |
+
public function addFilter($callback) {
|
46 |
+
if ( ! is_callable($callback)) {
|
47 |
+
throw new Exception(get_class($this) . '::' . __METHOD__ . ' parameter must be a proper callback function reference.');
|
48 |
+
}
|
49 |
+
if ( ! in_array($callback, $this->filters)) {
|
50 |
+
$this->filters[] = $callback;
|
51 |
+
}
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function removeFilter($callback) {
|
56 |
+
$this->filters = array_diff($this->filters, array($callback));
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function applyFilters($val) {
|
61 |
+
if (is_array($val)) {
|
62 |
+
foreach ($val as $k => $v) {
|
63 |
+
$val[$k] = $this->applyFilters($v);
|
64 |
+
}
|
65 |
+
} else {
|
66 |
+
foreach ($this->filters as $filter) {
|
67 |
+
$val = call_user_func($filter, $val);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return $val;
|
71 |
+
}
|
72 |
+
}
|
classes/session.php
ADDED
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WordPress session managment.
|
4 |
+
*
|
5 |
+
* Standardizes WordPress session data using database-backed options for storage.
|
6 |
+
* for storing user session information.
|
7 |
+
*
|
8 |
+
* @package WordPress
|
9 |
+
* @subpackage Session
|
10 |
+
* @since 3.7.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* WordPress Session class for managing user session data.
|
15 |
+
*
|
16 |
+
* @package WordPress
|
17 |
+
* @since 3.7.0
|
18 |
+
*/
|
19 |
+
final class PMXE_Session extends PMXE_ArrayAccess implements Iterator, Countable {
|
20 |
+
/**
|
21 |
+
* ID of the current session.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
protected $session_id;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Unix timestamp when session expires.
|
29 |
+
*
|
30 |
+
* @var int
|
31 |
+
*/
|
32 |
+
protected $expires;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Unix timestamp indicating when the expiration time needs to be reset.
|
36 |
+
*
|
37 |
+
* @var int
|
38 |
+
*/
|
39 |
+
protected $exp_variant;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Singleton instance.
|
43 |
+
*
|
44 |
+
* @var bool|WP_Session
|
45 |
+
*/
|
46 |
+
private static $instance = false;
|
47 |
+
|
48 |
+
public $data = array();
|
49 |
+
|
50 |
+
public $session_mode = '';
|
51 |
+
/**
|
52 |
+
* Retrieve the current session instance.
|
53 |
+
*
|
54 |
+
* @param bool $session_id Session ID from which to populate data.
|
55 |
+
*
|
56 |
+
* @return bool|WP_Session
|
57 |
+
*/
|
58 |
+
public static function get_instance() {
|
59 |
+
if ( ! self::$instance ) {
|
60 |
+
self::$instance = new self();
|
61 |
+
}
|
62 |
+
|
63 |
+
return self::$instance;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Default constructor.
|
68 |
+
* Will rebuild the session collection from the given session ID if it exists. Otherwise, will
|
69 |
+
* create a new session with that ID.
|
70 |
+
*
|
71 |
+
* @param $session_id
|
72 |
+
* @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire.
|
73 |
+
*/
|
74 |
+
protected function __construct() {
|
75 |
+
|
76 |
+
$this->session_mode = PMXE_Plugin::getInstance()->getOption('session_mode');
|
77 |
+
|
78 |
+
if ($this->session_mode != 'default'){
|
79 |
+
|
80 |
+
if ( isset( $_COOKIE[PMXE_SESSION_COOKIE] ) ) {
|
81 |
+
|
82 |
+
$cookie = stripslashes( $_COOKIE[PMXE_SESSION_COOKIE] );
|
83 |
+
$cookie_crumbs = explode( '||', $cookie );
|
84 |
+
|
85 |
+
$this->session_id = (!empty($cookie_crumbs[0])) ? $cookie_crumbs[0] : $this->generate_id();
|
86 |
+
$this->expires = $cookie_crumbs[1];
|
87 |
+
$this->exp_variant = $cookie_crumbs[2];
|
88 |
+
|
89 |
+
// Update the session expiration if we're past the variant time
|
90 |
+
if ( time() > $this->exp_variant ) {
|
91 |
+
$this->set_expiration();
|
92 |
+
if ($this->session_mode == 'database'){
|
93 |
+
update_option( "_pmxi_session_expires_{$this->session_id}", $this->expires );
|
94 |