HEX
Server: Apache/2
System: Linux s01 6.1.0-34-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.135-1 (2025-04-25) x86_64
User: beestg (1003)
PHP: 8.3.25
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/beestg/public_html/wp-content/plugins/gogetters_dropshipping/gogetters_dropshipping.php
<?php
/**
 * Plugin Name: GOGETTERS Dropshipping
 * Plugin URI: https://gogetters.nl/pages/woocommerce
 * Description: GOGETTERS Dropshipping
 * Version: 2.2.1
 * Author: GOGETTERS.
 * Author URI: https://gogetters.nl/
 * Text Domain: gogetters_dropshipping
 * License: GPLv2 or later
 */

// Make sure we don't expose any info if called directly
if ( ! function_exists('add_action')) {
    echo __('Hi there! I\'m just a plugin, not much I can do when called directly.');
    exit;
}

class GogettersDropshipping
{

    protected $_version = "2.2.1";

    protected $_webhook_install_url = "https://dropshipping.gogettersapp.com/webhook/woocommerce/install";

    protected $_portal_url = "https://dropshipping.gogettersapp.com";

    function __construct()
    {
        // Hooks
        // register_activation_hook(__FILE__, [$this, 'activation']);
        // register_deactivation_hook(__FILE__, [$this, 'activation']);
        register_uninstall_hook(__FILE__, [$this, 'uninstall']);

        // Add custom endpoint
        add_action('rest_api_init', function () {
            register_rest_route('wc/v3', 'media', [
                'methods' => WP_REST_Server::DELETABLE,
                'callback' => [$this, 'wc_api_delete_media'],
                'permission_callback' => function ($request) {
                    return true; // We do a custom token check
                },
            ]);

            register_rest_route('wc/v3', 'bulk-inventory', [
                'methods' => WP_REST_Server::EDITABLE,
                'callback' => [$this, 'wc_api_bulk_inventory'],
                'permission_callback' => function ($request) {
                    return true;  // We do a custom token check
                },
            ]);

            register_rest_route('wc/v3', 'gogetters-version', [
                'methods' => WP_REST_Server::ALLMETHODS,
                'callback' => [$this, 'wc_api_gogetters_version'],
                'permission_callback' => function ($request) {
                    return true; // This information is not sensitive
                },
            ]);
        });

        // Add cron function
        add_action('gogetters_cron_hook', [$this, 'gogetters_cron']);

        // Schedule cron
        if ( ! wp_next_scheduled('gogetters_cron_hook')) {
            wp_schedule_event(time(), 'daily', 'gogetters_cron_hook');
        }
    }

    public function uninstall()
    {
        // Delete option values
        delete_option('gogetters_eudropshipping_api_key_id');
        delete_option('gogetters_eudropshipping_shared_secret');
        delete_option('gogetters_eudropshipping_shop_id');
    }

    public function wc_api_delete_media($request)
    {
        // Set params
        $params = $request->get_params();

        // Check token
        if (
            ! isset($params[ 'token' ]) ||
            ! isset($params[ 'id' ]) ||
            $params[ 'token' ] != base64_encode($params[ 'id' ] . get_option('gogetters_eudropshipping_shared_secret'))
        ) {
            return [
                'error' => 'Unauthenticated',
            ];
        }

        // Delete media
        $result = wp_delete_attachment((int)$params[ 'id' ], true);

        if ($result == null) {
            return [
                'error' => 'Not found',
            ];
        } else {
            return [
                'success' => true,
            ];
        }
    }

    public function wc_api_bulk_inventory($request)
    {
        // Set start time
        $start = microtime(true);

        // Set params
        $params = $request->get_params();

        // Check token
        if (
            ! isset($params[ 'token' ]) ||
            ! isset($params[ 'json' ]) ||
            $params[ 'token' ] != hash_hmac('sha256', $params[ 'json' ], get_option('gogetters_eudropshipping_shared_secret'))
        ) {
            return [
                'error' => 'Unauthenticated',
            ];
        }

        // Get json
        $json = json_decode($params[ 'json' ]);

        // Check
        if (is_countable($json) && count($json) > 0) {
            foreach ($json as $inventory) {
                $_product = wc_get_product($inventory->id);
                if ($_product != false) {
                    try {
                        $_product->set_manage_stock(true);
                        $_product->set_stock_quantity($inventory->stock);
                        $_product->set_stock_status($inventory->stock > 0 ? 'instock' : 'outofstock');
                        $_product->save();
                    } catch (\Exception $e) {
                        continue;
                    }
                }
            }
        }

        return [
            'duration' => microtime(true) - $start,
        ];
    }

    public function wc_api_gogetters_version()
    {
        return [
            'version' => $this->_version,
        ];
    }

    public function gogetters_cron()
    {
        // Get shared secret
        $shared_secret = get_option('gogetters_eudropshipping_shared_secret', null);

        // Do we have a secret?
        if ( ! empty($shared_secret)) {
            wp_remote_get("https://dropshipping.gogettersapp.com/webhook/version?store=" . urlencode(get_site_url()) . "&hash=" . base64_encode(get_site_url() . $shared_secret) . "&version=wc_" . $this->_version);
        }
    }

}

// Init plugin
require_once(__DIR__ . '/gogetters_dropshipping_admin.php');
$gogetters_dropshipping = new GogettersDropshippingAdmin();