Plugin Directory

Changeset 2482785

Timestamp:
02/27/2021 08:12:38 PM (3 years ago)
Author:
mavit
Message:

Security fixes, english lang added

Location:
deliveo/trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • deliveo/trunk/inc/deliveo-api.class.php

    r2373889 r2482785  
    7878    public function session_start()
    7979    {
    80         session_start();
     80        if(!session_id()) {
     81            session_start();
     82        }
    8183    }
    8284}
  • deliveo/trunk/inc/deliveo-filter.class.php

    r2464819 r2482785  
    2727        $deliveo_api = new Deliveo_API(new MAV_IT_Deliveo_Settings());
    2828        $options = new MAV_IT_Deliveo_Settings();
    29         // var_dump($options);
    3029        $shipping_options = $deliveo_api->get_shipping_options();
    3130
     
    4948    public function add_deliveo_columns_header($columns)
    5049    {
    51 
    5250        $new_columns = array();
    5351        $index = 0;
     
    8482                $opts = json_decode(get_option('mav_it_deliveo_settings'))->shipping_options;
    8583                echo "<input type='hidden' name='order[" . $post->ID . "][id]' value='" . $post->ID . "'>";
    86                 echo '<select data-id="' . $post->ID . '" style="max-width:100%" name="order[' . $post->ID . '][option]" title="Válasszon szállítási módot">';
     84                echo '<select data-id="' . $post->ID . '" style="max-width:100%" name="order[' . $post->ID . '][option]" title="">';
    8785                foreach ($opts as $option) {
    8886                    if ($deliveo_api->api_settings_obj->deliveo_settings["delivery"] == $option->value) {
     
    107105        if ($column == 'packaging_unit') {
    108106            $exported = get_metadata('post', $post->ID, '_deliveo_exported', true);
    109            
     107
    110108            $packaking_unit = json_decode(get_option('mav_it_deliveo_settings'))->packaging_unit;
    111109            if ($exported != 'true') {
     
    131129    public function not_exported_products_filter($post_type)
    132130    {
    133         if (isset($_GET['post_type'])) {
    134             $post_type = $_GET['post_type'];
    135         }
     131        $post_type = Deliveo_Request_Filter::getInstance()
     132            ->getPostType(INPUT_GET, 'post_type');
    136133
    137134        $selected_1 = '';
    138135        $selected_2 = '';
    139136
    140         if (isset($_GET['deliveo_exported'])) {
    141             switch ($_GET['deliveo_exported']) {
     137        $deliveoExported = Deliveo_Request_Filter::getInstance()
     138            ->getDeliveoExported(INPUT_GET, 'deliveo_exported');
     139        if ($deliveoExported !== null) {
     140            switch ($deliveoExported) {
    142141                case 'not_exported':
    143142                    $selected_1 = 'selected';
     
    165164        $meta_key_query = array();
    166165
    167         if ($query->is_admin && $pagenow == 'edit.php' && isset($_GET['deliveo_exported']) && $_GET['deliveo_exported'] != '' && $_GET['post_type'] == 'shop_order') {
    168             switch ($_GET['deliveo_exported']) {
     166        $postType = Deliveo_Request_Filter::getInstance()
     167            ->getPostType(INPUT_GET, 'post_type');
     168        $deliveoExported = Deliveo_Request_Filter::getInstance()
     169            ->getDeliveoExported(INPUT_GET, 'deliveo_exported');
     170
     171        if ($query->is_admin && $pagenow == 'edit.php' && $deliveoExported !== null && $postType == 'shop_order') {
     172            switch ($deliveoExported) {
    169173                case 'not_exported':
    170174                    $query_filters = array(
     
    195199        global $post_type;
    196200
    197         if ($_GET['post_type'] == 'shop_order') {
    198 ?>
     201        $postType = Deliveo_Request_Filter::getInstance()
     202            ->getPostType(INPUT_GET, 'post_type');
     203
     204        if ($postType == 'shop_order') {
     205            ?>
    199206            <script type="text/javascript">
    200                 jQuery(document).ready(function() {
    201                     jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_send'>Deliveo API feladás</option>");
    202                     jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_export'>Deliveo API export</option>");
     207                jQuery(document).ready(function() {
     208                    jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_send'></option>");
     209                    jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_export'></option>");
    203210                });
    204211            </script>
    205 <?php
    206         }
    207     }
     212            <?php
     213        }
     214    }
     215
    208216    function custom_bulk_action()
    209217    {
     
    221229                $failed = 0;
    222230                $failed_message = [];
    223                 foreach ($_GET['order'] as $order) {
    224                     if (in_array($order['id'], $_GET['post'])) {
    225                         $send = $deliveo->send_by_api((int) $order['id'], $order['option'], $order['unit']);
     231
     232                $orderArray = Deliveo_Request_Filter::getInstance()
     233                    ->getOrderArray(INPUT_GET, 'order');
     234                $postArray = Deliveo_Request_Filter::getInstance()
     235                    ->getIntegerArray(INPUT_GET, 'post');
     236
     237                foreach ($orderArray as $order) {
     238                    if (in_array($order['id'], $postArray)) {
     239                        $send = $deliveo->send_by_api((int)$order['id'], $order['option'], $order['unit']);
    226240
    227241                        if ($send->type == "success") {
     
    230244                        if ($send->type == "warning") {
    231245                            $failed++;
    232                             $failed_message[] = 'Rendelés ID: ' . $order['id'] . ' - ' . $send->msg . ": " . ($send->field ?? '');
     246                            $failed_message[] = : ' . $order['id'] . ' - ' . $send->msg . ": " . ($send->field ?? '');
    233247                        }
    234248                    }
     
    241255                );
    242256
    243                 // echo "<pre>";
    244                 // var_dump($feedback);
    245                 // die;
    246 
    247257                $sendback = add_query_arg($feedback, wp_get_referer());
    248258
     
    251261                $deliveo = new MAV_IT_Deliveo(new MAV_IT_Deliveo_Settings());
    252262                $ids = [];
    253                 if ($_GET['order']) {
    254 
    255                     foreach ($_GET['order'] as $order) {
     263                $orderArray = Deliveo_Request_Filter::getInstance()
     264                    ->getOrderArray(INPUT_GET, 'order');
     265                if (count($orderArray)>0) {
     266
     267                    foreach ($orderArray as $order) {
    256268                        $ids[] = $order['id'];
    257269                    }
  • deliveo/trunk/inc/deliveo-settings.class.php

    r2373889 r2482785  
    33class MAV_IT_Deliveo_Settings
    44{
     5
     6
     7
     8
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
    533    public function __construct()
    634    {
     
    1442    private function init_deliveo_settings()
    1543    {
    16         $init_settings = array(
    17             'api_key' => '',
    18             'licence_key' => '',
    19             'sender' => '',
    20             'sender_country_code' => '',
    21             'sender_zip' => '',
    22             'sender_city' => '',
    23             'sender_address' => '',
    24             'sender_apartment' => '',
    25             'sender_phone' => '',
    26             'sender_email' => '',
    27             'x' => '',
    28             'y' => '',
    29             'z' => '',
    30             'priority' => '',
    31             'saturday' => '',
    32             'insurance' => '',
    33             'freight' => '',
    34             'delivery' => '',
    35             'deliveo_settings' => '',
    36             'reference_id_is_order_id' => '',
    37             'delivered_status' => '',
    38             'currency_multiplier' => '',
    39             'tracking__id_is_order_id' => '',
    40             'shipping_options' => '',
    41             'packaging_unit' => '',
    42         );
     44        $init_settings = [];
     45        foreach (self::$deliveoSettingsKeyList as $key => $value) {
     46            $init_settings[$key] = '';
     47        }
    4348
    4449        $init_settings = json_encode($init_settings);
     
    115120            </td>
    116121        <tr>
    117             <td colspan="2"><h2>Szállítási paraméterek | <small>Ezekkel a paraméterekkel lesz feladva minden csomag.</small></h2></td>
     122            <td colspan="2"><h2></h2></td>
    118123        </tr>
    119124        <tr>
     
    167172        </tr>
    168173        <tr>
    169             <td colspan="2"><h2>Csomagolási egység</small></h2></td>
     174            <td colspan="2"><h2></small></h2></td>
    170175        </tr>
    171176        <tr>
    172177            <td>' . __('Csomagok száma', 'mav-it') . '</td>
    173178            <td><select name="packaging_unit">
    174                 <option ' . ($settings['packaging_unit'] == 0 ? 'selected' : '') . ' value="0">Mindig egy</option>
    175                 <option ' . ($settings['packaging_unit'] == 1 ? 'selected' : '') . ' value="1">Tételenként egy</option>
    176                 <option ' . ($settings['packaging_unit'] == 2 ? 'selected' : '') . ' value="2">Mindig manuálisan adom meg</option>
     179                <option ' . ($settings['packaging_unit'] == 0 ? 'selected' : '') . ' value="0"></option>
     180                <option ' . ($settings['packaging_unit'] == 1 ? 'selected' : '') . ' value="1"></option>
     181                <option ' . ($settings['packaging_unit'] == 2 ? 'selected' : '') . ' value="2"></option>
    177182            </select>
    178183            </td>
    179184        </tr>
    180185        <tr>
    181             <td colspan="2"><h2>Szállítási mód</small></h2></td>
     186            <td colspan="2"><h2></small></h2></td>
    182187        </tr>
    183188        <tr>
     
    235240    public function save_deliveo_settings()
    236241    {
    237         if (isset($_POST['deliveo_settings'])) {
     242        $deliveoSettings = Deliveo_Request_Filter::getInstance()
     243            ->getDeliveoSettings(INPUT_POST, 'deliveo_settings');
     244
     245        if ($deliveoSettings !== null) {
    238246            $deliveo_api = new Deliveo_API(new MAV_IT_Deliveo_Settings());
    239247            $shipping_options = $deliveo_api->get_shipping_options();
    240             $_POST['shipping_options'] = $shipping_options;
    241 
    242             $settings = json_encode($_POST);
     248            $['shipping_options'] = $shipping_options;
     249
     250            $settings = json_encode($);
    243251            update_option('mav_it_deliveo_settings', $settings);
    244252        }
    245253
    246         if (isset($_POST['action']) && $_POST['action'] == 'save_api_key_and_licence') {
     254        $action = Deliveo_Request_Filter::getInstance()
     255            ->filterBasicCode(INPUT_POST, 'action');
     256
     257        if ($action !== null && $action == 'save_api_key_and_licence') {
    247258            $settings = $this->get_deliveo_settings();
    248259
    249             $settings['api_key'] = $_POST['api_key'];
    250             $settings['licence_key'] = $_POST['licence_key'];
     260            $settings['api_key'] = Deliveo_Request_Filter::getInstance()
     261                ->filterBasicCode(INPUT_POST, 'api_key');
     262            $settings['licence_key'] = Deliveo_Request_Filter::getInstance()
     263                ->filterBasicCode(INPUT_POST, 'licence_key');
    251264
    252265            $this->admin_notice__success();
  • deliveo/trunk/inc/mav-it-deliveo.class.php

    r2464819 r2482785  
    2323
    2424        add_action('admin_notices', array($this, 'deliveo_success_msg'));
     25
     26
     27
     28
     29
     30
     31
     32
    2533    }
    2634
     
    7482        }
    7583
    76         if (isset($_GET['order'])) {
     84        $orderArray = Deliveo_Request_Filter::getInstance()
     85            ->getOrderArray(INPUT_GET, 'order');
     86
     87        if (is_array($orderArray) && count($orderArray) > 0) {
    7788            $order_id = $orderID;
    7889
     
    112123                            "weight"  => $weight ?: 1,
    113124                            "item_no" => $sku ?: '',
    114                             // "item_no" => '',
    115 
    116125                        );
    117126                    }
     
    182191    public function deliveo_success_msg()
    183192    {
    184         if (isset($_GET['deliveo_ok'])) {
     193        $deliveoOk = Deliveo_Request_Filter::getInstance()
     194            ->getFilteredVar(INPUT_POST, 'deliveo_ok');
     195        $succeded = Deliveo_Request_Filter::getInstance()
     196            ->getFilteredVar(INPUT_GET, 'succeded');
     197        $failed = Deliveo_Request_Filter::getInstance()
     198            ->getFilteredVar(INPUT_GET, 'failed');
     199        $failedMessages = Deliveo_Request_Filter::getInstance()
     200            ->getFilteredVar(INPUT_GET, 'failed_messages');
     201        $deliveoExportFailed = Deliveo_Request_Filter::getInstance()
     202            ->getFilteredVar(INPUT_GET, 'deliveo_export_failed');
     203
     204        if ($deliveoOk) {
    185205            echo '<div class="notice notice-success is-dismissible">
    186             <p><strong><h2>Deliveo csomagfeladás befejezve</h2></strong> Sikeres: ' . $_GET['succeded'] . ', sikertelen: ' . $_GET['failed'] . '.</p>
     206            <p><strong><h2> . '.</p>
    187207            </div>';
    188208        }
    189         if (isset($_GET['failed_messages'])) {
    190             foreach ($_GET['failed_messages'] as $msg) {
     209        if () {
     210            foreach ($ as $msg) {
    191211                echo '<div class="notice notice-error is-dismissible">
    192212                <p>' . $msg . '</p>
     
    195215        }
    196216
    197         if (isset($_GET['deliveo_export_failed'])) {
     217        if () {
    198218            echo '<div class="notice notice-error is-dismissible">
    199                  <p><strong><h2>Deliveo Export hiba</h2></strong>Nem sikerült exportálni a rendeléseket. A korábban feladott rendeléseket már nem tölthetjük le!</p>
     219                 <p><strong><h2></p>
    200220             </div>';
    201221        }
     
    228248    public function init_export_details_for_api($order_id)
    229249    {
    230 
    231         $allSelected = explode(',', $_GET['generate_deliveo_csv']);
     250        $generateDeliveoCsv = Deliveo_Request_Filter::getInstance()
     251            ->getFilteredVar(INPUT_GET, 'generate_deliveo_csv');
     252
     253        $allSelected = explode(',', $generateDeliveoCsv);
    232254        $shipping    = '';
    233255
     
    412434    public function label_download()
    413435    {
     436
     437
     438
    414439        $settings    = $this->deliveo_settings;
    415         $label_url   = "https://deliveo.nanosoft.hu/api/package/v2/label/" . $_POST["group_id"] . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
    416         $package_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $_POST["group_id"] . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
     440        $label_url   = "https://deliveo.nanosoft.hu/api/package/v2/label/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
     441        $package_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
    417442
    418443        $tmpfile = download_url($label_url, $timeout = 300);
    419444
    420445        $check_signature = json_decode(wp_remote_fopen($package_url), true);
    421         if ($check_signature['data'][0]['group_id'] == $_POST["group_id"]) {
    422             $permfile = $_POST['group_id'] . '.pdf';
    423             $destfile = wp_get_upload_dir()['path'] . "/" . $_POST['group_id'] . '.pdf';
    424             $dest_url = wp_get_upload_dir()['url'] . "/" . $_POST['group_id'] . '.pdf';
     446        if ($check_signature['data'][0]['group_id'] == $) {
     447            $permfile = $ . '.pdf';
     448            $destfile = wp_get_upload_dir()['path'] . "/" . $ . '.pdf';
     449            $dest_url = wp_get_upload_dir()['url'] . "/" . $ . '.pdf';
    425450            copy($tmpfile, $destfile);
    426451            unlink($tmpfile);
    427452            $package =
    428                 '<a target="blank" href="' . $dest_url . '"><img title="Csomagcímke letöltése ehhez a csoportkódhoz: ' . $_POST['group_id'] . '"  style="vertical-align:middle;height:36px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" ></a>';
     453                '<a target="blank" href="' . $dest_url . '"><img title=" . '"  style="vertical-align:middle;height:36px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" ></a>';
    429454            echo $package;
    430455        } else {
    431456            $package =
    432                 '<img title="Csomagcímke nem található ehhez a csoportkódhoz: ' . $_POST['group_id'] . '"  style="vertical-align:middle;height:36px;filter:grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" >';
     457                '<img title=" . '"  style="vertical-align:middle;height:36px;filter:grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" >';
    433458            echo $package;
    434459        }
     
    438463    public function view_signature()
    439464    {
     465
     466
     467
    440468        $settings      = $this->deliveo_settings;
    441         $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $_POST["group_id"] . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
     469        $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
    442470
    443471        $tmpfile = download_url($signature_url, $timeout = 300);
     
    447475            $response = array(
    448476                "error" => "no_signature",
    449                 "img"   => '<img title="Nem tartozik aláíráslap ehhez a csoportkódhoz: ' . $_POST['group_id'] . '"  style="vertical-align:middle;height:24px; filter: grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>',
     477                "img"   => '<img title=" . '"  style="vertical-align:middle;height:24px; filter: grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>',
    450478            );
    451479            echo json_encode($response);
    452480        } else {
    453             $permfile = $_POST['group_id'] . '_sign.pdf';
    454             $destfile = wp_get_upload_dir()['path'] . "/" . $_POST['group_id'] . '_sign.pdf';
    455             $dest_url = wp_get_upload_dir()['url'] . "/" . $_POST['group_id'] . '_sign.pdf';
     481            $permfile = $. '_sign.pdf';
     482            $destfile = wp_get_upload_dir()['path'] . "/" . $ . '_sign.pdf';
     483            $dest_url = wp_get_upload_dir()['url'] . "/" . $ . '_sign.pdf';
    456484            copy($tmpfile, $destfile);
    457485            unlink($tmpfile);
    458486            $package = array(
    459487                'url' => $dest_url,
    460                 'img' => '<a href="' . $dest_url . '" target="blank"><img title="Aláíráslap letöltése ehhez a csoportkódhoz: ' . $_POST['group_id'] . '"  style="vertical-align:middle;height:24px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>',
     488                'img' => '<a href="' . $dest_url . '" target="blank"><img title=" . '"  style="vertical-align:middle;height:24px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>',
    461489            );
    462490            echo json_encode($package);
     
    467495    public function view_package_log()
    468496    {
     497
     498
    469499        $settings        = $this->deliveo_settings;
    470         $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package_log/" . $_POST["group_id"] . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
     500        $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package_log/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
    471501
    472502        $package_log = json_decode(wp_remote_fopen($package_log_url), true)['data'];
     
    475505            $row = '<h4>Csomagnapló</h4>';
    476506        } else {
    477             $row = '<h4 style="background-color:red">A csomagnapló nem található</h4>';
     507            $row = '<h4 style="background-color:red"></h4>';
    478508        }
    479509
     
    500530    public function package_details()
    501531    {
     532
     533
     534
    502535        $settings        = $this->deliveo_settings;
    503         $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $_POST["group_id"] . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
    504         // $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $_POST["group_id"] . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
     536        $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
     537        // $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];
    505538
    506539        $package_details = json_decode(wp_remote_fopen($package_log_url), true)['data'];
    507540        if ($package_details[0]['dropped_off'] != null) {
    508             $delivered = 'Átvette (' . $package_details[0]['dropped_off'] . ')';
    509         } else {
    510             $delivered = 'A csomag átvétele még nem történt meg!';
     541            $delivered = (' . $package_details[0]['dropped_off'] . ')';
     542        } else {
     543            $delivered = ;
    511544        }
    512545        if (isset($package_details[0])) {
     
    515548            echo '<div class="group_info" style="background-image:url(' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-icon.png' . ')">';
    516549
    517             echo '<h4>Címzett</h4>';
     550            echo '<h4></h4>';
    518551            echo '<div class="content">[' . $package_details[0]['consignee_zip'] . '] ' . $package_details[0]['consignee_city'] . '</div>';
    519552            echo '<div class="content">' . $package_details[0]['consignee_address'] . ' ' . $package_details[0]['consignee_apartment'] . '</div>';
     
    524557        } else {
    525558            echo '<div class="group_info" style="background-image:url(' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-icon.png' . ')">';
    526             echo '<h4>A csomag nem található a Deliveo rendszerben!</h4>';
     559            echo '<h4></h4>';
    527560            echo '</div>';
    528561        }
  • deliveo/trunk/readme.txt

    r2480126 r2482785  
    11=== Deliveo plugin for WordPress ===
    22
     3
    34Plugin Name: Deliveo
    45Description: Deliveo plugin for WordPress
     
    910License URI: http://www.gnu.org/licenses/gpl-3.0.html
    1011Tested up to: 5.6
     12
     13
     14
     15
    1116
    1217== Description ==
     
    22275. Click *Install Plugin*.
    23286. Done. :)
     29
     30
     31
     32
     33
     34
     35
     36
     37
  • deliveo/trunk/wordpress-mav-it-deliveo.php

    r2480126 r2482785  
    1111 * Text Domain: mav-it
    1212 * Version: 2.2.0
     13
    1314 *
    1415 * License: GNU General Public License v3.0
     
    2021
    2122include_once __DIR__ . '/inc/helpers.php';
     23
    2224include_once __DIR__ . '/inc/mav-it-deliveo.class.php';
    2325include_once __DIR__ . '/inc/csv-export.class.php';
     
    3032}
    3133
     34
     35
     36
     37
     38
     39
    3240if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
    3341    define('MAV_IT_DELIVEO_DIR_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.