Plugin Directory

Changeset 3267685


Ignore:
Timestamp:
04/07/2025 07:53:30 AM (12 months ago)
Author:
arture
Message:

Version 4.1.4

Location:
storecontrl-wp-connection/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • storecontrl-wp-connection/trunk/includes/admin/class-storecontrl-wp-connection-admin.php

    r3258641 r3267685  
    1010        $plugin_basename = STORECONTRL_WP_CONNECTION_PLUGIN_BASENAME;
    1111        add_filter( "plugin_action_links_$plugin_basename", array( $this, 'plugin_add_settings_link') );
    12 
    13         if(isset($_POST['btnDownloadLog'])) {
    14             $this->downloadLogFile();
    15         }
    16     }
     12        add_filter('cron_schedules', array( $this, 'storecontrl_connect_cron_schedules') );
     13        add_action('admin_post_download_log', array($this, 'handle_log_download_request'));
     14    }
     15
     16    public function handle_log_download_request() {
     17        if (
     18            isset($_POST['btnDownloadLog']) &&
     19            current_user_can('manage_options') &&
     20            check_admin_referer('download_log_action', 'download_log_nonce')
     21        ) {
     22            $this->downloadLogFile();
     23        }
     24    }
     25
     26    public function downloadLogFile() {
     27        if ( ! current_user_can( 'manage_options' ) ) {
     28            wp_die( 'Unauthorized', '403 Forbidden', array( 'response' => 403 ) );
     29        }
     30
     31        $filename = isset($_POST['btnDownloadLog']) ? sanitize_file_name($_POST['btnDownloadLog']) : '';
     32
     33        $basedir = wp_upload_dir();
     34        $log_dir = $basedir['basedir'] . '/storecontrl/logs/';
     35        $full_path = realpath( $log_dir . $filename );
     36
     37        if (
     38            ! $full_path ||
     39            strpos($full_path, realpath($log_dir)) !== 0 ||
     40            ! file_exists($full_path)
     41        ) {
     42            wp_die( 'Invalid file requested.', '403 Forbidden', array( 'response' => 403 ) );
     43        }
     44
     45        header('Content-Description: File Transfer');
     46        header('Content-Type: application/octet-stream');
     47        header('Content-Disposition: attachment; filename="' . basename($full_path) . '"');
     48        header('Expires: 0');
     49        header('Cache-Control: must-revalidate');
     50        header('Pragma: public');
     51        header('Content-Length: ' . filesize($full_path));
     52        readfile($full_path);
     53        exit;
     54    }
     55
     56    public function storecontrl_connect_cron_schedules($schedules)
     57    {
     58        if (!isset($schedules['storecontrl_connect'])) {
     59            $schedules['storecontrl_connect'] = array(
     60                'interval' => 300,
     61                'display'  => 'StoreContrl Connect | Every 5 minutes'
     62            );
     63        }
     64        return $schedules;
     65    }
    1766
    1867    public function plugin_add_settings_link( $links ) {
     
    404453        $selectBox .= "</select>";
    405454
    406         // Display the form for selecting and downloading log files
    407         echo "<form method='post' action='class-storecontrl-wp-connection-admin.php'>" . $selectBox . "<button type='submit' class='button button-primary' id='btnDownloadLog' name='btnDownloadLog' value='" . $firstReadFile . "' style='margin-left: 10px;'>".__('Download Log File', 'storecontrl-wp-connection-plugin')."</button>";
     455        echo $selectBox;
     456
     457        echo '<input type="hidden" name="action" value="download_log">';
     458        echo '<input id="btnDownloadLog" type="hidden" name="btnDownloadLog" value="' . $firstReadFile . '">';
     459        echo wp_nonce_field( 'download_log_action', 'download_log_nonce' );
     460        echo '<button style="margin-left: 10px;" type="submit" class="button button-primary">Download Log File</button>';
    408461
    409462        // Make some space
     
    11731226    }
    11741227
    1175     public function downloadLogFile() {
    1176         // Get information from the button
    1177         $basedir        = wp_upload_dir();
    1178         $directory  = $basedir['basedir'];
    1179         $directory  = $directory . '/storecontrl/logs';
    1180         $file = sanitize_text_field($_POST['btnDownloadLog']);
    1181         $file = $directory . "/" . $file;
    1182 
    1183         header('Content-Description: File Transfer');
    1184         header('Content-Type: application/octet-stream');
    1185         header('Content-Disposition: attachment; filename="'.basename($file).'"');
    1186         header('Expires: 0');
    1187         header('Cache-Control: must-revalidate');
    1188         header('Pragma: public');
    1189         header('Content-Length: ' . filesize($file));
    1190         readfile($file);
    1191         exit;
    1192     }
    1193 
    11941228    public function resend_new_order_to_storecontrl() {
    11951229        if (isset($_POST['order_id'])) {
  • storecontrl-wp-connection/trunk/includes/admin/partials/storecontrl_wp_connection_settings_page.php

    r2868726 r3267685  
    7676
    7777        <div role="tabpanel" class="tab-pane fade" id="debug_section">
    78             <form method='post' action='options.php'>
     78            <form method='post' action="<?php echo admin_url('admin-post.php'); ?>">
    7979                <?php
    8080                settings_fields( 'storecontrl_debug_options' );
  • storecontrl-wp-connection/trunk/includes/woocommerce/class-storecontrl-woocommerce-functions.php

    r3226914 r3267685  
    888888            }
    889889
    890             //$order    = wc_get_order( $post->ID );
    891890            if (strlen(get_post_meta($order_id, 'order_returned_successfully_to_storecontrl', true)) > 0) {
    892891                //ORDER HAS BEEN SENT TO STORECONTRL
  • storecontrl-wp-connection/trunk/readme.txt

    r3258641 r3267685  
    55Requires at least: 1.6.1
    66Tested up to: 6.7.2
    7 Stable tag: 4.1.3
     7Stable tag: 4.1.4
    88Requires PHP: 0.0
    99License: GPLv2 or later
     
    9393== Changelog ==
    9494
     95= 4.1.4 =
     96* Improved and secure log file download function
     97
    9598= 4.1.3 =
    9699* New feature for cronjobs status
  • storecontrl-wp-connection/trunk/storecontrl-wp-connection.php

    r3258641 r3267685  
    44Plugin URI:  http://www.arture.nl/storecontrl
    55Description: The Wordpress plugin for connecting Woocommerce with StoreContrl Cloud. With the synchronizing cronjobs your products will be automatically processed, images added, and the categories set. Every 5 minutes all stock changes are processed. We provide a up-to-date plugin, easy setup and always the best support.
    6 Version:     4.1.3
     6Version:     4.1.4
    77Requires Plugins: woocommerce
    88Author:      Arture
Note: See TracChangeset for help on using the changeset viewer.